diff options
25 files changed, 78 insertions, 81 deletions
diff --git a/include/sfx2/objsh.hxx b/include/sfx2/objsh.hxx index ae7d32e34d54..da28df348996 100644 --- a/include/sfx2/objsh.hxx +++ b/include/sfx2/objsh.hxx @@ -586,6 +586,10 @@ public: const css::uno::Sequence<OUString>& rExceptions = css::uno::Sequence<OUString>()); bool isEditDocLocked(); + bool isContentExtractionLocked(); + bool isExportLocked(); + bool isPrintLocked(); + bool isSaveLocked(); // The functions from SvPersist void EnableSetModified( bool bEnable = true ); diff --git a/include/sfx2/viewsh.hxx b/include/sfx2/viewsh.hxx index 47a50f23a3df..63441f17d883 100644 --- a/include/sfx2/viewsh.hxx +++ b/include/sfx2/viewsh.hxx @@ -289,10 +289,6 @@ public: void AddRemoveClipboardListener( const css::uno::Reference < css::datatransfer::clipboard::XClipboardListener>&, bool ); css::uno::Reference< css::datatransfer::clipboard::XClipboardNotifier > GetClipboardNotifier() const; - bool isContentExtractionLocked(); - bool isExportLocked(); - bool isPrintLocked(); - bool isSaveLocked(); SAL_DLLPRIVATE SfxInPlaceClient* GetUIActiveIPClient_Impl() const; SAL_DLLPRIVATE void AddContextMenuInterceptor_Impl( const css::uno::Reference < css::ui::XContextMenuInterceptor >& xInterceptor ); diff --git a/sc/source/ui/docshell/docsh4.cxx b/sc/source/ui/docshell/docsh4.cxx index 14058badaa02..be9ac2921f40 100644 --- a/sc/source/ui/docshell/docsh4.cxx +++ b/sc/source/ui/docshell/docsh4.cxx @@ -2075,7 +2075,7 @@ void ScDocShell::GetState( SfxItemSet &rSet ) case SID_SHARE_DOC: { - if ( IsReadOnly() || GetBestViewShell()->isExportLocked() ) + if ( IsReadOnly() || GetObjectShell()->isExportLocked() ) { rSet.DisableItem( nWhich ); } diff --git a/sc/source/ui/drawfunc/chartsh.cxx b/sc/source/ui/drawfunc/chartsh.cxx index b70ce15e57c2..70a46b8d5e71 100644 --- a/sc/source/ui/drawfunc/chartsh.cxx +++ b/sc/source/ui/drawfunc/chartsh.cxx @@ -73,7 +73,7 @@ void ScChartShell::GetExportAsGraphicState( SfxItemSet& rSet ) bEnable = true; } - if (GetViewShell()->isExportLocked()) + if (GetObjectShell()->isExportLocked()) bEnable = false; if( !bEnable ) diff --git a/sc/source/ui/drawfunc/drawsh2.cxx b/sc/source/ui/drawfunc/drawsh2.cxx index 772e2936911a..b34b3c19522b 100644 --- a/sc/source/ui/drawfunc/drawsh2.cxx +++ b/sc/source/ui/drawfunc/drawsh2.cxx @@ -156,7 +156,8 @@ void ScDrawShell::GetDrawFuncState( SfxItemSet& rSet ) // disable functions rSet.DisableItem( SID_FLIP_VERTICAL ); } - if (pViewData->GetViewShell()->isContentExtractionLocked()) + + if (GetObjectShell()->isContentExtractionLocked()) { rSet.DisableItem(SID_COPY); rSet.DisableItem(SID_CUT); diff --git a/sc/source/ui/drawfunc/drtxtob.cxx b/sc/source/ui/drawfunc/drtxtob.cxx index 67fe69e1c957..06012848c489 100644 --- a/sc/source/ui/drawfunc/drtxtob.cxx +++ b/sc/source/ui/drawfunc/drtxtob.cxx @@ -465,7 +465,7 @@ void ScDrawTextObjectBar::GetState( SfxItemSet& rSet ) rSet.DisableItem( SID_THESAURUS ); } - if (pViewData->GetViewShell()->isContentExtractionLocked()) + if (GetObjectShell()->isContentExtractionLocked()) { rSet.DisableItem(SID_COPY); rSet.DisableItem(SID_CUT); diff --git a/sc/source/ui/drawfunc/graphsh.cxx b/sc/source/ui/drawfunc/graphsh.cxx index c3c5dd4b5f5c..e48c425419d6 100644 --- a/sc/source/ui/drawfunc/graphsh.cxx +++ b/sc/source/ui/drawfunc/graphsh.cxx @@ -145,7 +145,7 @@ void ScGraphicShell::GetExternalEditState( SfxItemSet& rSet ) bEnable = true; } - if (GetViewShell()->isExportLocked()) + if (GetObjectShell()->isExportLocked()) bEnable = false; if( !bEnable ) @@ -307,7 +307,7 @@ void ScGraphicShell::GetSaveGraphicState(SfxItemSet &rSet) bEnable = true; } - if (GetViewShell()->isExportLocked()) + if (GetObjectShell()->isExportLocked()) bEnable = false; if( !bEnable ) diff --git a/sc/source/ui/view/cellsh.cxx b/sc/source/ui/view/cellsh.cxx index e8b47ddcef34..a9dfdc4db199 100644 --- a/sc/source/ui/view/cellsh.cxx +++ b/sc/source/ui/view/cellsh.cxx @@ -210,7 +210,7 @@ void ScCellShell::GetBlockState( SfxItemSet& rSet ) bDisable = false; break; case SID_CUT: // cut - bDisable = !bSimpleArea || GetViewData()->GetViewShell()->isContentExtractionLocked(); + bDisable = !bSimpleArea || GetObjectShell()->isContentExtractionLocked(); break; case FID_INS_CELL: // insert cells, just simple selection bDisable = (!bSimpleArea); @@ -273,7 +273,7 @@ void ScCellShell::GetBlockState( SfxItemSet& rSet ) //! work is to be done once more if ( !(!bEditable && bOnlyNotBecauseOfMatrix) ) bNeedEdit = false; // allowed when protected/ReadOnly - bDisable = GetViewData()->GetViewShell()->isContentExtractionLocked(); + bDisable = GetObjectShell()->isContentExtractionLocked(); break; case SID_AUTOFORMAT: // Autoformat, at least 3x3 selected diff --git a/sc/source/ui/view/editsh.cxx b/sc/source/ui/view/editsh.cxx index bf2ebc3d75cf..9997dd3f703d 100644 --- a/sc/source/ui/view/editsh.cxx +++ b/sc/source/ui/view/editsh.cxx @@ -813,7 +813,7 @@ void ScEditShell::GetState( SfxItemSet& rSet ) break; case SID_COPY: case SID_CUT: - if (pViewData->GetViewShell()->isContentExtractionLocked()) + if (GetObjectShell()->isContentExtractionLocked()) { rSet.DisableItem(SID_COPY); rSet.DisableItem(SID_CUT); diff --git a/sd/source/ui/slidesorter/controller/SlsSlotManager.cxx b/sd/source/ui/slidesorter/controller/SlsSlotManager.cxx index 0f421b7f99ba..27febd5dde42 100644 --- a/sd/source/ui/slidesorter/controller/SlsSlotManager.cxx +++ b/sd/source/ui/slidesorter/controller/SlsSlotManager.cxx @@ -763,7 +763,7 @@ void SlotManager::GetClipboardState ( SfxItemSet& rSet) } ViewShellBase* pBase = mrSlideSorter.GetViewShellBase(); - if (pBase && pBase->isContentExtractionLocked()) + if (pBase && pBase->GetObjectShell()->isContentExtractionLocked()) { rSet.DisableItem(SID_COPY); rSet.DisableItem(SID_CUT); diff --git a/sd/source/ui/view/drviews7.cxx b/sd/source/ui/view/drviews7.cxx index e1ea9d36287e..693d0bd1a8dc 100644 --- a/sd/source/ui/view/drviews7.cxx +++ b/sd/source/ui/view/drviews7.cxx @@ -915,7 +915,7 @@ void DrawViewShell::GetMenuState( SfxItemSet &rSet ) if (pOlView) { - if (pOlView->GetSelected().isEmpty() || GetViewShell()->isContentExtractionLocked()) + if (pOlView->GetSelected().isEmpty() || GetObjectShell()->isContentExtractionLocked()) { rSet.DisableItem( SID_CUT ); rSet.DisableItem( SID_COPY ); @@ -1585,7 +1585,7 @@ void DrawViewShell::GetMenuState( SfxItemSet &rSet ) rSet.DisableItem(SID_SAVE_BACKGROUND); } - if (GetViewShell()->isExportLocked()) + if (GetObjectShell()->isExportLocked()) rSet.DisableItem(SID_PRESENTATION_MINIMIZER); GetModeSwitchingMenuState (rSet); diff --git a/sd/source/ui/view/drviewsj.cxx b/sd/source/ui/view/drviewsj.cxx index ee65cb87fa94..772cf4a48ddb 100644 --- a/sd/source/ui/view/drviewsj.cxx +++ b/sd/source/ui/view/drviewsj.cxx @@ -21,6 +21,7 @@ #include <com/sun/star/embed/EmbedMisc.hpp> #include <com/sun/star/embed/XEmbeddedObject.hpp> #include <com/sun/star/presentation/ClickAction.hpp> +#include <sfx2/objsh.hxx> #include <svx/svxids.hrc> #include <svx/sdmetitm.hxx> #include <editeng/flditem.hxx> @@ -503,12 +504,12 @@ void DrawViewShell::GetMenuStateSel( SfxItemSet &rSet ) rSet.DisableItem (SID_OBJECT_SHEAR); } - if (GetViewShell()->isContentExtractionLocked()) + if (GetObjectShell()->isContentExtractionLocked()) { rSet.DisableItem(SID_COPY); rSet.DisableItem(SID_CUT); } - if(GetViewShell()->isExportLocked()) + if(GetObjectShell()->isExportLocked()) { rSet.DisableItem(SID_SAVE_GRAPHIC); rSet.DisableItem(SID_EXTERNAL_EDIT); diff --git a/sd/source/ui/view/outlnvsh.cxx b/sd/source/ui/view/outlnvsh.cxx index cf594e1f9e85..2c7dcdfdba83 100644 --- a/sd/source/ui/view/outlnvsh.cxx +++ b/sd/source/ui/view/outlnvsh.cxx @@ -885,7 +885,7 @@ void OutlineViewShell::GetMenuState( SfxItemSet &rSet ) } if (!pOlView->GetViewByWindow(GetActiveWindow())->HasSelection() - || GetViewShell()->isContentExtractionLocked()) + || GetObjectShell()->isContentExtractionLocked()) { rSet.DisableItem(SID_CUT); rSet.DisableItem(SID_COPY); diff --git a/sfx2/source/doc/objmisc.cxx b/sfx2/source/doc/objmisc.cxx index 7cc979a87e43..81f9f9ce4573 100644 --- a/sfx2/source/doc/objmisc.cxx +++ b/sfx2/source/doc/objmisc.cxx @@ -1880,4 +1880,40 @@ bool SfxObjectShell::isEditDocLocked() return aArgs.getOrDefault("LockEditDoc", false); } +bool SfxObjectShell::isContentExtractionLocked() +{ + Reference<XModel> xModel = GetModel(); + if (!xModel.is()) + return false; + comphelper::NamedValueCollection aArgs(xModel->getArgs()); + return aArgs.getOrDefault("LockContentExtraction", false); +} + +bool SfxObjectShell::isExportLocked() +{ + Reference<XModel> xModel = GetModel(); + if (!xModel.is()) + return false; + comphelper::NamedValueCollection aArgs(xModel->getArgs()); + return aArgs.getOrDefault("LockExport", false); +} + +bool SfxObjectShell::isPrintLocked() +{ + Reference<XModel> xModel = GetModel(); + if (!xModel.is()) + return false; + comphelper::NamedValueCollection aArgs(xModel->getArgs()); + return aArgs.getOrDefault("LockPrint", false); +} + +bool SfxObjectShell::isSaveLocked() +{ + Reference<XModel> xModel = GetModel(); + if (!xModel.is()) + return false; + comphelper::NamedValueCollection aArgs(xModel->getArgs()); + return aArgs.getOrDefault("LockSave", false); +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sfx2/source/doc/objserv.cxx b/sfx2/source/doc/objserv.cxx index 96f932049c28..7e29c9b7ded9 100644 --- a/sfx2/source/doc/objserv.cxx +++ b/sfx2/source/doc/objserv.cxx @@ -1098,8 +1098,7 @@ void SfxObjectShell::GetState_Impl(SfxItemSet &rSet) { case SID_DOCTEMPLATE : { - SfxViewFrame *pFrame = SfxViewFrame::GetFirst(this); - if ( pFrame && pFrame->GetViewShell()->isExportLocked()) + if ( isExportLocked()) rSet.DisableItem( nWhich ); break; } @@ -1183,8 +1182,7 @@ void SfxObjectShell::GetState_Impl(SfxItemSet &rSet) } case SID_SAVEDOC: { - SfxViewFrame *pFrame = SfxViewFrame::GetFirst(this); - if ( IsReadOnly() || (pFrame && pFrame->GetViewShell()->isSaveLocked())) + if ( IsReadOnly() || isSaveLocked()) { rSet.DisableItem(nWhich); break; @@ -1204,9 +1202,8 @@ void SfxObjectShell::GetState_Impl(SfxItemSet &rSet) case SID_SAVEASDOC: { - SfxViewFrame *pFrame = SfxViewFrame::GetFirst(this); if (!(pImpl->nLoadedFlags & SfxLoadedFlags::MAINDOCUMENT) - || (pFrame && pFrame->GetViewShell()->isExportLocked())) + || isExportLocked()) { rSet.DisableItem( nWhich ); break; @@ -1220,9 +1217,7 @@ void SfxObjectShell::GetState_Impl(SfxItemSet &rSet) case SID_SAVEACOPY: { - SfxViewFrame *pFrame = SfxViewFrame::GetFirst(this); - if (!(pImpl->nLoadedFlags & SfxLoadedFlags::MAINDOCUMENT) - || (pFrame && pFrame->GetViewShell()->isExportLocked())) + if (!(pImpl->nLoadedFlags & SfxLoadedFlags::MAINDOCUMENT) || isExportLocked()) { rSet.DisableItem( nWhich ); break; @@ -1243,8 +1238,7 @@ void SfxObjectShell::GetState_Impl(SfxItemSet &rSet) case SID_AUTOREDACTDOC: case SID_SAVEASREMOTE: { - SfxViewFrame *pFrame = SfxViewFrame::GetFirst(this); - if (pFrame && pFrame->GetViewShell()->isExportLocked()) + if (isExportLocked()) rSet.DisableItem( nWhich ); break; } diff --git a/sfx2/source/view/viewsh.cxx b/sfx2/source/view/viewsh.cxx index d34b1d817a07..bc2ca6a447f6 100644 --- a/sfx2/source/view/viewsh.cxx +++ b/sfx2/source/view/viewsh.cxx @@ -658,6 +658,7 @@ void SfxViewShell::GetState_Impl( SfxItemSet &rSet ) { SfxWhichIter aIter( rSet ); + SfxObjectShell *pSh = GetViewFrame()->GetObjectShell(); for ( sal_uInt16 nSID = aIter.FirstWhich(); nSID; nSID = aIter.NextWhich() ) { switch ( nSID ) @@ -673,13 +674,13 @@ void SfxViewShell::GetState_Impl( SfxItemSet &rSet ) #if HAVE_FEATURE_MACOSX_SANDBOX rSet.DisableItem(nSID); #endif - if (isExportLocked() && nSID != SID_MAIL_SENDDOC) + if (pSh && pSh->isExportLocked() && nSID != SID_MAIL_SENDDOC) rSet.DisableItem(nSID); break; } case SID_WEBHTML: { - if (isExportLocked()) + if (pSh && pSh->isExportLocked()) rSet.DisableItem(nSID); break; } @@ -689,7 +690,8 @@ void SfxViewShell::GetState_Impl( SfxItemSet &rSet ) case SID_SETUPPRINTER: case SID_PRINTER_NAME: { - if (Application::GetSettings().GetMiscSettings().GetDisablePrinting() || isPrintLocked()) + if (Application::GetSettings().GetMiscSettings().GetDisablePrinting() + || (pSh && pSh->isPrintLocked())) { rSet.DisableItem(nSID); break; @@ -1752,42 +1754,6 @@ void SfxViewShell::SetController( SfxBaseController* pController ) pImpl->xClipboardListener = new SfxClipboardChangeListener( this, GetClipboardNotifier() ); } -bool SfxViewShell::isContentExtractionLocked() -{ - Reference<XModel> xModel = GetCurrentDocument(); - if (!xModel.is()) - return false; - comphelper::NamedValueCollection aArgs(xModel->getArgs()); - return aArgs.getOrDefault("LockContentExtraction", false); -} - -bool SfxViewShell::isExportLocked() -{ - Reference<XModel> xModel = GetCurrentDocument(); - if (!xModel.is()) - return false; - comphelper::NamedValueCollection aArgs(xModel->getArgs()); - return aArgs.getOrDefault("LockExport", false); -} - -bool SfxViewShell::isPrintLocked() -{ - Reference<XModel> xModel = GetCurrentDocument(); - if (!xModel.is()) - return false; - comphelper::NamedValueCollection aArgs(xModel->getArgs()); - return aArgs.getOrDefault("LockPrint", false); -} - -bool SfxViewShell::isSaveLocked() -{ - Reference<XModel> xModel = GetCurrentDocument(); - if (!xModel.is()) - return false; - comphelper::NamedValueCollection aArgs(xModel->getArgs()); - return aArgs.getOrDefault("LockSave", false); -} - Reference < XController > SfxViewShell::GetController() const { return pImpl->m_pController.get(); diff --git a/sw/source/uibase/app/apphdl.cxx b/sw/source/uibase/app/apphdl.cxx index 09ff2872f3a3..782445027c8c 100644 --- a/sw/source/uibase/app/apphdl.cxx +++ b/sw/source/uibase/app/apphdl.cxx @@ -158,8 +158,7 @@ void SwModule::StateOther(SfxItemSet &rSet) break; case FN_MAILMERGE_WIZARD: { - SwView* pView = ::GetActiveView(); - if (pView && pView->GetViewShell()->isExportLocked()) + if (GetObjectShell()->isExportLocked()) rSet.DisableItem(nWhich); break; } diff --git a/sw/source/uibase/app/docsh.cxx b/sw/source/uibase/app/docsh.cxx index a8e80a688e58..5ccae0801946 100644 --- a/sw/source/uibase/app/docsh.cxx +++ b/sw/source/uibase/app/docsh.cxx @@ -1019,7 +1019,7 @@ void SwDocShell::GetState(SfxItemSet& rSet) case FN_OUTLINE_TO_IMPRESS: { SvtModuleOptions aMOpt; - if (!aMOpt.IsImpress() || (GetViewShell() && GetViewShell()->isExportLocked())) + if (!aMOpt.IsImpress() || GetObjectShell()->isExportLocked()) rSet.DisableItem( nWhich ); } [[fallthrough]]; @@ -1042,13 +1042,13 @@ void SwDocShell::GetState(SfxItemSet& rSet) case FN_NEW_GLOBAL_DOC: if (dynamic_cast<const SwGlobalDocShell*>(this) != nullptr - || (GetViewShell() && GetViewShell()->isExportLocked())) + || GetObjectShell()->isExportLocked()) rSet.DisableItem( nWhich ); break; case FN_NEW_HTML_DOC: if (dynamic_cast<const SwWebDocShell*>(this) != nullptr - || (GetViewShell() && GetViewShell()->isExportLocked())) + || GetObjectShell()->isExportLocked()) rSet.DisableItem( nWhich ); break; diff --git a/sw/source/uibase/dochdl/swdtflvr.cxx b/sw/source/uibase/dochdl/swdtflvr.cxx index f79f27ed271c..ea3dcf29db71 100644 --- a/sw/source/uibase/dochdl/swdtflvr.cxx +++ b/sw/source/uibase/dochdl/swdtflvr.cxx @@ -1125,7 +1125,7 @@ int SwTransferable::PrepareForCopy( bool bIsCut ) int SwTransferable::Copy( bool bIsCut ) { - if (m_pWrtShell->GetView().isContentExtractionLocked()) + if (m_pWrtShell->GetView().GetObjectShell()->isContentExtractionLocked()) return 0; int nRet = PrepareForCopy( bIsCut ); diff --git a/sw/source/uibase/docvw/edtdd.cxx b/sw/source/uibase/docvw/edtdd.cxx index 1a5690e96e7e..44728b9ba129 100644 --- a/sw/source/uibase/docvw/edtdd.cxx +++ b/sw/source/uibase/docvw/edtdd.cxx @@ -63,7 +63,7 @@ void SwEditWin::StopDDTimer(SwWrtShell *pSh, const Point &rPt) void SwEditWin::StartDrag( sal_Int8 /*nAction*/, const Point& rPosPixel ) { - if (m_rView.isContentExtractionLocked()) + if (m_rView.GetObjectShell()->isContentExtractionLocked()) return; SwWrtShell &rSh = m_rView.GetWrtShell(); diff --git a/sw/source/uibase/shells/annotsh.cxx b/sw/source/uibase/shells/annotsh.cxx index 1df965b8c343..df50cb78163d 100644 --- a/sw/source/uibase/shells/annotsh.cxx +++ b/sw/source/uibase/shells/annotsh.cxx @@ -963,7 +963,7 @@ void SwAnnotationShell::StateClpbrd(SfxItemSet &rSet) } case SID_COPY: { - if (!pOLV->HasSelection() || rView.isContentExtractionLocked()) + if (!pOLV->HasSelection() || GetObjectShell()->isContentExtractionLocked()) rSet.DisableItem( nWhich ); break; } diff --git a/sw/source/uibase/shells/basesh.cxx b/sw/source/uibase/shells/basesh.cxx index 55a0293a47c8..2cdd1e3a44cd 100644 --- a/sw/source/uibase/shells/basesh.cxx +++ b/sw/source/uibase/shells/basesh.cxx @@ -462,7 +462,7 @@ void SwBaseShell::StateClpbrd(SfxItemSet &rSet) } [[fallthrough]]; case SID_COPY: - if( !bCopy || GetView().isContentExtractionLocked()) + if( !bCopy || GetObjectShell()->isContentExtractionLocked()) rSet.DisableItem( nWhich ); break; diff --git a/sw/source/uibase/shells/drwtxtex.cxx b/sw/source/uibase/shells/drwtxtex.cxx index 8ace0fde6156..185b79dd3eb2 100644 --- a/sw/source/uibase/shells/drwtxtex.cxx +++ b/sw/source/uibase/shells/drwtxtex.cxx @@ -1162,7 +1162,7 @@ void SwDrawTextShell::StateClpbrd(SfxItemSet &rSet) { case SID_CUT: case SID_COPY: - if( !bCopy || GetView().isContentExtractionLocked()) + if( !bCopy || GetObjectShell()->isContentExtractionLocked()) rSet.DisableItem( nWhich ); break; diff --git a/sw/source/uibase/shells/grfsh.cxx b/sw/source/uibase/shells/grfsh.cxx index 1d91400926a3..e9808d6be430 100644 --- a/sw/source/uibase/shells/grfsh.cxx +++ b/sw/source/uibase/shells/grfsh.cxx @@ -754,7 +754,7 @@ void SwGrfShell::GetAttrState(SfxItemSet &rSet) case SID_SAVE_GRAPHIC: case SID_EXTERNAL_EDIT: - if( rSh.GetGraphicType() == GraphicType::NONE || GetView().isExportLocked()) + if( rSh.GetGraphicType() == GraphicType::NONE || GetObjectShell()->isExportLocked()) bDisable = true; break; diff --git a/sw/source/uibase/shells/textsh1.cxx b/sw/source/uibase/shells/textsh1.cxx index 89df49393efa..9567067f13e7 100644 --- a/sw/source/uibase/shells/textsh1.cxx +++ b/sw/source/uibase/shells/textsh1.cxx @@ -2170,7 +2170,7 @@ void SwTextShell::GetState( SfxItemSet &rSet ) case SID_COPY: case SID_CUT: { - if (GetShell().GetView().isContentExtractionLocked()) + if (GetObjectShell()->isContentExtractionLocked()) rSet.DisableItem(nWhich); break; } |