Exemplo n.º 1
0
        public void EnsureThemePartLoaded(Assembly assembly)
        {
            var name = ThemePart.GetName(assembly);

            if (ThemeParts.TryGetValue(name, out var themeParts) == false)
            {
                return;
            }

            var newXamlResources = new List <XamlResourceInfo>();

            foreach (var themePart in themeParts.ToList())
            {
                themePart.ResolveDependency(assembly);

                if (themePart.HasDependencies == false)
                {
                    var themePartAssembly = themePart.EnsureThemePartAssembly();

                    if (themePartAssembly != null)
                    {
                        LoadThemeAssembly(themePartAssembly, newXamlResources);
                    }

                    ThemeParts.RemoveValue(name, themePart);
                }
            }

            if (newXamlResources.Count > 0)
            {
                OnXamlResourceLoading(new XamlResourceLoadingEventArgs(newXamlResources));
            }
        }
Exemplo n.º 2
0
        public static string[] GetThemeColorList(ThemePart themPart)
        {
            var themColorList = (((DocumentFormat.OpenXml.Drawing.ThemeElements)(themPart.Theme.ChildElements[0])).ColorScheme).ChildElements;
            var themColor     = new string[10];

            for (int i = 0; i < themColor.Count(); i++)
            {
                if (i < 2)
                {
                    themColor[0] = ((DocumentFormat.OpenXml.Drawing.SystemColor)((themColorList[1]).ChildElements[0])).LastColor;
                    themColor[1] = ((DocumentFormat.OpenXml.Drawing.SystemColor)((themColorList[0]).ChildElements[0])).LastColor;
                }
                else
                {
                    if (i < 4)
                    {
                        themColor[2] = ((DocumentFormat.OpenXml.Drawing.RgbColorModelHex)((themColorList[3]).ChildElements[0])).Val;
                        themColor[3] = ((DocumentFormat.OpenXml.Drawing.RgbColorModelHex)((themColorList[2]).ChildElements[0])).Val;
                    }
                    else
                    {
                        themColor[i] = ((DocumentFormat.OpenXml.Drawing.RgbColorModelHex)((themColorList[i]).ChildElements[0])).Val;
                    }
                }
            }
            return(themColor);
        }
Exemplo n.º 3
0
        public static ThemePart CreateTheme(SlideMasterPart slideMasterPart1)
        {
            ThemePart themePart1 = slideMasterPart1.AddNewPart <ThemePart>("rId12");

            GeneratePartContent(themePart1);
            return(themePart1);
        }
Exemplo n.º 4
0
        private static IEnumerable <ThemePart> LoadThemeParts(Assembly assembly)
        {
            if (assembly.HasAttribute <ThemeAssemblyAttribute>(false) == false)
            {
                yield break;
            }

            var themeParts = new Dictionary <string, Tuple <string, string> >();

            foreach (var resourceUri in assembly.EnumerateEmbeddedResources())
            {
                if (resourceUri.EndsWith(".themepart.xml", StringComparison.OrdinalIgnoreCase))
                {
                    var themePartName  = resourceUri.LeftOf(".themepart", StringComparison.OrdinalIgnoreCase);
                    var themePartTuple = themeParts.GetValueOrCreate(themePartName, n => new Tuple <string, string>(resourceUri, null));

                    themeParts[themePartName] = new Tuple <string, string>(resourceUri, themePartTuple.Item2);
                }
                else if (resourceUri.EndsWith(".themepart.zip", StringComparison.OrdinalIgnoreCase))
                {
                    var themePartName  = resourceUri.LeftOf(".themepart", StringComparison.OrdinalIgnoreCase);
                    var themePartTuple = themeParts.GetValueOrCreate(themePartName, n => new Tuple <string, string>(null, resourceUri));

                    themeParts[themePartName] = new Tuple <string, string>(themePartTuple.Item1, resourceUri);
                }
            }

            foreach (var kv in themeParts)
            {
                var themePart = new ThemePart(kv.Key, assembly, kv.Value.Item1, kv.Value.Item2);

                yield return(themePart);
            }
        }
Exemplo n.º 5
0
        private Dr.Theme BuildRootElementFromPart(ThemePart part, RootElementConstructors buildWay)
        {
            Dr.Theme root = null;
            switch (buildWay)
            {
            case RootElementConstructors.DefaultConstructor:
                root = new Dr.Theme();
                root.Load(part);
                break;

            case RootElementConstructors.IEnumerable:
                root = new Dr.Theme(part.Theme.Elements().AsEnumerable());
                break;

            case RootElementConstructors.Params:
                root = new Dr.Theme(part.Theme.Elements().ToArray());
                break;

            case RootElementConstructors.OuterXml:
                root = new Dr.Theme(part.Theme.OuterXml);
                break;
            }

            return(root);
        }
        /// <summary>
        /// Sets the document theme
        /// </summary>
        /// <param name="theme">Theme package</param>
        public static OpenXmlPowerToolsDocument SetTheme(WmlDocument doc, OpenXmlPowerToolsDocument themeDoc)
        {
            using (OpenXmlMemoryStreamDocument streamDoc = new OpenXmlMemoryStreamDocument(doc))
            {
                using (WordprocessingDocument document = streamDoc.GetWordprocessingDocument())
                {
                    using (OpenXmlMemoryStreamDocument themeStream = new OpenXmlMemoryStreamDocument(themeDoc))
                        using (Package theme = themeStream.GetPackage())
                        {
                            // Gets the theme manager part
                            PackageRelationship themeManagerRelationship =
                                theme.GetRelationshipsByType(mainDocumentRelationshipType).FirstOrDefault();
                            if (themeManagerRelationship != null)
                            {
                                PackagePart themeManagerPart = theme.GetPart(themeManagerRelationship.TargetUri);

                                // Gets the theme main part
                                PackageRelationship themeRelationship =
                                    themeManagerPart.GetRelationshipsByType(themeRelationshipType).FirstOrDefault();
                                if (themeRelationship != null)
                                {
                                    PackagePart themePart        = theme.GetPart(themeRelationship.TargetUri);
                                    XDocument   newThemeDocument = XDocument.Load(XmlReader.Create(themePart.GetStream(FileMode.Open, FileAccess.Read)));

                                    // Removes existing theme part from document
                                    if (document.MainDocumentPart.ThemePart != null)
                                    {
                                        document.MainDocumentPart.DeletePart(document.MainDocumentPart.ThemePart);
                                    }

                                    // Creates a new theme part
                                    ThemePart documentThemePart = document.MainDocumentPart.AddNewPart <ThemePart>();

                                    var embeddedItems =
                                        newThemeDocument
                                        .Descendants()
                                        .Attributes(relationshipns + "embed");
                                    foreach (PackageRelationship imageRelationship in themePart.GetRelationships())
                                    {
                                        // Adds an image part to the theme part and stores contents inside
                                        PackagePart imagePart    = theme.GetPart(imageRelationship.TargetUri);
                                        ImagePart   newImagePart =
                                            documentThemePart.AddImagePart(GetImagePartType(imagePart.ContentType));
                                        newImagePart.FeedData(imagePart.GetStream(FileMode.Open, FileAccess.Read));

                                        // Updates relationship references into the theme XDocument
                                        XAttribute relationshipAttribute = embeddedItems.FirstOrDefault(e => e.Value == imageRelationship.Id);
                                        if (relationshipAttribute != null)
                                        {
                                            relationshipAttribute.Value = documentThemePart.GetIdOfPart(newImagePart);
                                        }
                                    }
                                    documentThemePart.PutXDocument(newThemeDocument);
                                }
                            }
                        }
                }
                return(streamDoc.GetModifiedDocument());
            }
        }
Exemplo n.º 7
0
 private static void Extract(ThemePart theme, TextWriter css, Style style)
 {
     if (style.StyleRunProperties == null)
     {
         return;
     }
     Extract(style.StyleRunProperties, style.StyleParagraphProperties, css, theme);
 }
        private void CreatePartsSubsectorPollutionSourceFieldSheet(SpreadsheetDocument document)
        {
            int SheetOrdinal = 0;

            BaseEnumService baseEnumService = new BaseEnumService(_TaskRunnerBaseService._BWObj.appTaskModel.Language);
            TVItemService   tvItemService   = new TVItemService(_TaskRunnerBaseService._BWObj.appTaskModel.Language, _TaskRunnerBaseService._User);
            List <string>   SheetNameList   = new List <string>();

            SheetNameList.Add("Active - " + baseEnumService.GetEnumText_TVTypeEnum(TVTypeEnum.Subsector));
            SheetNameList.Add("Inactive - " + baseEnumService.GetEnumText_TVTypeEnum(TVTypeEnum.Subsector));
            XlsxBase.AddSheetNameAndID(SheetNameList[0]);
            XlsxBase.AddSheetNameAndID(SheetNameList[1]);

            ExtendedFilePropertiesPart extendedFilePropertiesPart = document.AddNewPart <ExtendedFilePropertiesPart>("rId1000");

            XlsxBase.GenerateExtendedFilePropertiesPart1Content(extendedFilePropertiesPart);

            WorkbookPart workbookPart = document.AddWorkbookPart();

            XlsxBase.GenerateWorkbookPart1Content(workbookPart);

            SheetOrdinal = 0;
            WorksheetPart worksheetA = workbookPart.AddNewPart <WorksheetPart>(XlsxBase.sheetNameAndIDList[SheetOrdinal].SheetID);

            GenerateWorksheetAContentSubsectorPollutionSourceFieldSheet(worksheetA, workbookPart.Workbook, SheetNameList[0], SheetOrdinal, true);

            foreach (UsedHyperlink usedHyperlink in XlsxBase.UsedHyperlinkList)
            {
                worksheetA.AddHyperlinkRelationship(new System.Uri(usedHyperlink.URL, System.UriKind.Absolute), true, usedHyperlink.Id);
            }

            SheetOrdinal = 1;
            WorksheetPart worksheetB = workbookPart.AddNewPart <WorksheetPart>(XlsxBase.sheetNameAndIDList[SheetOrdinal].SheetID);

            GenerateWorksheetAContentSubsectorPollutionSourceFieldSheet(worksheetB, workbookPart.Workbook, SheetNameList[1], SheetOrdinal, false);

            foreach (UsedHyperlink usedHyperlink in XlsxBase.UsedHyperlinkList)
            {
                worksheetB.AddHyperlinkRelationship(new System.Uri(usedHyperlink.URL, System.UriKind.Absolute), true, usedHyperlink.Id);
            }

            SharedStringTablePart sharedStringTablePart = workbookPart.AddNewPart <SharedStringTablePart>("rId2000");

            XlsxBase.GenerateSharedStringTablePart1Content(sharedStringTablePart);

            WorkbookStylesPart workbookStylesPart = workbookPart.AddNewPart <WorkbookStylesPart>("rId3000");

            XlsxBase.GenerateWorkbookStylesPart1Content(workbookStylesPart);

            ThemePart themePart = workbookPart.AddNewPart <ThemePart>("rId4000");

            XlsxBase.GenerateThemePart1Content(themePart);


            XlsxBase.SetPackageProperties(document);
        }
        public ThemePartViewModel(ThemePart part, ThemeClassViewModel parent)
        {
            Part   = part;
            Parent = parent;

            properties.AddRange(part.Properties.Select(x => new OwnedThemePropertyViewModel(x)));

            states = part.States.Select(x => new ThemeStateViewModel(x, this)).ToList();
            states.Sort((x, y) => x.Id.CompareTo(y.Id));
        }
Exemplo n.º 10
0
        /// <summary>
        /// Sets the document theme
        /// </summary>
        /// <param name="theme">Theme package</param>
        public void SetTheme(Package theme)
        {
            // Gets the theme manager part
            PackageRelationship themeManagerRelationship =
                theme.GetRelationshipsByType(mainDocumentRelationshipType).FirstOrDefault();

            if (themeManagerRelationship != null)
            {
                PackagePart themeManagerPart = theme.GetPart(themeManagerRelationship.TargetUri);

                // Gets the theme main part
                PackageRelationship themeRelationship =
                    themeManagerPart.GetRelationshipsByType(themeRelationshipType).FirstOrDefault();
                if (themeRelationship != null)
                {
                    PackagePart themePart        = theme.GetPart(themeRelationship.TargetUri);
                    XDocument   newThemeDocument = XDocument.Load(XmlReader.Create(themePart.GetStream(FileMode.Open, FileAccess.Read)));

                    // Removes existing theme part from document
                    if (parentDocument.Document.MainDocumentPart.ThemePart != null)
                    {
                        parentDocument.Document.MainDocumentPart.DeletePart(parentDocument.Document.MainDocumentPart.ThemePart);
                    }

                    // Creates a new theme part
                    ThemePart documentThemePart = parentDocument.Document.MainDocumentPart.AddNewPart <ThemePart>();
                    XDocument themeDocument     = parentDocument.GetXDocument(documentThemePart);
                    themeDocument.Add(newThemeDocument.Root);

                    var embeddedItems =
                        themeDocument
                        .Descendants()
                        .Attributes(relationshipns + "embed");
                    foreach (PackageRelationship imageRelationship in themePart.GetRelationships())
                    {
                        // Adds an image part to the theme part and stores contents inside
                        PackagePart imagePart    = theme.GetPart(imageRelationship.TargetUri);
                        ImagePart   newImagePart =
                            documentThemePart.AddImagePart(GetImagePartType(imagePart.ContentType));
                        newImagePart.FeedData(imagePart.GetStream(FileMode.Open, FileAccess.Read));

                        // Updates relationship references into the theme XDocument
                        XAttribute relationshipAttribute = embeddedItems.FirstOrDefault(e => e.Value == imageRelationship.Id);
                        if (relationshipAttribute != null)
                        {
                            relationshipAttribute.Value = documentThemePart.GetIdOfPart(newImagePart);
                        }
                    }

                    // Updates the theme part with actual contents of the theme XDocument
                    using (XmlWriter newThemeWriter = XmlWriter.Create(documentThemePart.GetStream(FileMode.Create, FileAccess.Write)))
                        themeDocument.WriteTo(newThemeWriter);
                }
            }
        }
