diff --git a/src/AdvGeneral.cpp b/src/AdvGeneral.cpp index f2314420..78c122c1 100644 --- a/src/AdvGeneral.cpp +++ b/src/AdvGeneral.cpp @@ -162,6 +162,7 @@ END_MESSAGE_MAP() #define SETTING_DO_NOT_HIDE_ON_DEACTIVATE 108 #define SETTING_HIDE_TASKBAR_ICON_ON_CLOSE 109 #define SETTING_USE_MODERN_SCROLLBAR 110 +#define SETTING_ENFORCE_CLIPBOARD_IGNORE_FORMATS 111 BOOL CAdvGeneral::OnInitDialog() { @@ -235,6 +236,7 @@ BOOL CAdvGeneral::OnInitDialog() AddTrueFalse(pGroupTest, _T("Draw RTF text in list (for RTF types) (could increase memory usage an display speed)"), CGetSetOptions::GetDrawRTF(), SETTING_DRAW_RTF); pGroupTest->AddSubItem(new CMFCPropertyGridProperty(_T("Editor default font size"), (long)CGetSetOptions::GetEditorDefaultFontSize(), _T(""), SETTING_EDITOR_FONT_SIZE)); + AddTrueFalse(pGroupTest, _T("Enforce clipboard ignore formats"), CGetSetOptions::GetEnforceClipboardIgnoreFormats(), SETTING_ENFORCE_CLIPBOARD_IGNORE_FORMATS); AddTrueFalse(pGroupTest, _T("Elevated privileges to paste into elevated apps"), CGetSetOptions::GetPasteAsAdmin(), SETTING_PASTE_AS_ADMIN); AddTrueFalse(pGroupTest, _T("Ensure Ditto is always connected to the clipboard"), CGetSetOptions::GetEnsureConnectToClipboard(), SETTING_ENSURE_CONNECTED); AddTrueFalse(pGroupTest, _T("Ensure entire window is visible"), CGetSetOptions::GetEnsureEntireWindowCanBeSeen(), SETTING_ENSURE_WINDOW_IS_VISIBLE); @@ -280,7 +282,8 @@ BOOL CAdvGeneral::OnInitDialog() CMFCPropertyGridFileProperty* pTextEditorProp = new CMFCPropertyGridFileProperty(_T("Text editor path (empty for system mapping)"), TRUE, CGetSetOptions::GetTextEditorPath(), _T("exe"), 0, szTextEditorFilter, (LPCTSTR)0, SETTING_TEXT_EDITOR_PATH); pGroupTest->AddSubItem(pTextEditorProp); - AddTrueFalse(pGroupTest, _T("Paste clip in active window after selection"), CGetSetOptions::GetSendPasteAfterSelection(), SETTING_PASTE_IN_ACTIVE_WINDOW); + AddTrueFalse(pGroupTest, _T("Paste clip in active window after selection"), CGetSetOptions::GetSendPasteAfterSelection(), SETTING_PASTE_IN_ACTIVE_WINDOW); + AddTrueFalse(pGroupTest, _T("Prompt when deleting clips"), CGetSetOptions::GetPromptWhenDeletingClips(), SETTING_PROMPT_ON_DELETE); AddTrueFalse(pGroupTest, _T("Revert to top level group on close"), CGetSetOptions::GetRevertToTopLevelGroup(), SETTING_REVERT_TO_TOP_LEVEL_GROUP); @@ -989,6 +992,13 @@ void CAdvGeneral::OnBnClickedOk() CGetSetOptions::SetHideTaskbarIconOnClose(val); } break; + case SETTING_ENFORCE_CLIPBOARD_IGNORE_FORMATS: + if (wcscmp(pNewValue->bstrVal, pOrigValue->bstrVal) != 0) + { + BOOL val = wcscmp(pNewValue->bstrVal, L"True") == 0; + CGetSetOptions::SetEnforceClipboardIgnoreFormats(val); + } + break; } } } diff --git a/src/Clip.cpp b/src/Clip.cpp index 0343d69b..fb2f0e7f 100644 --- a/src/Clip.cpp +++ b/src/Clip.cpp @@ -360,19 +360,22 @@ int CClip::LoadFromClipboard(CClipTypes* pClipTypes, bool checkClipboardIgnore, // m_Formats should be empty when this is called. ASSERT(m_Formats.GetSize() == 0); - + // If the data is supposed to be private, then return - if(::IsClipboardFormatAvailable(theApp.m_cfIgnoreClipboard)) + if (::IsClipboardFormatAvailable(theApp.m_cfIgnoreClipboard)) { Log(_T("Clipboard ignore type is on the clipboard, skipping this clipboard change")); return FALSE; } - - //https://learn.microsoft.com/en-us/windows/win32/dataxchg/clipboard-formats - if (::IsClipboardFormatAvailable(theApp.m_excludeClipboardContentFromMonitorProcessing)) + + if (CGetSetOptions::m_enforceClipboardIgnoreFormats) { - Log(_T("ExcludeClipboardContentFromMonitorProcessing type is on the clipboard, skipping this clipboard change")); - return FALSE; + //https://learn.microsoft.com/en-us/windows/win32/dataxchg/clipboard-formats + if (::IsClipboardFormatAvailable(theApp.m_excludeClipboardContentFromMonitorProcessing)) + { + Log(_T("ExcludeClipboardContentFromMonitorProcessing type is on the clipboard, skipping this clipboard change")); + return FALSE; + } } //If we are saving a multi paste then delay us connecting to the clipboard @@ -394,7 +397,8 @@ int CClip::LoadFromClipboard(CClipTypes* pClipTypes, bool checkClipboardIgnore, oleData.EnsureClipboardObject(); //https://learn.microsoft.com/en-us/windows/win32/dataxchg/clipboard-formats - if (oleData.IsDataAvailable(theApp.m_canIncludeInClipboardHistory)) + if (CGetSetOptions::m_enforceClipboardIgnoreFormats && + oleData.IsDataAvailable(theApp.m_canIncludeInClipboardHistory)) { HGLOBAL includeInHistory = oleData.GetGlobalData(theApp.m_canIncludeInClipboardHistory); if (includeInHistory != nullptr) diff --git a/src/ClipboardViewer.cpp b/src/ClipboardViewer.cpp index 05bdb3ad..577fbff9 100644 --- a/src/ClipboardViewer.cpp +++ b/src/ClipboardViewer.cpp @@ -254,12 +254,18 @@ bool CClipboardViewer::GetIgnoreClipboardChange() return true; } + if (CGetSetOptions::m_enforceClipboardIgnoreFormats == false) + { + return false; + } + //https://learn.microsoft.com/en-us/windows/win32/dataxchg/clipboard-formats if (::IsClipboardFormatAvailable(theApp.m_excludeClipboardContentFromMonitorProcessing)) { Log(_T("ExcludeClipboardContentFromMonitorProcessing clipboard format is on the clipboard, ignoring change")); return true; } + return false; } diff --git a/src/Options.cpp b/src/Options.cpp index e25bcbda..3bb1a932 100644 --- a/src/Options.cpp +++ b/src/Options.cpp @@ -93,6 +93,7 @@ BOOL CGetSetOptions::m_supportAllTypes = FALSE; int CGetSetOptions::m_clipEditSaveDelayAfterLoadSeconds = 3; int CGetSetOptions::m_clipEditSaveDelayAfterSaveSeconds = 3; BOOL CGetSetOptions::m_bDoNotHideOnDeactivate = FALSE; +BOOL CGetSetOptions::m_enforceClipboardIgnoreFormats = TRUE; CGetSetOptions::CGetSetOptions() @@ -300,6 +301,7 @@ void CGetSetOptions::LoadSettings() m_clipEditSaveDelayAfterLoadSeconds = GetClipEditSaveDelayAfterLoadSeconds(); m_clipEditSaveDelayAfterSaveSeconds = GetClipEditSaveDelayAfterSaveSeconds(); m_bDoNotHideOnDeactivate = GetDoNotHideOnDeactivate(); + m_enforceClipboardIgnoreFormats = GetEnforceClipboardIgnoreFormats(); GetExtraNetworkPassword(true); @@ -3272,4 +3274,15 @@ void CGetSetOptions::SetDoNotHideOnDeactivate(BOOL val) BOOL CGetSetOptions::GetDoNotHideOnDeactivate() { return GetProfileLong("DoNotHideOnDeactivate", FALSE); +} + +void CGetSetOptions::SetEnforceClipboardIgnoreFormats(BOOL val) +{ + SetProfileLong("EnforceClipboardIgnoreFormats", val); + m_enforceClipboardIgnoreFormats = val; +} + +BOOL CGetSetOptions::GetEnforceClipboardIgnoreFormats() +{ + return GetProfileLong("EnforceClipboardIgnoreFormats", TRUE); } \ No newline at end of file diff --git a/src/Options.h b/src/Options.h index 0060556d..9f1196f7 100644 --- a/src/Options.h +++ b/src/Options.h @@ -739,6 +739,10 @@ class CGetSetOptions static BOOL SetEditWndPoint(CPoint point); static void GetEditWndPoint(CPoint& point); + + static BOOL m_enforceClipboardIgnoreFormats; + static void SetEnforceClipboardIgnoreFormats(BOOL val); + static BOOL GetEnforceClipboardIgnoreFormats(); }; // global for easy access and for initialization of fast access variables