diff options
Diffstat (limited to 'sfx2')
-rw-r--r-- | sfx2/source/appl/appserv.cxx | 8 | ||||
-rw-r--r-- | sfx2/source/appl/childwin.cxx | 19 | ||||
-rw-r--r-- | sfx2/source/appl/macroloader.cxx | 9 | ||||
-rw-r--r-- | sfx2/source/appl/workwin.cxx | 6 | ||||
-rw-r--r-- | sfx2/source/dialog/basedlgs.cxx | 8 | ||||
-rw-r--r-- | sfx2/source/dialog/infobar.cxx | 20 | ||||
-rw-r--r-- | sfx2/source/doc/docfile.cxx | 52 | ||||
-rw-r--r-- | sfx2/source/doc/docmacromode.cxx | 8 | ||||
-rw-r--r-- | sfx2/source/doc/iframe.cxx | 77 | ||||
-rw-r--r-- | sfx2/source/doc/objembed.cxx | 9 | ||||
-rw-r--r-- | sfx2/source/doc/objmisc.cxx | 53 | ||||
-rw-r--r-- | sfx2/source/doc/objxtor.cxx | 9 | ||||
-rw-r--r-- | sfx2/source/doc/printhelper.cxx | 9 | ||||
-rw-r--r-- | sfx2/source/inc/eventsupplier.hxx | 1 | ||||
-rw-r--r-- | sfx2/source/inc/macroloader.hxx | 2 | ||||
-rw-r--r-- | sfx2/source/inc/objshimp.hxx | 3 | ||||
-rw-r--r-- | sfx2/source/view/viewfrm.cxx | 10 | ||||
-rw-r--r-- | sfx2/source/view/viewprn.cxx | 12 | ||||
-rw-r--r-- | sfx2/source/view/viewsh.cxx | 9 |
19 files changed, 258 insertions, 66 deletions
diff --git a/sfx2/source/appl/appserv.cxx b/sfx2/source/appl/appserv.cxx index 9df5f4232445..96577e81f72d 100644 --- a/sfx2/source/appl/appserv.cxx +++ b/sfx2/source/appl/appserv.cxx @@ -228,8 +228,10 @@ namespace SfxStringItem aURL(SID_FILE_NAME, ".component:Bibliography/View1"); SfxStringItem aRef(SID_REFERER, "private:user"); SfxStringItem aTarget(SID_TARGETNAME, "_blank"); - SfxViewFrame::Current()->GetDispatcher()->ExecuteList(SID_OPENDOC, - SfxCallMode::ASYNCHRON, { &aURL, &aRef, &aTarget }); + const SfxViewFrame* pViewFrame = SfxViewFrame::Current(); + if ( pViewFrame ) + pViewFrame->GetDispatcher()->ExecuteList(SID_OPENDOC, + SfxCallMode::ASYNCHRON, { &aURL, &aRef, &aTarget }); } catch (const Exception &) { @@ -549,7 +551,7 @@ void SfxApplication::MiscExec_Impl( SfxRequest& rReq ) case SID_SEND_FEEDBACK: { - sfx2::openUriExternally("https://www.cib.de/libreoffice-poweredbycib", false); + sfx2::openUriExternally("https://www.cib.de/office", false); break; } case SID_DOCUMENTATION: diff --git a/sfx2/source/appl/childwin.cxx b/sfx2/source/appl/childwin.cxx index a7013fa6c530..97a8c2e43bc2 100644 --- a/sfx2/source/appl/childwin.cxx +++ b/sfx2/source/appl/childwin.cxx @@ -628,7 +628,7 @@ void SfxChildWindow::SetVisible_Impl( bool bVis ) void SfxChildWindow::Hide() { if (xController) - xController->EndDialog(); + xController->EndDialog(nCloseResponseToJustHide); else pWindow->Hide(); } @@ -639,8 +639,21 @@ void SfxChildWindow::Show( ShowFlags nFlags ) { if (!xController->getDialog()->get_visible()) { - weld::DialogController::runAsync(xController, - [this](sal_Int32 /*nResult*/){ xController->Close(); }); + if (!xController->CloseOnHide()) + { + // tdf#155708 - do not run a new (Async) validation window, + // because we already have one in sync mode, just show the running one + xController->getDialog()->show(); + } + else + { + weld::DialogController::runAsync(xController, + [this](sal_Int32 nResult) { + if (nResult == nCloseResponseToJustHide) + return; + xController->Close(); + }); + } } } else diff --git a/sfx2/source/appl/macroloader.cxx b/sfx2/source/appl/macroloader.cxx index 98e036e0a7ea..b50d1e63c789 100644 --- a/sfx2/source/appl/macroloader.cxx +++ b/sfx2/source/appl/macroloader.cxx @@ -76,10 +76,10 @@ css::uno::Sequence<OUString> SAL_CALL SfxMacroLoader::getSupportedServiceNames() return aSeq; } -SfxObjectShell* SfxMacroLoader::GetObjectShell_Impl() +SfxObjectShell* SfxMacroLoader::GetObjectShell(const Reference <XFrame>& xFrame) { SfxObjectShell* pDocShell = nullptr; - Reference < XFrame > xFrame( m_xFrame.get(), UNO_QUERY ); + if ( xFrame.is() ) { SfxFrame* pFrame=nullptr; @@ -96,6 +96,11 @@ SfxObjectShell* SfxMacroLoader::GetObjectShell_Impl() return pDocShell; } +SfxObjectShell* SfxMacroLoader::GetObjectShell_Impl() +{ + Reference < XFrame > xFrame( m_xFrame.get(), UNO_QUERY ); + return SfxMacroLoader::GetObjectShell(xFrame); +} uno::Reference<frame::XDispatch> SAL_CALL SfxMacroLoader::queryDispatch( const util::URL& aURL , diff --git a/sfx2/source/appl/workwin.cxx b/sfx2/source/appl/workwin.cxx index 5feb326243fc..5fba0e02079f 100644 --- a/sfx2/source/appl/workwin.cxx +++ b/sfx2/source/appl/workwin.cxx @@ -1009,7 +1009,11 @@ void SfxWorkWindow::ShowChildren_Impl() { auto xController = pCli->xController; weld::DialogController::runAsync(xController, - [=](sal_Int32 /*nResult*/){ xController->Close(); }); + [=](sal_Int32 nResult){ + if (nResult == nCloseResponseToJustHide) + return; + xController->Close(); + }); } } else diff --git a/sfx2/source/dialog/basedlgs.cxx b/sfx2/source/dialog/basedlgs.cxx index 905d27fd3a3e..187a030fab4d 100644 --- a/sfx2/source/dialog/basedlgs.cxx +++ b/sfx2/source/dialog/basedlgs.cxx @@ -169,11 +169,11 @@ SfxModelessDialogController::~SfxModelessDialogController() m_pBindings->SetActiveFrame(nullptr); } -void SfxDialogController::EndDialog() +void SfxDialogController::EndDialog(int nResponse) { if (!m_xDialog->get_visible()) return; - response(RET_CLOSE); + response(nResponse); } bool SfxModelessDialogController::IsClosing() const @@ -181,7 +181,7 @@ bool SfxModelessDialogController::IsClosing() const return m_xImpl->bClosing; } -void SfxModelessDialogController::EndDialog() +void SfxModelessDialogController::EndDialog(int nResponse) { if (m_xImpl->bClosing) return; @@ -190,7 +190,7 @@ void SfxModelessDialogController::EndDialog() // stack frame. auto aHoldSelf = shared_from_this(); m_xImpl->bClosing = true; - SfxDialogController::EndDialog(); + SfxDialogController::EndDialog(nResponse); if (!m_xImpl) return; m_xImpl->bClosing = false; diff --git a/sfx2/source/dialog/infobar.cxx b/sfx2/source/dialog/infobar.cxx index 3479fe72ad7d..b8d79f0b5a9c 100644 --- a/sfx2/source/dialog/infobar.cxx +++ b/sfx2/source/dialog/infobar.cxx @@ -13,6 +13,7 @@ #include <drawinglayer/primitive2d/polypolygonprimitive2d.hxx> #include <drawinglayer/processor2d/baseprocessor2d.hxx> #include <drawinglayer/processor2d/processorfromoutputdevice.hxx> +#include <officecfg/Office/UI/Infobar.hxx> #include <sfx2/bindings.hxx> #include <sfx2/dispatch.hxx> #include <sfx2/infobar.hxx> @@ -392,6 +393,9 @@ SfxInfoBarContainerWindow::appendInfoBar(const OUString& sId, const OUString& sP const OUString& sSecondaryMessage, InfobarType ibType, WinBits nMessageStyle, bool bShowCloseButton) { + if (!isInfobarEnabled(sId)) + return nullptr; + auto pInfoBar = VclPtr<SfxInfoBarWindow>::Create(this, sId, sPrimaryMessage, sSecondaryMessage, ibType, nMessageStyle, bShowCloseButton); @@ -437,6 +441,22 @@ void SfxInfoBarContainerWindow::removeInfoBar(VclPtr<SfxInfoBarWindow> const & p m_pChildWin->Update(); } +bool SfxInfoBarContainerWindow::isInfobarEnabled(const OUString& sId) +{ + if (sId == "readonly") + return officecfg::Office::UI::Infobar::Enabled::Readonly::get(); + if (sId == "signature") + return officecfg::Office::UI::Infobar::Enabled::Signature::get(); + if (sId == "donate") + return officecfg::Office::UI::Infobar::Enabled::Donate::get(); + if (sId == "getinvolved") + return officecfg::Office::UI::Infobar::Enabled::GetInvolved::get(); + if (sId == "hyphenationmissing") + return officecfg::Office::UI::Infobar::Enabled::HyphenationMissing::get(); + + return true; +} + void SfxInfoBarContainerWindow::Resize() { long nWidth = GetSizePixel().getWidth(); diff --git a/sfx2/source/doc/docfile.cxx b/sfx2/source/doc/docfile.cxx index 5d00d39bd837..8c0d101c4ea9 100644 --- a/sfx2/source/doc/docfile.cxx +++ b/sfx2/source/doc/docfile.cxx @@ -51,6 +51,7 @@ #include <com/sun/star/ucb/CommandFailedException.hpp> #include <com/sun/star/ucb/CommandAbortedException.hpp> #include <com/sun/star/ucb/InteractiveLockingLockedException.hpp> +#include <com/sun/star/ucb/InteractiveNetworkReadException.hpp> #include <com/sun/star/ucb/InteractiveNetworkWriteException.hpp> #include <com/sun/star/ucb/Lock.hpp> #include <com/sun/star/ucb/XCommandEnvironment.hpp> @@ -1125,6 +1126,37 @@ namespace } } +namespace +{ + +// for LOCK request, suppress dialog on 403, typically indicates read-only +// document and there's a 2nd dialog prompting to open a copy anyway +class LockInteractionHandler : public ::cppu::WeakImplHelper<task::XInteractionHandler> +{ +private: + uno::Reference<task::XInteractionHandler> m_xHandler; + +public: + explicit LockInteractionHandler(uno::Reference<task::XInteractionHandler> const& xHandler) + : m_xHandler(xHandler) + { + } + + virtual void SAL_CALL handle(uno::Reference<task::XInteractionRequest> const& xRequest) override + { + ucb::InteractiveNetworkWriteException readException; + ucb::InteractiveNetworkReadException writeException; + if ((xRequest->getRequest() >>= readException) + || (xRequest->getRequest() >>= writeException)) + { + return; // 403 gets reported as one of these; ignore to avoid dialog + } + m_xHandler->handle(xRequest); + } +}; + +} // namespace + #endif // HAVE_FEATURE_MULTIUSER_ENVIRONMENT // sets SID_DOC_READONLY if the document cannot be opened for editing @@ -1172,6 +1204,13 @@ SfxMedium::LockFileResult SfxMedium::LockOrigFileOnDemand(bool bLoading, bool bN if( !bResult ) { uno::Reference< task::XInteractionHandler > xCHandler = GetInteractionHandler( true ); + // Dialog with error is superfluous: + // on loading, will result in read-only with infobar. + // bNoUI case for Reload failing, will open dialog later. + if (bLoading || bNoUI) + { + xCHandler = new LockInteractionHandler(xCHandler); + } Reference< css::ucb::XCommandEnvironment > xComEnv = new ::ucbhelper::CommandEnvironment( xCHandler, Reference< css::ucb::XProgressHandler >() ); @@ -4215,17 +4254,18 @@ OUString SfxMedium::SwitchDocumentToTempFile() {} } + if (bWasReadonly) + { + // set the readonly state back + pImpl->m_nStorOpenMode = SFX_STREAM_READONLY; + GetItemSet()->Put(SfxBoolItem(SID_DOC_READONLY, true)); + } + if ( aResult.isEmpty() ) { Close(); SetPhysicalName_Impl( OUString() ); SetName( aOrigURL ); - if ( bWasReadonly ) - { - // set the readonly state back - pImpl->m_nStorOpenMode = SFX_STREAM_READONLY; - GetItemSet()->Put( SfxBoolItem(SID_DOC_READONLY, true)); - } GetMedium_Impl(); pImpl->xStorage = xStorage; } diff --git a/sfx2/source/doc/docmacromode.cxx b/sfx2/source/doc/docmacromode.cxx index 2fa7b968fc41..8a617b1785c6 100644 --- a/sfx2/source/doc/docmacromode.cxx +++ b/sfx2/source/doc/docmacromode.cxx @@ -404,8 +404,12 @@ namespace sfx2 return bHasMacros; } + bool DocumentMacroMode::hasMacros() const + { + return m_xData->m_rDocumentAccess.documentStorageHasMacros() || hasMacroLibrary() || m_xData->m_rDocumentAccess.macroCallsSeenWhileLoading(); + } - bool DocumentMacroMode::checkMacrosOnLoading( const Reference< XInteractionHandler >& rxInteraction, bool bHasValidContentSignature ) + bool DocumentMacroMode::checkMacrosOnLoading( const Reference< XInteractionHandler >& rxInteraction, bool bHasValidContentSignature, bool bHasMacros ) { bool bAllow = false; if ( SvtSecurityOptions().IsMacroDisabled() ) @@ -415,7 +419,7 @@ namespace sfx2 } else { - if (m_xData->m_rDocumentAccess.documentStorageHasMacros() || hasMacroLibrary() || m_xData->m_rDocumentAccess.macroCallsSeenWhileLoading()) + if (bHasMacros) { if (m_xData->m_rDocumentAccess.macroCallsSeenWhileLoading()) m_bNeedsContentSigned = true; diff --git a/sfx2/source/doc/iframe.cxx b/sfx2/source/doc/iframe.cxx index 8b1271545dfb..23c2defd92d8 100644 --- a/sfx2/source/doc/iframe.cxx +++ b/sfx2/source/doc/iframe.cxx @@ -38,12 +38,16 @@ #include <svtools/miscopt.hxx> #include <svl/ownlist.hxx> #include <svl/itemprop.hxx> +#include <sfx2/docfile.hxx> #include <sfx2/frmdescr.hxx> +#include <sfx2/objsh.hxx> #include <sfx2/sfxdlg.hxx> #include <sfx2/sfxsids.hrc> #include <toolkit/helper/vclunohelper.hxx> #include <vcl/window.hxx> #include <tools/debug.hxx> +#include <macroloader.hxx> +#include <eventsupplier.hxx> using namespace ::com::sun::star; @@ -159,38 +163,67 @@ sal_Bool SAL_CALL IFrameObject::load( { if ( SvtMiscOptions().IsPluginsEnabled() ) { - DBG_ASSERT( !mxFrame.is(), "Frame already existing!" ); - VclPtr<vcl::Window> pParent = VCLUnoHelper::GetWindow( xFrame->getContainerWindow() ); - VclPtr<IFrameWindow_Impl> pWin = VclPtr<IFrameWindow_Impl>::Create( pParent, maFrmDescr.IsFrameBorderOn() ); - pWin->SetSizePixel( pParent->GetOutputSizePixel() ); - pWin->SetBackground(); - pWin->Show(); + util::URL aTargetURL; + aTargetURL.Complete = maFrmDescr.GetURL().GetMainURL( INetURLObject::DecodeMechanism::NONE ); + uno::Reference < util::XURLTransformer > xTrans( util::URLTransformer::create( mxContext ) ); + xTrans->parseStrict( aTargetURL ); - uno::Reference < awt::XWindow > xWindow( pWin->GetComponentInterface(), uno::UNO_QUERY ); - xFrame->setComponent( xWindow, uno::Reference < frame::XController >() ); + INetURLObject aURLObject(aTargetURL.Complete); + if (aURLObject.IsExoticProtocol()) + { + SAL_WARN("sfx", "IFrameObject::load ignoring: " << aTargetURL.Complete); + return false; + } - // we must destroy the IFrame before the parent is destroyed - xWindow->addEventListener( this ); + uno::Reference<frame::XFramesSupplier> xParentFrame = xFrame->getCreator(); + SfxObjectShell* pDoc = SfxMacroLoader::GetObjectShell(xParentFrame); - mxFrame = frame::Frame::create( mxContext ); - uno::Reference < awt::XWindow > xWin( pWin->GetComponentInterface(), uno::UNO_QUERY ); - mxFrame->initialize( xWin ); - mxFrame->setName( maFrmDescr.GetName() ); + bool bUpdateAllowed(true); + if (pDoc) + { + comphelper::EmbeddedObjectContainer& rEmbeddedObjectContainer = pDoc->getEmbeddedObjectContainer(); + bUpdateAllowed = rEmbeddedObjectContainer.getUserAllowsLinkUpdate(); + } + if (!bUpdateAllowed) + return false; - uno::Reference < frame::XFramesSupplier > xFramesSupplier( xFrame, uno::UNO_QUERY ); - if ( xFramesSupplier.is() ) - mxFrame->setCreator( xFramesSupplier ); + OUString sReferer; + if (pDoc && pDoc->HasName()) + sReferer = pDoc->GetMedium()->GetName(); - util::URL aTargetURL; - aTargetURL.Complete = maFrmDescr.GetURL().GetMainURL( INetURLObject::DecodeMechanism::NONE ); - uno::Reference < util::XURLTransformer > xTrans( util::URLTransformer::create( mxContext ) ); - xTrans->parseStrict( aTargetURL ); + uno::Reference<css::awt::XWindow> xParentWindow(xFrame->getContainerWindow()); + + if (!mxFrame.is()) + { + VclPtr<vcl::Window> pParent = VCLUnoHelper::GetWindow(xParentWindow); + VclPtr<IFrameWindow_Impl> pWin = VclPtr<IFrameWindow_Impl>::Create( pParent, maFrmDescr.IsFrameBorderOn() ); + pWin->SetSizePixel( pParent->GetOutputSizePixel() ); + pWin->SetBackground(); + pWin->Show(); + + uno::Reference < awt::XWindow > xWindow( pWin->GetComponentInterface(), uno::UNO_QUERY ); + xFrame->setComponent( xWindow, uno::Reference < frame::XController >() ); + + // we must destroy the IFrame before the parent is destroyed + xWindow->addEventListener( this ); + + mxFrame = frame::Frame::create( mxContext ); + uno::Reference < awt::XWindow > xWin( pWin->GetComponentInterface(), uno::UNO_QUERY ); + mxFrame->initialize( xWin ); + mxFrame->setName( maFrmDescr.GetName() ); + + uno::Reference < frame::XFramesSupplier > xFramesSupplier( xFrame, uno::UNO_QUERY ); + if ( xFramesSupplier.is() ) + mxFrame->setCreator( xFramesSupplier ); + } - uno::Sequence < beans::PropertyValue > aProps(2); + uno::Sequence < beans::PropertyValue > aProps(3); aProps[0].Name = "PluginMode"; aProps[0].Value <<= sal_Int16(2); aProps[1].Name = "ReadOnly"; aProps[1].Value <<= true; + aProps[2].Name = "Referer"; + aProps[2].Value <<= sReferer; uno::Reference < frame::XDispatch > xDisp = mxFrame->queryDispatch( aTargetURL, "_self", 0 ); if ( xDisp.is() ) xDisp->dispatch( aTargetURL, aProps ); diff --git a/sfx2/source/doc/objembed.cxx b/sfx2/source/doc/objembed.cxx index 7d5cdb5cb21c..2d4b6ef5229e 100644 --- a/sfx2/source/doc/objembed.cxx +++ b/sfx2/source/doc/objembed.cxx @@ -28,6 +28,7 @@ #include <sfx2/app.hxx> #include <objshimp.hxx> #include <sfx2/event.hxx> +#include <sfx2/sfxbasemodel.hxx> #include <comphelper/fileformat.h> #include <svtools/embedtransfer.hxx> @@ -118,8 +119,14 @@ void SfxObjectShell::SetVisArea( const tools::Rectangle & rVisArea ) pImpl->m_aVisArea = rVisArea; if ( GetCreateMode() == SfxObjectCreateMode::EMBEDDED ) { - if ( IsEnableSetModified() ) + if (IsEnableSetModified() + // Base forms use EMBEDDED but they actually live in their own + // frame - resizing that shouldn't set it to modified. + && pImpl->pBaseModel + && pImpl->pBaseModel->getIdentifier() != "com.sun.star.sdb.FormDesign") + { SetModified(); + } SfxGetpApp()->NotifyEvent(SfxEventHint( SfxEventHintId::VisAreaChanged, GlobalEventConfig::GetEventName(GlobalEventId::VISAREACHANGED), this)); } diff --git a/sfx2/source/doc/objmisc.cxx b/sfx2/source/doc/objmisc.cxx index 04ff6ecd5314..9ff78bff6eea 100644 --- a/sfx2/source/doc/objmisc.cxx +++ b/sfx2/source/doc/objmisc.cxx @@ -87,6 +87,8 @@ #include <comphelper/interaction.hxx> #include <comphelper/storagehelper.hxx> #include <comphelper/documentconstants.hxx> +#include <comphelper/namedvaluecollection.hxx> +#include <officecfg/Office/Common.hxx> #include <sfx2/signaturestate.hxx> #include <sfx2/app.hxx> @@ -260,7 +262,12 @@ void SfxObjectShell::EnableSetModified( bool bEnable ) bool SfxObjectShell::IsEnableSetModified() const { - return pImpl->m_bEnableSetModified && !IsReadOnly(); + // tdf#146547 read-only does not prevent modified, instead try to prevent + // setting "internal" documents that may be displayed in some dialog but + // which the user didn't load or activate to modified. + return pImpl->m_bEnableSetModified && !IsPreview() + && eCreateMode != SfxObjectCreateMode::ORGANIZER + && eCreateMode != SfxObjectCreateMode::INTERNAL; } @@ -965,9 +972,42 @@ void SfxObjectShell::CheckSecurityOnLoading_Impl() // check macro security const bool bHasValidContentSignature = HasValidSignatures(); - pImpl->aMacroMode.checkMacrosOnLoading( xInteraction, bHasValidContentSignature ); + const bool bHasMacros = pImpl->aMacroMode.hasMacros(); + pImpl->aMacroMode.checkMacrosOnLoading( xInteraction, bHasValidContentSignature, bHasMacros ); + pImpl->m_bHadCheckedMacrosOnLoad = bHasMacros; } +bool SfxObjectShell::GetHadCheckedMacrosOnLoad() const +{ + return pImpl->m_bHadCheckedMacrosOnLoad; +} + +bool SfxObjectShell::AllowedLinkProtocolFromDocument(const OUString& rUrl, SfxObjectShell* pObjShell, weld::Window* pDialogParent) +{ + if (!INetURLObject(rUrl).IsExoticProtocol()) + return true; + // Default to ignoring exotic protocols + bool bAllow = false; + if (pObjShell) + { + // If the document had macros when loaded then follow the allowed macro-mode + if (pObjShell->GetHadCheckedMacrosOnLoad()) + bAllow = pObjShell->AdjustMacroMode(); + else // otherwise ask the user, defaulting to cancel + { + //Reuse URITools::onOpenURI warning string + std::unique_ptr<weld::MessageDialog> xQueryBox(Application::CreateMessageDialog(pDialogParent, + VclMessageType::Warning, VclButtonsType::YesNo, + SfxResId(STR_DANGEROUS_TO_OPEN))); + xQueryBox->set_primary_text(xQueryBox->get_primary_text().replaceFirst("$(ARG1)", + INetURLObject::decode(rUrl, INetURLObject::DecodeMechanism::Unambiguous))); + xQueryBox->set_default_response(RET_NO); + bAllow = xQueryBox->run() == RET_YES; + } + } + SAL_WARN_IF(!bAllow, "sfx.appl", "SfxObjectShell::AllowedLinkProtocolFromDocument ignoring: " << rUrl); + return bAllow; +} void SfxObjectShell::CheckEncryption_Impl( const uno::Reference< task::XInteractionHandler >& xHandler ) { @@ -1896,4 +1936,13 @@ bool SfxObjectShell::IsContinueImportOnFilterExceptions(const OUString& aErrMess return mbContinueImportOnFilterExceptions == yes; } +bool SfxObjectShell::isEditDocLocked() +{ + Reference<XModel> xModel = GetModel(); + if (!xModel.is()) + return false; + comphelper::NamedValueCollection aArgs(xModel->getArgs()); + return aArgs.getOrDefault("LockEditDoc", false); +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sfx2/source/doc/objxtor.cxx b/sfx2/source/doc/objxtor.cxx index 510c35daf59f..ecac02074ea2 100644 --- a/sfx2/source/doc/objxtor.cxx +++ b/sfx2/source/doc/objxtor.cxx @@ -237,6 +237,7 @@ SfxObjectShell_Impl::SfxObjectShell_Impl( SfxObjectShell& _rDocShell ) ,m_bAllowShareControlFileClean( true ) ,m_bConfigOptionsChecked( false ) ,m_bMacroCallsSeenWhileLoading( false ) + ,m_bHadCheckedMacrosOnLoad( false ) ,lErr(ERRCODE_NONE) ,nEventId ( SfxEventHintId::NONE ) ,nLoadedFlags ( SfxLoadedFlags::ALL ) @@ -589,7 +590,13 @@ bool SfxObjectShell::PrepareClose { // Save by each Dispatcher const SfxPoolItem *pPoolItem; - if ( IsSaveVersionOnClose() ) + if (IsReadOnly()) + { + SfxBoolItem aWarnItem( SID_FAIL_ON_WARNING, bUI ); + const SfxPoolItem* ppArgs[] = { &aWarnItem, nullptr }; + pPoolItem = pFrame->GetBindings().ExecuteSynchron(SID_SAVEASDOC, ppArgs); + } + else if (IsSaveVersionOnClose()) { SfxStringItem aItem( SID_DOCINFO_COMMENTS, SfxResId(STR_AUTOMATICVERSION) ); SfxBoolItem aWarnItem( SID_FAIL_ON_WARNING, bUI ); diff --git a/sfx2/source/doc/printhelper.cxx b/sfx2/source/doc/printhelper.cxx index 42936e53fe99..263c20b58e26 100644 --- a/sfx2/source/doc/printhelper.cxx +++ b/sfx2/source/doc/printhelper.cxx @@ -711,6 +711,15 @@ void SAL_CALL SfxPrintHelper::print(const uno::Sequence< beans::PropertyValue >& aCheckedArgs[nProps++].Value <<= bTemp; } + else if ( rProp.Name == "JobName" ) + { + OUString sTemp; + if( !(rProp.Value >>= sTemp) ) + throw css::lang::IllegalArgumentException(); + aCheckedArgs[nProps].Name = rProp.Name; + aCheckedArgs[nProps++].Value <<= sTemp; + } + // Pages-Property else if ( rProp.Name == "Pages" ) { diff --git a/sfx2/source/inc/eventsupplier.hxx b/sfx2/source/inc/eventsupplier.hxx index 4624ed8b4907..d24345dba1c5 100644 --- a/sfx2/source/inc/eventsupplier.hxx +++ b/sfx2/source/inc/eventsupplier.hxx @@ -87,7 +87,6 @@ public: SfxObjectShell* i_document ); static void Execute( css::uno::Any const & aEventData, const css::document::DocumentEvent& aTrigger, SfxObjectShell* pDoc ); -private: /// Check if script URL whitelist exists, and if so, if current script url is part of it static bool isScriptURLAllowed(const OUString& aScriptURL); }; diff --git a/sfx2/source/inc/macroloader.hxx b/sfx2/source/inc/macroloader.hxx index 9e1dfba18ed0..b3e7a5ec1abc 100644 --- a/sfx2/source/inc/macroloader.hxx +++ b/sfx2/source/inc/macroloader.hxx @@ -82,6 +82,8 @@ public: virtual void SAL_CALL addStatusListener( const css::uno::Reference< css::frame::XStatusListener >& xControl, const css::util::URL& aURL ) override; virtual void SAL_CALL removeStatusListener( const css::uno::Reference< css::frame::XStatusListener >& xControl, const css::util::URL& aURL ) override; + + static SfxObjectShell* GetObjectShell(const css::uno::Reference<css::frame::XFrame>& xFrame); }; #endif diff --git a/sfx2/source/inc/objshimp.hxx b/sfx2/source/inc/objshimp.hxx index 3d7b0b69c945..4afdd706d05e 100644 --- a/sfx2/source/inc/objshimp.hxx +++ b/sfx2/source/inc/objshimp.hxx @@ -91,7 +91,8 @@ struct SfxObjectShell_Impl : public ::sfx2::IMacroDocumentAccess m_bSharedXMLFlag:1, // whether the document should be edited in shared mode m_bAllowShareControlFileClean:1, // whether the flag should be stored in xml file m_bConfigOptionsChecked:1, // whether or not the user options are checked after the Options dialog is closed. - m_bMacroCallsSeenWhileLoading:1; // whether or not the user options are checked after the Options dialog is closed. + m_bMacroCallsSeenWhileLoading:1, // whether or not macro calls were seen when loading document. + m_bHadCheckedMacrosOnLoad:1; // if document contained macros (or calls) when loaded IndexBitSet aBitSet; ErrCode lErr; diff --git a/sfx2/source/view/viewfrm.cxx b/sfx2/source/view/viewfrm.cxx index 885023465120..bbfb37e5291d 100644 --- a/sfx2/source/view/viewfrm.cxx +++ b/sfx2/source/view/viewfrm.cxx @@ -308,8 +308,7 @@ void SfxViewFrame::ExecReload_Impl( SfxRequest& rReq ) if( !pSh || !pSh->HasName() || !(pSh->Get_Impl()->nLoadedFlags & SfxLoadedFlags::MAINDOCUMENT )) break; - SfxViewShell* pViewSh = GetViewShell(); - if (pViewSh && pViewSh->isEditDocLocked()) + if (pSh->isEditDocLocked()) break; // Only change read-only UI and remove info bar when we succeed @@ -331,9 +330,12 @@ void SfxViewFrame::ExecReload_Impl( SfxRequest& rReq ) m_pFrame->RemoveInfoBar("readonly"); if (m_pMed) { + bool const isEnableSetModified(m_pSh->IsEnableSetModified()); + m_pSh->EnableSetModified(false); // tdf#116066: DoSaveCompleted should be called after SetReadOnlyUI m_pSh->DoSaveCompleted(m_pMed); m_pSh->Broadcast(SfxHint(SfxHintId::ModeChanged)); + m_pSh->EnableSetModified(isEnableSetModified); } } } @@ -929,7 +931,7 @@ void SfxViewFrame::StateReload_Impl( SfxItemSet& rSet ) const SfxShell *pFSh; if ( !pSh->HasName() || !( pSh->Get_Impl()->nLoadedFlags & SfxLoadedFlags::MAINDOCUMENT ) || - (GetViewShell() && GetViewShell()->isEditDocLocked()) || + (pSh->isEditDocLocked()) || ( pSh->GetCreateMode() == SfxObjectCreateMode::EMBEDDED && ( !(pVSh = pSh->GetViewShell()) || !(pFSh = pVSh->GetFormShell()) || @@ -1351,7 +1353,7 @@ void SfxViewFrame::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint ) } bool showEditDocumentButton = true; - if (m_xObjSh->GetViewShell() && m_xObjSh->GetViewShell()->isEditDocLocked()) + if (m_xObjSh->isEditDocLocked()) showEditDocumentButton = false; if (showEditDocumentButton) diff --git a/sfx2/source/view/viewprn.cxx b/sfx2/source/view/viewprn.cxx index b67267a61b53..f9cd9c005c39 100644 --- a/sfx2/source/view/viewprn.cxx +++ b/sfx2/source/view/viewprn.cxx @@ -616,10 +616,14 @@ void SfxViewShell::StartPrint( const uno::Sequence < beans::PropertyValue >& rPr )); pImpl->m_xPrinterController = xNewController; - SfxObjectShell *pObjShell = GetObjectShell(); - xNewController->setValue( "JobName", - makeAny( pObjShell->GetTitle(1) ) ); - xNewController->setPrinterModified( mbPrinterSettingsModified ); + // When no JobName was specified via com::sun::star::view::PrintOptions::JobName , + // use the document title as default job name + css::beans::PropertyValue* pJobNameVal = xNewController->getValue("JobName"); + if (!pJobNameVal) + { + xNewController->setValue("JobName", Any(GetObjectShell()->GetTitle(1))); + xNewController->setPrinterModified(mbPrinterSettingsModified); + } } void SfxViewShell::ExecPrint( const uno::Sequence < beans::PropertyValue >& rProps, bool bIsAPI, bool bIsDirect ) diff --git a/sfx2/source/view/viewsh.cxx b/sfx2/source/view/viewsh.cxx index 80cd8a122d07..cb7925efa907 100644 --- a/sfx2/source/view/viewsh.cxx +++ b/sfx2/source/view/viewsh.cxx @@ -1776,15 +1776,6 @@ bool SfxViewShell::isPrintLocked() return aArgs.getOrDefault("LockPrint", false); } -bool SfxViewShell::isEditDocLocked() -{ - Reference<XModel> xModel = GetCurrentDocument(); - if (!xModel.is()) - return false; - comphelper::NamedValueCollection aArgs(xModel->getArgs()); - return aArgs.getOrDefault("LockEditDoc", false); -} - bool SfxViewShell::isSaveLocked() { Reference<XModel> xModel = GetCurrentDocument(); |