Ejemplo n.º 1
0
 public XSSFHyperlink(CT_Hyperlink ctHyperlink, PackageRelationship hyperlinkRel)
 {
     this._ctHyperlink = ctHyperlink;
     this._externalRel = hyperlinkRel;
     if (ctHyperlink.location != null)
     {
         this._type     = HyperlinkType.DOCUMENT;
         this._location = ctHyperlink.location;
     }
     else if (this._externalRel == null)
     {
         if (ctHyperlink.id != null)
         {
             throw new InvalidOperationException("The hyperlink for cell " + ctHyperlink.@ref + " references relation " + ctHyperlink.id + ", but that didn't exist!");
         }
         this._type = HyperlinkType.DOCUMENT;
     }
     else
     {
         this._location = this._externalRel.TargetUri.ToString();
         if (this._location.StartsWith("http://") || this._location.StartsWith("https://") || this._location.StartsWith("ftp://"))
         {
             this._type = HyperlinkType.URL;
         }
         else if (this._location.StartsWith("mailto:"))
         {
             this._type = HyperlinkType.EMAIL;
         }
         else
         {
             this._type = HyperlinkType.FILE;
         }
     }
 }
Ejemplo n.º 2
0
 public CT_TextCharacterProperties()
 {
     this.extLstField         = new CT_OfficeArtExtensionList();
     this.hlinkMouseOverField = new CT_Hyperlink();
     this.hlinkClickField     = new CT_Hyperlink();
     this.symField            = new CT_TextFont();
     this.csField             = new CT_TextFont();
     this.eaField             = new CT_TextFont();
     this.latinField          = new CT_TextFont();
     this.uFillField          = new CT_TextUnderlineFillGroupWrapper();
     this.uFillTxField        = new CT_TextUnderlineFillFollowText();
     this.uLnField            = new CT_LineProperties();
     this.uLnTxField          = new CT_TextUnderlineLineFollowText();
     this.highlightField      = new CT_Color();
     this.effectDagField      = new CT_EffectContainer();
     this.effectLstField      = new CT_EffectList();
     this.grpFillField        = new CT_GroupFillProperties();
     this.pattFillField       = new CT_PatternFillProperties();
     this.blipFillField       = new CT_BlipFillProperties();
     this.gradFillField       = new CT_GradientFillProperties();
     this.solidFillField      = new CT_SolidColorFillProperties();
     this.noFillField         = new CT_NoFillProperties();
     this.lnField             = new CT_LineProperties();
     this.dirtyField          = true;
     this.errField            = false;
     this.smtCleanField       = true;
     this.smtIdField          = ((uint)(0));
 }
Ejemplo n.º 3
0
        /**
         * Create a XSSFHyperlink amd Initialize it from the supplied CTHyperlink bean and namespace relationship
         *
         * @param ctHyperlink the xml bean Containing xml properties
         * @param hyperlinkRel the relationship in the underlying OPC namespace which stores the actual link's Address
         */
        public XSSFHyperlink(CT_Hyperlink ctHyperlink, PackageRelationship hyperlinkRel)
        {
            _ctHyperlink = ctHyperlink;
            _externalRel = hyperlinkRel;

            // Figure out the Hyperlink type and distination

            // If it has a location, it's internal
            if (ctHyperlink.location != null)
            {
                _type     = HyperlinkType.Document;
                _location = ctHyperlink.location;
            }
            else
            {
                // Otherwise it's somehow external, check
                //  the relation to see how
                if (_externalRel == null)
                {
                    if (ctHyperlink.id != null)
                    {
                        throw new InvalidOperationException("The hyperlink for cell " +
                                                            ctHyperlink.@ref + " references relation " + ctHyperlink.id + ", but that didn't exist!");
                    }
                    // hyperlink is internal and is not related to other parts
                    _type = HyperlinkType.Document;
                }
                else
                {
                    Uri target = _externalRel.TargetUri;
                    try
                    {
                        _location = target.ToString();
                    }
                    catch (UriFormatException)
                    {
                        _location = target.OriginalString;
                    }

                    // Try to figure out the type
                    if (_location.StartsWith("http://") || _location.StartsWith("https://") ||
                        _location.StartsWith("ftp://"))
                    {
                        _type = HyperlinkType.Url;
                    }
                    else if (_location.StartsWith("mailto:"))
                    {
                        _type = HyperlinkType.Email;
                    }
                    else
                    {
                        _type = HyperlinkType.File;
                    }
                }
            }
        }
 public XMLHyperlinkModel(string area, string href, string text, PartManager manager, CT_Sheet entry)
 {
     _link               = new CT_Hyperlink();
     _link._ref_Attr     = area;
     _link.Location_Attr = href;
     _link.Display_Attr  = text;
     _isInternal         = !href.Contains("://");
     _manager            = manager;
     _worksheetEntry     = entry;
 }