Exemplo n.º 11
0
        public static string GetCategoryAndPartLabel(ThemeCategory category, ThemePart part)
        {
            string prefix = string.Concat(Translation.Instance.GetTranslation(TranslationID.LABEL_SELECT), " ");
            string text   = string.Empty;

            switch (category)
            {
            case ThemeCategory.Themes:
                text = Translation.Instance.GetTranslation(TranslationID.LABEL_THEME);
                break;

            case ThemeCategory.Terrain:
                text = Translation.Instance.GetTranslation(TranslationID.LABEL_TERRAIN);
                break;

            case ThemeCategory.Water:
                text = Translation.Instance.GetTranslation(TranslationID.LABEL_WATER);
                break;

            case ThemeCategory.Structures:
                text = Translation.Instance.GetTranslation(TranslationID.LABEL_STRUCTURES);
                break;

            case ThemeCategory.Atmosphere:
                text = Translation.Instance.GetTranslation(TranslationID.LABEL_ATMOSPHERE);
                break;

            case ThemeCategory.Weather:
                text = Translation.Instance.GetTranslation(TranslationID.LABEL_WEATHER);
                break;
            }
            string postFix = string.Empty;

            switch (part)
            {
            case ThemePart.Texture:
                postFix = string.Concat(" ", Translation.Instance.GetTranslation(TranslationID.LABEL_TEXTURE));
                break;

            case ThemePart.Color:
                postFix = string.Concat(" ", Translation.Instance.GetTranslation(TranslationID.LABEL_COLOR));
                break;

            case ThemePart.Offset:
                postFix = string.Concat(" ", Translation.Instance.GetTranslation(TranslationID.LABEL_OFFSET));
                break;

            case ThemePart.Value:
                postFix = string.Concat(" ", Translation.Instance.GetTranslation(TranslationID.LABEL_VALUE));
                break;
            }
            return(string.Concat(prefix, text, postFix));
        }
Exemplo n.º 12
0
        /// <summary>
        /// replace the current theme with a user specified theme
        /// </summary>
        /// <param name="document">document file lcoation</param>
        /// <param name="themeFile">theme xml file location</param>
        /// <param name="app">which app is the document</param>
        public static void ReplaceTheme(string document, string themeFile, string app)
        {
            if (app == "Word")
            {
                using (WordprocessingDocument wordDoc = WordprocessingDocument.Open(document, true))
                {
                    MainDocumentPart mainPart = wordDoc.MainDocumentPart;

                    // Delete the old document part.
                    mainPart.DeletePart(mainPart.ThemePart);

                    // Add a new document part and then add content.
                    ThemePart themePart = mainPart.AddNewPart <ThemePart>();

                    using (StreamReader streamReader = new StreamReader(themeFile))
                        using (StreamWriter streamWriter = new StreamWriter(themePart.GetStream(FileMode.Create)))
                        {
                            streamWriter.Write(streamReader.ReadToEnd());
                        }
                }
            }
            else if (app == "PowerPoint")
            {
                using (PresentationDocument presDoc = PresentationDocument.Open(document, true))
                {
                    PresentationPart mainPart = presDoc.PresentationPart;
                    mainPart.DeletePart(mainPart.ThemePart);
                    ThemePart themePart = mainPart.AddNewPart <ThemePart>();

                    using (StreamReader streamReader = new StreamReader(themeFile))
                        using (StreamWriter streamWriter = new StreamWriter(themePart.GetStream(FileMode.Create)))
                        {
                            streamWriter.Write(streamReader.ReadToEnd());
                        }
                }
            }
            else
            {
                using (SpreadsheetDocument excelDoc = SpreadsheetDocument.Open(document, true))
                {
                    WorkbookPart mainPart = excelDoc.WorkbookPart;
                    mainPart.DeletePart(mainPart.ThemePart);
                    ThemePart themePart = mainPart.AddNewPart <ThemePart>();

                    using (StreamReader streamReader = new StreamReader(themeFile))
                        using (StreamWriter streamWriter = new StreamWriter(themePart.GetStream(FileMode.Create)))
                        {
                            streamWriter.Write(streamReader.ReadToEnd());
                        }
                }
            }
        }
Exemplo n.º 13
0
        public override void Awake()
        {
            base.Awake();
            Setup("Select Theme Panel", 478.0f, 0.0f, UIUtils.DefaultSpacing, true, LayoutDirection.Vertical, LayoutStart.TopLeft, "GenericPanel");
            Part = Controller.Part;
            float panelWidth = ThemeManager.Instance.Themes.Count > 7 ? 468.0f : 456.0f;

            CreateLabel();
            CreateFastList(new Vector2(panelWidth, 720.0f), 76.0f);
            CreateButton();
            this.CreateSpace(panelWidth, 0.0f);
            SetupRowsData();
            BindEvents();
        }
Exemplo n.º 14
0
        private void insert(PresentationPart presentationPart, List <String> imgList)
        {
            int  idx        = 1;
            uint uid        = UInt32.MaxValue;
            var  slideParts = presentationPart.SlideParts;

            string            slideMasterRid    = "rId" + idx;
            SlideMasterIdList slideMasterIdList = new SlideMasterIdList(new SlideMasterId()
            {
                Id = uid, RelationshipId = slideMasterRid
            });
            SlideIdList slideIdList = new SlideIdList();
            SlideSize   slideSize   = new SlideSize()
            {
                Cx = 9144000, Cy = 6858000, Type = SlideSizeValues.Screen4x3
            };
            NotesSize notesSize = new NotesSize()
            {
                Cx = 6858000, Cy = 9144000
            };
            DefaultTextStyle defaultTextStyle = new DefaultTextStyle();

            presentationPart.Presentation.Append(slideMasterIdList, slideIdList, slideSize, notesSize, defaultTextStyle);

            SlideLayoutPart layoutPart = null;
            SlideMasterPart masterPart = null;
            ThemePart       themePart  = null;

            foreach (string imgPath in imgList)
            {
                String imgIdx   = "rId" + (900 + idx);
                String slideIdx = "rId" + (idx + 1);
                String themeIdx = "rId" + (idx + 4);

                var slidePart = CreateSlidePart(presentationPart, slideIdx, uid = uid - 10);
                if (null == layoutPart)
                {
                    layoutPart = CreateSlideLayoutPart(slidePart, slideMasterRid, uid = uid - 10);
                    masterPart = CreateSlideMasterPart(layoutPart, slideMasterRid, uid = uid - 10);
                    themePart  = CreateTheme(masterPart, themeIdx);
                    masterPart.AddPart(layoutPart, slideMasterRid);
                    presentationPart.AddPart(masterPart, slideMasterRid);
                    presentationPart.AddPart(themePart, themeIdx);
                }

                //insert(slidePart, imgPath, imgIdx, uid = uid - 10);
                idx += 5;
            }
            presentationPart.Presentation.Save();
        }
Exemplo n.º 15
0
        public StyleHelper(WordprocessingDocument doc)
        {
            if (doc != null)
            {
                this.doc = doc;
                if (this.doc.MainDocumentPart.StyleDefinitionsPart != null)
                {
                    this.docDefaults = this.doc.MainDocumentPart.StyleDefinitionsPart.Styles.Descendants <Word.DocDefaults>().FirstOrDefault();
                    this.styles      = this.doc.MainDocumentPart.StyleDefinitionsPart.Styles.Descendants <Word.Style>();
                }
                this.sections = this.doc.MainDocumentPart.Document.Body.Descendants <Word.SectionProperties>().ToList();
                if (this.doc.MainDocumentPart.ThemePart != null)
                {
                    this.theme = this.doc.MainDocumentPart.ThemePart;
                }
                if (this.doc.MainDocumentPart.NumberingDefinitionsPart != null &&
                    this.doc.MainDocumentPart.NumberingDefinitionsPart.Numbering != null)
                {
                    this.numbering = this.doc.MainDocumentPart.NumberingDefinitionsPart.Numbering;

                    // set all ilevel's start value for all abstractNums
                    foreach (Word.AbstractNum an in this.numbering.Descendants <Word.AbstractNum>())
                    {
                        int abstractNumId = an.AbstractNumberId.Value;
                        foreach (Word.Level lvl in an.Descendants <Word.Level>())
                        {
                            if (lvl.LevelIndex != null && lvl.StartNumberingValue != null)
                            {
                                this.nc.SetStart(abstractNumId, lvl.LevelIndex.Value, lvl.StartNumberingValue.Val);
                            }
                        }
                    }
                }
                if (this.doc.MainDocumentPart.HyperlinkRelationships != null)
                {
                    this.hyperlinkRelationships = this.doc.MainDocumentPart.HyperlinkRelationships;
                }
                if (this.doc.MainDocumentPart.DocumentSettingsPart != null &&
                    this.doc.MainDocumentPart.DocumentSettingsPart.Settings != null)
                {
                    Word.Compatibility compat = this.doc.MainDocumentPart.DocumentSettingsPart.Settings.Descendants <Word.Compatibility>().FirstOrDefault();
                    if (compat != null && compat.BalanceSingleByteDoubleByteWidth != null)
                    {
                        this.balanceSingleByteDoubleByteWidth = StyleHelper.GetToggleProperty(compat.BalanceSingleByteDoubleByteWidth);
                    }
                }
            }
        }
Exemplo n.º 16
0
        public void ThemeAsPartRootClassTest()
        {
            this.MyTestInitialize(TestContext.GetCurrentMethod());
            var testfile = CopyTestFiles(@"wordprocessing", true, "complex0.docx", f => f.IsWordprocessingFile())
                           .FirstOrDefault();

            using (var package = testfile.OpenPackage(true) as WordprocessingDocument)
            {
                ThemePart themePart = package.MainDocumentPart.ThemePart;

                Log.Comment("Constructing Theme...");
                Dr.Theme themeFromPart  = themePart.Theme;
                Dr.Theme theme          = buildRootElementFromPart(themePart, RootElementConstructors.OuterXml);
                var      xThemeFromFile = ConvertToXElement(themePart, themeFromPart);
                var      xThemeInMemory = theme.ToXElement();
                var      isEqual        = xThemeInMemory.Compare(xThemeFromFile);
                Log.VerifyTrue(isEqual, "Theme constructing from file is different from the one in memory.");

                Log.Comment("Attribute Properties...");
                var expectedName = "Office Theme";
                Log.VerifyValue(themeFromPart.Name.ToString(), expectedName, "Name of current element: {0} is different from {1}.", themeFromPart.Name, expectedName);

                Log.Comment("Hallow Clone...");
                var hClone = themeFromPart.CloneNode(false) as Dr.Theme;
                foreach (var ao in themeFromPart.GetAttributes())
                {
                    var ac = hClone.GetAttribute(ao.LocalName, ao.NamespaceUri);
                    Log.VerifyValue(ao.Value, ac.Value,
                                    "Attribute: {0} value: {1} NOT cloned as expected {2}", ao.GetFullName(), ac.Value, ao.Value);
                }

                Log.Comment("Deep Clone...");
                var dClone = themeFromPart.CloneNode(true) as Dr.Theme;
                isEqual = xThemeFromFile.Compare(dClone.ToXElement());
                Log.VerifyTrue(isEqual, "Theme Cloned IS different from the original one.");

                Log.Comment("LocalName...");
                Log.VerifyValue(theme.LocalName, "theme", "LocalName of Theme is {0} instead ofexpected a:theme", theme.LocalName);

                Log.Comment("Associating Part...");
                Log.VerifyReference(themePart, themePart.Theme.ThemePart, "Associating Part of Theme is different from Hosting Part!");

                Log.Comment("Saving changes to Theme Part...");
                theme.Save(themePart);
            }
            Log.Pass("Theme as PartRoot Class Testing Passed.");
        }
        private void CreateParts(SpreadsheetDocument document)
        {
            int SheetOrdinal = 0;

            BaseEnumService baseEnumService = new BaseEnumService(_TaskRunnerBaseService._BWObj.appTaskModel.Language);
            TVItemService   tvItemService   = new TVItemService(_TaskRunnerBaseService._BWObj.appTaskModel.Language, _TaskRunnerBaseService._User);

            XlsxBase.AddSheetNameAndID(baseEnumService.GetEnumText_TVTypeEnum(TVTypeEnum.Province));

            ExtendedFilePropertiesPart extendedFilePropertiesPart = document.AddNewPart <ExtendedFilePropertiesPart>("rId1000");

            XlsxBase.GenerateExtendedFilePropertiesPart1Content(extendedFilePropertiesPart);

            WorkbookPart workbookPart = document.AddWorkbookPart();

            XlsxBase.GenerateWorkbookPart1Content(workbookPart);

            // update percentage
            _TaskRunnerBaseService.SendPercentToDB(_TaskRunnerBaseService._BWObj.appTaskModel.AppTaskID, 10);

            SheetOrdinal = 0;
            WorksheetPart worksheetA = workbookPart.AddNewPart <WorksheetPart>(XlsxBase.sheetNameAndIDList[SheetOrdinal].SheetID);

            GenerateWorksheetAContent(worksheetA, SheetOrdinal);

            // update percentage
            _TaskRunnerBaseService.SendPercentToDB(_TaskRunnerBaseService._BWObj.appTaskModel.AppTaskID, 30);

            foreach (UsedHyperlink usedHyperlink in XlsxBase.UsedHyperlinkList)
            {
                worksheetA.AddHyperlinkRelationship(new System.Uri(usedHyperlink.URL, System.UriKind.Absolute), true, usedHyperlink.Id);
            }

            SharedStringTablePart sharedStringTablePart = workbookPart.AddNewPart <SharedStringTablePart>("rId2000");

            XlsxBase.GenerateSharedStringTablePart1Content(sharedStringTablePart);

            WorkbookStylesPart workbookStylesPart = workbookPart.AddNewPart <WorkbookStylesPart>("rId3000");

            XlsxBase.GenerateWorkbookStylesPart1Content(workbookStylesPart);

            ThemePart themePart = workbookPart.AddNewPart <ThemePart>("rId4000");

            XlsxBase.GenerateThemePart1Content(themePart);

            XlsxBase.SetPackageProperties(document);
        }
