internal CheckFileInfoResponse() { _wopiHostCapabilities = WopiConfiguration.WopiHostCapabilities.Clone(); _wopiHostProperties = WopiConfiguration.WopiHostProperties.Clone(); _postMessageProperties = WopiConfiguration.PostMessageProperties.Clone(); _breadcrumbProperties = new BreadcrumbProperties(); _fileProperties = new FileProperties(); _fileUrlProperties = new FileUrlProperties(); _userMetadata = new UserMetadata() { IsEduUser = false }; _userPermissions = new UserPermissions() { DisablePrint = false, DisableTranslation = false, ReadOnly = false, RestrictedWebViewOnly = false, UserCanAttend = false, UserCanNotWriteRelative = false, UserCanPresent = false, UserCanRename = true, UserCanWrite = true, WebEditingDisabled = false }; }
public void SetFileProperties(IFileProperties fileInfo) { targetFile = new XmlDocument(); targetFile.PreserveWhitespace = false; targetFile.Load(originalFileProperties.OriginalFilePath); nsmgr = new XmlNamespaceManager(targetFile.NameTable); nsmgr.AddNamespace("x", "urn:oasis:names:tc:xliff:document:1.2"); nsmgr.AddNamespace("m", "http://www.memsource.com/mxlf/2.0"); var level = targetFile.DocumentElement.Attributes["m:level"]; if (level != null) { workflowLevel = Int32.Parse(level.Value); } // Acquire users var memsourceUsers = targetFile.SelectNodes("//m:user", nsmgr); if (memsourceUsers != null) { foreach (XmlElement user in memsourceUsers) { var id = user.Attributes["id"]?.Value; var username = user.Attributes["username"]?.Value; if (!string.IsNullOrWhiteSpace(username) && !string.IsNullOrWhiteSpace(id) && users.ContainsKey(username)) { users.Add(username, id); } } } }
public bool ParseNext() { if (_documentProperties == null) { _documentProperties = ItemFactory.CreateDocumentProperties(); } Output.Initialize(_documentProperties); IFileProperties fileInfo = ItemFactory.CreateFileProperties(); fileInfo.FileConversionProperties = _fileProperties.FileConversionProperties; Output.SetFileProperties(fileInfo); // variables for the progress report var xmlNodeList = _document.SelectNodes("//translatable"); if (xmlNodeList != null) { int totalUnitCount = xmlNodeList.Count; int currentUnitCount = 0; foreach (XmlNode item in xmlNodeList) { Output.ProcessParagraphUnit(CreateParagraphUnit(item)); // update the progress report currentUnitCount++; OnProgress(Convert.ToByte(Math.Round(100 * ((decimal)currentUnitCount / totalUnitCount), 0))); } } Output.FileComplete(); Output.Complete(); return(false); }
private void CreateDummyOutputFiles(IFileProperties fileInfo) { foreach (var fileProperties in fileInfo.FileConversionProperties.DependencyFiles) { var iDependencyFileProperties = fileProperties; if (iDependencyFileProperties.PreferredLinkage == DependencyFileLinkOption.Embed || iDependencyFileProperties.FileExists) { continue; } try { fileProperties.PreferredLinkage = DependencyFileLinkOption.ReferenceRelative; if (!System.IO.File.Exists(iDependencyFileProperties.CurrentFilePath) && iDependencyFileProperties.CurrentFilePath != null) { var dummyOutputFullPath = Path.Combine(Path.GetDirectoryName(_inputPath), Path.GetFileName(iDependencyFileProperties.CurrentFilePath)); DummyOutputFiles.Add(dummyOutputFullPath); using (var sw = new StreamWriter(dummyOutputFullPath)) { sw.WriteLine(string.Empty); sw.Flush(); sw.Close(); } } } catch { // catch all; ignore } } }
public override void SetFileProperties(IFileProperties fileInfo) { if (_settings.CommentChecked) { _usernameService.AnonymizeCommentAuthor(fileInfo, _settings.CommentAuthorName); } }
public void SetFileProperties(IFileProperties fileInfo) { try { _targetFile = new XmlDocument { PreserveWhitespace = true }; if (File.Exists(_originalFileProperties.OriginalFilePath)) { _targetFile.Load(_originalFileProperties.OriginalFilePath); } else { //User changed the location of the project, we need to get the new path for source files, we can use the LastOpenedPath but there we //have the location on target folder, we need the path to source language folder var targetLanguageCode = _originalFileProperties.TargetLanguage.CultureInfo.Name; if (!string.IsNullOrEmpty(_documentInfo?.LastOpenedAsPath)) { var lastOpenedPath = _documentInfo?.LastOpenedAsPath; var newRoothDirectory = lastOpenedPath.Substring(0, lastOpenedPath.LastIndexOf(targetLanguageCode, StringComparison.Ordinal)); var fileName = Path.GetFileName(_originalFileProperties.OriginalFilePath); var newPath = Path.Combine(newRoothDirectory, _originalFileProperties.SourceLanguage.CultureInfo.Name, fileName); _targetFile.Load(newPath); } } } catch (Exception e) { _logger.Error(e); throw; } }
public void SetFileProperties(IFileProperties fileInfo) { _targetFile = new XmlDocument { PreserveWhitespace = false }; LoadFile(); _nsmgr = new XmlNamespaceManager(_targetFile.NameTable); _nsmgr.AddNamespace("x", "urn:oasis:names:tc:xliff:document:1.2"); _nsmgr.AddNamespace("m", "http://www.memsource.com/mxlf/2.0"); // Acquire users var memsourceUsers = _targetFile.SelectNodes("//m:user", _nsmgr); if (memsourceUsers is null) { return; } foreach (XmlElement user in memsourceUsers) { var id = user.Attributes["id"]?.Value; var username = user.Attributes["username"]?.Value; if (!string.IsNullOrWhiteSpace(username) && !string.IsNullOrWhiteSpace(id) && _users.ContainsKey(username)) { _users.Add(username, id); } } }
public override bool Resolve(IFileProperties fileProperties) { if (_rule == null) { throw new RuleException($"Resolve called when {nameof(_rule)} is null"); } return(!_rule.Resolve(fileProperties)); }
public override void SetFileProperties(IFileProperties fileInfo) { //base.SetFileProperties(fileInfo); //Read the updated DOCX file and collect all the segments var reader = new WordReader(_importOptions, SourceLanguage.Name, TargetLanguage.Name); _updatedSegments = reader.ReadFile(_updatedFilePath); base.SetFileProperties(fileInfo); }
/// <summary> /// Overridden to determine if this is a file where segments should be re-numbered. /// </summary> /// <param name="fileInfo"></param> /// <remarks> /// <para> /// Sets the <see cref="Enabled"/> property to true or false depending on whether the /// file ID is part of a collection of file IDs in a published shared object of type <see cref="ISegmentRenumberingController"/>. /// </para> /// <para> /// To ensure that segment renumbering happens only once after segmentation the NeedsSegmentRenumbering flag is set to false. /// </para> /// </remarks> public override void SetFileProperties(IFileProperties fileInfo) { Enabled = (fileInfo.FileConversionProperties.GetMetaData(Constants.File_NeedsSegmentRenumbering) == true.ToString()); if (Enabled) { fileInfo.FileConversionProperties.SetMetaData(Constants.File_NeedsSegmentRenumbering, false.ToString()); } base.SetFileProperties(fileInfo); }
public void SetFileProperties(IFileProperties properties) { _fileProperties = properties.FileConversionProperties; Output.Initialize(DocumentProperties); IFileProperties fileInfo = ItemFactory.CreateFileProperties(); fileInfo.FileConversionProperties = _fileProperties; Output.SetFileProperties(fileInfo); }
public override bool Resolve(IFileProperties fileProperties) { BaseFileProperties baseFileProperties = fileProperties as BaseFileProperties; if (baseFileProperties == null) { throw new RuleException($"Resolve unable to cast {nameof(fileProperties)} arg to {nameof(BaseFileProperties)}, {nameof(fileProperties)}.Type = {fileProperties.GetType()}"); } return(ResolveStringMatch(fileProperties.FileNameWithoutExtension)); }
/// <summary> /// Start of new file /// </summary> /// <param name="fileInfo"></param> public override void SetFileProperties(IFileProperties fileInfo) { //get output file name FileInfo info = new FileInfo(_originalFilePath); string targetfilename = info.DirectoryName + Path.DirectorySeparatorChar + _convertSettings.FileNamePrefix + info.Name.Substring(0, info.Name.IndexOf(info.Extension)); //initialize Excel writer _excelSuperWriter = new ExcelSuperWriter(); _excelSuperWriter.Initialize(targetfilename + ".Preview.xlsx", _convertSettings); }
public void SetFileProperties(IFileProperties fileInfo) { // A bilingual document can potentially be a master document that contains // a number of single (smaller) bilingual documents. // The File Info object can be used to access properties of particular bilingual file // in a bilingual document, such as the file type definition id, the creation tool. // This information can be different from biligual file to bilingual file, as // each single bilingual file might have been created using different // file types, e.g. one bilingual file was derived from a PPT document, // another one from a DOC file. // This is not required for this implementation. }
public void SetFileProperties(IFileProperties properties) { try { _rootToken = _jsonFactory.GetRootToken(_originalFileProperties.OriginalFilePath); } catch (System.IO.DirectoryNotFoundException) { //if we can't find the directory, we read from the embedded base64 in the sdlxliff file _rootToken = _jsonFactory.GetRootToken(_originalFileProperties.DependencyFiles.First().CurrentFilePath); } }
public void AnonymizeCommentAuthor(IFileProperties fileProperties, string commentAuthor) { var comments = fileProperties?.Comments?.Comments; if (comments == null || !comments.Any()) { return; } foreach (var fileComment in comments) { fileComment.Author = commentAuthor; } }
public void SetFileProperties(IFileProperties properties) { try { _yamlTextWriter = _yamlFactory.CreateYamlTextWriter(_originalFileProperties.OriginalFilePath, _nativeFileProperties.OutputFilePath); } catch (System.IO.DirectoryNotFoundException) { //if we can't find the directory, we read from the embedded base64 in the sdlxliff file _yamlTextWriter = _yamlFactory.CreateYamlTextWriter(_originalFileProperties.DependencyFiles.First().CurrentFilePath, _nativeFileProperties.OutputFilePath); } }
/// <summary> /// Get the complete, fully resolved, path+filename of the fileProperties after tokens have been substituted /// </summary> /// <param name="searchDirectoryPath">The root dir that the search is running in</param> /// <param name="fileProperties">the file properties object</param> /// <param name="matchingFileCount">the number of files that have matched this config, including fileProperties</param> /// <returns></returns> public string GetResolvedCombinedPath(string searchDirectoryPath, IFileProperties fileProperties, uint matchingFileCount) { string resolvedOutputFileName = ResolveTokenString(_outputFileName, fileProperties, matchingFileCount, "output_filename"); string resolvedOutputPath = ResolveTokenString(_outputPath, fileProperties, matchingFileCount, "output_path"); //If we have an "output_path" that is relative, combine it with the searchDirectoryPath if (resolvedOutputPath.StartsWith('.')) { resolvedOutputPath = Path.Combine(searchDirectoryPath, resolvedOutputPath); } return(Path.Combine(resolvedOutputPath, resolvedOutputFileName)); }
public void SetFileProperties(IFileProperties fileInfo) { try { _extendedStreamReader = _fileHelper.GetExtendedStreamReader(_originalFileProperties.OriginalFilePath); } catch (System.IO.DirectoryNotFoundException) { //if we can't find the directory, we read from the embedded base64 in the sdlxliff file _extendedStreamReader = _fileHelper.GetExtendedStreamReader(_originalFileProperties.DependencyFiles.First().CurrentFilePath); } _streamWriter = _fileHelper.GetStreamWriter(_nativeFileProperties.OutputFilePath); _lineParsingSession = _lineParser.StartLineParsingSession(); }
public override bool Resolve(IFileProperties fileProperties) { TextureFileProperties textureFileProperties = fileProperties as TextureFileProperties; if (textureFileProperties == null) { throw new RuleException($"Resolve unable to cast {nameof(fileProperties)} arg to {nameof(TextureFileProperties)}, {nameof(fileProperties)}.Type = {fileProperties.GetType()}"); } bool resolveWidth = ResolveNumberValue(textureFileProperties.Width); bool resolveHeight = ResolveNumberValue(textureFileProperties.Height); //TODO consider supporting different width and height return(resolveWidth && resolveHeight); }
public void SetFileProperties(IFileProperties properties) { Output.Initialize(DocumentProperties); var fileProperties = ItemFactory.CreateFileProperties(); fileProperties.FileConversionProperties = properties.FileConversionProperties; Output.SetFileProperties(fileProperties); _paragraphUnitFactory.ItemFactory = ItemFactory; _paragraphUnitFactory.PropertiesFactory = PropertiesFactory; _fileConversionProperties = properties.FileConversionProperties; }
/// <summary> /// Start of new file /// </summary> /// <param name="fileInfo"></param> public override void SetFileProperties(IFileProperties fileInfo) { //handle merged files if (_exportingSameFile) { return; } _wordWriter = new WordWriter(SourceLanguage.Name, TargetLanguage.Name); _wordWriter.Initialize(_projectId, fileInfo.FileConversionProperties.FileId.Id, _originalFilePath, _outputFilePath, _exportOptions); //base.SetFileProperties(fileInfo); }
public uint NumberOfMatchingFilterRules(IFileProperties fileProperties) { uint matchingCount = 0; int filterRulesCount = (_filterRules != null) ? _filterRules.Count : 0; for (int i = 0; i < filterRulesCount; ++i) { if (_filterRules[i].Resolve(fileProperties)) { matchingCount++; } } return(matchingCount); }
public override void SetFileProperties(IFileProperties fileInfo) { _fileProperties = fileInfo; var file = new File { SourceLanguage = SourceLanguage.Name, TargetLanguage = TargetLanguage.Name }; file.Original = fileInfo.FileConversionProperties.OriginalFilePath; file.DataType = fileInfo.FileConversionProperties.FileTypeDefinitionId.Id; Xliff.Files.Add(file); CreateDummyOutputFiles(fileInfo); }
private string GetSdlXliffFilePath(IFileProperties fileProperties) { var projectPath = ProjectInProcessing; if (projectPath is null) { return(null); } var fileConversionProperties = fileProperties.FileConversionProperties; var originalFilePath = fileConversionProperties.OriginalFilePath; var fileName = Path.GetFileName(originalFilePath); var sdlxliffFilePath = $@"{projectPath}\{fileConversionProperties.TargetLanguage.IsoAbbreviation}\{fileName}.sdlxliff"; return(sdlxliffFilePath); }
public override void SetFileProperties(IFileProperties fileInfo) { CultureInfo cultureInfo = null; try { var sniffInfo = fileInfo.FileConversionProperties?.FileSnifferInfo; cultureInfo = sniffInfo?.DetectedSourceLanguage?.First?.CultureInfo; } catch (UnsupportedLanguageException) { // We just ignore these and fall back on oridinal comparison } finally { targetSettings.SourceCulture = cultureInfo; } }
public void SetFileProperties(IFileProperties fileInfo) { CurrentFileProperties = fileInfo; ParagraphUnits = new Dictionary <string, ParagraphUnit>(); // this should output the individual file names that the sdlxliff file is comprized of. // in the case of a merged file, it will indicate the source file names as it is iterating // through the file. foreach (var fileProperties in fileInfo.FileConversionProperties.DependencyFiles) { var iDependencyFileProperties = fileProperties; if (iDependencyFileProperties.PreferredLinkage == DependencyFileLinkOption.Embed || iDependencyFileProperties.FileExists) { continue; } fileProperties.PreferredLinkage = DependencyFileLinkOption.ReferenceRelative; try { if (!System.IO.File.Exists(iDependencyFileProperties.CurrentFilePath)) { if (iDependencyFileProperties.CurrentFilePath != null) { var dummyOutputFullPath = System.IO.Path.Combine(OutputPath, System.IO.Path.GetFileName(iDependencyFileProperties.CurrentFilePath)); CreatedDummyOutput = true; DummyOutputFiles.Add(dummyOutputFullPath); using (var sw = new System.IO.StreamWriter(dummyOutputFullPath)) { sw.WriteLine(string.Empty); sw.Flush(); sw.Close(); } } } } catch (Exception ex) { Console.WriteLine(ex.Message); } } }
/// <summary> /// Class that creates an appropriate <see cref="IFileProperties"/> object from a filePath /// based on the mapping <see cref="SupportedFileTypes"/> /// </summary> /// <param name="fullFilePath"></param> /// <returns></returns> public async Task <IFileProperties> FetchFileProperties(string fullFilePath) { FileInfo fileInfo = new FileInfo(fullFilePath); IFileProperties fileProperties = null; if (SupportedFileTypes.ExtensionToFilePropertiesFactory.ContainsKey(fileInfo.Extension)) { Func <FileInfo, Task <IFileProperties> > filePropertiesCreateFunc = SupportedFileTypes.ExtensionToFilePropertiesFactory[fileInfo.Extension]; fileProperties = await filePropertiesCreateFunc(fileInfo); } else { Console.WriteLine($"Warning: FileLoader attempt to load unknown file extension: {fileInfo.Extension}, defaulting to {nameof(BaseFileProperties)}"); fileProperties = new BaseFileProperties(); await fileProperties.PopuplateFromFileInfo(fileInfo); } return(fileProperties); }
public void SetFileProperties(IFileProperties fileInfo) { _fileProperties = fileInfo; var file = new File { SourceLanguage = SourceLanguage.Name, TargetLanguage = TargetLanguage.Name }; var originalFilePath = fileInfo.FileConversionProperties.OriginalFilePath ?? fileInfo.FileConversionProperties.InputFilePath; var systemFileInfo = new FileInfo(originalFilePath); file.Original = fileInfo.FileConversionProperties.OriginalFilePath; //file.DataType = systemFileInfo.Extension; file.DataType = fileInfo.FileConversionProperties.FileTypeDefinitionId.Id; //var addedExternalDependency = false; //foreach (var dependencyFile in fileInfo.FileConversionProperties.DependencyFiles) //{ // if (!addedExternalDependency && // dependencyFile.PreferredLinkage != DependencyFileLinkOption.Embed) // { // addedExternalDependency = true; // var externalFile = new ExternalFile // { // Uid = dependencyFile.Id, // Href = dependencyFile.CurrentFilePath ?? // dependencyFile.OriginalFilePath ?? dependencyFile.PathRelativeToConverted // }; // file.Header.Skl.ExternalFile = externalFile; // } //} Xliff.Files.Add(file); CreateDummyOutputFiles(fileInfo); }
public override bool Resolve(IFileProperties fileProperties) { if (_rules == null) { throw new RuleException($"Resolve called when {nameof(_rules)} is null"); } int count = _rules.Count; if (count == 0) { throw new RuleException($"Resolve called on empty {nameof(OrValidatorRule)}: {Name}"); } for (int i = 0; i < count; ++i) { if (_rules[i].Resolve(fileProperties)) { return(true); } } return(false); }
public void SetFileProperties(IFileProperties fileInfo) { _targetFile = new XmlDocument(); _targetFile.PreserveWhitespace = true; _targetFile.Load(_originalFileProperties.OriginalFilePath); }
public void SetFileProperties(IFileProperties fileInfo) { // Not required for this implementation. }
public async static Task FillFileProperties(IFileProperties fileProps, StorageFile file, StorageFolder topFolder, string fileSubPath, BasicProperties basicProps) { try { fileProps.FileName = file.Name; fileProps.AbsolutePath = file.Path; fileProps.SelectedFolder = Util.FolderPath(topFolder); if (!string.IsNullOrEmpty(fileSubPath)) fileProps.ContainingFolder = fileSubPath; else fileProps.ContainingFolder = ""; //fileProps.HideContainingFolder(); string ftype = GetFileTypeText(file, false); if (!string.IsNullOrEmpty(ftype)) fileProps.FileType = ftype; else fileProps.HideFileType(); if (basicProps != null) fileProps.FileSize = Util.SizeToString(basicProps.Size, "B"); else fileProps.HideFileSize(); if (!string.IsNullOrEmpty(file.Provider.DisplayName)) { string flocation = file.Provider.DisplayName; if (!string.IsNullOrEmpty(file.Provider.Id) && file.Provider.DisplayName.IndexOf(file.Provider.Id, StringComparison.OrdinalIgnoreCase) <= -1) flocation += " (" + file.Provider.Id.Substring(0, 1).ToUpper() + file.Provider.Id.Substring(1) + ") "; fileProps.FileLocation = flocation; } else if (!string.IsNullOrEmpty(file.Provider.Id)) fileProps.FileLocation = file.Provider.Id; else fileProps.HideFileLocation(); StorageItemThumbnail thumbnail = await file.GetThumbnailAsync(ThumbnailMode.DocumentsView, 260, ThumbnailOptions.None); Image image = Util.GetImage(thumbnail); if (image != null) fileProps.FileImage = image.Source; } catch (Exception ex) { Debug.WriteLine(ex.ToString()); } }
public void SetFileProperties(IFileProperties properties) { _fileProperties = properties; }