Ejemplo n.º 5
0
        /**
         * Create a XSSFHyperlink amd Initialize it from the supplied CTHyperlink bean and namespace relationship
         *
         * @param ctHyperlink the xml bean Containing xml properties
         * @param hyperlinkRel the relationship in the underlying OPC namespace which stores the actual link's Address
         */
        public XSSFHyperlink(CT_Hyperlink ctHyperlink, PackageRelationship hyperlinkRel)
        {
            _ctHyperlink = ctHyperlink;
            _externalRel = hyperlinkRel;

            // Figure out the Hyperlink type and distination

            // If it has a location, it's internal
            if (ctHyperlink.location != null)
            {
                _type     = HyperlinkType.DOCUMENT;
                _location = ctHyperlink.location;
            }
            else
            {
                // Otherwise it's somehow external, check
                //  the relation to see how
                if (_externalRel == null)
                {
                    if (ctHyperlink.id != null)
                    {
                        throw new InvalidOperationException("The hyperlink for cell " +
                                                            ctHyperlink.@ref + " references relation " + ctHyperlink.id + ", but that didn't exist!");
                    }
                    throw new InvalidOperationException("A sheet hyperlink must either have a location, or a relationship. Found:\n" + ctHyperlink);
                }

                Uri target = _externalRel.TargetUri;
                _location = target.ToString();

                // Try to figure out the type
                if (_location.StartsWith("http://") || _location.StartsWith("https://") ||
                    _location.StartsWith("ftp://"))
                {
                    _type = HyperlinkType.URL;
                }
                else if (_location.StartsWith("mailto:"))
                {
                    _type = HyperlinkType.EMAIL;
                }
                else
                {
                    _type = HyperlinkType.FILE;
                }
            }
        }
Ejemplo n.º 6
0
 /**
  * Create a new XSSFHyperlink. This method is for Internal use only.
  * XSSFHyperlinks can be created by XSSFCreationHelper.
  *
  * @param type - the type of hyperlink to create, see {@link Hyperlink}
  */
 //FIXME: change to protected if/when SXSSFHyperlink class is created
 public XSSFHyperlink(IHyperlink other)
 {
     if (other is XSSFHyperlink)
     {
         XSSFHyperlink xlink = (XSSFHyperlink)other;
         _type        = xlink.Type;
         _location    = xlink._location;
         _externalRel = xlink._externalRel;
         _ctHyperlink = xlink._ctHyperlink.Copy();
     }
     else
     {
         _type        = other.Type;
         _location    = other.Address;
         _externalRel = null;
         _ctHyperlink = new CT_Hyperlink();
         SetCellReference(new CellReference(other.FirstRow, other.FirstColumn));
     }
 }
