public IVbComponentDecorator MapVbComponentToVbComponentDecorator(VBComponent rawComponent) { VbComponentType componentType = VbComponentType.Values .FirstOrDefault(type => type.VbCompTypeCode == rawComponent.Type.ToString()); return(new VbComponentDecoratorImpl(rawComponent, componentType)); }
private void CleanupComponentAfterImport(IVbComponentDecorator component) { VbComponentType componentType = component.ComponentType; string headerText; if (componentType == VbComponentType.ClassModule || componentType == VbComponentType.Sheet) { // Delete header lines in sheets and classes headerText = vbComponentIo.GetVbCodeLines(component, 4); if (headerText.ToLower() == "VERSION 1.0 CLASS\r\nBEGIN\r\n MultiUse = -1 'True\r\nEnd".ToLower()) { vbComponentIo.DeleteVbCodeLines(component, 4); } } if (componentType == VbComponentType.UserForm) { // Delete header lines in forms headerText = vbComponentIo.GetVbCodeLines(component, 10); if (headerText.StartsWith("version 5#\r\nbegin {", StringComparison.OrdinalIgnoreCase) && headerText.EndsWith("end", StringComparison.OrdinalIgnoreCase)) { vbComponentIo.DeleteVbCodeLines(component, 10); } } }
private void PlainImportComponent(string componentFilePath) { string fileExt = Path.GetExtension(componentFilePath); VbComponentType componentType = VbComponentType.Values .First(type => type.FileExt.Equals(fileExt, StringComparison.OrdinalIgnoreCase)); if (componentType == VbComponentType.Sheet) { //Log.Warn(string.Format("Using incorrect import method for file: '{0}' - module type '{1}'", importFile, vbCompType.VbCompTypeCode)); return; } vbComponentIo.ImportComponentFromFile(_workbook, componentFilePath); }
public string GetComponentExportName(IVbComponentDecorator component) { VbComponentType componentType = component.ComponentType; string componentName = component.Name; if (componentType == VbComponentType.Sheet && componentName != ThisWorkbookComponentName) { return(componentName + SheetNameSeparatorString + component.PrettyName + componentType.FileExt); } else { return(componentName + componentType.FileExt); } }