summaryrefslogtreecommitdiff
path: root/cui/source
diff options
context:
space:
mode:
authorMuhammet Kara <muhammet.kara@collabora.com>2019-07-02 23:25:00 +0300
committerMuhammet Kara <muhammet.kara@collabora.com>2019-07-11 07:14:19 +0200
commite679343128133fa05569816ed69e7a74852cf584 (patch)
tree258dda703098d3b6eb0a08be4f3cc1eafd14d367 /cui/source
parent674d58312a3682df6be2cf8680aab4e3d1528789 (diff)
Prepare PasteSpecial for Async-ness (sw, basesh.cxx)
This change is needed to make the paste special dialog async exec because the current design relies on return values of inner functions/methods while moving on. After this patch, the dialog creation and execution will not be so deep, so that it will be able to be converted to async exec in the usual way. The duplication in SvPasteObjectDialog::PreGetFormat() coming from SvPasteObjectDialog::GetFormat() will go away when the conversion is complete for all modules. It is only temporarily needed. Change-Id: I55e8aee39c41be6035c89f217f90f79720f32196 Reviewed-on: https://gerrit.libreoffice.org/75016 Tested-by: Jenkins Reviewed-by: Muhammet Kara <muhammet.kara@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/75369 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Diffstat (limited to 'cui/source')
-rw-r--r--cui/source/dialogs/pastedlg.cxx119
-rw-r--r--cui/source/factory/dlgfact.cxx10
-rw-r--r--cui/source/factory/dlgfact.hxx2
-rw-r--r--cui/source/inc/pastedlg.hxx15
4 files changed, 146 insertions, 0 deletions
diff --git a/cui/source/dialogs/pastedlg.cxx b/cui/source/dialogs/pastedlg.cxx
index b0acc4b8f2ee..1bba253d5ad6 100644
--- a/cui/source/dialogs/pastedlg.cxx
+++ b/cui/source/dialogs/pastedlg.cxx
@@ -72,6 +72,125 @@ void SvPasteObjectDialog::Insert( SotClipboardFormatId nFormat, const OUString&
aSupplementMap.insert( std::make_pair( nFormat, rFormatName ) );
}
+void SvPasteObjectDialog::PreGetFormat( const TransferableDataHelper &rHelper )
+{
+ //TODO/LATER: why is the Descriptor never used?!
+ TransferableObjectDescriptor aDesc;
+ if (rHelper.HasFormat(SotClipboardFormatId::OBJECTDESCRIPTOR))
+ {
+ (void)const_cast<TransferableDataHelper&>(rHelper).GetTransferableObjectDescriptor(
+ SotClipboardFormatId::OBJECTDESCRIPTOR, aDesc);
+ }
+ const DataFlavorExVector* pFormats = &rHelper.GetDataFlavorExVector();
+
+ // create and fill dialog box
+ OUString aSourceName, aTypeName;
+ SvGlobalName aEmptyNm;
+
+ //ObjectLB().SetUpdateMode( false );
+ ObjectLB().freeze();
+
+ DataFlavorExVector::iterator aIter( const_cast<DataFlavorExVector&>(*pFormats).begin() ),
+ aEnd( const_cast<DataFlavorExVector&>(*pFormats).end() );
+ while( aIter != aEnd )
+ {
+ SotClipboardFormatId nFormat = (*aIter++).mnSotId;
+
+ std::map< SotClipboardFormatId, OUString >::iterator itName =
+ aSupplementMap.find( nFormat );
+
+ // if there is an "Embed Source" or and "Embedded Object" on the
+ // Clipboard we read the Description and the Source of this object
+ // from an accompanied "Object Descriptor" format on the clipboard
+ // Remember: these formats mostly appear together on the clipboard
+ OUString aName;
+ const OUString* pName = nullptr;
+ if ( itName == aSupplementMap.end() )
+ {
+ SvPasteObjectHelper::GetEmbeddedName(rHelper,aName,aSourceName,nFormat);
+ if ( !aName.isEmpty() )
+ pName = &aName;
+ }
+ else
+ {
+ pName = &(itName->second);
+ }
+
+ if( pName )
+ {
+ aName = *pName;
+
+ if( SotClipboardFormatId::EMBED_SOURCE == nFormat )
+ {
+ if( aDesc.maClassName != aEmptyNm )
+ {
+ aSourceName = aDesc.maDisplayName;
+
+ if( aDesc.maClassName == aObjClassName )
+ aName = aObjName;
+ else
+ aName = aTypeName = aDesc.maTypeName;
+ }
+ }
+ else if( SotClipboardFormatId::LINK_SOURCE == nFormat )
+ {
+ continue;
+ }
+ else if( aName.isEmpty() )
+ aName = SvPasteObjectHelper::GetSotFormatUIName( nFormat );
+
+ // Show RICHTEXT only in case RTF is not present.
+ if (nFormat == SotClipboardFormatId::RICHTEXT &&
+ std::any_of(pFormats->begin(), pFormats->end(),
+ [](const DataFlavorEx& rFlavor) {
+ return rFlavor.mnSotId == SotClipboardFormatId::RTF;
+ }))
+ {
+ continue;
+ }
+
+ if (ObjectLB().find_text(aName) == -1)
+ {
+ ObjectLB().append(OUString::number(static_cast<sal_uInt32>(nFormat)), aName);
+ }
+ }
+ }
+
+ if( aTypeName.isEmpty() && aSourceName.isEmpty() )
+ {
+ if( aDesc.maClassName != aEmptyNm )
+ {
+ aSourceName = aDesc.maDisplayName;
+ aTypeName = aDesc.maTypeName;
+ }
+
+ if( aTypeName.isEmpty() && aSourceName.isEmpty() )
+ {
+ // global resource from svtools (former so3 resource)
+ aSourceName = SvtResId(STR_UNKNOWN_SOURCE);
+ }
+ }
+
+ ObjectLB().thaw();
+ SelectObject();
+
+ if( !aSourceName.isEmpty() )
+ {
+ if( !aTypeName.isEmpty() )
+ aTypeName += "\n";
+
+ aTypeName += aSourceName;
+ aTypeName = convertLineEnd(aTypeName, GetSystemLineEnd());
+ }
+
+ m_xFtObjectSource->set_label(aTypeName);
+}
+
+SotClipboardFormatId SvPasteObjectDialog::GetFormatOnly()
+{
+ return static_cast<SotClipboardFormatId>(ObjectLB().get_selected_id().toUInt32());
+}
+
SotClipboardFormatId SvPasteObjectDialog::GetFormat( const TransferableDataHelper& rHelper)
{
//TODO/LATER: why is the Descriptor never used?!
diff --git a/cui/source/factory/dlgfact.cxx b/cui/source/factory/dlgfact.cxx
index 413d9c6f34e9..9d6275e7c237 100644
--- a/cui/source/factory/dlgfact.cxx
+++ b/cui/source/factory/dlgfact.cxx
@@ -503,6 +503,16 @@ void AbstractPasteDialog_Impl::SetObjName(const SvGlobalName & rClass, const OUS
m_xDlg->SetObjName(rClass, rObjName);
}
+void AbstractPasteDialog_Impl::PreGetFormat( const TransferableDataHelper& aHelper )
+{
+ m_xDlg->PreGetFormat(aHelper);
+}
+
+SotClipboardFormatId AbstractPasteDialog_Impl::GetFormatOnly()
+{
+ return m_xDlg->GetFormatOnly();
+}
+
SotClipboardFormatId AbstractPasteDialog_Impl::GetFormat( const TransferableDataHelper& aHelper )
{
return m_xDlg->GetFormat(aHelper);
diff --git a/cui/source/factory/dlgfact.hxx b/cui/source/factory/dlgfact.hxx
index 0ebec6647414..acd3e63dedfe 100644
--- a/cui/source/factory/dlgfact.hxx
+++ b/cui/source/factory/dlgfact.hxx
@@ -566,6 +566,8 @@ public:
public:
virtual void Insert( SotClipboardFormatId nFormat, const OUString & rFormatName ) override;
virtual void SetObjName( const SvGlobalName & rClass, const OUString & rObjName ) override;
+ virtual void PreGetFormat( const TransferableDataHelper& aHelper ) override;
+ virtual SotClipboardFormatId GetFormatOnly() override;
virtual SotClipboardFormatId GetFormat( const TransferableDataHelper& aHelper ) override;
};
diff --git a/cui/source/inc/pastedlg.hxx b/cui/source/inc/pastedlg.hxx
index 45495dba119a..ff66beca7c5a 100644
--- a/cui/source/inc/pastedlg.hxx
+++ b/cui/source/inc/pastedlg.hxx
@@ -50,6 +50,21 @@ public:
void Insert( SotClipboardFormatId nFormat, const OUString & rFormatName );
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()
+ * @param aHelper
+ */
+ void PreGetFormat( const TransferableDataHelper& aHelper);
+ /**
+ * @brief GetFormatOnly Returns a SotClipboardFormatId value. Should be called after actually running the dialog.
+ * @return
+ */
+ SotClipboardFormatId GetFormatOnly();
+ /**
+ * @brief GetFormat Prepares and runs the dialog, and returns a SotClipboardFormatId depending on the RET_OK result
+ * @param aHelper TransferableDataHelper containing the data to be pasted
+ * @return a SotClipboardFormatId value depending on the result of running the dialog
+ */
SotClipboardFormatId GetFormat( const TransferableDataHelper& aHelper);
};