public XElement?FindStyleElement(string styleId)
        {
            var document = XmlResourceHelper.GetXmlResource("Wordroller.Styles.Resources.DefaultOnDemandStyles.xml");

            return(document.Root?.Elements(Namespaces.w + "style")
                   .SingleOrDefault(e => e.Attribute(Namespaces.w + "styleId")?.Value == styleId));
        }
Пример #2
0
 public void CommitSettings(string filePath)
 {
     if (File.Exists(filePath))
     {
         File.Delete(filePath);
     }
     XmlResourceHelper.WriteXmlResource(filePath, _resourceValues);
 }
 public void CommitSettings()
 {
     if (File.Exists(AppCenterResourcesPath))
     {
         File.Delete(AppCenterResourcesPath);
     }
     XmlResourceHelper.WriteXmlResource(AppCenterResourcesPath, _resourceValues);
 }
Пример #4
0
    static void UpdateJson()
    {
#if UNITY_ANDROID
        var bundleId            = ApplicationIdHelper.GetApplicationId();
        var projectDir          = Path.Combine(Application.dataPath, "..");
        var googleServicesFiles = FindGoogleServicesFiles();
        if (googleServicesFiles == null)
        {
            return;
        }
        if (googleServicesFiles.Length > 1)
        {
            Debug.LogWarning("More than one " + GoogleServicesInputFile + " file found, using first one.");
        }
        var inputPath  = Path.Combine(projectDir, googleServicesFiles[0]);
        var outputPath = Path.Combine(projectDir, GoogleServicesOutputPath);
        var outputDir  = Path.Combine(projectDir, GoogleServicesOutputDirectory);
        if (!Directory.Exists(outputDir))
        {
            try
            {
                Directory.CreateDirectory(outputDir);
            }
            catch (Exception ex)
            {
                Debug.LogException(ex);
                return;
            }
        }
        if (File.Exists(outputPath) &&
            File.GetLastWriteTime(outputPath).CompareTo(File.GetLastWriteTime(inputPath)) >= 0)
        {
            return;
        }
        var json               = File.ReadAllText(inputPath);
        var googleServices     = JsonUtility.FromJson <GoogleServices>(json);
        var resolvedClientInfo = googleServices.GetClient(bundleId);
        if (resolvedClientInfo == null)
        {
            Debug.LogWarning("Failed to find client_info in " + GoogleServicesInputFile + " matching package name: " + bundleId);
        }
        var valuesItems = new Dictionary <string, string> {
            { DefaultWebClientIdKey, googleServices.GetDefaultWebClientId(bundleId) },
            { FirebaseDatabaseUrlKey, googleServices.GetFirebaseDatabaseUrl() },
            { GATrackingIdKey, googleServices.GetGATrackingId(bundleId) },
            { GSMDefaultSenderIdKey, googleServices.GetDefaultGcmSenderId() },
            { GoogleAPIKey, googleServices.GetGoogleApiKey(bundleId) },
            { GoogleAppIdKey, googleServices.GetGoogleAppId(bundleId) },
            { CrashReportingApiKey, googleServices.GetCrashReportingApiKey(bundleId) },
            { GoogleStorageBucketKey, googleServices.GetStorageBucket(bundleId) },
            { ProjectIdKey, googleServices.GetProjectId() },
        };
        XmlResourceHelper.WriteXmlResource(outputPath, valuesItems);
        // Update editor project view.
        AssetDatabase.Refresh();
#endif
    }
Пример #5
0
        private PackagePart CreateDefaultDocumentPart(bool isTemplate)
        {
            var contentType  = isTemplate ? ContentTypes.Template : ContentTypes.Document;
            var documentPart = package.CreatePart(new Uri("/word/document.xml", UriKind.Relative), contentType, CompressionOption.Normal);

            package.CreateRelationship(documentPart.Uri, TargetMode.Internal, RelationshipTypes.OfficeDocument);
            var document = XmlResourceHelper.GetXmlResource("Wordroller.Packages.Defaults.document.xml");

            PackagePartHelper.SavePackagePart(documentPart, document);
            return(documentPart);
        }
Пример #6
0
        internal PackagePart CreateDefaultNumberingPart()
        {
            var packagePartUri = new Uri("/word/numbering.xml", UriKind.Relative);
            var part           = package.CreatePart(packagePartUri, ContentTypes.Numbering, CompressionOption.Normal);

            DocumentPart.CreateRelationship(packagePartUri, TargetMode.Internal, RelationshipTypes.Numbering);
            var content = XmlResourceHelper.GetXmlResource("Wordroller.Packages.Defaults.numbering.xml");

            PackagePartHelper.SavePackagePart(part, content);
            return(part);
        }
Пример #7
0
        public (PackagePart, PackageRelationship) AddFooterPart()
        {
            var safePartIndex = package.GetParts().Count() + 1;
            var partUri       = new Uri($"/word/footer{safePartIndex}.xml", UriKind.Relative);
            var part          = package.CreatePart(partUri, ContentTypes.Footer, CompressionOption.Normal);
            var content       = XmlResourceHelper.GetXmlResource("Wordroller.Packages.Defaults.footer.xml");

            PackagePartHelper.SavePackagePart(part, content);
            var relationship = DocumentPart.CreateRelationship(part.Uri, TargetMode.Internal, RelationshipTypes.Footer);

            return(part, relationship);
        }
Пример #8
0
        private PackagePart CreateDefaultSettingsPart(CultureInfo culture, PackagePart documentPart)
        {
            var packagePartUri = new Uri("/word/settings.xml", UriKind.Relative);
            var part           = package.CreatePart(packagePartUri, ContentTypes.Settings, CompressionOption.Normal);

            documentPart.CreateRelationship(packagePartUri, TargetMode.Internal, RelationshipTypes.Settings);
            var settings = XmlResourceHelper.GetXmlResource("Wordroller.Packages.Defaults.settings.xml");

            var themeFontLang = settings.Root?.Element(XName.Get("themeFontLang", Namespaces.w.NamespaceName));

            themeFontLang?.SetAttributeValue(XName.Get("val", Namespaces.w.NamespaceName), culture);
            PackagePartHelper.SavePackagePart(part, settings);
            return(part);
        }
Пример #9
0
        private PackagePart CreateDefaultStylesPart(CultureInfo culture, PackagePart documentPart)
        {
            var packagePartUri = new Uri("/word/styles.xml", UriKind.Relative);
            var part           = package.CreatePart(packagePartUri, ContentTypes.Styles, CompressionOption.Normal);

            documentPart.CreateRelationship(packagePartUri, TargetMode.Internal, RelationshipTypes.Styles);
            var content = XmlResourceHelper.GetXmlResource("Wordroller.Packages.Defaults.styles.xml");

            var lang = content.Root
                       ?.Element(XName.Get("docDefaults", Namespaces.w.NamespaceName))
                       ?.Element(XName.Get("rPrDefault", Namespaces.w.NamespaceName))
                       ?.Element(XName.Get("rPr", Namespaces.w.NamespaceName))
                       ?.Element(XName.Get("lang", Namespaces.w.NamespaceName))
                       ?? throw new Exception("The default styles part is corrupt");

            lang.SetAttributeValue(XName.Get("val", Namespaces.w.NamespaceName), culture.ToString());
            PackagePartHelper.SavePackagePart(part, content);
            return(part);
        }