summaryrefslogtreecommitdiff
path: root/framework/source
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2023-11-27 10:16:40 +0100
committerMike Kaganski <mike.kaganski@collabora.com>2023-11-27 12:54:34 +0100
commit6ea42a11669e2b3d3a10dd5eb199f45d6050c86b (patch)
treecbfcb6b5ff2bd20a6d5a9043b02f66bd21147df6 /framework/source
parent657f98d9272dd97e4f4c6e03cce4a0fa9f526819 (diff)
tdf#158396: show DocumentTitle when set in MediaDescriptor
Change-Id: Ic89de9e7d83c7c96eb1b2cc51798d354b38f86d6 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159904 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'framework/source')
-rw-r--r--framework/source/fwe/helper/titlehelper.cxx30
1 files changed, 20 insertions, 10 deletions
diff --git a/framework/source/fwe/helper/titlehelper.cxx b/framework/source/fwe/helper/titlehelper.cxx
index 48583681b9a4..5ab03ab10e8f 100644
--- a/framework/source/fwe/helper/titlehelper.cxx
+++ b/framework/source/fwe/helper/titlehelper.cxx
@@ -298,6 +298,13 @@ void TitleHelper::impl_updateTitle (bool init)
}
}
+static OUString getURLFromModel(const css::uno::Reference< css::frame::XModel3 >& xModel)
+{
+ if (css::uno::Reference<css::frame::XStorable> xURLProvider{ xModel, css::uno::UNO_QUERY })
+ return xURLProvider->getLocation();
+ return {};
+}
+
void TitleHelper::impl_updateTitleForModel (const css::uno::Reference< css::frame::XModel3 >& xModel, bool init)
{
css::uno::Reference< css::uno::XInterface > xOwner;
@@ -326,24 +333,27 @@ void TitleHelper::impl_updateTitleForModel (const css::uno::Reference< css::fram
return;
OUString sTitle;
- OUString sURL;
- css::uno::Reference< css::frame::XStorable > xURLProvider(xModel , css::uno::UNO_QUERY);
- if (xURLProvider.is())
- sURL = xURLProvider->getLocation ();
+ utl::MediaDescriptor aDescriptor(
+ xModel->getArgs2({ utl::MediaDescriptor::PROP_DOCUMENTTITLE,
+ utl::MediaDescriptor::PROP_SUGGESTEDSAVEASNAME }));
- utl::MediaDescriptor aDescriptor(xModel->getArgs2( { utl::MediaDescriptor::PROP_SUGGESTEDSAVEASNAME } ));
- const OUString sSuggestedSaveAsName = aDescriptor.getUnpackedValueOrDefault(
- utl::MediaDescriptor::PROP_SUGGESTEDSAVEASNAME, OUString());
-
- if (!sURL.isEmpty())
+ if (const OUString sMediaTitle = aDescriptor.getUnpackedValueOrDefault(
+ utl::MediaDescriptor::PROP_DOCUMENTTITLE, OUString());
+ !sMediaTitle.isEmpty())
+ {
+ sTitle = sMediaTitle;
+ }
+ else if (const OUString sURL = getURLFromModel(xModel); !sURL.isEmpty())
{
sTitle = impl_convertURL2Title(sURL);
if (nLeasedNumber != css::frame::UntitledNumbersConst::INVALID_NUMBER)
xNumbers->releaseNumber (nLeasedNumber);
nLeasedNumber = css::frame::UntitledNumbersConst::INVALID_NUMBER;
}
- else if (!sSuggestedSaveAsName.isEmpty())
+ else if (const OUString sSuggestedSaveAsName = aDescriptor.getUnpackedValueOrDefault(
+ utl::MediaDescriptor::PROP_SUGGESTEDSAVEASNAME, OUString());
+ !sSuggestedSaveAsName.isEmpty())
{
// tdf#121537 Use suggested save as name for title if file has not yet been saved
sTitle = sSuggestedSaveAsName;