Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion src/AdvGeneral.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
}
}
}
Expand Down
20 changes: 12 additions & 8 deletions src/Clip.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down
6 changes: 6 additions & 0 deletions src/ClipboardViewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
13 changes: 13 additions & 0 deletions src/Options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -300,6 +301,7 @@ void CGetSetOptions::LoadSettings()
m_clipEditSaveDelayAfterLoadSeconds = GetClipEditSaveDelayAfterLoadSeconds();
m_clipEditSaveDelayAfterSaveSeconds = GetClipEditSaveDelayAfterSaveSeconds();
m_bDoNotHideOnDeactivate = GetDoNotHideOnDeactivate();
m_enforceClipboardIgnoreFormats = GetEnforceClipboardIgnoreFormats();

GetExtraNetworkPassword(true);

Expand Down Expand Up @@ -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);
}
4 changes: 4 additions & 0 deletions src/Options.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down