-Werror,-Wunused-function
...sincece59f88514
"INTEGRATION: CWS desktintgr03: #i34294#" commented out the uses (whicht got later removed completely with45f0cc2ec1
"Remove commented code in libs-core/shell") Change-Id: Icb7f97b72634d07045f5880af33b372be36e66b2
This commit is contained in:
@@ -953,280 +953,6 @@ extern "C" SCODE STDMETHODCALLTYPE DllCanUnloadNow()
|
|||||||
// E_UNEXPECTED
|
// E_UNEXPECTED
|
||||||
// (not implemented)
|
// (not implemented)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//F-------------------------------------------------------------------------
|
|
||||||
// helper functions to register the Indexing Service.
|
|
||||||
|
|
||||||
|
|
||||||
namespace /* private */
|
|
||||||
{
|
|
||||||
const char* GUID_PLACEHOLDER = "{GUID}";
|
|
||||||
const char* GUID_PERSIST_PLACEHOLDER = "{GUIDPERSIST}";
|
|
||||||
const char* EXTENSION_PLACEHOLDER = "{EXT}";
|
|
||||||
|
|
||||||
const char* CLSID_GUID_INPROC_ENTRY = "CLSID\\{GUID}\\InProcServer32";
|
|
||||||
const char* CLSID_GUID_ENTRY = "CLSID\\{GUID}";
|
|
||||||
const char* CLSID_GUID_PERSIST_ADDIN_ENTRY = "CLSID\\{GUID}\\PersistentAddinsRegistered\\{GUIDPERSIST}";
|
|
||||||
const char* CLSID_PERSIST_ENTRY = "CLSID\\{GUID}\\PersistentHandler";
|
|
||||||
const char* EXT_PERSIST_ENTRY = "{EXT}\\PersistentHandler";
|
|
||||||
|
|
||||||
const char* INDEXING_FILTER_DLLSTOREGISTER = "SYSTEM\\CurrentControlSet\\Control\\ContentIndex";
|
|
||||||
|
|
||||||
|
|
||||||
// "String Placeholder" ->
|
|
||||||
// "String Replacement"
|
|
||||||
|
|
||||||
|
|
||||||
void SubstitutePlaceholder(std::string& String, const std::string& Placeholder, const std::string& Replacement)
|
|
||||||
{
|
|
||||||
std::string::size_type idx = String.find(Placeholder);
|
|
||||||
std::string::size_type len = Placeholder.length();
|
|
||||||
|
|
||||||
while (std::string::npos != idx)
|
|
||||||
{
|
|
||||||
String.replace(idx, len, Replacement);
|
|
||||||
idx = String.find(Placeholder);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Make the registry entry and set Filter Handler
|
|
||||||
// HKCR\CLSID\{7BC0E710-5703-45be-A29D-5D46D8B39262} = LibreOffice Filter
|
|
||||||
// InProcServer32 (Default) = Path\ooofilt.dll
|
|
||||||
// ThreadingModel = Both
|
|
||||||
|
|
||||||
|
|
||||||
HRESULT RegisterFilterHandler(const char* FilePath, const CLSID& FilterGuid)
|
|
||||||
{
|
|
||||||
std::string ClsidEntry = CLSID_GUID_ENTRY;
|
|
||||||
SubstitutePlaceholder(ClsidEntry, GUID_PLACEHOLDER, ClsidToString(FilterGuid));
|
|
||||||
|
|
||||||
if (!SetRegistryKey(HKEY_CLASSES_ROOT, ClsidEntry.c_str(), "", "LibreOffice Filter"))
|
|
||||||
return E_FAIL;
|
|
||||||
|
|
||||||
ClsidEntry = CLSID_GUID_INPROC_ENTRY;
|
|
||||||
SubstitutePlaceholder(ClsidEntry, GUID_PLACEHOLDER, ClsidToString(FilterGuid));
|
|
||||||
|
|
||||||
if (!SetRegistryKey(HKEY_CLASSES_ROOT, ClsidEntry.c_str(), "", FilePath))
|
|
||||||
return E_FAIL;
|
|
||||||
|
|
||||||
if (!SetRegistryKey(HKEY_CLASSES_ROOT, ClsidEntry.c_str(), "ThreadingModel", "Both"))
|
|
||||||
return E_FAIL;
|
|
||||||
|
|
||||||
return S_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Make the registry entry and set Persistent Handler
|
|
||||||
// HKCR\CLSID\{7BC0E713-5703-45be-A29D-5D46D8B39262} = LibreOffice Persistent Handler
|
|
||||||
// PersistentAddinsRegistered
|
|
||||||
// {89BCB740-6119-101A-BCB7-00DD010655AF} = {7BC0E710-5703-45be-A29D-5D46D8B39262}
|
|
||||||
|
|
||||||
|
|
||||||
HRESULT RegisterPersistentHandler(const CLSID& FilterGuid, const CLSID& PersistentGuid)
|
|
||||||
{
|
|
||||||
std::string ClsidEntry_Persist = CLSID_GUID_ENTRY;
|
|
||||||
SubstitutePlaceholder(ClsidEntry_Persist, GUID_PLACEHOLDER, ClsidToString(PersistentGuid));
|
|
||||||
|
|
||||||
|
|
||||||
if (!SetRegistryKey(HKEY_CLASSES_ROOT, ClsidEntry_Persist.c_str(), "", "LibreOffice Persistent Handler"))
|
|
||||||
return E_FAIL;
|
|
||||||
|
|
||||||
// Add missing entry
|
|
||||||
std::string ClsidEntry_Persist_Entry = CLSID_PERSIST_ENTRY;
|
|
||||||
SubstitutePlaceholder(ClsidEntry_Persist_Entry,
|
|
||||||
GUID_PLACEHOLDER,
|
|
||||||
ClsidToString(PersistentGuid));
|
|
||||||
|
|
||||||
if (!SetRegistryKey(HKEY_CLASSES_ROOT, ClsidEntry_Persist_Entry.c_str(), "", ClsidToString(PersistentGuid).c_str()))
|
|
||||||
return E_FAIL;
|
|
||||||
|
|
||||||
std::string ClsidEntry_Persist_Addin = CLSID_GUID_PERSIST_ADDIN_ENTRY;
|
|
||||||
SubstitutePlaceholder(ClsidEntry_Persist_Addin,
|
|
||||||
GUID_PLACEHOLDER,
|
|
||||||
ClsidToString(PersistentGuid));
|
|
||||||
SubstitutePlaceholder(ClsidEntry_Persist_Addin,
|
|
||||||
GUID_PERSIST_PLACEHOLDER,
|
|
||||||
ClsidToString(CLSID_PERSISTENT_HANDLER_ADDIN));
|
|
||||||
|
|
||||||
if (!SetRegistryKey(HKEY_CLASSES_ROOT, ClsidEntry_Persist_Addin.c_str(), "", ClsidToString(FilterGuid).c_str() ))
|
|
||||||
return E_FAIL;
|
|
||||||
|
|
||||||
return S_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Unregister Filter Handler or persistent handler
|
|
||||||
|
|
||||||
|
|
||||||
HRESULT UnregisterHandler(const CLSID& Guid)
|
|
||||||
{
|
|
||||||
std::string tmp = "CLSID\\";
|
|
||||||
tmp += ClsidToString(Guid);
|
|
||||||
return DeleteRegistryKey(HKEY_CLASSES_ROOT, tmp.c_str()) ? S_OK : E_FAIL;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Register Indexing Service ext and class.
|
|
||||||
// HKCR\{EXT}\PersistentHandler = {7BC0E713-5703-45be-A29D-5D46D8B39262}
|
|
||||||
// HKCR\{GUID\PersistentHandler = {7BC0E713-5703-45be-A29D-5D46D8B39262}
|
|
||||||
|
|
||||||
|
|
||||||
HRESULT RegisterSearchHandler(const char* ModuleFileName)
|
|
||||||
{
|
|
||||||
if (FAILED(RegisterFilterHandler(ModuleFileName, CLSID_FILTER_HANDLER)))
|
|
||||||
return E_FAIL;
|
|
||||||
|
|
||||||
if (FAILED(RegisterPersistentHandler(CLSID_FILTER_HANDLER, CLSID_PERSISTENT_HANDLER )))
|
|
||||||
return E_FAIL;
|
|
||||||
|
|
||||||
std::string sExtPersistEntry;
|
|
||||||
|
|
||||||
for(size_t i = 0; i < OOFileExtensionTableSize; i++)
|
|
||||||
{
|
|
||||||
// first, register extension.
|
|
||||||
sExtPersistEntry = EXT_PERSIST_ENTRY;
|
|
||||||
SubstitutePlaceholder(sExtPersistEntry, EXTENSION_PLACEHOLDER, OOFileExtensionTable[i].ExtensionAnsi);
|
|
||||||
if (!SetRegistryKey(HKEY_CLASSES_ROOT,
|
|
||||||
sExtPersistEntry.c_str(),
|
|
||||||
"",
|
|
||||||
ClsidToString(CLSID_PERSISTENT_HANDLER).c_str()))
|
|
||||||
return E_FAIL;
|
|
||||||
|
|
||||||
// second, register class.
|
|
||||||
char extClassName[MAX_PATH];
|
|
||||||
if (QueryRegistryKey(HKEY_CLASSES_ROOT, OOFileExtensionTable[i].ExtensionAnsi, "", extClassName,MAX_PATH))
|
|
||||||
{
|
|
||||||
::std::string extCLSIDName( extClassName );
|
|
||||||
extCLSIDName += "\\CLSID";
|
|
||||||
char extCLSID[MAX_PATH];
|
|
||||||
|
|
||||||
if (QueryRegistryKey( HKEY_CLASSES_ROOT, extCLSIDName.c_str(), "", extCLSID, MAX_PATH))
|
|
||||||
{
|
|
||||||
std::string ClsidEntry_CLSID_Persist = CLSID_PERSIST_ENTRY;
|
|
||||||
SubstitutePlaceholder(ClsidEntry_CLSID_Persist,
|
|
||||||
GUID_PLACEHOLDER,
|
|
||||||
extCLSID);
|
|
||||||
|
|
||||||
if (!SetRegistryKey(HKEY_CLASSES_ROOT,
|
|
||||||
ClsidEntry_CLSID_Persist.c_str(),
|
|
||||||
"",
|
|
||||||
ClsidToString(CLSID_PERSISTENT_HANDLER).c_str() ))
|
|
||||||
return E_FAIL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return S_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Register Indexing Service ext and class.
|
|
||||||
HRESULT UnregisterSearchHandler()
|
|
||||||
{
|
|
||||||
std::string sExtPersistEntry;
|
|
||||||
|
|
||||||
for (size_t i = 0; i < OOFileExtensionTableSize; i++)
|
|
||||||
{
|
|
||||||
// first, unregister extension
|
|
||||||
sExtPersistEntry = EXT_PERSIST_ENTRY;
|
|
||||||
SubstitutePlaceholder(sExtPersistEntry, EXTENSION_PLACEHOLDER, OOFileExtensionTable[i].ExtensionAnsi);
|
|
||||||
DeleteRegistryKey(HKEY_CLASSES_ROOT, sExtPersistEntry.c_str());
|
|
||||||
|
|
||||||
// second, unregister class
|
|
||||||
char extClassName[MAX_PATH];
|
|
||||||
if (QueryRegistryKey(HKEY_CLASSES_ROOT, OOFileExtensionTable[i].ExtensionAnsi, "", extClassName,MAX_PATH))
|
|
||||||
{
|
|
||||||
::std::string extCLSIDName( extClassName );
|
|
||||||
extCLSIDName += "\\CLSID";
|
|
||||||
char extCLSID[MAX_PATH];
|
|
||||||
|
|
||||||
if (QueryRegistryKey( HKEY_CLASSES_ROOT, extCLSIDName.c_str(), "", extCLSID, MAX_PATH))
|
|
||||||
{
|
|
||||||
std::string ClsidEntry_CLSID_Persist = CLSID_PERSIST_ENTRY;
|
|
||||||
SubstitutePlaceholder(ClsidEntry_CLSID_Persist,
|
|
||||||
GUID_PLACEHOLDER,
|
|
||||||
extCLSID);
|
|
||||||
|
|
||||||
DeleteRegistryKey(HKEY_CLASSES_ROOT, ClsidEntry_CLSID_Persist.c_str());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return ((UnregisterHandler(CLSID_FILTER_HANDLER)==S_OK) && (UnregisterHandler(CLSID_PERSISTENT_HANDLER)==S_OK))?S_OK:E_FAIL;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// add or remove an entry to DllsToRegister entry of Indexing
|
|
||||||
// Filter to let Indexing Service register our filter automatically
|
|
||||||
// each time.
|
|
||||||
|
|
||||||
HRESULT AddOrRemoveDllsToRegisterList( const ::std::string & DllPath, bool isAdd )
|
|
||||||
{
|
|
||||||
char DllsToRegisterList[4096];
|
|
||||||
if (QueryRegistryKey(HKEY_LOCAL_MACHINE,
|
|
||||||
INDEXING_FILTER_DLLSTOREGISTER,
|
|
||||||
"DLLsToRegister",
|
|
||||||
DllsToRegisterList,
|
|
||||||
4096))
|
|
||||||
{
|
|
||||||
char * pChar = DllsToRegisterList;
|
|
||||||
for ( ; *pChar != '\0' || *(pChar +1) != '\0'; pChar++)
|
|
||||||
if ( *pChar == '\0')
|
|
||||||
*pChar = ';';
|
|
||||||
*pChar = ';';
|
|
||||||
*(pChar+1) = '\0';
|
|
||||||
|
|
||||||
::std::string DllList(DllsToRegisterList);
|
|
||||||
if ( ( isAdd )&&( DllList.find( DllPath ) == ::std::string::npos ) )
|
|
||||||
DllList.append( DllPath );
|
|
||||||
else if ( ( !isAdd )&&( DllList.find( DllPath ) != ::std::string::npos ) )
|
|
||||||
DllList.erase( DllList.find( DllPath )-1, DllPath.length()+1 );
|
|
||||||
else
|
|
||||||
return S_OK;
|
|
||||||
|
|
||||||
pChar = DllsToRegisterList;
|
|
||||||
for ( size_t nChar = 0; nChar < DllList.length(); pChar++,nChar++)
|
|
||||||
{
|
|
||||||
if ( DllList[nChar] == ';')
|
|
||||||
*pChar = '\0';
|
|
||||||
else
|
|
||||||
*pChar = DllList[nChar];
|
|
||||||
}
|
|
||||||
*pChar = *( pChar+1 ) ='\0';
|
|
||||||
|
|
||||||
HKEY hSubKey;
|
|
||||||
char dummy[] = "";
|
|
||||||
int rc = RegCreateKeyExA(HKEY_LOCAL_MACHINE,
|
|
||||||
INDEXING_FILTER_DLLSTOREGISTER,
|
|
||||||
0,
|
|
||||||
dummy,
|
|
||||||
REG_OPTION_NON_VOLATILE,
|
|
||||||
KEY_WRITE,
|
|
||||||
0,
|
|
||||||
&hSubKey,
|
|
||||||
0);
|
|
||||||
|
|
||||||
if (ERROR_SUCCESS == rc)
|
|
||||||
{
|
|
||||||
rc = RegSetValueExA( hSubKey,
|
|
||||||
"DLLsToRegister",
|
|
||||||
0,
|
|
||||||
REG_MULTI_SZ,
|
|
||||||
reinterpret_cast<const BYTE*>(DllsToRegisterList),
|
|
||||||
static_cast<DWORD>(DllList.length() + 2));
|
|
||||||
|
|
||||||
RegCloseKey(hSubKey);
|
|
||||||
}
|
|
||||||
|
|
||||||
return (ERROR_SUCCESS == rc)?S_OK:E_FAIL;
|
|
||||||
}
|
|
||||||
|
|
||||||
return S_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace /* private */
|
|
||||||
|
|
||||||
STDAPI DllRegisterServer()
|
STDAPI DllRegisterServer()
|
||||||
{
|
{
|
||||||
return S_OK;
|
return S_OK;
|
||||||
|
Reference in New Issue
Block a user