diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2024-08-30 23:39:52 +0500 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2024-08-31 12:05:10 +0200 |
commit | 3cf243ac31098de2d275c722a474a36b330df6e1 (patch) | |
tree | fcf4b8118262fff9a27548f641b834bcb4fd79e3 /xmloff/source/style | |
parent | 688ddd1eaaa7064a0c3fc6018ca2c37a6e323f46 (diff) |
tdf#162715: do not import theme when pasting from clipboard
This change makes the two code paths consistent, that are used to paste
native ODF data into the Writer document: that uses own transferable in
usual copy/paste procedure; and that uses "foreign" clipboard data from
another Writer session. The path using own transferable already didn't
set document theme. This change passes the "IsInPaste" flag down to the
XML reader, to let the latter code path skip the theme when reading ODT.
Change-Id: I44d36e4583c58500febd647bb3def6421e585ed6
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/172688
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'xmloff/source/style')
-rw-r--r-- | xmloff/source/style/xmlstyle.cxx | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/xmloff/source/style/xmlstyle.cxx b/xmloff/source/style/xmlstyle.cxx index efc4da3e6842..e09ef37bfa12 100644 --- a/xmloff/source/style/xmlstyle.cxx +++ b/xmloff/source/style/xmlstyle.cxx @@ -21,6 +21,7 @@ #include <sal/config.h> +#include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/frame/XModel.hpp> #include <com/sun/star/container/XNameContainer.hpp> #include <com/sun/star/style/XStyleFamiliesSupplier.hpp> @@ -28,6 +29,8 @@ #include <com/sun/star/style/XAutoStyleFamily.hpp> #include <com/sun/star/drawing/XDrawPageSupplier.hpp> #include <PageMasterPropMapper.hxx> + +#include <comphelper/diagnose_ex.hxx> #include <sal/log.hxx> #include <svl/style.hxx> #include <utility> @@ -683,6 +686,26 @@ css::uno::Reference< css::xml::sax::XFastContextHandler > SvXMLStylesContext::cr { if (nElement == XML_ELEMENT(LO_EXT, XML_THEME)) { + if (auto xImportInfo = GetImport().getImportInfo()) + { + try + { + if (auto xPropertySetInfo = xImportInfo->getPropertySetInfo()) + { + if (xPropertySetInfo->hasPropertyByName(u"IsInPaste"_ustr)) + { + css::uno::Any value = xImportInfo->getPropertyValue(u"IsInPaste"_ustr); + if (bool b; (value >>= b) && b) + return nullptr; // do not import themes in paste mode + } + } + } + catch (const css::uno::Exception&) + { + DBG_UNHANDLED_EXCEPTION("xmloff"); + } + } + uno::Reference<uno::XInterface> xObject(GetImport().GetModel(), uno::UNO_QUERY); uno::Reference<drawing::XDrawPageSupplier> const xDrawPageSupplier(GetImport().GetModel(), uno::UNO_QUERY); if (xDrawPageSupplier.is()) |