Ejemplo n.º 7
0
        public static CT_TextCharacterProperties Parse(XmlNode node, XmlNamespaceManager namespaceManager)
        {
            if (node == null)
            {
                return(null);
            }
            CT_TextCharacterProperties ctObj = new CT_TextCharacterProperties();

            ctObj.kumimoji = XmlHelper.ReadBool(node.Attributes["kumimoji"]);
            ctObj.lang     = XmlHelper.ReadString(node.Attributes["lang"]);
            ctObj.altLang  = XmlHelper.ReadString(node.Attributes["altLang"]);
            ctObj.sz       = XmlHelper.ReadInt(node.Attributes["sz"]);
            if (node.Attributes["b"] != null)
            {
                ctObj.b = XmlHelper.ReadBool(node.Attributes["b"]);
            }
            if (node.Attributes["i"] != null)
            {
                ctObj.i = XmlHelper.ReadBool(node.Attributes["i"]);
            }
            if (node.Attributes["u"] != null)
            {
                ctObj.u = (ST_TextUnderlineType)Enum.Parse(typeof(ST_TextUnderlineType), node.Attributes["u"].Value);
            }
            if (node.Attributes["strike"] != null)
            {
                ctObj.strike = (ST_TextStrikeType)Enum.Parse(typeof(ST_TextStrikeType), node.Attributes["strike"].Value);
            }
            ctObj.kern = XmlHelper.ReadInt(node.Attributes["kern"]);
            if (node.Attributes["cap"] != null)
            {
                ctObj.cap = (ST_TextCapsType)Enum.Parse(typeof(ST_TextCapsType), node.Attributes["cap"].Value);
            }
            ctObj.spc        = XmlHelper.ReadInt(node.Attributes["spc"]);
            ctObj.normalizeH = XmlHelper.ReadBool(node.Attributes["normalizeH"]);
            ctObj.baseline   = XmlHelper.ReadInt(node.Attributes["baseline"]);
            ctObj.noProof    = XmlHelper.ReadBool(node.Attributes["noProof"]);
            if (node.Attributes["dirty"] != null)
            {
                ctObj.dirty = XmlHelper.ReadBool(node.Attributes["dirty"]);
            }
            ctObj.err = XmlHelper.ReadBool(node.Attributes["err"]);
            if (node.Attributes["smtClean"] != null)
            {
                ctObj.smtClean = XmlHelper.ReadBool(node.Attributes["smtClean"]);
            }
            ctObj.smtId = XmlHelper.ReadUInt(node.Attributes["smtId"]);
            ctObj.bmk   = XmlHelper.ReadString(node.Attributes["bmk"]);
            foreach (XmlNode childNode in node.ChildNodes)
            {
                if (childNode.LocalName == "ln")
                {
                    ctObj.ln = CT_LineProperties.Parse(childNode, namespaceManager);
                }
                else if (childNode.LocalName == "noFill")
                {
                    ctObj.noFill = new CT_NoFillProperties();
                }
                else if (childNode.LocalName == "solidFill")
                {
                    ctObj.solidFill = CT_SolidColorFillProperties.Parse(childNode, namespaceManager);
                }
                else if (childNode.LocalName == "gradFill")
                {
                    ctObj.gradFill = CT_GradientFillProperties.Parse(childNode, namespaceManager);
                }
                else if (childNode.LocalName == "blipFill")
                {
                    ctObj.blipFill = CT_BlipFillProperties.Parse(childNode, namespaceManager);
                }
                else if (childNode.LocalName == "pattFill")
                {
                    ctObj.pattFill = CT_PatternFillProperties.Parse(childNode, namespaceManager);
                }
                else if (childNode.LocalName == "grpFill")
                {
                    ctObj.grpFill = new CT_GroupFillProperties();
                }
                else if (childNode.LocalName == "effectLst")
                {
                    ctObj.effectLst = CT_EffectList.Parse(childNode, namespaceManager);
                }
                else if (childNode.LocalName == "effectDag")
                {
                    ctObj.effectDag = CT_EffectContainer.Parse(childNode, namespaceManager);
                }
                else if (childNode.LocalName == "highlight")
                {
                    ctObj.highlight = CT_Color.Parse(childNode, namespaceManager);
                }
                else if (childNode.LocalName == "uLnTx")
                {
                    ctObj.uLnTx = new CT_TextUnderlineLineFollowText();
                }
                else if (childNode.LocalName == "uLn")
                {
                    ctObj.uLn = CT_LineProperties.Parse(childNode, namespaceManager);
                }
                else if (childNode.LocalName == "uFillTx")
                {
                    ctObj.uFillTx = new CT_TextUnderlineFillFollowText();
                }
                else if (childNode.LocalName == "uFill")
                {
                    ctObj.uFill = CT_TextUnderlineFillGroupWrapper.Parse(childNode, namespaceManager);
                }
                else if (childNode.LocalName == "latin")
                {
                    ctObj.latin = CT_TextFont.Parse(childNode, namespaceManager);
                }
                else if (childNode.LocalName == "ea")
                {
                    ctObj.ea = CT_TextFont.Parse(childNode, namespaceManager);
                }
                else if (childNode.LocalName == "cs")
                {
                    ctObj.cs = CT_TextFont.Parse(childNode, namespaceManager);
                }
                else if (childNode.LocalName == "sym")
                {
                    ctObj.sym = CT_TextFont.Parse(childNode, namespaceManager);
                }
                else if (childNode.LocalName == "hlinkClick")
                {
                    ctObj.hlinkClick = CT_Hyperlink.Parse(childNode, namespaceManager);
                }
                else if (childNode.LocalName == "hlinkMouseOver")
                {
                    ctObj.hlinkMouseOver = CT_Hyperlink.Parse(childNode, namespaceManager);
                }
                else if (childNode.LocalName == "extLst")
                {
                    ctObj.extLst = CT_OfficeArtExtensionList.Parse(childNode, namespaceManager);
                }
            }
            return(ctObj);
        }
