[Libreoffice-commits] core.git: Branch 'libreoffice-7-1' - sw/source writerfilter/source
Mike Kaganski (via logerrit)
logerrit at kemper.freedesktop.org
Tue Apr 6 20:52:52 UTC 2021
sw/source/uibase/dochdl/swdtflvr.cxx | 6 ++++++
writerfilter/source/rtftok/rtfdocumentimpl.cxx | 3 ++-
2 files changed, 8 insertions(+), 1 deletion(-)
New commits:
commit 6d9d8c5a1abaf4ce2672406e2c04d68da5bb2cf7
Author: Mike Kaganski <mike.kaganski at collabora.com>
AuthorDate: Mon Apr 5 19:19:44 2021 +0300
Commit: Xisco Fauli <xiscofauli at libreoffice.org>
CommitDate: Tue Apr 6 22:52:17 2021 +0200
tdf#136740: Do not initialize document settings when pasting
When pasting from clipboard, the document already has the defaults
set, and pasted text must not change those defaults.
When pasting RTF, RTFDocumentImpl::outputSettingsTable does the document
settings initialization, and is called from RTFDocumentImpl::checkFirstRun
when m_bFirstRun is true. Other defaults are set in the latter function,
too.
This makes m_bFirstRun false when RTFDocumentImpl is created in the context
of a paste operation. Alternatively, checking the context could be made
when deciding if to apply specific settings.
Change-Id: Ide1eabbef1d04a4fa2f1ca14846b8e404f2a0cb1
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/113613
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski at collabora.com>
(cherry picked from commit d7c4d0d4ea83481693af3645a03b03b53e456f60)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/113634
Reviewed-by: Xisco Fauli <xiscofauli at libreoffice.org>
diff --git a/sw/source/uibase/dochdl/swdtflvr.cxx b/sw/source/uibase/dochdl/swdtflvr.cxx
index 894d9049bcfd..8caa6c50c358 100644
--- a/sw/source/uibase/dochdl/swdtflvr.cxx
+++ b/sw/source/uibase/dochdl/swdtflvr.cxx
@@ -32,6 +32,7 @@
#include <comphelper/fileformat.h>
#include <comphelper/processfactory.hxx>
#include <comphelper/servicehelper.hxx>
+#include <comphelper/SetFlagContextHelper.hxx>
#include <comphelper/storagehelper.hxx>
#include <comphelper/string.hxx>
#include <o3tl/deleter.hxx>
@@ -2100,6 +2101,11 @@ bool SwTransferable::PasteFileContent( TransferableDataHelper& rData,
rSh.SetChgLnk( Link<LinkParamNone*,void>() );
const SwPosition& rInsPos = *rSh.GetCursor()->Start();
+
+ // Reader might need to know if we are pasting into an existing document, or initializing
+ // a new document; e.g. initializing document setting could be skipped when pasting.
+ css::uno::ContextLayer layer(comphelper::NewFlagContext("InPasteFromClipboard"));
+
SwReader aReader(*pStream, OUString(), OUString(), *rSh.GetCursor());
rSh.SaveTableBoxContent( &rInsPos );
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index 9977306b90f0..3cc89508c71c 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -22,6 +22,7 @@
#include <com/sun/star/drawing/XDrawPageSupplier.hpp>
#include <filter/msfilter/util.hxx>
#include <filter/msfilter/rtfutil.hxx>
+#include <comphelper/SetFlagContextHelper.hxx>
#include <comphelper/string.hxx>
#include <tools/diagnose_ex.h>
#include <tools/globname.hxx>
@@ -266,7 +267,7 @@ RTFDocumentImpl::RTFDocumentImpl(uno::Reference<uno::XComponentContext> const& x
, m_pMapperStream(nullptr)
, m_aDefaultState(this)
, m_bSkipUnknown(false)
- , m_bFirstRun(true)
+ , m_bFirstRun(!comphelper::IsContextFlagActive("InPasteFromClipboard"))
, m_bFirstRunException(false)
, m_bNeedPap(true)
, m_bNeedCr(false)
More information about the Libreoffice-commits
mailing list