From acd820fd39394acc9829836a597c277d8965242e Mon Sep 17 00:00:00 2001 From: Katarina Behrens Date: Tue, 7 May 2019 16:27:22 +0200 Subject: tdf#83722: don't recycle frame with unmodified template a frame that contained valid but unmodified document opened from template or explicitly opened by the user (File > New) was treated the same as blank document i.e. it was reused and the content was overwritten by newly opened document (even if it already had non-empty content provided by the template). So let's not do that and let's open a new document in a new frame instead Change-Id: I10252d114e8cc5fcad3c98194ef07fd59873d6da Reviewed-on: https://gerrit.libreoffice.org/71919 Tested-by: Jenkins Reviewed-by: Michael Stahl Reviewed-by: Katarina Behrens --- framework/source/loadenv/loadenv.cxx | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/framework/source/loadenv/loadenv.cxx b/framework/source/loadenv/loadenv.cxx index 2ddfd34492d0..f37f267733b3 100644 --- a/framework/source/loadenv/loadenv.cxx +++ b/framework/source/loadenv/loadenv.cxx @@ -1076,7 +1076,7 @@ bool LoadEnv::impl_loadContent() // if it will be run out of scope. // Note further: ignore if this internal guard already contains a resource. - // Might impl_searchRecylcTarget() set it before. But in case this impl-method wasn't used + // Might impl_searchRecycleTarget() set it before. But in case this impl-method wasn't used // and the target frame was new created ... this lock here must be set! css::uno::Reference< css::document::XActionLockable > xTargetLock(xTargetFrame, css::uno::UNO_QUERY); m_aTargetLock.setResource(xTargetLock); @@ -1514,6 +1514,15 @@ css::uno::Reference< css::frame::XFrame > LoadEnv::impl_searchRecycleTarget() css::uno::Reference< css::frame::XController > xOldDoc = xTask->getController(); if (xOldDoc.is()) { + utl::MediaDescriptor lOldDocDescriptor(xModel->getArgs()); + bool bFromTemplate = lOldDocDescriptor.getUnpackedValueOrDefault(utl::MediaDescriptor::PROP_ASTEMPLATE() , false); + OUString sReferrer = lOldDocDescriptor.getUnpackedValueOrDefault(utl::MediaDescriptor::PROP_REFERRER(), OUString()); + + // tdf#83722: valid but unmodified document, either from template + // or opened by the user (File > New) + if (bFromTemplate || !sReferrer.isEmpty()) + return css::uno::Reference< css::frame::XFrame >(); + bReactivateOldControllerOnError = xOldDoc->suspend(true); if (! bReactivateOldControllerOnError) return css::uno::Reference< css::frame::XFrame >(); -- cgit