Exemplo n.º 18
0
        internal static void ApplyTheme(PresentationPart presentationPart, Drawing.Theme theme)
        {
            string themeId = null;

            if (presentationPart.ThemePart != null)
            {
                themeId = presentationPart.GetIdOfPart(presentationPart.ThemePart);
                presentationPart.DeletePart(themeId);
            }
            else
            {
                themeId = presentationPart.GetNextRelationshipId();
            }

            ThemePart themePart = presentationPart.AddNewPart <ThemePart>(themeId);

            theme.Save(themePart);
        }
Exemplo n.º 19
0
        public static void CreatePresentationPart(PresentationPart part, PPTXSetting FileSettings, PPTXSlideLayoutGroup SlideLayouts)
        {
            var partCreator = new DefaultPresentationPart();

            partCreator._CreatePresentationPart(part);

            SlidePart slidePart1 = DefaultSlidePart.CreateSlidePart(part, "rId2", FileSettings);

            // 1枚目のスライド追加
            var topLayoutPart = new SlideLayout_TitleSlide();

            topLayoutPart.Init(EPPTXSlideLayoutType.TitleSlide, SlideLayouts);
            SlideLayoutPart slideLayoutPart1 = topLayoutPart.CreateSlideLayoutPart(slidePart1);
            SlideMasterPart slideMasterPart1 = DefaultSlideMasterPart.CreateSlideMasterPart(slideLayoutPart1, "rId1");
            ThemePart       themePart1       = DefaultTheme.CreateTheme(slideMasterPart1);

            slideMasterPart1.AddPart(slideLayoutPart1, "rId1");
            part.AddPart(slideMasterPart1, "rId1");
            part.AddPart(themePart1, "rId5");

            // 残りのスライドレイアウトを追加
            foreach (EPPTXSlideLayoutType layoutType in Enum.GetValues(typeof(EPPTXSlideLayoutType)))
            {
                if (layoutType == EPPTXSlideLayoutType.TitleSlide)
                {
                    continue;
                }

                var otherLayoutPartType = Type.GetType($"MDToPPTX.PPTX.DefaultParts.SlideLayouts.SlideLayout_{layoutType.ToString()}");
                if (otherLayoutPartType == null)
                {
                    continue;
                }
                SlideLayoutPartBase otherLayoutPart = Activator.CreateInstance(otherLayoutPartType) as SlideLayoutPartBase;
                if (otherLayoutPart != null)
                {
                    otherLayoutPart.Init(layoutType, SlideLayouts);
                    SlideLayoutPart otherSlideLayoutPart = otherLayoutPart.CreateSlideLayoutPart(slideMasterPart1);

                    otherSlideLayoutPart.AddPart(slideMasterPart1, "rId1");
                }
            }
        }
Exemplo n.º 20
0
        public static IEnumerable <ThemePart> GetSectionParts(Assembly target)
        {
            var allViewComponents = target.GetTypes().Where(a => a.BaseType == typeof(ViewComponent));
            var themeSectionParts = new List <ThemePart>();

            foreach (var viewComponent in allViewComponents)
            {
                var themePartAttribute = viewComponent.GetCustomAttribute <ThemePartAttribute>();
                if (themePartAttribute != null)
                {
                    var themSectionPart = new ThemePart
                    {
                        Name = viewComponent.Name.Replace("ViewComponent", ""),
                        ConfigurableManifests = new List <ThemeConfigurableManifest>(),
                        BindingType           = themePartAttribute.BindingType
                    };

                    if (themePartAttribute.BindingType != BindingType.None)
                    {
                        var allProperties = themePartAttribute.Type.GetProperties();
                        foreach (var prop in allProperties)
                        {
                            if ((prop.GetSetMethod() != null || prop.CanWrite) && prop.GetCustomAttribute <NotManifestAttribute>() == null)
                            {
                                if (!themSectionPart.ConfigurableManifests.Any(a => a.Key.Equals(prop.Name, StringComparison.OrdinalIgnoreCase)))
                                {
                                    themSectionPart.ConfigurableManifests.Add(new ThemeConfigurableManifest
                                    {
                                        Key        = prop.Name,
                                        EditorType = GetManifestEditorType(prop)
                                    });
                                }
                            }
                        }
                    }

                    themeSectionParts.Add(themSectionPart);
                }
            }

            return(themeSectionParts);
        }
Exemplo n.º 21
0
        public static event EventHandler ReloadEvent; //2014.12.24.

        public static void SkinControl(ThemePart themepart, Control control)
        {
            if (control != null && !control.IsDisposed && Images.ContainsKey(themepart))
            {
                control.BackgroundImage = Images[themepart];
                if (themepart == ThemePart.MainBackgorund)
                {
                    foreach (Control c in control.GetAll())
                    {
                        Bitmap bmp = new Bitmap(Images[themepart]).Clone(new Rectangle(c.Location.X, c.Location.Y, c.Width, c.Height), PixelFormat.Format32bppRgb);
                        c.BackgroundImage = bmp;
                    }
                }
            }
            ReloadEvent += delegate
            { //Ugyanazt az indexű képet fogja használni, csak a kép változik meg
                if (control != null && !control.IsDisposed && Images.ContainsKey(themepart))
                {
                    control.BackgroundImage = Images[themepart];
                }
            };
        }
        private static ThemePart CreateTheme(SlideMasterPart slideMasterPart1)
        {
            ThemePart themePart1 = slideMasterPart1.AddNewPart <ThemePart>("rId5");

            D.Theme theme1 = new D.Theme()
            {
                Name = "Office Theme"
            };

            D.ThemeElements themeElements1 = new D.ThemeElements(
                new D.ColorScheme(
                    new D.Dark1Color(new D.SystemColor()
            {
                Val = D.SystemColorValues.WindowText, LastColor = "000000"
            }),
                    new D.Light1Color(new D.SystemColor()
            {
                Val = D.SystemColorValues.Window, LastColor = "FFFFFF"
            }),
                    new D.Dark2Color(new D.RgbColorModelHex()
            {
                Val = "1F497D"
            }),
                    new D.Light2Color(new D.RgbColorModelHex()
            {
                Val = "EEECE1"
            }),
                    new D.Accent1Color(new D.RgbColorModelHex()
            {
                Val = "4F81BD"
            }),
                    new D.Accent2Color(new D.RgbColorModelHex()
            {
                Val = "C0504D"
            }),
                    new D.Accent3Color(new D.RgbColorModelHex()
            {
                Val = "9BBB59"
            }),
                    new D.Accent4Color(new D.RgbColorModelHex()
            {
                Val = "8064A2"
            }),
                    new D.Accent5Color(new D.RgbColorModelHex()
            {
                Val = "4BACC6"
            }),
                    new D.Accent6Color(new D.RgbColorModelHex()
            {
                Val = "F79646"
            }),
                    new D.Hyperlink(new D.RgbColorModelHex()
            {
                Val = "0000FF"
            }),
                    new D.FollowedHyperlinkColor(new D.RgbColorModelHex()
            {
                Val = "800080"
            }))
            {
                Name = "Office"
            },
                new D.FontScheme(
                    new D.MajorFont(
                        new D.LatinFont()
            {
                Typeface = "Calibri"
            },
                        new D.EastAsianFont()
            {
                Typeface = ""
            },
                        new D.ComplexScriptFont()
            {
                Typeface = ""
            }),
                    new D.MinorFont(
                        new D.LatinFont()
            {
                Typeface = "Calibri"
            },
                        new D.EastAsianFont()
            {
                Typeface = ""
            },
                        new D.ComplexScriptFont()
            {
                Typeface = ""
            }))
            {
                Name = "Office"
            },
                new D.FormatScheme(
                    new D.FillStyleList(
                        new D.SolidFill(new D.SchemeColor()
            {
                Val = D.SchemeColorValues.PhColor
            }),
                        new D.GradientFill(
                            new D.GradientStopList(
                                new D.GradientStop(new D.SchemeColor(new D.Tint()
            {
                Val = 50000
            },
                                                                     new D.SaturationModulation()
            {
                Val = 300000
            })
            {
                Val = D.SchemeColorValues.PhColor
            })
            {
                Position = 0
            },
                                new D.GradientStop(new D.SchemeColor(new D.Tint()
            {
                Val = 37000
            },
                                                                     new D.SaturationModulation()
            {
                Val = 300000
            })
            {
                Val = D.SchemeColorValues.PhColor
            })
            {
                Position = 35000
            },
                                new D.GradientStop(new D.SchemeColor(new D.Tint()
            {
                Val = 15000
            },
                                                                     new D.SaturationModulation()
            {
                Val = 350000
            })
            {
                Val = D.SchemeColorValues.PhColor
            })
            {
                Position = 100000
            }
                                ),
                            new D.LinearGradientFill()
            {
                Angle = 16200000, Scaled = true
            }),
                        new D.NoFill(),
                        new D.PatternFill(),
                        new D.GroupFill()),
                    new D.LineStyleList(
                        new D.Outline(
                            new D.SolidFill(
                                new D.SchemeColor(
                                    new D.Shade()
            {
                Val = 95000
            },
                                    new D.SaturationModulation()
            {
                Val = 105000
            })
            {
                Val = D.SchemeColorValues.PhColor
            }),
                            new D.PresetDash()
            {
                Val = D.PresetLineDashValues.Solid
            })
            {
                Width            = 9525,
                CapType          = D.LineCapValues.Flat,
                CompoundLineType = D.CompoundLineValues.Single,
                Alignment        = D.PenAlignmentValues.Center
            },
                        new D.Outline(
                            new D.SolidFill(
                                new D.SchemeColor(
                                    new D.Shade()
            {
                Val = 95000
            },
                                    new D.SaturationModulation()
            {
                Val = 105000
            })
            {
                Val = D.SchemeColorValues.PhColor
            }),
                            new D.PresetDash()
            {
                Val = D.PresetLineDashValues.Solid
            })
            {
                Width            = 9525,
                CapType          = D.LineCapValues.Flat,
                CompoundLineType = D.CompoundLineValues.Single,
                Alignment        = D.PenAlignmentValues.Center
            },
                        new D.Outline(
                            new D.SolidFill(
                                new D.SchemeColor(
                                    new D.Shade()
            {
                Val = 95000
            },
                                    new D.SaturationModulation()
            {
                Val = 105000
            })
            {
                Val = D.SchemeColorValues.PhColor
            }),
                            new D.PresetDash()
            {
                Val = D.PresetLineDashValues.Solid
            })
            {
                Width            = 9525,
                CapType          = D.LineCapValues.Flat,
                CompoundLineType = D.CompoundLineValues.Single,
                Alignment        = D.PenAlignmentValues.Center
            }),
                    new D.EffectStyleList(
                        new D.EffectStyle(
                            new D.EffectList(
                                new D.OuterShadow(
                                    new D.RgbColorModelHex(
                                        new D.Alpha()
            {
                Val = 38000
            })
            {
                Val = "000000"
            })
            {
                BlurRadius = 40000L, Distance = 20000L, Direction = 5400000, RotateWithShape = false
            })),
                        new D.EffectStyle(
                            new D.EffectList(
                                new D.OuterShadow(
                                    new D.RgbColorModelHex(
                                        new D.Alpha()
            {
                Val = 38000
            })
            {
                Val = "000000"
            })
            {
                BlurRadius = 40000L, Distance = 20000L, Direction = 5400000, RotateWithShape = false
            })),
                        new D.EffectStyle(
                            new D.EffectList(
                                new D.OuterShadow(
                                    new D.RgbColorModelHex(
                                        new D.Alpha()
            {
                Val = 38000
            })
            {
                Val = "000000"
            })
            {
                BlurRadius = 40000L, Distance = 20000L, Direction = 5400000, RotateWithShape = false
            }))),
                    new D.BackgroundFillStyleList(
                        new D.SolidFill(new D.SchemeColor()
            {
                Val = D.SchemeColorValues.PhColor
            }),
                        new D.GradientFill(
                            new D.GradientStopList(
                                new D.GradientStop(
                                    new D.SchemeColor(new D.Tint()
            {
                Val = 50000
            },
                                                      new D.SaturationModulation()
            {
                Val = 300000
            })
            {
                Val = D.SchemeColorValues.PhColor
            })
            {
                Position = 0
            },
                                new D.GradientStop(
                                    new D.SchemeColor(new D.Tint()
            {
                Val = 50000
            },
                                                      new D.SaturationModulation()
            {
                Val = 300000
            })
            {
                Val = D.SchemeColorValues.PhColor
            })
            {
                Position = 0
            },
                                new D.GradientStop(
                                    new D.SchemeColor(new D.Tint()
            {
                Val = 50000
            },
                                                      new D.SaturationModulation()
            {
                Val = 300000
            })
            {
                Val = D.SchemeColorValues.PhColor
            })
            {
                Position = 0
            }),
                            new D.LinearGradientFill()
            {
                Angle = 16200000, Scaled = true
            }),
                        new D.GradientFill(
                            new D.GradientStopList(
                                new D.GradientStop(
                                    new D.SchemeColor(new D.Tint()
            {
                Val = 50000
            },
                                                      new D.SaturationModulation()
            {
                Val = 300000
            })
            {
                Val = D.SchemeColorValues.PhColor
            })
            {
                Position = 0
            },
                                new D.GradientStop(
                                    new D.SchemeColor(new D.Tint()
            {
                Val = 50000
            },
                                                      new D.SaturationModulation()
            {
                Val = 300000
            })
            {
                Val = D.SchemeColorValues.PhColor
            })
            {
                Position = 0
            }),
                            new D.LinearGradientFill()
            {
                Angle = 16200000, Scaled = true
            })))
            {
                Name = "Office"
            });

            theme1.Append(themeElements1);
            theme1.Append(new D.ObjectDefaults());
            theme1.Append(new D.ExtraColorSchemeList());

            themePart1.Theme = theme1;
            return(themePart1);
        }
