Example #1
0
 /**
  * determines whether specified CharacterRun Contains reference to a picture
  * @param run
  */
 public bool HasPicture(CharacterRun run)
 {
     if (run.IsSpecialCharacter() && !run.IsObj() && !run.IsOle2() && !run.IsData())
     {
         // Image should be in it's own run, or in a run with the end-of-special marker
         if ("\u0001".Equals(run.Text) || "\u0001\u0015".Equals(run.Text))
         {
             return IsBlockContainsImage(run.GetPicOffset());
         }
     }
     return false;
 }
Example #2
0
        public static void AddCharactersProperties(CharacterRun characterRun, StringBuilder style)
        {
            AddBorder(characterRun.GetBorder(), string.Empty, style);

            if (characterRun.IsCapitalized())
            {
                style.Append("text-transform:uppercase;");
            }
            if (characterRun.GetIco24() != -1)
            {
                style.Append("color:" + GetColor24(characterRun.GetIco24()) + ";");
            }
            if (characterRun.IsHighlighted())
            {
                style.Append("background-color:" + GetColor(characterRun.GetHighlightedColor()) + ";");
            }
            if (characterRun.IsStrikeThrough())
            {
                style.Append("text-decoration:line-through;");
            }
            if (characterRun.IsShadowed())
            {
                style.Append("text-shadow:" + characterRun.GetFontSize() / 24 + "pt;");
            }
            if (characterRun.IsSmallCaps())
            {
                style.Append("font-variant:small-caps;");
            }
            if (characterRun.GetSubSuperScriptIndex() == 1)
            {
                style.Append("vertical-align:super;");
                style.Append("font-size:smaller;");
            }
            if (characterRun.GetSubSuperScriptIndex() == 2)
            {
                style.Append("vertical-align:sub;");
                style.Append("font-size:smaller;");
            }
            if (characterRun.GetUnderlineCode() > 0)
            {
                style.Append("text-decoration:underline;");
            }
            if (characterRun.IsVanished())
            {
                style.Append("visibility:hidden;");
            }
        }
Example #3
0
 protected override void ProcessLineBreak(XmlElement block, CharacterRun characterRun)
 {
     block.AppendChild(foDocumentFacade.CreateBlock());
 }
Example #4
0
 protected override void ProcessDrawnObject(HWPFDocument doc,
         CharacterRun characterRun, OfficeDrawing officeDrawing,
         String path, XmlElement block)
 {
     XmlElement externalGraphic = foDocumentFacade.CreateExternalGraphic(path);
     block.AppendChild(externalGraphic);
 }
Example #5
0
        protected override void OutputCharacters(XmlElement block, CharacterRun characterRun,
                String text)
        {
            XmlElement inline = foDocumentFacade.CreateInline();

            Triplet triplet = GetCharacterRunTriplet(characterRun);

            if (!string.IsNullOrEmpty(triplet.fontName))
                WordToFoUtils.SetFontFamily(inline, triplet.fontName);
            WordToFoUtils.SetBold(inline, triplet.bold);
            WordToFoUtils.SetItalic(inline, triplet.italic);
            WordToFoUtils.SetFontSize(inline, characterRun.GetFontSize() / 2);
            WordToFoUtils.SetCharactersProperties(characterRun, inline);

            if (IsOutputCharactersLanguage())
                WordToFoUtils.SetLanguage(characterRun, inline);

            block.AppendChild(inline);

            XmlText textNode = foDocumentFacade.CreateText(text);
            inline.AppendChild(textNode);
        }
Example #6
0
        public static void SetCharactersProperties(CharacterRun characterRun, XmlElement inline)
        {
            StringBuilder textDecorations = new StringBuilder();

            SetBorder(inline, characterRun.GetBorder(), string.Empty);

            if (characterRun.GetIco24() != -1)
            {
                inline.SetAttribute("color", GetColor24(characterRun.GetIco24()));
            }
            int opacity = (int)(characterRun.GetIco24() & 0xFF000000L) >> 24;
            if (opacity != 0 && opacity != 0xFF)
            {
                inline.SetAttribute("opacity",
                        GetOpacity(characterRun.GetIco24()));
            }
            if (characterRun.IsCapitalized())
            {
                inline.SetAttribute("text-transform", "uppercase");
            }
            if (characterRun.isHighlighted())
            {
                inline.SetAttribute("background-color",
                        GetColor(characterRun.GetHighlightedColor()));
            }
            if (characterRun.IsStrikeThrough())
            {
                if (textDecorations.Length > 0)
                    textDecorations.Append(" ");
                textDecorations.Append("line-through");
            }
            if (characterRun.IsShadowed())
            {
                inline.SetAttribute("text-shadow", characterRun.GetFontSize() / 24 + "pt");
            }
            if (characterRun.IsSmallCaps())
            {
                inline.SetAttribute("font-variant", "small-caps");
            }
            if (characterRun.GetSubSuperScriptIndex() == 1)
            {
                inline.SetAttribute("baseline-shift", "super");
                inline.SetAttribute("font-size", "smaller");
            }
            if (characterRun.GetSubSuperScriptIndex() == 2)
            {
                inline.SetAttribute("baseline-shift", "sub");
                inline.SetAttribute("font-size", "smaller");
            }
            if (characterRun.GetUnderlineCode() > 0)
            {
                if (textDecorations.Length > 0)
                    textDecorations.Append(" ");
                textDecorations.Append("underline");
            }
            if (characterRun.IsVanished())
            {
                inline.SetAttribute("visibility", "hidden");
            }
            if (textDecorations.Length > 0)
            {
                inline.SetAttribute("text-decoration", textDecorations.ToString());
            }
        }