Ejemplo n.º 8
0
 /**
  * Create a new XSSFHyperlink. This method is protected to be used only by XSSFCreationHelper
  *
  * @param type - the type of hyperlink to create
  */
 public XSSFHyperlink(HyperlinkType type)
 {
     _type        = type;
     _ctHyperlink = new CT_Hyperlink();
 }
Ejemplo n.º 9
0
 public void SetHyperlinkArray(CT_Hyperlink[] array)
 {
     hyperlinkField = new List<CT_Hyperlink>(array);
 }
Ejemplo n.º 10
0
 public XSSFHyperlink(HyperlinkType type)
 {
     this._type        = type;
     this._ctHyperlink = new CT_Hyperlink();
 }
Ejemplo n.º 11
0
 public void WriteHyperlink(CT_Hyperlink link)
 {
     this.WriteTagInCollection <CT_Hyperlinks>(link, StreamSheetSection.Hyperlinks, CT_Hyperlinks.HyperlinkElementName, CT_Worksheet.HyperlinksElementName);
 }
Ejemplo n.º 12
0
        public void SerializeWorksheetDocumentTest()
        {
            CT_Worksheet worksheet = new CT_Worksheet();

            worksheet.dimension      = new CT_SheetDimension();
            worksheet.dimension.@ref = "A1:C1";

            var sheetData = worksheet.AddNewSheetData();
            var row       = sheetData.AddNewRow();

            row.r     = 1u;
            row.spans = "1:3";
            {
                var c = row.AddNewC();
                c.r = "A1";
                c.t = ST_CellType.s;
                c.v = "0";
            }
            {
                var c = row.AddNewC();
                c.r = "B1";
                c.t = ST_CellType.s;
                c.v = "1";
            }
            {
                var c = row.AddNewC();
                c.r = "C1";
                c.t = ST_CellType.s;
                c.v = "8";
            }
            var hyper = worksheet.AddNewHyperlinks();
            var link  = new CT_Hyperlink();

            link.@ref = "B1";
            link.id   = "rId1";
            hyper.hyperlink.Add(link);
            StringWriter stream = new StringWriter();

            WorksheetDocument_Accessor.serializer.Serialize(stream, worksheet, WorksheetDocument_Accessor.namespaces);
            string expected = @"<?xml version=""1.0"" encoding=""utf-16""?>
<worksheet xmlns:r=""http://schemas.openxmlformats.org/officeDocument/2006/relationships"" xmlns=""http://schemas.openxmlformats.org/spreadsheetml/2006/main"">
  <dimension ref=""A1:C1"" />
  <sheetData>
    <row r=""1"" spans=""1:3"">
      <c r=""A1"" t=""s"">
        <v>0</v>
      </c>
      <c r=""B1"" t=""s"">
        <v>1</v>
      </c>
      <c r=""C1"" t=""s"">
        <v>8</v>
      </c>
    </row>
  </sheetData>
  <hyperlinks>
    <hyperlink ref=""B1"" r:id=""rId1"" />
  </hyperlinks>
</worksheet>";

            Assert.AreEqual(expected, stream.ToString());
        }
Ejemplo n.º 13
0
        private String _location;          //what the hyperlink refers to

        /**
         * Create a new XSSFHyperlink. This method is protected to be used only by XSSFCreationHelper
         *
         * @param type - the type of hyperlink to create
         */
        public XSSFHyperlink(HyperlinkType type)
        {
            _type        = type;
            _ctHyperlink = new CT_Hyperlink();
            _externalRel = null;
        }