Exemplo n.º 23
0
 public OpenXmlTheme(IOpenXmlDocument document, ThemePart themePart)
 {
     this.document  = document;
     this.themePart = themePart;
 }
Exemplo n.º 24
0
        private void SetupStyles()
        {
            WordprocessingCommentsPart commentsPart        = AddTemplatePart <WordprocessingCommentsPart>(this.document, CommentsStyleResource);
            EndnotesPart             endNotesPart          = AddTemplatePart <EndnotesPart>(this.document, EndNotesStyleResource);
            FontTablePart            fontTablePart         = AddTemplatePart <FontTablePart>(this.document, FontsTableStyleResource);
            FootnotesPart            footnotesPart         = AddTemplatePart <FootnotesPart>(this.document, FootNotesStyleResource);
            HeaderPart               headerPart            = AddTemplatePart <HeaderPart>(this.document, HeaderStyleResource);
            DocumentSettingsPart     settingsPart          = AddTemplatePart <DocumentSettingsPart>(this.document, SettingsStyleResource);
            StyleDefinitionsPart     styles                = AddTemplatePart <StyleDefinitionsPart>(this.document, StylesStyleResource);
            StylesWithEffectsPart    stylesWithEffectsPart = AddTemplatePart <StylesWithEffectsPart>(this.document, StylesWithEffectsStyleResource);
            WebSettingsPart          webSettingsPart       = AddTemplatePart <WebSettingsPart>(this.document, WebSettingsStyleResource);
            ThemePart                themePart             = AddTemplatePart <ThemePart>(this.document, ThemeStyleResource);
            NumberingDefinitionsPart numberingPart         = AddTemplatePart <NumberingDefinitionsPart>(this.document, NumberingStyleResource);

            // Initialize the comments manager with the comments part
            this.commentManager = new CommentManager(commentsPart.Comments);

            // Initialize the footer
            string     footerTitle      = this.implementationGuide.GetDisplayName();
            DateTime   footerDate       = this.implementationGuide.PublishDate != null ? this.implementationGuide.PublishDate.Value : DateTime.Now;
            string     footerDateString = footerDate.ToString("m");
            FooterPart newFooterPart    = this.document.MainDocumentPart.AddNewPart <FooterPart>();
            Footer     newFooter        = new Footer();
            Paragraph  pFooter          = new Paragraph(
                new ParagraphProperties(
                    new ParagraphStyleId()
            {
                Val = "Footer"
            }));

            pFooter.Append(
                new Run(
                    new Text(footerTitle)),
                new Run(
                    new TabChar(),
                    new Text(footerDateString)
            {
                Space = SpaceProcessingModeValues.Preserve
            }),
                new Run(
                    new TabChar(),
                    new Text("Page ")
            {
                Space = SpaceProcessingModeValues.Preserve
            }),
                new Run(
                    new FieldChar()
            {
                FieldCharType = FieldCharValues.Begin
            }),
                new Run(
                    new FieldCode(" PAGE ")
            {
                Space = SpaceProcessingModeValues.Preserve
            }),
                new Run(
                    new FieldChar()
            {
                FieldCharType = FieldCharValues.Separate
            }),
                new Run(
                    new RunProperties(
                        new NoProof()),
                    new Text("54")),
                new Run(
                    new FieldChar()
            {
                FieldCharType = FieldCharValues.End
            }));
            newFooter.Append(pFooter);
            newFooterPart.Footer = newFooter;

            // Add numbering for templates
            foreach (Template cTemplate in this.templates)
            {
                NumberingInstance ni = new NumberingInstance(
                    new AbstractNumId()
                {
                    Val = 3
                })
                {
                    NumberID = GenerationConstants.BASE_TEMPLATE_INDEX + (int)cTemplate.Id
                };

                for (int i = 0; i < 9; i++)
                {
                    ni.Append(new LevelOverride(
                                  new StartOverrideNumberingValue()
                    {
                        Val = 1
                    })
                    {
                        LevelIndex = i
                    });
                }

                numberingPart.Numbering.Append(ni);
            }
        }
