コード例 #1
0
ファイル: wordlist1.cs プロジェクト: akinomyoga/Hanyu
            public override string ToHTML(XmlPart xmlpart)
            {
                string title = "<b>例</b> ";

                if (this.Part != "")
                {
                    title += xmlpart.GetElemPart(this.Part).IcoHTML;
                }
                title += " <span class=\"zh\">" + Hanyu.statics.EscapeHTML(this.elem.InnerText) + "</span>";
                string div = "";

                div += this.elem.GetAttribute("ja");
                div += this.attrClass.ToHTML(xmlpart);
                div += this.htmlDesc;
                //TODO:level
                //TODO:en
                if (div == "")
                {
                    return("<p class=\"exm\">" + title + "</p>");
                }
                else
                {
                    return("<p class=\"exmt\">" + title + "</p><div class=\"exm\">" + div + "</div>");
                }
            }
コード例 #2
0
 public OfficePart(PackagePart part, XmlPart partType, string relationshipId)
 {
     Part     = part;
     PartType = partType;
     _id      = relationshipId;
     Name     = Path.GetFileName(Part.Uri.ToString());
 }
コード例 #3
0
 public OfficePart(PackagePart part, XmlPart partType, string relationshipId)
 {
     this.Part     = part;
     this.PartType = partType;
     this.id       = relationshipId;
     this.Name     = Path.GetFileName(this.Part.Uri.ToString());
 }
コード例 #4
0
        public static XmlSchema Load(XmlPart partType)
        {
            var resource = partType == XmlPart.RibbonX12 ? SchemasResource.customUI : SchemasResource.customui14;

            using var stringReader = new StringReader(resource);
            using var reader       = XmlReader.Create(stringReader, new XmlReaderSettings { XmlResolver = null });
            return(XmlSchema.Read(reader, null));
        }
コード例 #5
0
        public bool TestEmpty(XmlPart partType)
        {
            // Arrange
            var content = string.Empty;
            var schema  = Schema.Load(partType);

            // Act
            var errors = XmlValidation.Validate(content, schema);

            return(!errors.Any());
        }
コード例 #6
0
ファイル: wordlist1.cs プロジェクト: akinomyoga/Hanyu
            public override string ToHTML(XmlPart xmlpart)
            {
                string r = "<h2 class=\"mean\">"
                           + ((this.Part == "")?"[?]":xmlpart.GetElemPart(this.Part).IcoHTML)
                           + " " + Hanyu.statics.EscapeHTML(this.attrJa) + "</h2>";

                r += this.attrClass.ToHTML(xmlpart);
                r += this.htmlDesc;
                //TODO:level
                //TODO:en
                //TODO:quant(名詞の場合)
                r += this.htmlChilds(xmlpart);
                return(r);
            }
コード例 #7
0
        public OfficePart CreateCustomPart(XmlPart partType)
        {
            string relativePath;
            string relType;

            switch (partType)
            {
            case XmlPart.RibbonX12:
                relativePath = "/customUI/customUI.xml";
                relType      = CustomUiPartRelType;
                break;

            case XmlPart.RibbonX14:
                relativePath = "/customUI/customUI14.xml";
                relType      = CustomUi14PartRelType;
                break;

            case XmlPart.Qat12:
                relativePath = "/customUI/qat.xml";
                relType      = QatPartRelType;
                break;

            default:
                throw new ArgumentException($"Unexpected {nameof(partType)}: {partType}");
            }

            var customUiUri  = new Uri(relativePath, UriKind.Relative);
            var relationship = UnderlyingPackage.CreateRelationship(customUiUri, TargetMode.Internal, relType);

            OfficePart part;

            if (!UnderlyingPackage.PartExists(customUiUri))
            {
                part = new OfficePart(UnderlyingPackage.CreatePart(customUiUri, "application/xml"), partType, relationship.Id);
            }
            else
            {
                part = new OfficePart(UnderlyingPackage.GetPart(customUiUri), partType, relationship.Id);
            }

            if (Parts == null)
            {
                Parts = new List <OfficePart>();
            }

            Parts.Add(part);
            IsDirty = true;

            return(part);
        }
