diff options
author | Jan-Marek Glogowski <jan-marek.glogowski@extern.cib.de> | 2020-02-07 23:16:50 +0000 |
---|---|---|
committer | Thorsten Behrens <Thorsten.Behrens@CIB.de> | 2020-02-12 00:27:51 +0100 |
commit | 61e1e0413296928d929f99c0f006c6cbbcf4ac40 (patch) | |
tree | 7381bdafbe0176f9102934ddb292fc4897d2d3a4 /sfx2 | |
parent | 38e6a5ddb408d8cfabf7f3e578b8bce760c02d11 (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.
Change-Id: I45ffa8709f7cdda949fac78f3b363f120f0c4a03
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/88257
Tested-by: Jenkins
Reviewed-by: Thorsten Behrens <Thorsten.Behrens@CIB.de>
Diffstat (limited to 'sfx2')
-rw-r--r-- | sfx2/source/appl/appuno.cxx | 18 | ||||
-rw-r--r-- | sfx2/source/doc/sfxbasemodel.cxx | 8 | ||||
-rw-r--r-- | sfx2/source/view/frmload.cxx | 4 |
3 files changed, 29 insertions, 1 deletions
diff --git a/sfx2/source/appl/appuno.cxx b/sfx2/source/appl/appuno.cxx index 2989ee0ad2ac..ede87667adce 100644 --- a/sfx2/source/appl/appuno.cxx +++ b/sfx2/source/appl/appuno.cxx @@ -153,6 +153,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 ) { @@ -865,6 +866,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; @@ -1092,6 +1101,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; @@ -1259,6 +1270,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)); @@ -1676,6 +1689,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 5e363821be93..7d6c8317f804 100644 --- a/sfx2/source/doc/sfxbasemodel.cxx +++ b/sfx2/source/doc/sfxbasemodel.cxx @@ -1122,6 +1122,14 @@ void SAL_CALL SfxBaseModel::setArgs(const Sequence<beans::PropertyValue>& aArgs) ok = true; } } + else if (rArg.Name == "Replaceable") + { + if (rArg.Value >>= bValue) + { + pMedium->GetItemSet()->Put(SfxBoolItem(SID_REPLACEABLE, bValue)); + ok = true; + } + } if (!ok) { throw lang::IllegalArgumentException("Setting property not supported: " + rArg.Name, diff --git a/sfx2/source/view/frmload.cxx b/sfx2/source/view/frmload.cxx index 82b438d8e7fa..f69706de1b04 100644 --- a/sfx2/source/view/frmload.cxx +++ b/sfx2/source/view/frmload.cxx @@ -611,7 +611,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 |