Exemplo n.º 25
0
        private void CreateParts(WordprocessingDocument document)
        {
            DocxBase.CurrentTitle = DocxServiceProvinceRes.Title;

            ExtendedFilePropertiesPart extendedFilePropertiesPart1 = document.AddNewPart <ExtendedFilePropertiesPart>("rId3");

            DocxBase.GenerateExtendedFilePropertiesPart1Content(extendedFilePropertiesPart1);

            MainDocumentPart mainDocumentPart1 = document.AddMainDocumentPart();

            GenerateMainDocumentPart1Content(mainDocumentPart1);

            FontTablePart fontTablePart1 = mainDocumentPart1.AddNewPart <FontTablePart>("rId13");

            DocxBase.GenerateFontTablePart1Content(fontTablePart1);

            StyleDefinitionsPart styleDefinitionsPart1 = mainDocumentPart1.AddNewPart <StyleDefinitionsPart>("rId3");

            DocxBase.GenerateStyleDefinitionsPart1Content(styleDefinitionsPart1);

            EndnotesPart endnotesPart1 = mainDocumentPart1.AddNewPart <EndnotesPart>("rId7");

            DocxBase.GenerateEndnotesPart1Content(endnotesPart1);

            FooterPart footerPart1 = mainDocumentPart1.AddNewPart <FooterPart>("rId12");

            DocxBase.GenerateFooterPart1Content(footerPart1);

            NumberingDefinitionsPart numberingDefinitionsPart1 = mainDocumentPart1.AddNewPart <NumberingDefinitionsPart>("rId2");

            DocxBase.GenerateNumberingDefinitionsPart1Content(numberingDefinitionsPart1);

            CustomXmlPart customXmlPart1 = mainDocumentPart1.AddNewPart <CustomXmlPart>("application/xml", "rId1");

            DocxBase.GenerateCustomXmlPart1Content(customXmlPart1);

            CustomXmlPropertiesPart customXmlPropertiesPart1 = customXmlPart1.AddNewPart <CustomXmlPropertiesPart>("rId1");

            DocxBase.GenerateCustomXmlPropertiesPart1Content(customXmlPropertiesPart1);

            FootnotesPart footnotesPart1 = mainDocumentPart1.AddNewPart <FootnotesPart>("rId6");

            DocxBase.GenerateFootnotesPart1Content(footnotesPart1);

            HeaderPart headerPart1 = mainDocumentPart1.AddNewPart <HeaderPart>("rId11");

            DocxBase.GenerateHeaderPart1Content(headerPart1);

            WebSettingsPart webSettingsPart1 = mainDocumentPart1.AddNewPart <WebSettingsPart>("rId5");

            DocxBase.GenerateWebSettingsPart1Content(webSettingsPart1);

            //ChartPart chartPart1 = mainDocumentPart1.AddNewPart<ChartPart>("rId10");
            //DocxBase.GenerateChartPart1Content(chartPart1);

            //EmbeddedPackagePart embeddedPackagePart1 = chartPart1.AddNewPart<EmbeddedPackagePart>("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "rId3");
            //DocxBase.GenerateEmbeddedPackagePart1Content(embeddedPackagePart1);

            //ChartColorStylePart chartColorStylePart1 = chartPart1.AddNewPart<ChartColorStylePart>("rId2");
            //DocxBase.GenerateChartColorStylePart1Content(chartColorStylePart1);

            //ChartStylePart chartStylePart1 = chartPart1.AddNewPart<ChartStylePart>("rId1");
            //DocxBase.GenerateChartStylePart1Content(chartStylePart1);

            DocumentSettingsPart documentSettingsPart1 = mainDocumentPart1.AddNewPart <DocumentSettingsPart>("rId4");

            DocxBase.GenerateDocumentSettingsPart1Content(documentSettingsPart1);

            //ChartPart chartPart2 = mainDocumentPart1.AddNewPart<ChartPart>("rId9");
            //DocxBase.GenerateChartPart2Content(chartPart2);

            //EmbeddedPackagePart embeddedPackagePart2 = chartPart2.AddNewPart<EmbeddedPackagePart>("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "rId3");
            //DocxBase.GenerateEmbeddedPackagePart2Content(embeddedPackagePart2);

            //ChartColorStylePart chartColorStylePart2 = chartPart2.AddNewPart<ChartColorStylePart>("rId2");
            //DocxBase.GenerateChartColorStylePart2Content(chartColorStylePart2);

            //ChartStylePart chartStylePart2 = chartPart2.AddNewPart<ChartStylePart>("rId1");
            //DocxBase.GenerateChartStylePart2Content(chartStylePart2);

            ThemePart themePart1 = mainDocumentPart1.AddNewPart <ThemePart>("rId14");

            DocxBase.GenerateThemePart1Content(themePart1);

            foreach (UsedHyperlink usedHyperlink in DocxBase.UsedHyperlinkList)
            {
                mainDocumentPart1.AddHyperlinkRelationship(new System.Uri(usedHyperlink.URL, System.UriKind.Absolute), true, usedHyperlink.Id.ToString());
            }

            DocxBase.SetPackageProperties(document);
        }
        public static void GenerateThemePart1Content(ThemePart themePart1)
        {
            var theme1 = new DocumentFormat.OpenXml.Drawing.Theme()
            {
                Name = "Office Theme"
            };

            theme1.AddNamespaceDeclaration("a", "http://schemas.openxmlformats.org/drawingml/2006/main");

            var themeElements1 = new DocumentFormat.OpenXml.Drawing.ThemeElements();

            var colorScheme1 = new DocumentFormat.OpenXml.Drawing.ColorScheme {
                Name = "Office"
            };

            var dark1Color1  = new DocumentFormat.OpenXml.Drawing.Dark1Color();
            var systemColor1 = new DocumentFormat.OpenXml.Drawing.SystemColor {
                Val = DocumentFormat.OpenXml.Drawing.SystemColorValues.WindowText, LastColor = "000000"
            };

            dark1Color1.Append(systemColor1);

            var light1Color1 = new DocumentFormat.OpenXml.Drawing.Light1Color();
            var systemColor2 = new DocumentFormat.OpenXml.Drawing.SystemColor {
                Val = DocumentFormat.OpenXml.Drawing.SystemColorValues.Window, LastColor = "FFFFFF"
            };

            light1Color1.Append(systemColor2);

            var dark2Color1       = new DocumentFormat.OpenXml.Drawing.Dark2Color();
            var rgbColorModelHex1 = new DocumentFormat.OpenXml.Drawing.RgbColorModelHex {
                Val = "1F497D"
            };

            dark2Color1.Append(rgbColorModelHex1);

            var light2Color1      = new DocumentFormat.OpenXml.Drawing.Light2Color();
            var rgbColorModelHex2 = new DocumentFormat.OpenXml.Drawing.RgbColorModelHex {
                Val = "EEECE1"
            };

            light2Color1.Append(rgbColorModelHex2);

            var accent1Color1     = new DocumentFormat.OpenXml.Drawing.Accent1Color();
            var rgbColorModelHex3 = new DocumentFormat.OpenXml.Drawing.RgbColorModelHex {
                Val = "4F81BD"
            };

            accent1Color1.Append(rgbColorModelHex3);

            var accent2Color1     = new DocumentFormat.OpenXml.Drawing.Accent2Color();
            var rgbColorModelHex4 = new DocumentFormat.OpenXml.Drawing.RgbColorModelHex {
                Val = "C0504D"
            };

            accent2Color1.Append(rgbColorModelHex4);

            var accent3Color1     = new DocumentFormat.OpenXml.Drawing.Accent3Color();
            var rgbColorModelHex5 = new DocumentFormat.OpenXml.Drawing.RgbColorModelHex {
                Val = "9BBB59"
            };

            accent3Color1.Append(rgbColorModelHex5);

            var accent4Color1     = new DocumentFormat.OpenXml.Drawing.Accent4Color();
            var rgbColorModelHex6 = new DocumentFormat.OpenXml.Drawing.RgbColorModelHex {
                Val = "8064A2"
            };

            accent4Color1.Append(rgbColorModelHex6);

            var accent5Color1     = new DocumentFormat.OpenXml.Drawing.Accent5Color();
            var rgbColorModelHex7 = new DocumentFormat.OpenXml.Drawing.RgbColorModelHex {
                Val = "4BACC6"
            };

            accent5Color1.Append(rgbColorModelHex7);

            var accent6Color1     = new DocumentFormat.OpenXml.Drawing.Accent6Color();
            var rgbColorModelHex8 = new DocumentFormat.OpenXml.Drawing.RgbColorModelHex {
                Val = "F79646"
            };

            accent6Color1.Append(rgbColorModelHex8);

            var hyperlink1        = new DocumentFormat.OpenXml.Drawing.Hyperlink();
            var rgbColorModelHex9 = new DocumentFormat.OpenXml.Drawing.RgbColorModelHex {
                Val = "0000FF"
            };

            hyperlink1.Append(rgbColorModelHex9);

            var followedHyperlinkColor1 = new DocumentFormat.OpenXml.Drawing.FollowedHyperlinkColor();
            var rgbColorModelHex10      = new DocumentFormat.OpenXml.Drawing.RgbColorModelHex {
                Val = "800080"
            };

            followedHyperlinkColor1.Append(rgbColorModelHex10);

            colorScheme1.Append(dark1Color1);
            colorScheme1.Append(light1Color1);
            colorScheme1.Append(dark2Color1);
            colorScheme1.Append(light2Color1);
            colorScheme1.Append(accent1Color1);
            colorScheme1.Append(accent2Color1);
            colorScheme1.Append(accent3Color1);
            colorScheme1.Append(accent4Color1);
            colorScheme1.Append(accent5Color1);
            colorScheme1.Append(accent6Color1);
            colorScheme1.Append(hyperlink1);
            colorScheme1.Append(followedHyperlinkColor1);

            var fontScheme1 = new DocumentFormat.OpenXml.Drawing.FontScheme {
                Name = "Office"
            };

            var majorFont1 = new DocumentFormat.OpenXml.Drawing.MajorFont();
            var latinFont1 = new DocumentFormat.OpenXml.Drawing.LatinFont {
                Typeface = "Cambria"
            };
            var eastAsianFont1 = new DocumentFormat.OpenXml.Drawing.EastAsianFont {
                Typeface = ""
            };
            var complexScriptFont1 = new DocumentFormat.OpenXml.Drawing.ComplexScriptFont {
                Typeface = ""
            };
            var supplementalFont1 = new DocumentFormat.OpenXml.Drawing.SupplementalFont {
                Script = "Jpan", Typeface = "MS ゴシック"
            };
            var supplementalFont2 = new DocumentFormat.OpenXml.Drawing.SupplementalFont()
            {
                Script = "Hang", Typeface = "맑은 고딕"
            };
            var supplementalFont3 = new DocumentFormat.OpenXml.Drawing.SupplementalFont()
            {
                Script = "Hans", Typeface = "宋体"
            };
            var supplementalFont4 = new DocumentFormat.OpenXml.Drawing.SupplementalFont()
            {
                Script = "Hant", Typeface = "新細明體"
            };
            var supplementalFont5 = new DocumentFormat.OpenXml.Drawing.SupplementalFont()
            {
                Script = "Arab", Typeface = "Times New Roman"
            };
            var supplementalFont6 = new DocumentFormat.OpenXml.Drawing.SupplementalFont()
            {
                Script = "Hebr", Typeface = "Times New Roman"
            };
            var supplementalFont7 = new DocumentFormat.OpenXml.Drawing.SupplementalFont()
            {
                Script = "Thai", Typeface = "Angsana New"
            };
            var supplementalFont8 = new DocumentFormat.OpenXml.Drawing.SupplementalFont()
            {
                Script = "Ethi", Typeface = "Nyala"
            };
            var supplementalFont9 = new DocumentFormat.OpenXml.Drawing.SupplementalFont()
            {
                Script = "Beng", Typeface = "Vrinda"
            };
            var supplementalFont10 = new DocumentFormat.OpenXml.Drawing.SupplementalFont()
            {
                Script = "Gujr", Typeface = "Shruti"
            };
            var supplementalFont11 = new DocumentFormat.OpenXml.Drawing.SupplementalFont()
            {
                Script = "Khmr", Typeface = "MoolBoran"
            };
            var supplementalFont12 = new DocumentFormat.OpenXml.Drawing.SupplementalFont()
            {
                Script = "Knda", Typeface = "Tunga"
            };
            var supplementalFont13 = new DocumentFormat.OpenXml.Drawing.SupplementalFont()
            {
                Script = "Guru", Typeface = "Raavi"
            };
            var supplementalFont14 = new DocumentFormat.OpenXml.Drawing.SupplementalFont()
            {
                Script = "Cans", Typeface = "Euphemia"
            };
            var supplementalFont15 = new DocumentFormat.OpenXml.Drawing.SupplementalFont()
            {
                Script = "Cher", Typeface = "Plantagenet Cherokee"
            };
            var supplementalFont16 = new DocumentFormat.OpenXml.Drawing.SupplementalFont()
            {
                Script = "Yiii", Typeface = "Microsoft Yi Baiti"
            };
            var supplementalFont17 = new DocumentFormat.OpenXml.Drawing.SupplementalFont()
            {
                Script = "Tibt", Typeface = "Microsoft Himalaya"
            };
            var supplementalFont18 = new DocumentFormat.OpenXml.Drawing.SupplementalFont()
            {
                Script = "Thaa", Typeface = "MV Boli"
            };
            var supplementalFont19 = new DocumentFormat.OpenXml.Drawing.SupplementalFont()
            {
                Script = "Deva", Typeface = "Mangal"
            };
            var supplementalFont20 = new DocumentFormat.OpenXml.Drawing.SupplementalFont()
            {
                Script = "Telu", Typeface = "Gautami"
            };
            var supplementalFont21 = new DocumentFormat.OpenXml.Drawing.SupplementalFont()
            {
                Script = "Taml", Typeface = "Latha"
            };
            var supplementalFont22 = new DocumentFormat.OpenXml.Drawing.SupplementalFont()
            {
                Script = "Syrc", Typeface = "Estrangelo Edessa"
            };
            var supplementalFont23 = new DocumentFormat.OpenXml.Drawing.SupplementalFont()
            {
                Script = "Orya", Typeface = "Kalinga"
            };
            var supplementalFont24 = new DocumentFormat.OpenXml.Drawing.SupplementalFont()
            {
                Script = "Mlym", Typeface = "Kartika"
            };
            var supplementalFont25 = new DocumentFormat.OpenXml.Drawing.SupplementalFont()
            {
                Script = "Laoo", Typeface = "DokChampa"
            };
            var supplementalFont26 = new DocumentFormat.OpenXml.Drawing.SupplementalFont()
            {
                Script = "Sinh", Typeface = "Iskoola Pota"
            };
            var supplementalFont27 = new DocumentFormat.OpenXml.Drawing.SupplementalFont()
            {
                Script = "Mong", Typeface = "Mongolian Baiti"
            };
            var supplementalFont28 = new DocumentFormat.OpenXml.Drawing.SupplementalFont()
            {
                Script = "Viet", Typeface = "Times New Roman"
            };
            var supplementalFont29 = new DocumentFormat.OpenXml.Drawing.SupplementalFont()
            {
                Script = "Uigh", Typeface = "Microsoft Uighur"
            };

            majorFont1.Append(latinFont1);
            majorFont1.Append(eastAsianFont1);
            majorFont1.Append(complexScriptFont1);
            majorFont1.Append(supplementalFont1);
            majorFont1.Append(supplementalFont2);
            majorFont1.Append(supplementalFont3);
            majorFont1.Append(supplementalFont4);
            majorFont1.Append(supplementalFont5);
            majorFont1.Append(supplementalFont6);
            majorFont1.Append(supplementalFont7);
            majorFont1.Append(supplementalFont8);
            majorFont1.Append(supplementalFont9);
            majorFont1.Append(supplementalFont10);
            majorFont1.Append(supplementalFont11);
            majorFont1.Append(supplementalFont12);
            majorFont1.Append(supplementalFont13);
            majorFont1.Append(supplementalFont14);
            majorFont1.Append(supplementalFont15);
            majorFont1.Append(supplementalFont16);
            majorFont1.Append(supplementalFont17);
            majorFont1.Append(supplementalFont18);
            majorFont1.Append(supplementalFont19);
            majorFont1.Append(supplementalFont20);
            majorFont1.Append(supplementalFont21);
            majorFont1.Append(supplementalFont22);
            majorFont1.Append(supplementalFont23);
            majorFont1.Append(supplementalFont24);
            majorFont1.Append(supplementalFont25);
            majorFont1.Append(supplementalFont26);
            majorFont1.Append(supplementalFont27);
            majorFont1.Append(supplementalFont28);
            majorFont1.Append(supplementalFont29);

            DocumentFormat.OpenXml.Drawing.MinorFont minorFont1 = new DocumentFormat.OpenXml.Drawing.MinorFont();
            DocumentFormat.OpenXml.Drawing.LatinFont latinFont2 = new DocumentFormat.OpenXml.Drawing.LatinFont()
            {
                Typeface = "Calibri"
            };
            DocumentFormat.OpenXml.Drawing.EastAsianFont eastAsianFont2 = new DocumentFormat.OpenXml.Drawing.EastAsianFont()
            {
                Typeface = ""
            };
            DocumentFormat.OpenXml.Drawing.ComplexScriptFont complexScriptFont2 = new DocumentFormat.OpenXml.Drawing.ComplexScriptFont()
            {
                Typeface = ""
            };
            DocumentFormat.OpenXml.Drawing.SupplementalFont supplementalFont30 = new DocumentFormat.OpenXml.Drawing.SupplementalFont()
            {
                Script = "Jpan", Typeface = "MS 明朝"
            };
            DocumentFormat.OpenXml.Drawing.SupplementalFont supplementalFont31 = new DocumentFormat.OpenXml.Drawing.SupplementalFont()
            {
                Script = "Hang", Typeface = "맑은 고딕"
            };
            DocumentFormat.OpenXml.Drawing.SupplementalFont supplementalFont32 = new DocumentFormat.OpenXml.Drawing.SupplementalFont()
            {
                Script = "Hans", Typeface = "宋体"
            };
            DocumentFormat.OpenXml.Drawing.SupplementalFont supplementalFont33 = new DocumentFormat.OpenXml.Drawing.SupplementalFont()
            {
                Script = "Hant", Typeface = "新細明體"
            };
            DocumentFormat.OpenXml.Drawing.SupplementalFont supplementalFont34 = new DocumentFormat.OpenXml.Drawing.SupplementalFont()
            {
                Script = "Arab", Typeface = "Arial"
            };
            DocumentFormat.OpenXml.Drawing.SupplementalFont supplementalFont35 = new DocumentFormat.OpenXml.Drawing.SupplementalFont()
            {
                Script = "Hebr", Typeface = "Arial"
            };
            DocumentFormat.OpenXml.Drawing.SupplementalFont supplementalFont36 = new DocumentFormat.OpenXml.Drawing.SupplementalFont()
            {
                Script = "Thai", Typeface = "Cordia New"
            };
            DocumentFormat.OpenXml.Drawing.SupplementalFont supplementalFont37 = new DocumentFormat.OpenXml.Drawing.SupplementalFont()
            {
                Script = "Ethi", Typeface = "Nyala"
            };
            DocumentFormat.OpenXml.Drawing.SupplementalFont supplementalFont38 = new DocumentFormat.OpenXml.Drawing.SupplementalFont()
            {
                Script = "Beng", Typeface = "Vrinda"
            };
            DocumentFormat.OpenXml.Drawing.SupplementalFont supplementalFont39 = new DocumentFormat.OpenXml.Drawing.SupplementalFont()
            {
                Script = "Gujr", Typeface = "Shruti"
            };
            DocumentFormat.OpenXml.Drawing.SupplementalFont supplementalFont40 = new DocumentFormat.OpenXml.Drawing.SupplementalFont()
            {
                Script = "Khmr", Typeface = "DaunPenh"
            };
            DocumentFormat.OpenXml.Drawing.SupplementalFont supplementalFont41 = new DocumentFormat.OpenXml.Drawing.SupplementalFont()
            {
                Script = "Knda", Typeface = "Tunga"
            };
            DocumentFormat.OpenXml.Drawing.SupplementalFont supplementalFont42 = new DocumentFormat.OpenXml.Drawing.SupplementalFont()
            {
                Script = "Guru", Typeface = "Raavi"
            };
            DocumentFormat.OpenXml.Drawing.SupplementalFont supplementalFont43 = new DocumentFormat.OpenXml.Drawing.SupplementalFont()
            {
                Script = "Cans", Typeface = "Euphemia"
            };
            DocumentFormat.OpenXml.Drawing.SupplementalFont supplementalFont44 = new DocumentFormat.OpenXml.Drawing.SupplementalFont()
            {
                Script = "Cher", Typeface = "Plantagenet Cherokee"
            };
            DocumentFormat.OpenXml.Drawing.SupplementalFont supplementalFont45 = new DocumentFormat.OpenXml.Drawing.SupplementalFont()
            {
                Script = "Yiii", Typeface = "Microsoft Yi Baiti"
            };
            DocumentFormat.OpenXml.Drawing.SupplementalFont supplementalFont46 = new DocumentFormat.OpenXml.Drawing.SupplementalFont()
            {
                Script = "Tibt", Typeface = "Microsoft Himalaya"
            };
            DocumentFormat.OpenXml.Drawing.SupplementalFont supplementalFont47 = new DocumentFormat.OpenXml.Drawing.SupplementalFont()
            {
                Script = "Thaa", Typeface = "MV Boli"
            };
            DocumentFormat.OpenXml.Drawing.SupplementalFont supplementalFont48 = new DocumentFormat.OpenXml.Drawing.SupplementalFont()
            {
                Script = "Deva", Typeface = "Mangal"
            };
            DocumentFormat.OpenXml.Drawing.SupplementalFont supplementalFont49 = new DocumentFormat.OpenXml.Drawing.SupplementalFont()
            {
                Script = "Telu", Typeface = "Gautami"
            };
            DocumentFormat.OpenXml.Drawing.SupplementalFont supplementalFont50 = new DocumentFormat.OpenXml.Drawing.SupplementalFont()
            {
                Script = "Taml", Typeface = "Latha"
            };
            DocumentFormat.OpenXml.Drawing.SupplementalFont supplementalFont51 = new DocumentFormat.OpenXml.Drawing.SupplementalFont()
            {
                Script = "Syrc", Typeface = "Estrangelo Edessa"
            };
            DocumentFormat.OpenXml.Drawing.SupplementalFont supplementalFont52 = new DocumentFormat.OpenXml.Drawing.SupplementalFont()
            {
                Script = "Orya", Typeface = "Kalinga"
            };
            DocumentFormat.OpenXml.Drawing.SupplementalFont supplementalFont53 = new DocumentFormat.OpenXml.Drawing.SupplementalFont()
            {
                Script = "Mlym", Typeface = "Kartika"
            };
            DocumentFormat.OpenXml.Drawing.SupplementalFont supplementalFont54 = new DocumentFormat.OpenXml.Drawing.SupplementalFont()
            {
                Script = "Laoo", Typeface = "DokChampa"
            };
            DocumentFormat.OpenXml.Drawing.SupplementalFont supplementalFont55 = new DocumentFormat.OpenXml.Drawing.SupplementalFont()
            {
                Script = "Sinh", Typeface = "Iskoola Pota"
            };
            DocumentFormat.OpenXml.Drawing.SupplementalFont supplementalFont56 = new DocumentFormat.OpenXml.Drawing.SupplementalFont()
            {
                Script = "Mong", Typeface = "Mongolian Baiti"
            };
            DocumentFormat.OpenXml.Drawing.SupplementalFont supplementalFont57 = new DocumentFormat.OpenXml.Drawing.SupplementalFont()
            {
                Script = "Viet", Typeface = "Arial"
            };
            DocumentFormat.OpenXml.Drawing.SupplementalFont supplementalFont58 = new DocumentFormat.OpenXml.Drawing.SupplementalFont()
            {
                Script = "Uigh", Typeface = "Microsoft Uighur"
            };

            minorFont1.Append(latinFont2);
            minorFont1.Append(eastAsianFont2);
            minorFont1.Append(complexScriptFont2);
            minorFont1.Append(supplementalFont30);
            minorFont1.Append(supplementalFont31);
            minorFont1.Append(supplementalFont32);
            minorFont1.Append(supplementalFont33);
            minorFont1.Append(supplementalFont34);
            minorFont1.Append(supplementalFont35);
            minorFont1.Append(supplementalFont36);
            minorFont1.Append(supplementalFont37);
            minorFont1.Append(supplementalFont38);
            minorFont1.Append(supplementalFont39);
            minorFont1.Append(supplementalFont40);
            minorFont1.Append(supplementalFont41);
            minorFont1.Append(supplementalFont42);
            minorFont1.Append(supplementalFont43);
            minorFont1.Append(supplementalFont44);
            minorFont1.Append(supplementalFont45);
            minorFont1.Append(supplementalFont46);
            minorFont1.Append(supplementalFont47);
            minorFont1.Append(supplementalFont48);
            minorFont1.Append(supplementalFont49);
            minorFont1.Append(supplementalFont50);
            minorFont1.Append(supplementalFont51);
            minorFont1.Append(supplementalFont52);
            minorFont1.Append(supplementalFont53);
            minorFont1.Append(supplementalFont54);
            minorFont1.Append(supplementalFont55);
            minorFont1.Append(supplementalFont56);
            minorFont1.Append(supplementalFont57);
            minorFont1.Append(supplementalFont58);

            fontScheme1.Append(majorFont1);
            fontScheme1.Append(minorFont1);

            DocumentFormat.OpenXml.Drawing.FormatScheme formatScheme1 = new DocumentFormat.OpenXml.Drawing.FormatScheme()
            {
                Name = "Office"
            };

            DocumentFormat.OpenXml.Drawing.FillStyleList fillStyleList1 = new DocumentFormat.OpenXml.Drawing.FillStyleList();

            DocumentFormat.OpenXml.Drawing.SolidFill   solidFill1   = new DocumentFormat.OpenXml.Drawing.SolidFill();
            DocumentFormat.OpenXml.Drawing.SchemeColor schemeColor1 = new DocumentFormat.OpenXml.Drawing.SchemeColor()
            {
                Val = DocumentFormat.OpenXml.Drawing.SchemeColorValues.PhColor
            };

            solidFill1.Append(schemeColor1);

            DocumentFormat.OpenXml.Drawing.GradientFill gradientFill1 = new DocumentFormat.OpenXml.Drawing.GradientFill()
            {
                RotateWithShape = true
            };

            DocumentFormat.OpenXml.Drawing.GradientStopList gradientStopList1 = new DocumentFormat.OpenXml.Drawing.GradientStopList();

            DocumentFormat.OpenXml.Drawing.GradientStop gradientStop1 = new DocumentFormat.OpenXml.Drawing.GradientStop()
            {
                Position = 0
            };

            DocumentFormat.OpenXml.Drawing.SchemeColor schemeColor2 = new DocumentFormat.OpenXml.Drawing.SchemeColor()
            {
                Val = DocumentFormat.OpenXml.Drawing.SchemeColorValues.PhColor
            };
            DocumentFormat.OpenXml.Drawing.Tint tint1 = new DocumentFormat.OpenXml.Drawing.Tint()
            {
                Val = 50000
            };
            DocumentFormat.OpenXml.Drawing.SaturationModulation saturationModulation1 = new DocumentFormat.OpenXml.Drawing.SaturationModulation()
            {
                Val = 300000
            };

            schemeColor2.Append(tint1);
            schemeColor2.Append(saturationModulation1);

            gradientStop1.Append(schemeColor2);

            DocumentFormat.OpenXml.Drawing.GradientStop gradientStop2 = new DocumentFormat.OpenXml.Drawing.GradientStop()
            {
                Position = 35000
            };

            DocumentFormat.OpenXml.Drawing.SchemeColor schemeColor3 = new DocumentFormat.OpenXml.Drawing.SchemeColor()
            {
                Val = DocumentFormat.OpenXml.Drawing.SchemeColorValues.PhColor
            };
            DocumentFormat.OpenXml.Drawing.Tint tint2 = new DocumentFormat.OpenXml.Drawing.Tint()
            {
                Val = 37000
            };
            DocumentFormat.OpenXml.Drawing.SaturationModulation saturationModulation2 = new DocumentFormat.OpenXml.Drawing.SaturationModulation()
            {
                Val = 300000
            };

            schemeColor3.Append(tint2);
            schemeColor3.Append(saturationModulation2);

            gradientStop2.Append(schemeColor3);

            DocumentFormat.OpenXml.Drawing.GradientStop gradientStop3 = new DocumentFormat.OpenXml.Drawing.GradientStop()
            {
                Position = 100000
            };

            DocumentFormat.OpenXml.Drawing.SchemeColor schemeColor4 = new DocumentFormat.OpenXml.Drawing.SchemeColor()
            {
                Val = DocumentFormat.OpenXml.Drawing.SchemeColorValues.PhColor
            };
            DocumentFormat.OpenXml.Drawing.Tint tint3 = new DocumentFormat.OpenXml.Drawing.Tint()
            {
                Val = 15000
            };
            DocumentFormat.OpenXml.Drawing.SaturationModulation saturationModulation3 = new DocumentFormat.OpenXml.Drawing.SaturationModulation()
            {
                Val = 350000
            };

            schemeColor4.Append(tint3);
            schemeColor4.Append(saturationModulation3);

            gradientStop3.Append(schemeColor4);

            gradientStopList1.Append(gradientStop1);
            gradientStopList1.Append(gradientStop2);
            gradientStopList1.Append(gradientStop3);
            DocumentFormat.OpenXml.Drawing.LinearGradientFill linearGradientFill1 = new DocumentFormat.OpenXml.Drawing.LinearGradientFill()
            {
                Angle = 16200000, Scaled = true
            };

            gradientFill1.Append(gradientStopList1);
            gradientFill1.Append(linearGradientFill1);

            DocumentFormat.OpenXml.Drawing.GradientFill gradientFill2 = new DocumentFormat.OpenXml.Drawing.GradientFill()
            {
                RotateWithShape = true
            };

            DocumentFormat.OpenXml.Drawing.GradientStopList gradientStopList2 = new DocumentFormat.OpenXml.Drawing.GradientStopList();

            DocumentFormat.OpenXml.Drawing.GradientStop gradientStop4 = new DocumentFormat.OpenXml.Drawing.GradientStop()
            {
                Position = 0
            };

            DocumentFormat.OpenXml.Drawing.SchemeColor schemeColor5 = new DocumentFormat.OpenXml.Drawing.SchemeColor()
            {
                Val = DocumentFormat.OpenXml.Drawing.SchemeColorValues.PhColor
            };
            DocumentFormat.OpenXml.Drawing.Shade shade1 = new DocumentFormat.OpenXml.Drawing.Shade()
            {
                Val = 51000
            };
            DocumentFormat.OpenXml.Drawing.SaturationModulation saturationModulation4 = new DocumentFormat.OpenXml.Drawing.SaturationModulation()
            {
                Val = 130000
            };

            schemeColor5.Append(shade1);
            schemeColor5.Append(saturationModulation4);

            gradientStop4.Append(schemeColor5);

            DocumentFormat.OpenXml.Drawing.GradientStop gradientStop5 = new DocumentFormat.OpenXml.Drawing.GradientStop()
            {
                Position = 80000
            };

            DocumentFormat.OpenXml.Drawing.SchemeColor schemeColor6 = new DocumentFormat.OpenXml.Drawing.SchemeColor()
            {
                Val = DocumentFormat.OpenXml.Drawing.SchemeColorValues.PhColor
            };
            DocumentFormat.OpenXml.Drawing.Shade shade2 = new DocumentFormat.OpenXml.Drawing.Shade()
            {
                Val = 93000
            };
            DocumentFormat.OpenXml.Drawing.SaturationModulation saturationModulation5 = new DocumentFormat.OpenXml.Drawing.SaturationModulation()
            {
                Val = 130000
            };

            schemeColor6.Append(shade2);
            schemeColor6.Append(saturationModulation5);

            gradientStop5.Append(schemeColor6);

            DocumentFormat.OpenXml.Drawing.GradientStop gradientStop6 = new DocumentFormat.OpenXml.Drawing.GradientStop()
            {
                Position = 100000
            };

            DocumentFormat.OpenXml.Drawing.SchemeColor schemeColor7 = new DocumentFormat.OpenXml.Drawing.SchemeColor()
            {
                Val = DocumentFormat.OpenXml.Drawing.SchemeColorValues.PhColor
            };
            DocumentFormat.OpenXml.Drawing.Shade shade3 = new DocumentFormat.OpenXml.Drawing.Shade()
            {
                Val = 94000
            };
            DocumentFormat.OpenXml.Drawing.SaturationModulation saturationModulation6 = new DocumentFormat.OpenXml.Drawing.SaturationModulation()
            {
                Val = 135000
            };

            schemeColor7.Append(shade3);
            schemeColor7.Append(saturationModulation6);

            gradientStop6.Append(schemeColor7);

            gradientStopList2.Append(gradientStop4);
            gradientStopList2.Append(gradientStop5);
            gradientStopList2.Append(gradientStop6);
            DocumentFormat.OpenXml.Drawing.LinearGradientFill linearGradientFill2 = new DocumentFormat.OpenXml.Drawing.LinearGradientFill()
            {
                Angle = 16200000, Scaled = false
            };

            gradientFill2.Append(gradientStopList2);
            gradientFill2.Append(linearGradientFill2);

            fillStyleList1.Append(solidFill1);
            fillStyleList1.Append(gradientFill1);
            fillStyleList1.Append(gradientFill2);

            DocumentFormat.OpenXml.Drawing.LineStyleList lineStyleList1 = new DocumentFormat.OpenXml.Drawing.LineStyleList();

            DocumentFormat.OpenXml.Drawing.Outline outline28 = new DocumentFormat.OpenXml.Drawing.Outline()
            {
                Width = 9525, CapType = DocumentFormat.OpenXml.Drawing.LineCapValues.Flat, CompoundLineType = DocumentFormat.OpenXml.Drawing.CompoundLineValues.Single, Alignment = DocumentFormat.OpenXml.Drawing.PenAlignmentValues.Center
            };

            DocumentFormat.OpenXml.Drawing.SolidFill solidFill2 = new DocumentFormat.OpenXml.Drawing.SolidFill();

            DocumentFormat.OpenXml.Drawing.SchemeColor schemeColor8 = new DocumentFormat.OpenXml.Drawing.SchemeColor()
            {
                Val = DocumentFormat.OpenXml.Drawing.SchemeColorValues.PhColor
            };
            DocumentFormat.OpenXml.Drawing.Shade shade4 = new DocumentFormat.OpenXml.Drawing.Shade()
            {
                Val = 95000
            };
            DocumentFormat.OpenXml.Drawing.SaturationModulation saturationModulation7 = new DocumentFormat.OpenXml.Drawing.SaturationModulation()
            {
                Val = 105000
            };

            schemeColor8.Append(shade4);
            schemeColor8.Append(saturationModulation7);

            solidFill2.Append(schemeColor8);
            DocumentFormat.OpenXml.Drawing.PresetDash presetDash1 = new DocumentFormat.OpenXml.Drawing.PresetDash()
            {
                Val = DocumentFormat.OpenXml.Drawing.PresetLineDashValues.Solid
            };

            outline28.Append(solidFill2);
            outline28.Append(presetDash1);

            DocumentFormat.OpenXml.Drawing.Outline outline29 = new DocumentFormat.OpenXml.Drawing.Outline()
            {
                Width = 25400, CapType = DocumentFormat.OpenXml.Drawing.LineCapValues.Flat, CompoundLineType = DocumentFormat.OpenXml.Drawing.CompoundLineValues.Single, Alignment = DocumentFormat.OpenXml.Drawing.PenAlignmentValues.Center
            };

            DocumentFormat.OpenXml.Drawing.SolidFill   solidFill3   = new DocumentFormat.OpenXml.Drawing.SolidFill();
            DocumentFormat.OpenXml.Drawing.SchemeColor schemeColor9 = new DocumentFormat.OpenXml.Drawing.SchemeColor()
            {
                Val = DocumentFormat.OpenXml.Drawing.SchemeColorValues.PhColor
            };

            solidFill3.Append(schemeColor9);
            DocumentFormat.OpenXml.Drawing.PresetDash presetDash2 = new DocumentFormat.OpenXml.Drawing.PresetDash()
            {
                Val = DocumentFormat.OpenXml.Drawing.PresetLineDashValues.Solid
            };

            outline29.Append(solidFill3);
            outline29.Append(presetDash2);

            DocumentFormat.OpenXml.Drawing.Outline outline30 = new DocumentFormat.OpenXml.Drawing.Outline()
            {
                Width = 38100, CapType = DocumentFormat.OpenXml.Drawing.LineCapValues.Flat, CompoundLineType = DocumentFormat.OpenXml.Drawing.CompoundLineValues.Single, Alignment = DocumentFormat.OpenXml.Drawing.PenAlignmentValues.Center
            };

            DocumentFormat.OpenXml.Drawing.SolidFill   solidFill4    = new DocumentFormat.OpenXml.Drawing.SolidFill();
            DocumentFormat.OpenXml.Drawing.SchemeColor schemeColor10 = new DocumentFormat.OpenXml.Drawing.SchemeColor()
            {
                Val = DocumentFormat.OpenXml.Drawing.SchemeColorValues.PhColor
            };

            solidFill4.Append(schemeColor10);
            DocumentFormat.OpenXml.Drawing.PresetDash presetDash3 = new DocumentFormat.OpenXml.Drawing.PresetDash()
            {
                Val = DocumentFormat.OpenXml.Drawing.PresetLineDashValues.Solid
            };

            outline30.Append(solidFill4);
            outline30.Append(presetDash3);

            lineStyleList1.Append(outline28);
            lineStyleList1.Append(outline29);
            lineStyleList1.Append(outline30);

            DocumentFormat.OpenXml.Drawing.EffectStyleList effectStyleList1 = new DocumentFormat.OpenXml.Drawing.EffectStyleList();

            DocumentFormat.OpenXml.Drawing.EffectStyle effectStyle1 = new DocumentFormat.OpenXml.Drawing.EffectStyle();

            DocumentFormat.OpenXml.Drawing.EffectList effectList1 = new DocumentFormat.OpenXml.Drawing.EffectList();

            DocumentFormat.OpenXml.Drawing.OuterShadow outerShadow1 = new DocumentFormat.OpenXml.Drawing.OuterShadow()
            {
                BlurRadius = 40000L, Distance = 20000L, Direction = 5400000, RotateWithShape = false
            };

            DocumentFormat.OpenXml.Drawing.RgbColorModelHex rgbColorModelHex11 = new DocumentFormat.OpenXml.Drawing.RgbColorModelHex()
            {
                Val = "000000"
            };
            DocumentFormat.OpenXml.Drawing.Alpha alpha1 = new DocumentFormat.OpenXml.Drawing.Alpha()
            {
                Val = 38000
            };

            rgbColorModelHex11.Append(alpha1);

            outerShadow1.Append(rgbColorModelHex11);

            effectList1.Append(outerShadow1);

            effectStyle1.Append(effectList1);

            DocumentFormat.OpenXml.Drawing.EffectStyle effectStyle2 = new DocumentFormat.OpenXml.Drawing.EffectStyle();

            DocumentFormat.OpenXml.Drawing.EffectList effectList2 = new DocumentFormat.OpenXml.Drawing.EffectList();

            DocumentFormat.OpenXml.Drawing.OuterShadow outerShadow2 = new DocumentFormat.OpenXml.Drawing.OuterShadow()
            {
                BlurRadius = 40000L, Distance = 23000L, Direction = 5400000, RotateWithShape = false
            };

            DocumentFormat.OpenXml.Drawing.RgbColorModelHex rgbColorModelHex12 = new DocumentFormat.OpenXml.Drawing.RgbColorModelHex()
            {
                Val = "000000"
            };
            DocumentFormat.OpenXml.Drawing.Alpha alpha2 = new DocumentFormat.OpenXml.Drawing.Alpha()
            {
                Val = 35000
            };

            rgbColorModelHex12.Append(alpha2);

            outerShadow2.Append(rgbColorModelHex12);

            effectList2.Append(outerShadow2);

            effectStyle2.Append(effectList2);

            DocumentFormat.OpenXml.Drawing.EffectStyle effectStyle3 = new DocumentFormat.OpenXml.Drawing.EffectStyle();

            DocumentFormat.OpenXml.Drawing.EffectList effectList3 = new DocumentFormat.OpenXml.Drawing.EffectList();

            DocumentFormat.OpenXml.Drawing.OuterShadow outerShadow3 = new DocumentFormat.OpenXml.Drawing.OuterShadow()
            {
                BlurRadius = 40000L, Distance = 23000L, Direction = 5400000, RotateWithShape = false
            };

            DocumentFormat.OpenXml.Drawing.RgbColorModelHex rgbColorModelHex13 = new DocumentFormat.OpenXml.Drawing.RgbColorModelHex()
            {
                Val = "000000"
            };
            DocumentFormat.OpenXml.Drawing.Alpha alpha3 = new DocumentFormat.OpenXml.Drawing.Alpha()
            {
                Val = 35000
            };

            rgbColorModelHex13.Append(alpha3);

            outerShadow3.Append(rgbColorModelHex13);

            effectList3.Append(outerShadow3);

            DocumentFormat.OpenXml.Drawing.Scene3DType scene3DType1 = new DocumentFormat.OpenXml.Drawing.Scene3DType();

            DocumentFormat.OpenXml.Drawing.Camera camera1 = new DocumentFormat.OpenXml.Drawing.Camera()
            {
                Preset = DocumentFormat.OpenXml.Drawing.PresetCameraValues.OrthographicFront
            };
            DocumentFormat.OpenXml.Drawing.Rotation rotation1 = new DocumentFormat.OpenXml.Drawing.Rotation()
            {
                Latitude = 0, Longitude = 0, Revolution = 0
            };

            camera1.Append(rotation1);

            DocumentFormat.OpenXml.Drawing.LightRig lightRig1 = new DocumentFormat.OpenXml.Drawing.LightRig()
            {
                Rig = DocumentFormat.OpenXml.Drawing.LightRigValues.ThreePoints, Direction = DocumentFormat.OpenXml.Drawing.LightRigDirectionValues.Top
            };
            DocumentFormat.OpenXml.Drawing.Rotation rotation2 = new DocumentFormat.OpenXml.Drawing.Rotation()
            {
                Latitude = 0, Longitude = 0, Revolution = 1200000
            };

            lightRig1.Append(rotation2);

            scene3DType1.Append(camera1);
            scene3DType1.Append(lightRig1);

            DocumentFormat.OpenXml.Drawing.Shape3DType shape3DType1 = new DocumentFormat.OpenXml.Drawing.Shape3DType();
            DocumentFormat.OpenXml.Drawing.BevelTop    bevelTop1    = new DocumentFormat.OpenXml.Drawing.BevelTop()
            {
                Width = 63500L, Height = 25400L
            };

            shape3DType1.Append(bevelTop1);

            effectStyle3.Append(effectList3);
            effectStyle3.Append(scene3DType1);
            effectStyle3.Append(shape3DType1);

            effectStyleList1.Append(effectStyle1);
            effectStyleList1.Append(effectStyle2);
            effectStyleList1.Append(effectStyle3);

            DocumentFormat.OpenXml.Drawing.BackgroundFillStyleList backgroundFillStyleList1 = new DocumentFormat.OpenXml.Drawing.BackgroundFillStyleList();

            DocumentFormat.OpenXml.Drawing.SolidFill   solidFill5    = new DocumentFormat.OpenXml.Drawing.SolidFill();
            DocumentFormat.OpenXml.Drawing.SchemeColor schemeColor11 = new DocumentFormat.OpenXml.Drawing.SchemeColor()
            {
                Val = DocumentFormat.OpenXml.Drawing.SchemeColorValues.PhColor
            };

            solidFill5.Append(schemeColor11);

            DocumentFormat.OpenXml.Drawing.GradientFill gradientFill3 = new DocumentFormat.OpenXml.Drawing.GradientFill()
            {
                RotateWithShape = true
            };

            DocumentFormat.OpenXml.Drawing.GradientStopList gradientStopList3 = new DocumentFormat.OpenXml.Drawing.GradientStopList();

            DocumentFormat.OpenXml.Drawing.GradientStop gradientStop7 = new DocumentFormat.OpenXml.Drawing.GradientStop()
            {
                Position = 0
            };

            DocumentFormat.OpenXml.Drawing.SchemeColor schemeColor12 = new DocumentFormat.OpenXml.Drawing.SchemeColor()
            {
                Val = DocumentFormat.OpenXml.Drawing.SchemeColorValues.PhColor
            };
            DocumentFormat.OpenXml.Drawing.Tint tint4 = new DocumentFormat.OpenXml.Drawing.Tint()
            {
                Val = 40000
            };
            DocumentFormat.OpenXml.Drawing.SaturationModulation saturationModulation8 = new DocumentFormat.OpenXml.Drawing.SaturationModulation()
            {
                Val = 350000
            };

            schemeColor12.Append(tint4);
            schemeColor12.Append(saturationModulation8);

            gradientStop7.Append(schemeColor12);

            DocumentFormat.OpenXml.Drawing.GradientStop gradientStop8 = new DocumentFormat.OpenXml.Drawing.GradientStop()
            {
                Position = 40000
            };

            DocumentFormat.OpenXml.Drawing.SchemeColor schemeColor13 = new DocumentFormat.OpenXml.Drawing.SchemeColor()
            {
                Val = DocumentFormat.OpenXml.Drawing.SchemeColorValues.PhColor
            };
            DocumentFormat.OpenXml.Drawing.Tint tint5 = new DocumentFormat.OpenXml.Drawing.Tint()
            {
                Val = 45000
            };
            DocumentFormat.OpenXml.Drawing.Shade shade5 = new DocumentFormat.OpenXml.Drawing.Shade()
            {
                Val = 99000
            };
            DocumentFormat.OpenXml.Drawing.SaturationModulation saturationModulation9 = new DocumentFormat.OpenXml.Drawing.SaturationModulation()
            {
                Val = 350000
            };

            schemeColor13.Append(tint5);
            schemeColor13.Append(shade5);
            schemeColor13.Append(saturationModulation9);

            gradientStop8.Append(schemeColor13);

            DocumentFormat.OpenXml.Drawing.GradientStop gradientStop9 = new DocumentFormat.OpenXml.Drawing.GradientStop()
            {
                Position = 100000
            };

            DocumentFormat.OpenXml.Drawing.SchemeColor schemeColor14 = new DocumentFormat.OpenXml.Drawing.SchemeColor()
            {
                Val = DocumentFormat.OpenXml.Drawing.SchemeColorValues.PhColor
            };
            DocumentFormat.OpenXml.Drawing.Shade shade6 = new DocumentFormat.OpenXml.Drawing.Shade()
            {
                Val = 20000
            };
            DocumentFormat.OpenXml.Drawing.SaturationModulation saturationModulation10 = new DocumentFormat.OpenXml.Drawing.SaturationModulation()
            {
                Val = 255000
            };

            schemeColor14.Append(shade6);
            schemeColor14.Append(saturationModulation10);

            gradientStop9.Append(schemeColor14);

            gradientStopList3.Append(gradientStop7);
            gradientStopList3.Append(gradientStop8);
            gradientStopList3.Append(gradientStop9);

            DocumentFormat.OpenXml.Drawing.PathGradientFill pathGradientFill1 = new DocumentFormat.OpenXml.Drawing.PathGradientFill()
            {
                Path = DocumentFormat.OpenXml.Drawing.PathShadeValues.Circle
            };
            DocumentFormat.OpenXml.Drawing.FillToRectangle fillToRectangle1 = new DocumentFormat.OpenXml.Drawing.FillToRectangle()
            {
                Left = 50000, Top = -80000, Right = 50000, Bottom = 180000
            };

            pathGradientFill1.Append(fillToRectangle1);

            gradientFill3.Append(gradientStopList3);
            gradientFill3.Append(pathGradientFill1);

            DocumentFormat.OpenXml.Drawing.GradientFill gradientFill4 = new DocumentFormat.OpenXml.Drawing.GradientFill()
            {
                RotateWithShape = true
            };

            DocumentFormat.OpenXml.Drawing.GradientStopList gradientStopList4 = new DocumentFormat.OpenXml.Drawing.GradientStopList();

            DocumentFormat.OpenXml.Drawing.GradientStop gradientStop10 = new DocumentFormat.OpenXml.Drawing.GradientStop()
            {
                Position = 0
            };

            DocumentFormat.OpenXml.Drawing.SchemeColor schemeColor15 = new DocumentFormat.OpenXml.Drawing.SchemeColor()
            {
                Val = DocumentFormat.OpenXml.Drawing.SchemeColorValues.PhColor
            };
            DocumentFormat.OpenXml.Drawing.Tint tint6 = new DocumentFormat.OpenXml.Drawing.Tint()
            {
                Val = 80000
            };
            DocumentFormat.OpenXml.Drawing.SaturationModulation saturationModulation11 = new DocumentFormat.OpenXml.Drawing.SaturationModulation()
            {
                Val = 300000
            };

            schemeColor15.Append(tint6);
            schemeColor15.Append(saturationModulation11);

            gradientStop10.Append(schemeColor15);

            DocumentFormat.OpenXml.Drawing.GradientStop gradientStop11 = new DocumentFormat.OpenXml.Drawing.GradientStop()
            {
                Position = 100000
            };

            DocumentFormat.OpenXml.Drawing.SchemeColor schemeColor16 = new DocumentFormat.OpenXml.Drawing.SchemeColor()
            {
                Val = DocumentFormat.OpenXml.Drawing.SchemeColorValues.PhColor
            };
            DocumentFormat.OpenXml.Drawing.Shade shade7 = new DocumentFormat.OpenXml.Drawing.Shade()
            {
                Val = 30000
            };
            DocumentFormat.OpenXml.Drawing.SaturationModulation saturationModulation12 = new DocumentFormat.OpenXml.Drawing.SaturationModulation()
            {
                Val = 200000
            };

            schemeColor16.Append(shade7);
            schemeColor16.Append(saturationModulation12);

            gradientStop11.Append(schemeColor16);

            gradientStopList4.Append(gradientStop10);
            gradientStopList4.Append(gradientStop11);

            DocumentFormat.OpenXml.Drawing.PathGradientFill pathGradientFill2 = new DocumentFormat.OpenXml.Drawing.PathGradientFill()
            {
                Path = DocumentFormat.OpenXml.Drawing.PathShadeValues.Circle
            };
            DocumentFormat.OpenXml.Drawing.FillToRectangle fillToRectangle2 = new DocumentFormat.OpenXml.Drawing.FillToRectangle()
            {
                Left = 50000, Top = 50000, Right = 50000, Bottom = 50000
            };

            pathGradientFill2.Append(fillToRectangle2);

            gradientFill4.Append(gradientStopList4);
            gradientFill4.Append(pathGradientFill2);

            backgroundFillStyleList1.Append(solidFill5);
            backgroundFillStyleList1.Append(gradientFill3);
            backgroundFillStyleList1.Append(gradientFill4);

            formatScheme1.Append(fillStyleList1);
            formatScheme1.Append(lineStyleList1);
            formatScheme1.Append(effectStyleList1);
            formatScheme1.Append(backgroundFillStyleList1);

            themeElements1.Append(colorScheme1);
            themeElements1.Append(fontScheme1);
            themeElements1.Append(formatScheme1);
            DocumentFormat.OpenXml.Drawing.ObjectDefaults       objectDefaults1       = new DocumentFormat.OpenXml.Drawing.ObjectDefaults();
            DocumentFormat.OpenXml.Drawing.ExtraColorSchemeList extraColorSchemeList1 = new DocumentFormat.OpenXml.Drawing.ExtraColorSchemeList();

            theme1.Append(themeElements1);
            theme1.Append(objectDefaults1);
            theme1.Append(extraColorSchemeList1);

            themePart1.Theme = theme1;
        }