Example #7
0
 protected override void ProcessDrawnObject(HWPFDocument doc, CharacterRun characterRun, OfficeDrawing officeDrawing, string path, XmlElement block)
 {
     XmlElement img = htmlDocumentFacade.CreateImage(path);
     block.AppendChild(img);
 }
Example #8
0
        protected override void OutputCharacters(XmlElement pElement, CharacterRun characterRun, string text)
        {
            XmlElement span = htmlDocumentFacade.Document.CreateElement("span");
            pElement.AppendChild(span);

            StringBuilder style = new StringBuilder();
            BlockProperies blockProperies = this.blocksProperies.Peek();
            Triplet triplet = GetCharacterRunTriplet(characterRun);

            if (!string.IsNullOrEmpty(triplet.fontName)
                    && !WordToHtmlUtils.Equals(triplet.fontName,
                            blockProperies.pFontName))
            {
                style.Append("font-family:" + triplet.fontName + ";");
            }
            if (characterRun.GetFontSize() / 2 != blockProperies.pFontSize)
            {
                style.Append("font-size:" + characterRun.GetFontSize() / 2 + "pt;");
            }
            if (triplet.bold)
            {
                style.Append("font-weight:bold;");
            }
            if (triplet.italic)
            {
                style.Append("font-style:italic;");
            }

            WordToHtmlUtils.AddCharactersProperties(characterRun, style);
            if (style.Length != 0)
                htmlDocumentFacade.AddStyleClass(span, "s", style.ToString());

            XmlText textNode = htmlDocumentFacade.CreateText(text);
            span.AppendChild(textNode);
        }
Example #9
0
 public bool HasEscherPicture(CharacterRun run)
 {
     if (run.IsSpecialCharacter() && !run.IsObj() && !run.IsOle2() && !run.IsData() && run.Text.StartsWith("\u0008"))
     {
         return true;
     }
     return false;
 }
Example #10
0
 /**
  * Returns picture object tied to specified CharacterRun
  * @param run
  * @param FillBytes if true, Picture will be returned with Filled byte array that represent picture's contents. If you don't want
  * to have that byte array in memory but only write picture's contents to stream, pass false and then use Picture.WriteImageContent
  * @see Picture#WriteImageContent(java.io.OutputStream)
  * @return a Picture object if picture exists for specified CharacterRun, null otherwise. PicturesTable.hasPicture is used to determine this.
  * @see #hasPicture(NPOI.HWPF.usermodel.CharacterRun)
  */
 public Picture ExtractPicture(CharacterRun run, bool FillBytes)
 {
     if (HasPicture(run))
     {
         return new Picture(run.GetPicOffset(), _dataStream, FillBytes);
     }
     return null;
 }
Example #11
0
 /**
  * determines whether specified CharacterRun Contains reference to a picture
  * @param run
 */
 public bool HasHorizontalLine(CharacterRun run)
 {
     if (run.IsSpecialCharacter() && "\u0001".Equals(run.Text))
     {
         return IsBlockContainsHorizontalLine(run.GetPicOffset());
     }
     return false;
 }
Example #12
0
 public static void SetLanguage(CharacterRun characterRun, XmlElement inline)
 {
     if (characterRun.getLanguageCode() != 0)
     {
         String language = GetLanguage(characterRun.getLanguageCode());
         if (!string.IsNullOrEmpty(language))
             inline.SetAttribute("language", language);
     }
 }
 protected override void ProcessLineBreak(XmlElement block, CharacterRun characterRun)
 {
     block.AppendChild(textDocumentFacade.CreateText("\n"));
 }
 protected override void ProcessDrawnObject(HWPFDocument doc,
         CharacterRun characterRun, OfficeDrawing officeDrawing,
         String path, XmlElement block)
 {
     // ignore
 }
 protected override void OutputCharacters(XmlElement block, CharacterRun characterRun,
         String text)
 {
     block.AppendChild(textDocumentFacade.CreateText(text));
 }