コード例 #8
0
ファイル: wordlist1.cs プロジェクト: akinomyoga/Hanyu
            public string ToHTML(XmlPart xmlpart)
            {
                string r = "";

                Hanyu.XmlPart.Elem elm;
                for (int i = 0; i < this.classes.Count; i++)
                {
                    elm = xmlpart.GetElem((string)this.classes[i]);
                    if (elm != null)
                    {
                        r += elm.FullHTML;                           //Class2HTML((string)this.classes[i]);
                    }
                }
                return(r);
            }
コード例 #9
0
 public XMLPictureShapesModel(PartManager manager, CT_Sheet sheetEntry, string drawingId)
 {
     _manager  = manager;
     _parent   = _manager.GetWorksheetXmlPart(sheetEntry);
     _pictures = new List <XMLPictureShapeModel>();
     foreach (Relationship item in _manager.GetRelationshipsForSheet(sheetEntry, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/drawing"))
     {
         if (item.RelationshipId == drawingId)
         {
             _drawingrel = item;
             _drawing    = (WsDrPart)_manager.GetPartByLocation(item.RelatedPart).HydratedPart;
             _           = (Microsoft.ReportingServices.Rendering.ExcelOpenXmlRenderer.Parser.drawingml.x2006.spreadsheetDrawing.CT_Drawing)_drawing.Root;
             break;
         }
     }
 }
コード例 #10
0
        public void InsertPart(XmlPart type)
        {
            // Check if the part does not exist yet
            var part = this.document.RetrieveCustomPart(type);

            if (part != null)
            {
                return;
            }

            part = this.document.CreateCustomPart(type);
            var partModel = new OfficePartViewModel(part, this);

            this.Children.Add(partModel);
            partModel.IsSelected     = true;
            this.partsAddedOrRemoved = true;
        }
コード例 #11
0
        public OfficePart?RetrieveCustomPart(XmlPart partType)
        {
            Debug.Assert(Parts != null, "Document has no xmlParts to retrieve");
            if (Parts == null || Parts.Count == 0)
            {
                return(null);
            }

            foreach (var part in Parts)
            {
                if (part.PartType == partType)
                {
                    return(part);
                }
            }

            return(null);
        }
コード例 #12
0
        public void RemovePart(XmlPart type)
        {
            this.document.RemoveCustomPart(type);
            this.partsAddedOrRemoved = true;

            for (var i = 0; i < this.Children.Count; ++i)
            {
                if (!(this.Children[i] is OfficePartViewModel part) || part.Part == null)
                {
                    continue;
                }

                if (part.Part.PartType == type)
                {
                    this.Children.RemoveAt(i);
                    return;
                }
            }
        }
コード例 #13
0
ファイル: wordlist1.cs プロジェクト: akinomyoga/Hanyu
            protected string htmlChilds(XmlPart xmlpart)
            {
                string r = "";

                System.Xml.XmlElement child;
                for (int i = 0; i < this.elem.ChildNodes.Count; i++)
                {
                    if (this.elem.ChildNodes[i].NodeType != System.Xml.XmlNodeType.Element)
                    {
                        continue;
                    }
                    child = (System.Xml.XmlElement) this.elem.ChildNodes[i];
                    if (child.Name != "exm")
                    {
                        continue;
                    }
                    r += new Hanyu.Word.Example(child).ToHTML(xmlpart);
                }
                return(r);
            }
コード例 #14
0
        public void SaveCustomPart(XmlPart partType, string text, bool isCreatingNewPart)
        {
            var targetPart = RetrieveCustomPart(partType);

            if (targetPart == null)
            {
                if (isCreatingNewPart)
                {
                    targetPart = CreateCustomPart(partType);
                }
                else
                {
                    return;
                }
            }

            Debug.Assert(targetPart != null, "targetPart is null when saving custom part");
            targetPart?.Save(text);
            IsDirty = true;
        }
コード例 #15
0
 public XMLPictureShapeModel(PartManager manager, WsDrPart part, XmlPart parent, AnchorModel startAnchor, AnchorModel endAnchor, uint uniqueId)
     : base(manager, part, startAnchor, endAnchor)
 {
     this._parent = parent;
     base.TwoCellAnchor.Choice_0            = CT_TwoCellAnchor.ChoiceBucket_0.pic;
     base.TwoCellAnchor.ClientData          = new CT_AnchorClientData();
     this.Picture.NvPicPr                   = new CT_PictureNonVisual();
     this.Picture.NvPicPr.CNvPicPr          = new CT_NonVisualPictureProperties();
     this.Picture.NvPicPr.CNvPr             = new CT_NonVisualDrawingProps();
     this.Picture.NvPicPr.CNvPr.Id_Attr     = uniqueId;
     this.Picture.NvPicPr.CNvPr.Name_Attr   = "Picture " + uniqueId;
     this.Picture.BlipFill                  = new CT_BlipFillProperties();
     this.Picture.BlipFill.Blip             = new CT_Blip();
     this.Picture.BlipFill.Blip.Cstate_Attr = ST_BlipCompression.print;
     this.Picture.BlipFill.Choice_0         = CT_BlipFillProperties.ChoiceBucket_0.stretch;
     this.Picture.BlipFill.Stretch          = new CT_StretchInfoProperties();
     this.Picture.BlipFill.Stretch.FillRect = new CT_RelativeRect();
     this.Picture.SpPr.Choice_0             = CT_ShapeProperties.ChoiceBucket_0.prstGeom;
     this.Picture.SpPr.PrstGeom             = new CT_PresetGeometry2D();
     this.Picture.SpPr.PrstGeom.Prst_Attr   = ST_ShapeType.rect;
     this.Picture.SpPr.PrstGeom.AvLst       = new CT_GeomGuideList();
 }
コード例 #16
0
        public void RemoveCustomPart(XmlPart partType)
        {
            if (Parts == null)
            {
                return;
            }

            for (var i = Parts.Count - 1; i >= 0; i--)
            {
                if (Parts[i].PartType != partType)
                {
                    continue;
                }

                var part = Parts[i];
                part.Remove();

                Parts.RemoveAt(i);

                UnderlyingPackage.Flush();
                IsDirty = true;
            }
        }
コード例 #17
0
ファイル: wordlist1.cs プロジェクト: akinomyoga/Hanyu
            //METHODS
            public override string ToHTML(XmlPart xmlpart)
            {
                string r = "<h2 class=\"mean\"><span class=\"itemtype\">" + Word.Const.NameOfType(this.type) + "</span>";

                if (this.Part != "")
                {
                    r += xmlpart.GetElemPart(this.Part).IcoHTML + ": ";
                }
                if (this.type == Word.ContentType.Construct || this.type == Word.ContentType.Idiom)
                {
                    r += " " + this.htmlName + " " + this.htmlPinyin;
                }
                r += "</h2>";
                r += "<p>" + this.elem.GetAttribute("ja") + "</p>";
                r += this.attrClass.ToHTML(xmlpart);
                r += this.htmlTarget;
                r += this.htmlDesc;
                //TODO:level
                //TODO:en
                //TODO:quant(名詞の場合)
                r += this.htmlChilds(xmlpart);
                return(r);
            }
コード例 #18
0
 public bool TestNamespace(string xmlNamespace, XmlPart schema)
 => ValidateInternal(new ValidationOptions
 {
     Namespace = xmlNamespace,
     Schema    = schema,
 });
コード例 #19
0
 public Relationship AddPartToTree(OoxmlPart part, string contentType, string relationshipType, string locationHint, XmlPart parent)
 {
     return(_relationshipTree.AddPartToTree(part, contentType, relationshipType, locationHint, parent));
 }
コード例 #20
0
 public Relationship AddStreamingPartToTree(string contentType, string relationshipType, string locationHint, XmlPart parent)
 {
     return(_relationshipTree.AddStreamingPartToTree(contentType, relationshipType, locationHint, parent));
 }
コード例 #21
0
 public Relationship AddExternalPartToTree(string relationshipType, string externalTarget, XmlPart parent, TargetMode targetMode)
 {
     return(_relationshipTree.AddExternalPartToTree(relationshipType, externalTarget, parent, targetMode));
 }
コード例 #22
0
 public void SaveCustomPart(XmlPart partType, string text)
 {
     SaveCustomPart(partType, text, false /*isCreatingNewPart*/);
 }
コード例 #23
0
        public Relationship WriteStaticPart(OoxmlPart part, string contentType, string relationshipType, string locationHint, XmlPart parent)
        {
            Relationship relationship = _relationshipTree.AddPartToTree(part, contentType, relationshipType, locationHint, parent);

            _relationshipTree.WritePart(relationship.RelatedPart);
            return(relationship);
        }
コード例 #24
0
ファイル: wordlist1.cs プロジェクト: akinomyoga/Hanyu
 public abstract string ToHTML(XmlPart xmlpart);