Exemplo n.º 27
0
        private static void Extract(StyleRunProperties runStyle, StyleParagraphProperties pStyle, TextWriter css, ThemePart theme)
        {
            if (runStyle.Bold != null && (runStyle.Bold.Val == null || runStyle.Bold.Val.HasValue && runStyle.Bold.Val.Value))
            {
                Write(css, "font-weight", "bold");
            }
            Write(css, runStyle.Border);

            Write(css, "color", runStyle.Color);
            if (runStyle.Shading != null)
            {
                if (runStyle.Shading.Fill != null && runStyle.Shading.Fill.HasValue)
                {
                    Write(css, "background-color", "#" + runStyle.Shading.Fill);
                }
            }
            if (pStyle != null && pStyle.Justification != null)
            {
                Write(css, "text-align", pStyle.Justification.Val);
            }
            Write(css, "font-style", "italic", runStyle.Italic);
            if (runStyle.RunFonts != null)
            {
                Write(css, "font-face", runStyle.RunFonts.Ascii);
            }
            if (pStyle != null && pStyle.ParagraphBorders != null)
            {
                Write(css, pStyle.ParagraphBorders);
            }
            if (runStyle.Caps != null)
            {
                Write(css, "text-transform", "uppercase");
            }
        }
Exemplo n.º 28
0
 public ThemesPanelClosingEventArgs(ThemeCategory category, ThemePart part)
 {
     Category = category;
     Part     = part;
 }
