private void EhFileMonikerChanged(IMoniker fileMoniker) { if (null == _document) { return; } // see Brockschmidt, Inside Ole 2nd ed., p.998 // TODO we must pimp up this function RunningObjectTableHelper.ROTUnregister(ref _documentMonikerRotCookie); _documentMoniker = null; if (null != fileMoniker) { Ole32Func.CreateItemMoniker("!", DataObjectHelper.NormalStringToMonikerNameString(_document.Name), out var itemMoniker); if (null != itemMoniker) { fileMoniker.ComposeWith(itemMoniker, false, out var compositeMoniker); if (null != compositeMoniker) { _documentMoniker = compositeMoniker; RunningObjectTableHelper.ROTRegisterAsRunning(_documentMoniker, this, ref _documentMonikerRotCookie, typeof(IOleObject)); } } } SendAdvise_Renamed(); }
private void EhCurrentProjectFileNameChanged(string fileName) { // see Brockschmidt, Inside Ole 2nd ed., page 996 // make sure that if we have a valid file name, then the ComManager should be Active in order that this Com object is made public if (!string.IsNullOrEmpty(fileName) && !_comManager.IsActive) { ComDebug.ReportInfo("{0}.EhCurrentProjectFileNameChanged StartLocalServer because we have a valid file name. FileName: {1}", GetType().Name, fileName); _comManager.StartLocalServer(); } ComDebug.ReportInfo("{0}.EhCurrentProjectFileNameChanged", GetType().Name); RunningObjectTableHelper.ROTUnregister(ref _fileWithWildCardItemMonikerRotCookie); _fileWithWildCardItemMoniker = null; RunningObjectTableHelper.ROTUnregister(ref _fileMonikerRotCookie); _fileMoniker = null; if (!string.IsNullOrEmpty(fileName)) { Ole32Func.CreateFileMoniker(fileName, out _fileMoniker); if (null != _fileMoniker) { RunningObjectTableHelper.ROTRegisterAsRunning(_fileMoniker, this, ref _fileMonikerRotCookie, typeof(IPersistFile)); // Notify all other item Com objects of the new _fileMoniker if (null != FileMonikerChanged) { FileMonikerChanged(_fileMoniker); } // now register also a file moniker with a wild card item, that handles all items that are not open in the moment Ole32Func.CreateItemMoniker("!", "\\", out var wildCardItemMoniker); if (null != wildCardItemMoniker) { _fileMoniker.ComposeWith(wildCardItemMoniker, false, out _fileWithWildCardItemMoniker); RunningObjectTableHelper.ROTRegisterAsRunning(_fileWithWildCardItemMoniker, this, ref _fileWithWildCardItemMonikerRotCookie, typeof(IOleItemContainer)); } } } }
private void EhFileMonikerChanged(IMoniker fileMoniker) { if (null == _document) return; // see Brockschmidt, Inside Ole 2nd ed., p.998 // TODO we must pimp up this function RunningObjectTableHelper.ROTUnregister(ref _documentMonikerRotCookie); _documentMoniker = null; if (null != fileMoniker) { IMoniker itemMoniker; Ole32Func.CreateItemMoniker("!", DataObjectHelper.NormalStringToMonikerNameString(_document.Name), out itemMoniker); IMoniker compositeMoniker; if (null != itemMoniker) { fileMoniker.ComposeWith(itemMoniker, false, out compositeMoniker); if (null != compositeMoniker) { _documentMoniker = compositeMoniker; RunningObjectTableHelper.ROTRegisterAsRunning(_documentMoniker, this, ref _documentMonikerRotCookie, typeof(IOleObject)); } } } SendAdvise_Renamed(); }
private void EhCurrentProjectFileNameChanged(string fileName) { // see Brockschmidt, Inside Ole 2nd ed., page 996 // make sure that if we have a valid file name, then the ComManager should be Active in order that this Com object is made public if (!string.IsNullOrEmpty(fileName) && !_comManager.IsActive) { ComDebug.ReportInfo("{0}.EhCurrentProjectFileNameChanged StartLocalServer because we have a valid file name. FileName: {1}", this.GetType().Name, fileName); _comManager.StartLocalServer(); } ComDebug.ReportInfo("{0}.EhCurrentProjectFileNameChanged", this.GetType().Name); RunningObjectTableHelper.ROTUnregister(ref _fileWithWildCardItemMonikerRotCookie); _fileWithWildCardItemMoniker = null; RunningObjectTableHelper.ROTUnregister(ref _fileMonikerRotCookie); _fileMoniker = null; if (!string.IsNullOrEmpty(fileName)) { Ole32Func.CreateFileMoniker(fileName, out _fileMoniker); if (null != _fileMoniker) { RunningObjectTableHelper.ROTRegisterAsRunning(_fileMoniker, this, ref _fileMonikerRotCookie, typeof(IPersistFile)); // Notify all other item Com objects of the new _fileMoniker if (null != FileMonikerChanged) FileMonikerChanged(_fileMoniker); // now register also a file moniker with a wild card item, that handles all items that are not open in the moment IMoniker wildCardItemMoniker; Ole32Func.CreateItemMoniker("!", "\\", out wildCardItemMoniker); if (null != wildCardItemMoniker) { _fileMoniker.ComposeWith(wildCardItemMoniker, false, out _fileWithWildCardItemMoniker); RunningObjectTableHelper.ROTRegisterAsRunning(_fileWithWildCardItemMoniker, this, ref _fileWithWildCardItemMonikerRotCookie, typeof(IOleItemContainer)); } } } }