diff options
author | Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de> | 2020-03-03 13:57:24 +0100 |
---|---|---|
committer | Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de> | 2020-03-11 12:43:44 +0100 |
commit | eeeed08b428685dd7934c4576f1bf4aa7436f96a (patch) | |
tree | 3741ee1cb472a42ef776fff147d8608a75bfdab1 /cui | |
parent | dc4a291b900fd4786e9e9e7515c3a8675a8c3467 (diff) |
tdf#125440 Allow raising text import dialog for paste
This adds an entry to the "Paste special" dialog to raise
the Text Import Dialog.
This way, users can correctly import CSV/TSV,
even when pasting just one line of formatted input.
Change-Id: Ic09d7d60a05b14906f166668b38ec0eb8ead2d19
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/89886
Tested-by: Jenkins
Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>
Diffstat (limited to 'cui')
-rw-r--r-- | cui/source/dialogs/pastedlg.cxx | 24 | ||||
-rw-r--r-- | cui/source/factory/dlgfact.cxx | 5 | ||||
-rw-r--r-- | cui/source/factory/dlgfact.hxx | 1 | ||||
-rw-r--r-- | cui/source/inc/pastedlg.hxx | 3 |
4 files changed, 32 insertions, 1 deletions
diff --git a/cui/source/dialogs/pastedlg.cxx b/cui/source/dialogs/pastedlg.cxx index f9d9a76318ab..375a966c7786 100644 --- a/cui/source/dialogs/pastedlg.cxx +++ b/cui/source/dialogs/pastedlg.cxx @@ -26,6 +26,8 @@ #include <svtools/strings.hrc> #include <svtools/svtresid.hxx> #include <tools/lineend.hxx> +#include <comphelper/propertysequence.hxx> +#include <comphelper/dispatchcommand.hxx> SvPasteObjectDialog::SvPasteObjectDialog(weld::Window* pParent) : GenericDialogController(pParent, "cui/ui/pastespecial.ui", "PasteSpecialDialog") @@ -70,6 +72,13 @@ void SvPasteObjectDialog::Insert( SotClipboardFormatId nFormat, const OUString& aSupplementMap.insert( std::make_pair( nFormat, rFormatName ) ); } +void SvPasteObjectDialog::InsertUno(const OUString& sCmd, const OUString& sLabel) +{ + aExtraCommand.first = sCmd; + aExtraCommand.second = sLabel; +} + + void SvPasteObjectDialog::PreGetFormat( const TransferableDataHelper &rHelper ) { //TODO/LATER: why is the Descriptor never used?! @@ -286,6 +295,11 @@ SotClipboardFormatId SvPasteObjectDialog::GetFormat( const TransferableDataHelpe } } + if (!aExtraCommand.first.isEmpty()) + { + ObjectLB().append(aExtraCommand.first, aExtraCommand.second); + } + ObjectLB().thaw(); SelectObject(); @@ -302,7 +316,15 @@ SotClipboardFormatId SvPasteObjectDialog::GetFormat( const TransferableDataHelpe if (run() == RET_OK) { - nSelFormat = static_cast<SotClipboardFormatId>(ObjectLB().get_selected_id().toUInt32()); + if (ObjectLB().get_selected_id().startsWithIgnoreAsciiCase(".uno")) + { + comphelper::dispatchCommand(aExtraCommand.first, {}); + nSelFormat = SotClipboardFormatId::NONE; + } + else + { + nSelFormat = static_cast<SotClipboardFormatId>(ObjectLB().get_selected_id().toUInt32()); + } } return nSelFormat; diff --git a/cui/source/factory/dlgfact.cxx b/cui/source/factory/dlgfact.cxx index 600882742427..d7868049d4c7 100644 --- a/cui/source/factory/dlgfact.cxx +++ b/cui/source/factory/dlgfact.cxx @@ -533,6 +533,11 @@ void AbstractPasteDialog_Impl::Insert(SotClipboardFormatId nFormat, const OUStri m_xDlg->Insert(nFormat, rFormatName); } +void AbstractPasteDialog_Impl::InsertUno(const OUString& sCmd, const OUString& sLabel) +{ + m_xDlg->InsertUno(sCmd, sLabel); +} + void AbstractPasteDialog_Impl::SetObjName(const SvGlobalName & rClass, const OUString& rObjName) { m_xDlg->SetObjName(rClass, rObjName); diff --git a/cui/source/factory/dlgfact.hxx b/cui/source/factory/dlgfact.hxx index 0181e293f49d..cd4b4d36a9dd 100644 --- a/cui/source/factory/dlgfact.hxx +++ b/cui/source/factory/dlgfact.hxx @@ -609,6 +609,7 @@ public: virtual bool StartExecuteAsync(AsyncContext &rCtx) override; public: virtual void Insert( SotClipboardFormatId nFormat, const OUString & rFormatName ) override; + virtual void InsertUno( const OUString & sCmd, const OUString& sLabel ) override; virtual void SetObjName( const SvGlobalName & rClass, const OUString & rObjName ) override; virtual void PreGetFormat( const TransferableDataHelper& aHelper ) override; virtual SotClipboardFormatId GetFormatOnly() override; diff --git a/cui/source/inc/pastedlg.hxx b/cui/source/inc/pastedlg.hxx index 565101d7fe19..a9a691b4f8f8 100644 --- a/cui/source/inc/pastedlg.hxx +++ b/cui/source/inc/pastedlg.hxx @@ -32,6 +32,8 @@ class TransferableDataHelper; class SvPasteObjectDialog : public weld::GenericDialogController { std::map< SotClipboardFormatId, OUString > aSupplementMap; + // Additional UNO command to be displayed along the supported paste formats + std::pair<OUString, OUString> aExtraCommand; SvGlobalName aObjClassName; OUString aObjName; @@ -49,6 +51,7 @@ public: SvPasteObjectDialog(weld::Window* pParent); void Insert( SotClipboardFormatId nFormat, const OUString & rFormatName ); + void InsertUno( const OUString& sUnoCmd, const OUString& sLabel); void SetObjName( const SvGlobalName & rClass, const OUString & rObjName ); /** * @brief PreGetFormat Prepares the dialog for running to get format of paste as a SotClipboardFormatId value by calling GetFormatOnly() |