Exemplo n.º 29
0
        public void ThemeAsClassWithFixedOrderChildTest()
        {
            this.MyTestInitialize(TestContext.GetCurrentMethod());
            var testfile = CopyTestFiles(@"wordprocessing", true, "complex0.docx", f => f.IsWordprocessingFile())
                           .Where(f => f.IsWordprocessingFile() || f.IsSpreadsheetFile())
                           .FirstOrDefault();

            using (var package = testfile.OpenPackage(true) as WordprocessingDocument)
            {
                ThemePart themePart = package.MainDocumentPart.ThemePart;

                Log.Comment("Constructing Theme...");
                Dr.Theme theme          = buildRootElementFromPart(themePart, RootElementConstructors.defaultCtor);
                var      xThemeFromFile = ConvertToXElement(themePart, theme);

                Log.Comment("Child Element Properties...");
                XElement xTheme = ConvertToXElement(themePart, theme);
                // doc.CustomColorList
                CustomColorList ccl = theme.CustomColorList;
                if (null != ccl)
                {
                    XElement xccl    = xTheme.Element(ccl.GetXName());
                    var      isEqual = xccl.Compare(ccl.ToXElement());
                    Log.VerifyTrue(isEqual, "CustomColorList property is different from expectation.");
                }

                // doc.ExtensionList;
                var el = theme.OfficeStyleSheetExtensionList;
                if (null != el)
                {
                    XElement xel     = xTheme.Element(el.GetXName());
                    var      isEqual = xel.Compare(el.ToXElement());
                    Log.VerifyTrue(isEqual, "ExtensionList property is different from expectation.");
                }

                //doc.ExtraColorSchemeList;
                var ecsl = theme.ExtraColorSchemeList;
                if (null != ecsl)
                {
                    XElement xecsl   = xTheme.Element(ecsl.GetXName());
                    var      isEqual = xecsl.Compare(ecsl.ToXElement());
                    Log.VerifyTrue(isEqual, "ExtraColorSchemeList property is different from expectation.");
                }

                //doc.ObjectDefaults;
                var od = theme.ObjectDefaults;
                if (null != od)
                {
                    XElement xod     = xTheme.Element(od.GetXName());
                    var      isEqual = xod.Compare(od.ToXElement());
                    Log.VerifyTrue(isEqual, "ObjectDefaults property is different from expectation.");
                }

                //doc.ThemeElements;
                var te = theme.ThemeElements;
                if (null != te)
                {
                    XElement xte     = xTheme.Element(te.GetXName());
                    var      isEqual = xte.Compare(te.ToXElement());
                    Log.VerifyTrue(isEqual, "ThemeElements property is different from expectation.");
                }
                Log.Comment("Saving changes to Theme...");
                theme.Save(themePart);
            }
            Log.Pass("Theme as Class With Fixed Order Children Testing Passed.");
        }
Exemplo n.º 30
0
 private Theme(ThemePart themepart, Image image)
 {
     Images.Add(themepart, image);
     //Frissítse az összes helyen a képeket (lásd Language osztály) - Csak ne itt
 }