summaryrefslogtreecommitdiff
path: root/sfx2/source
diff options
context:
space:
mode:
authorJan-Marek Glogowski <jan-marek.glogowski@extern.cib.de>2020-02-07 23:16:50 +0000
committerThorsten Behrens <Thorsten.Behrens@CIB.de>2020-02-13 10:19:20 +0100
commitd6188f8c3803490f75fbd1931a0bd6f821c4d700 (patch)
tree09e4e9a924207f2c3045f5d2dd13c4fb63e5a25f /sfx2/source
parentc38ba97261c0af28cb48786a7ad7edcab1e85cb4 (diff)
tdf#126700 allow replacing the default documents
Per default, a document opened by a user action will always open in a new frame. For tdf#83722, this behaviour was extended to documents created from templates. But this currently also affects the default factory templates, if these are replaced by a config setting with a real template, which was not intentional. So this patch introduces a new MediaDescriptor property, which allows to mark a document as replaceable and automatically sets it for factory default documents. If this property is set to true, a document just acts as a placeholder while it's unmodified. I.e. the next opened document from its frame will close and replace it. For this backport the documentation in MediaDescriptor.idl is dropped, so people won't rely on this as a feature before 7.0. Change-Id: I45ffa8709f7cdda949fac78f3b363f120f0c4a03 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/88257 Tested-by: Jenkins Reviewed-by: Thorsten Behrens <Thorsten.Behrens@CIB.de> (cherry picked from commit 61e1e0413296928d929f99c0f006c6cbbcf4ac40) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/88537
Diffstat (limited to 'sfx2/source')
-rw-r--r--sfx2/source/appl/appuno.cxx18
-rw-r--r--sfx2/source/doc/sfxbasemodel.cxx5
-rw-r--r--sfx2/source/view/frmload.cxx4
3 files changed, 26 insertions, 1 deletions
diff --git a/sfx2/source/appl/appuno.cxx b/sfx2/source/appl/appuno.cxx
index bfbe90dc896b..ff3fdfe91b6e 100644
--- a/sfx2/source/appl/appuno.cxx
+++ b/sfx2/source/appl/appuno.cxx
@@ -174,6 +174,7 @@ static char const sLockExport[] = "LockExport";
static char const sLockPrint[] = "LockPrint";
static char const sLockSave[] = "LockSave";
static char const sLockEditDoc[] = "LockEditDoc";
+static char const sReplaceable[] = "Replaceable";
static bool isMediaDescriptor( sal_uInt16 nSlotId )
{
@@ -888,6 +889,14 @@ void TransformParameters( sal_uInt16 nSlotId, const uno::Sequence<beans::Propert
if (bOK)
rSet.Put( SfxBoolItem( SID_LOCK_EDITDOC, bVal ) );
}
+ else if (aName == sReplaceable)
+ {
+ bool bVal = false;
+ bool bOK = (rProp.Value >>= bVal);
+ DBG_ASSERT(bOK, "invalid type for Replaceable");
+ if (bOK)
+ rSet.Put(SfxBoolItem(SID_REPLACEABLE, bVal));
+ }
#ifdef DBG_UTIL
else
--nFoundArgs;
@@ -1115,6 +1124,8 @@ void TransformItems( sal_uInt16 nSlotId, const SfxItemSet& rSet, uno::Sequence<b
nAdditional++;
if ( rSet.GetItemState( SID_LOCK_EDITDOC ) == SfxItemState::SET )
nAdditional++;
+ if (rSet.GetItemState(SID_REPLACEABLE) == SfxItemState::SET)
+ nAdditional++;
// consider additional arguments
nProps += nAdditional;
@@ -1282,6 +1293,8 @@ void TransformItems( sal_uInt16 nSlotId, const SfxItemSet& rSet, uno::Sequence<b
continue;
if ( nId == SID_LOCK_EDITDOC )
continue;
+ if (nId == SID_REPLACEABLE)
+ continue;
}
OString aDbg = "Unknown item detected: " + OString::number(static_cast<sal_Int32>(nId));
@@ -1699,6 +1712,11 @@ void TransformItems( sal_uInt16 nSlotId, const SfxItemSet& rSet, uno::Sequence<b
pValue[nActProp].Name = sLockEditDoc;
pValue[nActProp++].Value <<= static_cast<const SfxBoolItem*>(pItem)->GetValue();
}
+ if (rSet.GetItemState(SID_REPLACEABLE, false, &pItem) == SfxItemState::SET)
+ {
+ pValue[nActProp].Name = sReplaceable;
+ pValue[nActProp++].Value <<= static_cast<const SfxBoolItem*>(pItem)->GetValue();
+ }
}
rArgs = aSequ;
diff --git a/sfx2/source/doc/sfxbasemodel.cxx b/sfx2/source/doc/sfxbasemodel.cxx
index 394475c40129..a136f74f2886 100644
--- a/sfx2/source/doc/sfxbasemodel.cxx
+++ b/sfx2/source/doc/sfxbasemodel.cxx
@@ -1099,6 +1099,11 @@ void SAL_CALL SfxBaseModel::setArgs(const Sequence<beans::PropertyValue>& aArgs)
rArg.Value >>= bValue;
pMedium->GetItemSet()->Put(SfxBoolItem(SID_LOCK_EDITDOC, bValue));
}
+ else if (rArg.Name == "Replaceable")
+ {
+ rArg.Value >>= bValue;
+ pMedium->GetItemSet()->Put(SfxBoolItem(SID_REPLACEABLE, bValue));
+ }
else
{
throw lang::IllegalArgumentException("Setting property not supported: " + rArg.Name,
diff --git a/sfx2/source/view/frmload.cxx b/sfx2/source/view/frmload.cxx
index d098ac5c00e2..b16d9b471048 100644
--- a/sfx2/source/view/frmload.cxx
+++ b/sfx2/source/view/frmload.cxx
@@ -624,7 +624,9 @@ sal_Bool SAL_CALL SfxFrameLoader_Impl::load( const Sequence< PropertyValue >& rA
const OUString sURL = aDescriptor.getOrDefault( "URL", OUString() );
const bool bIsFactoryURL = sURL.startsWith( "private:factory/" );
bool bInitNewModel = bIsFactoryURL;
- if ( bIsFactoryURL && !bExternalModel )
+ const bool bIsDefault = bIsFactoryURL && !bExternalModel;
+ aDescriptor.put("Replaceable", bIsDefault);
+ if (bIsDefault)
{
const OUString sFactory = sURL.copy( sizeof( "private:factory/" ) -1 );
// special handling for some weird factory URLs a la private:factory/swriter?slot=21053