Example #1
0
        private string GetXMLBorders(ExportIEMStyle style)
        {
            StringBuilder result = new StringBuilder(128);

            result.AppendLine("<Borders>");
            if ((style.Border.Lines & BorderLines.Left) > 0)
            {
                result.Append("<Border ss:Position=\"Left\" ").
                Append("ss:LineStyle=\"").
                AppendFormat(GetXMLLineStyle(style.Border.LeftLine.Style)).
                Append("\" ").
                Append("ss:Weight=\"").
                Append(GetXMLWeight(style.Border.LeftLine.Width)).
                Append("\" ").
                Append("ss:Color=\"").
                Append(ExportUtils.HTMLColor(style.Border.LeftLine.Color)).
                AppendLine("\"/>");
            }
            if ((style.Border.Lines & BorderLines.Top) > 0)
            {
                result.Append("<Border ss:Position=\"Top\" ").
                Append("ss:LineStyle=\"").
                AppendFormat(GetXMLLineStyle(style.Border.TopLine.Style)).
                Append("\" ").
                Append("ss:Weight=\"").
                Append(GetXMLWeight(style.Border.TopLine.Width)).
                Append("\" ").
                Append("ss:Color=\"").
                Append(ExportUtils.HTMLColor(style.Border.TopLine.Color)).
                AppendLine("\"/>");
            }
            if ((style.Border.Lines & BorderLines.Bottom) > 0)
            {
                result.AppendLine("<Border ss:Position=\"Bottom\" ").
                Append("ss:LineStyle=\"").
                AppendFormat(GetXMLLineStyle(style.Border.BottomLine.Style)).
                Append("\" ").
                Append("ss:Weight=\"").
                Append(GetXMLWeight(style.Border.BottomLine.Width)).
                Append("\" ").
                Append("ss:Color=\"").
                Append(ExportUtils.HTMLColor(style.Border.BottomLine.Color)).
                AppendLine("\"/>");
            }
            if ((style.Border.Lines & BorderLines.Right) > 0)
            {
                result.AppendLine("<Border ss:Position=\"Right\" ").
                Append("ss:LineStyle=\"").
                AppendFormat(GetXMLLineStyle(style.Border.RightLine.Style)).
                Append("\" ").
                Append("ss:Weight=\"").
                Append(GetXMLWeight(style.Border.RightLine.Width)).
                Append("\" ").
                Append("ss:Color=\"").
                Append(ExportUtils.HTMLColor(style.Border.RightLine.Color)).
                AppendLine("\"/>");
            }
            result.Append("</Borders>");
            return(result.ToString());
        }
        private string GetStyle(Font Font, Color TextColor, Color FillColor,
                                bool RTL, HorzAlign HAlign, Border Border, bool WordWrap, float LineHeight, float Width, float Height, bool Clip)
        {
            FastString style = new FastString(256);

            if (Font != null)
            {
                if (Zoom != 1)
                {
                    using (Font newFont = new Font(Font.FontFamily, Font.Size * Zoom, Font.Style, Font.Unit, Font.GdiCharSet, Font.GdiVerticalFont))
                        HTMLFontStyle(style, newFont, LineHeight);
                }
                else
                {
                    HTMLFontStyle(style, Font, LineHeight);
                }
            }
            style.Append("text-align:");
            if (HAlign == HorzAlign.Left)
            {
                style.Append(RTL ? "right" : "left");
            }
            else if (HAlign == HorzAlign.Right)
            {
                style.Append(RTL ? "left" : "right");
            }
            else if (HAlign == HorzAlign.Center)
            {
                style.Append("center");
            }
            else
            {
                style.Append("justify");
            }
            style.Append(";");

            if (WordWrap)
            {
                style.Append("word-wrap:break-word;");
            }

            if (Clip)
            {
                style.Append("overflow:hidden;");
            }

            style.Append("position:absolute;color:").
            Append(ExportUtils.HTMLColor(TextColor)).
            Append(";background-color:").
            Append(FillColor.A == 0 ? "transparent" : ExportUtils.HTMLColor(FillColor)).
            Append(";").Append(RTL ? "direction:rtl;" : String.Empty);

            Border newBorder = Border;

            HTMLBorder(style, newBorder);
            style.Append("width:").Append(Px(Width * Zoom)).Append("height:").Append(Px(Height * Zoom));
            return(style.ToString());
        }
Example #3
0
 private void HTMLBorder(StringBuilder BorderDesc, Border border)
 {
     if (border.Lines > 0)
     {
         // bottom
         if ((border.Lines & BorderLines.Bottom) > 0)
         {
             BorderDesc.Append("border-bottom-width:").
             Append(Px(HTMLBorderWidth(border.BottomLine))).
             Append("border-bottom-color:").
             Append(ExportUtils.HTMLColor(border.BottomLine.Color)).Append(";").
             Append("border-bottom-style:").Append(HTMLBorderStyle(border.BottomLine)).Append(";");
         }
         else
         {
             BorderDesc.Append("border-bottom-width:0;");
         }
         // top
         if ((border.Lines & BorderLines.Top) > 0)
         {
             BorderDesc.Append("border-top-width:").
             Append(Px(HTMLBorderWidth(border.TopLine))).
             Append("border-top-color:").
             Append(ExportUtils.HTMLColor(border.TopLine.Color)).Append(";").
             Append("border-top-style:").Append(HTMLBorderStyle(border.TopLine)).Append(";");
         }
         else
         {
             BorderDesc.Append("border-top-width:0;");
         }
         // left
         if ((border.Lines & BorderLines.Left) > 0)
         {
             BorderDesc.Append("border-left-width:").
             Append(Px(HTMLBorderWidth(border.LeftLine))).
             Append("border-left-color:").
             Append(ExportUtils.HTMLColor(border.LeftLine.Color)).Append(";").
             Append("border-left-style:").Append(HTMLBorderStyle(border.LeftLine)).Append(";");
         }
         else
         {
             BorderDesc.Append("border-left-width:0;");
         }
         // right
         if ((border.Lines & BorderLines.Right) > 0)
         {
             BorderDesc.Append("border-right-width:").
             Append(Px(HTMLBorderWidth(border.RightLine))).
             Append("border-right-color:").
             Append(ExportUtils.HTMLColor(border.RightLine.Color)).Append(";").
             Append(" border-right-style:").Append(HTMLBorderStyle(border.RightLine)).Append(";");
         }
         else
         {
             BorderDesc.Append("border-right-width:0;");
         }
     }
 }
Example #4
0
 private string GetXMLInterior(ExportIEMStyle style)
 {
     if (style.FillColor != Color.Transparent)
     {
         return("<Interior ss:Color=\"" +
                ExportUtils.HTMLColor(style.FillColor) + "\" ss:Pattern=\"Solid\"/>");
     }
     return(String.Empty);
 }
Example #5
0
 private void OdfTableCellStyles(ExportIEMStyle Style, StreamWriter Out)
 {
     Out.Write("<style:table-cell-properties fo:background-color=\"" +
               ExportUtils.HTMLColor(Style.FillColor) + "\" " +
               "style:repeat-content=\"false\" fo:wrap-option=\"wrap\" ");
     if (Style.Angle > 0)
     {
         Out.Write("style:rotation-angle=\"" + (360 - Style.Angle).ToString() + "\" " +
                   "style:rotation-align=\"none\" ");
     }
     if (Style.VAlign == VertAlign.Center)
     {
         Out.Write("style:vertical-align=\"middle\" ");
     }
     if (Style.VAlign == VertAlign.Top)
     {
         Out.Write("style:vertical-align=\"top\" ");
     }
     if (Style.VAlign == VertAlign.Bottom)
     {
         Out.Write("style:vertical-align=\"bottom\" ");
     }
     if ((Style.Border.Lines & BorderLines.Left) > 0)
     {
         Out.Write("fo:border-left=\"" +
                   ExportUtils.FloatToString(Style.Border.Width / odfDivider) + "cm " +
                   OdfGetFrameName(Style.Border.Style) + " " +
                   ExportUtils.HTMLColor(Style.Border.Color) + "\" ");
     }
     if ((Style.Border.Lines & BorderLines.Right) > 0)
     {
         Out.Write("fo:border-right=\"" +
                   ExportUtils.FloatToString(Style.Border.Width / odfDivider) + "cm " +
                   OdfGetFrameName(Style.Border.Style) + " " +
                   ExportUtils.HTMLColor(Style.Border.Color) + "\" ");
     }
     if ((Style.Border.Lines & BorderLines.Top) > 0)
     {
         Out.Write("fo:border-top=\"" +
                   ExportUtils.FloatToString(Style.Border.Width / odfDivider) + "cm " +
                   OdfGetFrameName(Style.Border.Style) + " " +
                   ExportUtils.HTMLColor(Style.Border.Color) + "\" ");
     }
     if ((Style.Border.Lines & BorderLines.Bottom) > 0)
     {
         Out.Write("fo:border-bottom=\"" +
                   ExportUtils.FloatToString(Style.Border.Width / odfDivider) + "cm " +
                   OdfGetFrameName(Style.Border.Style) + " " +
                   ExportUtils.HTMLColor(Style.Border.Color) + "\" ");
     }
     Out.WriteLine("/>");
     Out.WriteLine("</style:style>");
 }
Example #6
0
 private void HTMLGetStyle(FastString style, Font Font, Color TextColor, Color FillColor, HorzAlign HAlign, VertAlign VAlign,
                           Border Border, Padding Padding, bool RTL, bool wordWrap, float LineHeight, float ParagraphOffset)
 {
     HTMLFontStyle(style, Font, LineHeight);
     style.Append("color:").Append(ExportUtils.HTMLColor(TextColor)).Append(";");
     style.Append("background-color:");
     style.Append(FillColor.A == 0 ? "transparent" : ExportUtils.HTMLColor(FillColor)).Append(";");
     HTMLAlign(style, HAlign, VAlign, wordWrap);
     HTMLBorder(style, Border);
     HTMLPadding(style, Padding, ParagraphOffset);
     HTMLRtl(style, RTL);
     style.AppendLine("}");
 }
Example #7
0
        private string GetXMLFont(ExportIEMStyle style)
        {
            StringBuilder result = new StringBuilder(128);

            result.Append("<Font ss:FontName=\"").Append(style.Font.Name).Append("\" ss:Size=\"").
            Append(ExportUtils.FloatToString(style.Font.Size)).Append("\" ss:Color=\"").
            Append(ExportUtils.HTMLColor(style.TextColor)).Append("\" ").
            Append(((style.Font.Style & FontStyle.Bold) > 0 ? "ss:Bold=\"1\" " : String.Empty)).
            Append(((style.Font.Style & FontStyle.Italic) > 0 ? "ss:Italic=\"1\" " : String.Empty)).
            Append(((style.Font.Style & FontStyle.Underline) > 0 ? "ss:Underline=\"Single\" " : String.Empty)).
            Append("/>");
            return(result.ToString());
        }
Example #8
0
 private void HTMLGetStyle(StringBuilder style, Font Font, Color TextColor, Color FillColor, HorzAlign HAlign, VertAlign VAlign,
                           Border Border, System.Windows.Forms.Padding Padding, bool RTL)
 {
     HTMLFontStyle(style, Font);
     style.Append("color:").Append(ExportUtils.HTMLColor(TextColor)).Append(";");
     style.Append("background-color:");
     style.Append(FillColor == Color.Transparent ? "transparent" : ExportUtils.HTMLColor(FillColor)).Append(";");
     HTMLAlign(style, HAlign, VAlign);
     HTMLBorder(style, Border);
     HTMLPadding(style, Padding);
     HTMLRtl(style, RTL);
     style.AppendLine("}");
 }
Example #9
0
 private void HTMLBorder(FastString BorderDesc, Border border)
 {
     if (!layers)
     {
         BorderDesc.Append("border-collapse: separate;");
     }
     if (border.Lines > 0)
     {
         // bottom
         if ((border.Lines & BorderLines.Bottom) > 0)
         {
             BorderDesc.Append("border-bottom-width:").
             Append(HTMLBorderWidthPx(border.BottomLine)).
             Append("border-bottom-color:").
             Append(ExportUtils.HTMLColor(border.BottomLine.Color)).Append(";border-bottom-style:").
             Append(HTMLBorderStyle(border.BottomLine)).Append(";");
         }
         else
         {
             BorderDesc.Append("border-bottom:none;");
         }
         // top
         if ((border.Lines & BorderLines.Top) > 0)
         {
             BorderDesc.Append("border-top-width:").
             Append(HTMLBorderWidthPx(border.TopLine)).
             Append("border-top-color:").
             Append(ExportUtils.HTMLColor(border.TopLine.Color)).Append(";border-top-style:").
             Append(HTMLBorderStyle(border.TopLine)).Append(";");
         }
         else
         {
             BorderDesc.Append("border-top:none;");
         }
         // left
         if ((border.Lines & BorderLines.Left) > 0)
         {
             BorderDesc.Append("border-left-width:").
             Append(HTMLBorderWidthPx(border.LeftLine)).
             Append("border-left-color:").
             Append(ExportUtils.HTMLColor(border.LeftLine.Color)).Append(";border-left-style:").
             Append(HTMLBorderStyle(border.LeftLine)).Append(";");
         }
         else
         {
             BorderDesc.Append("border-left:none;");
         }
         // right
         if ((border.Lines & BorderLines.Right) > 0)
         {
             BorderDesc.Append("border-right-width:").
             Append(HTMLBorderWidthPx(border.RightLine)).
             Append("border-right-color:").
             Append(ExportUtils.HTMLColor(border.RightLine.Color)).Append(";border-right-style:").
             Append(HTMLBorderStyle(border.RightLine)).Append(";");
         }
         else
         {
             BorderDesc.Append("border-right:none;");
         }
     }
     else
     {
         BorderDesc.Append("border:none;");
     }
 }
        private void ExportHTMLPageLayeredBegin(HTMLData d)
        {
            if (!singlePage && !WebMode)
            {
                cssStyles.Clear();
            }

            css      = new FastString();
            htmlPage = new FastString();

            ReportPage reportPage = d.page;

            if (reportPage != null)
            {
                maxWidth  = ExportUtils.GetPageWidth(reportPage) * Units.Millimeters;
                maxHeight = ExportUtils.GetPageHeight(reportPage) * Units.Millimeters;

                if (enableMargins)
                {
                    leftMargin = reportPage.LeftMargin * Units.Millimeters;
                    topMargin  = reportPage.TopMargin * Units.Millimeters;
                }
                else
                {
                    maxWidth  -= (reportPage.LeftMargin + reportPage.RightMargin) * Units.Millimeters;
                    maxHeight -= (reportPage.TopMargin + reportPage.BottomMargin) * Units.Millimeters;
                    leftMargin = 0;
                    topMargin  = 0;
                }

                currentPage = d.PageNumber - 1;

                ExportHTMLPageStart(htmlPage, d.PageNumber, d.CurrentPage);

                doPageBreak = (singlePage && pageBreaks);

                htmlPage.Append(HTMLGetAncor((d.PageNumber).ToString()));

                htmlPage.Append("<div ").Append(doPageBreak ? "class=\"frpage\"" : String.Empty).
                Append(" style=\"position:relative;width:").Append(Px(maxWidth * Zoom + 3)).
                Append("height:").Append(Px(maxHeight * Zoom));

                if (reportPage.Fill is SolidFill)
                {
                    SolidFill fill = reportPage.Fill as SolidFill;
                    htmlPage.Append("; background-color:").
                    Append(fill.Color.A == 0 ? "transparent" : ExportUtils.HTMLColor(fill.Color));
                }
                htmlPage.Append("\">");

                if (!(reportPage.Fill is SolidFill))
                {
                    // to-do for picture background
                }

                if (reportPage.Watermark.Enabled && !reportPage.Watermark.ShowImageOnTop)
                {
                    Watermark(htmlPage, reportPage, false);
                }

                if (reportPage.Watermark.Enabled && !reportPage.Watermark.ShowTextOnTop)
                {
                    Watermark(htmlPage, reportPage, true);
                }
            }
        }
        private FastString GetSpanText(TextObjectBase obj, FastString text,
                                       float top, float width,
                                       float ParagraphOffset)
        {
            FastString style = new FastString();

            style.Append("display:block;border:0;width:").Append(Px(width * Zoom));
            if (ParagraphOffset != 0)
            {
                style.Append("text-indent:").Append(Px(ParagraphOffset * Zoom));
            }
            if (obj.Padding.Left != 0)
            {
                style.Append("padding-left:").Append(Px((obj.Padding.Left) * Zoom));
            }
            if (obj.Padding.Right != 0)
            {
                style.Append("padding-right:").Append(Px(obj.Padding.Right * Zoom));
            }
            if (top != 0)
            {
                style.Append("margin-top:").Append(Px(top * Zoom));
            }

            // we need to apply border width in order to position our div perfectly
            float borderLeft   = 0;
            float borderRight  = 0;
            float borderTop    = 0;
            float borderBottom = 0;

            if (HTMLBorderWidthValues(obj, out borderLeft, out borderTop, out borderRight, out borderBottom))
            {
                style.Append("position:absolute;")
                .Append("left:").Append(Px(-1 * borderLeft / 2f))
                .Append("top:").Append(Px(-1 * borderTop / 2f));
            }

            string href = String.Empty;

            if (!String.IsNullOrEmpty(obj.Hyperlink.Value))
            {
                string hrefStyle = String.Empty;
                if (obj is TextObject)
                {
                    TextObject textObject = obj as TextObject;
                    hrefStyle = String.Format("style=\"color:{0}{1}\"",
                                              ExportUtils.HTMLColor(textObject.TextColor),
                                              !textObject.Font.Underline ? ";text-decoration:none" : String.Empty
                                              );
                }
                string url = EncodeURL(obj.Hyperlink.Value);
                if (obj.Hyperlink.Kind == HyperlinkKind.URL)
                {
                    href = String.Format("<a {0} href=\"{1}\"" + (obj.Hyperlink.OpenLinkInNewTab ? "target=\"_blank\"" : "") + ">", hrefStyle, obj.Hyperlink.Value);
                }
                else if (obj.Hyperlink.Kind == HyperlinkKind.DetailReport)
                {
                    url = String.Format("{0},{1},{2}",
                                        EncodeURL(obj.Name), // object name for security reasons
                                        EncodeURL(obj.Hyperlink.ReportParameter),
                                        EncodeURL(obj.Hyperlink.Value));
                    string onClick = String.Format(OnClickTemplate, ReportID, "detailed_report", url);
                    href = String.Format("<a {0} href=\"#\" onclick=\"{1}\">", hrefStyle, onClick);
                }
                else if (obj.Hyperlink.Kind == HyperlinkKind.DetailPage)
                {
                    url = String.Format("{0},{1},{2}",
                                        EncodeURL(obj.Name),
                                        EncodeURL(obj.Hyperlink.ReportParameter),
                                        EncodeURL(obj.Hyperlink.Value));
                    string onClick = String.Format(OnClickTemplate, ReportID, "detailed_page", url);
                    href = String.Format("<a {0} href=\"#\" onclick=\"{1}\">", hrefStyle, onClick);
                }
                else if (SinglePage)
                {
                    if (obj.Hyperlink.Kind == HyperlinkKind.Bookmark)
                    {
                        href = String.Format("<a {0} href=\"#{1}\">", hrefStyle, url);
                    }
                    else if (obj.Hyperlink.Kind == HyperlinkKind.PageNumber)
                    {
                        href = String.Format("<a {0} href=\"#PageN{1}\">", hrefStyle, url);
                    }
                }
                else
                {
                    string onClick = String.Empty;
                    if (obj.Hyperlink.Kind == HyperlinkKind.Bookmark)
                    {
                        onClick = String.Format(OnClickTemplate, ReportID, "bookmark", url);
                    }
                    else if (obj.Hyperlink.Kind == HyperlinkKind.PageNumber)
                    {
                        onClick = String.Format(OnClickTemplate, ReportID, "goto", url);
                    }

                    if (onClick != String.Empty)
                    {
                        href = String.Format("<a {0} href=\"#\" onclick=\"{1}\">", hrefStyle, onClick);
                    }
                }
            }

            FastString result = new FastString(128);

            result.Append("<div ").
            Append(GetStyleTag(UpdateCSSTable(style.ToString()))).Append(">").
            Append(href).Append(text).Append(href != String.Empty ? "</a>" : String.Empty).
            Append("</div>");

            return(result);
        }
Example #12
0
        private string GetHref(ReportComponentBase obj)
        {
            string href = String.Empty;

            if (!String.IsNullOrEmpty(obj.Hyperlink.Value))
            {
                string hrefStyle = String.Empty;
                if (obj is TextObject)
                {
                    TextObject textObject = obj as TextObject;
                    hrefStyle = String.Format("style=\"color:{0}{1}\"",
                                              ExportUtils.HTMLColor(textObject.TextColor),
                                              !textObject.Font.Underline ? ";text-decoration:none" : String.Empty
                                              );
                }
                string url = EncodeURL(obj.Hyperlink.Value);
                if (obj.Hyperlink.Kind == HyperlinkKind.URL)
                {
                    href = String.Format("<a {0} href=\"{1}\"" + (obj.Hyperlink.OpenLinkInNewTab ? "target=\"_blank\"" : "") + ">", hrefStyle, obj.Hyperlink.Value);
                }
                else if (obj.Hyperlink.Kind == HyperlinkKind.DetailReport)
                {
                    url = String.Format("{0},{1},{2}",
                                        EncodeURL(obj.Name), // object name for security reasons
                                        EncodeURL(obj.Hyperlink.ReportParameter),
                                        EncodeURL(obj.Hyperlink.Value));
                    string onClick = String.Format(OnClickTemplate, ReportID, "detailed_report", url);
                    href = String.Format("<a {0} href=\"#\" onclick=\"{1}\">", hrefStyle, onClick);
                }
                else if (obj.Hyperlink.Kind == HyperlinkKind.DetailPage)
                {
                    url = String.Format("{0},{1},{2}",
                                        EncodeURL(obj.Name),
                                        EncodeURL(obj.Hyperlink.ReportParameter),
                                        EncodeURL(obj.Hyperlink.Value));
                    string onClick = String.Format(OnClickTemplate, ReportID, "detailed_page", url);
                    href = String.Format("<a {0} href=\"#\" onclick=\"{1}\">", hrefStyle, onClick);
                }
                else if (SinglePage)
                {
                    if (obj.Hyperlink.Kind == HyperlinkKind.Bookmark)
                    {
                        href = String.Format("<a {0} href=\"#{1}\">", hrefStyle, url);
                    }
                    else if (obj.Hyperlink.Kind == HyperlinkKind.PageNumber)
                    {
                        href = String.Format("<a {0} href=\"#PageN{1}\">", hrefStyle, url);
                    }
                }
                else
                {
                    string onClick = String.Empty;
                    if (obj.Hyperlink.Kind == HyperlinkKind.Bookmark)
                    {
                        onClick = String.Format(OnClickTemplate, ReportID, "bookmark", url);
                    }
                    else if (obj.Hyperlink.Kind == HyperlinkKind.PageNumber)
                    {
                        onClick = String.Format(OnClickTemplate, ReportID, "goto", url);
                    }

                    if (onClick != String.Empty)
                    {
                        href = String.Format("<a {0} href=\"#\" onclick=\"{1}\">", hrefStyle, onClick);
                    }
                }
            }
            return(href);
        }
Example #13
0
        private void ExportODF(Stream stream)
        {
            string s;
            int    fx, fy, dx, dy, Page;

            string FTempFolder = Path.GetTempPath() + Path.GetRandomFileName();

            Directory.CreateDirectory(FTempFolder);
            Directory.CreateDirectory(FTempFolder + "\\Pictures");
            Directory.CreateDirectory(FTempFolder + "\\Thumbnails");
            Directory.CreateDirectory(FTempFolder + "\\META-INF");

            int PicCount = 0;

            Page = 0;
            OdfMakeDocStyles(FTempFolder + "\\styles.xml");

            #region Content.xml

            using (FileStream file = new FileStream(FTempFolder + "\\content.xml", FileMode.Create))
                using (StreamWriter Out = new StreamWriter(file))
                {
                    Out.WriteLine("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
                    Out.Write("<office:document-content ");
                    Out.Write(OdfMakeXmlHeader());
                    Out.WriteLine(">");
                    Out.WriteLine("<office:scripts/>");
                    ExportIEMStyle Style;
                    OdfFontFaceDecals(Out);
                    Out.WriteLine("<office:automatic-styles>");
                    OdfColumnStyles(Out);
                    OdfRowStyles(Out);

                    for (int i = 0; i < FMatrix.StylesCount; i++)
                    {
                        Style = FMatrix.StyleById(i);
                        Out.WriteLine("<style:style style:name=\"ce" + i.ToString() + "\" " +
                                      "style:family=\"table-cell\" style:parent-style-name=\"Default\">");
                        if (FExportType == 0)
                        {
                            Out.Write("<style:text-properties style:font-name=\"" + Style.Font.Name + "\" " +
                                      "fo:font-size=\"" + ExportUtils.FloatToString(Style.Font.Size) + "pt\" ");
                            if ((Style.Font.Style & FontStyle.Underline) > 0)
                            {
                                Out.Write("style:text-underline-style=\"solid\" " +
                                          "style:text-underline-width=\"auto\" " +
                                          "style:text-underline-color=\"font-color\" ");
                            }
                            if ((Style.Font.Style & FontStyle.Italic) > 0)
                            {
                                Out.Write("fo:font-style=\"italic\" ");
                            }
                            if ((Style.Font.Style & FontStyle.Bold) > 0)
                            {
                                Out.Write("fo:font-weight=\"bold\" ");
                            }
                            Out.Write("fo:color=\"" + ExportUtils.HTMLColor(Style.TextColor) + "\"");
                            Out.WriteLine("/>");

                            Out.Write("<style:paragraph-properties ");
                            if (Style.HAlign == HorzAlign.Left)
                            {
                                Out.Write("fo:text-align=\"start\" ");
                            }
                            if (Style.HAlign == HorzAlign.Center)
                            {
                                Out.Write("fo:text-align=\"center\" ");
                            }
                            if (Style.HAlign == HorzAlign.Right)
                            {
                                Out.Write("fo:text-align=\"end\" ");
                            }
                            if (Style.Padding.Left > 0)
                            {
                                Out.Write("fo:margin-left=\"" +
                                          ExportUtils.FloatToString(Style.Padding.Left / odfDivider) + "cm\" ");
                            }
                            if (Style.Padding.Right > 0)
                            {
                                Out.Write("fo:margin-right=\"" +
                                          ExportUtils.FloatToString(Style.Padding.Right / odfDivider) + "cm\" ");
                            }
                            if (Style.Padding.Top > 0)
                            {
                                Out.Write("fo:margin-top=\"" +
                                          ExportUtils.FloatToString(Style.Padding.Top / odfDivider) + "cm\" ");
                            }
                            if (Style.Padding.Bottom > 0)
                            {
                                Out.Write("fo:margin-bottom=\"" +
                                          ExportUtils.FloatToString(Style.Padding.Bottom / odfDivider) + "cm\" ");
                            }
                            Out.WriteLine("/>");
                        }
                        OdfTableCellStyles(Style, Out);
                    }

                    if (FExportType == 1)
                    {
                        Out.WriteLine("<style:style style:name=\"pb\" " +
                                      "style:family=\"paragraph\" style:display=\"false\"/>");
                        for (int i = 0; i < FMatrix.StylesCount; i++)
                        {
                            Style = FMatrix.StyleById(i);
                            Out.WriteLine("<style:style style:name=\"p" + i.ToString() + "\" " +
                                          "style:family=\"paragraph\" style:parent-style-name=\"Default\">");

                            Out.Write("<style:text-properties style:font-name=\"" +
                                      Style.Font.Name + "\" fo:font-size=\"" +
                                      ExportUtils.FloatToString(Style.Font.Size) + "pt\" ");
                            if ((Style.Font.Style & FontStyle.Underline) > 0)
                            {
                                Out.Write(" style:text-underline-style=\"solid\" " +
                                          "style:text-underline-width=\"auto\" " +
                                          "style:text-underline-color=\"font-color\" ");
                            }
                            if ((Style.Font.Style & FontStyle.Italic) > 0)
                            {
                                Out.Write(" style:font-style=\"italic\" ");
                            }
                            if ((Style.Font.Style & FontStyle.Bold) > 0)
                            {
                                Out.Write(" style:font-weight=\"bold\" ");
                            }
                            Out.WriteLine(" fo:color=\"" +
                                          ExportUtils.HTMLColor(Style.TextColor) + "\"/>");

                            Out.Write("<style:paragraph-properties ");
                            if (Style.HAlign == HorzAlign.Left)
                            {
                                Out.Write("fo:text-align=\"start\" ");
                            }
                            if (Style.HAlign == HorzAlign.Center)
                            {
                                Out.Write("fo:text-align=\"center\" ");
                            }
                            if (Style.HAlign == HorzAlign.Right)
                            {
                                Out.Write("fo:text-align=\"end\" ");
                            }
                            if (Style.Padding.Left > 0)
                            {
                                Out.Write("fo:margin-left=\"" +
                                          ExportUtils.FloatToString(Style.Padding.Left / odfDivider) + "cm\" ");
                            }
                            if (Style.Padding.Right > 0)
                            {
                                Out.Write("fo:margin-right=\"" +
                                          ExportUtils.FloatToString(Style.Padding.Right / odfDivider) + "cm\" ");
                            }
                            if (Style.Padding.Top > 0)
                            {
                                Out.Write("fo:margin-top=\"" +
                                          ExportUtils.FloatToString(Style.Padding.Top / odfDivider) + "cm\" ");
                            }
                            if (Style.Padding.Bottom > 0)
                            {
                                Out.Write("fo:margin-bottom=\"" +
                                          ExportUtils.FloatToString(Style.Padding.Bottom / odfDivider) + "cm\" ");
                            }
                            Out.WriteLine("/>");
                            Out.WriteLine("</style:style>");
                        }
                    }

                    Out.WriteLine("<style:style style:name=\"gr1\" style:family=\"graphic\">");
                    Out.WriteLine("<style:graphic-properties draw:stroke=\"none\" " +
                                  "draw:fill=\"none\" draw:textarea-horizontal-align=\"left\" " +
                                  "draw:textarea-vertical-align=\"top\" draw:color-mode=\"standard\" " +
                                  "draw:luminance=\"0%\" draw:contrast=\"0%\" draw:gamma=\"100%\" " +
                                  "draw:red=\"0%\" draw:green=\"0%\" draw:blue=\"0%\" " +
                                  "fo:clip=\"rect(0cm 0cm 0cm 0cm)\" draw:image-opacity=\"100%\" " +
                                  "style:mirror=\"none\"/>");
                    Out.WriteLine("</style:style>");

                    Out.WriteLine("</office:automatic-styles>");

                    // body
                    Out.WriteLine("<office:body>");
                    Out.WriteLine("<office:spreadsheet>");
                    Out.WriteLine("<table:table table:name=\"Table\" table:style-name=\"ta1\" table:print=\"false\">");

                    for (int x = 1; x < FMatrix.Width; x++)
                    {
                        Out.WriteLine("<table:table-column table:style-name=\"co" +
                                      ExportUtils.FloatToString((FMatrix.XPosById(x) -
                                                                 FMatrix.XPosById(x - 1)) / odfDivider) + "\"/>");
                    }

                    for (int y = 0; y < FMatrix.Height - 1; y++)
                    {
                        Out.WriteLine("<table:table-row table:style-name=\"ro" +
                                      ExportUtils.FloatToString((FMatrix.YPosById(y + 1) -
                                                                 FMatrix.YPosById(y)) / odfDivider) + "\">");
                        if (FMatrix.YPosById(y) >= FMatrix.PageBreak(Page))
                        {
                            Page++;
                            if (FPageBreaks)
                            {
                                Out.WriteLine("<table:table-row table:style-name=\"ro_breaked\"/>");
                            }
                        }
                        for (int x = 0; x < FMatrix.Width; x++)
                        {
                            int i = FMatrix.Cell(x, y);
                            if (i != -1)
                            {
                                ExportIEMObject Obj = FMatrix.ObjectById(i);
                                if (Obj.Counter == 0)
                                {
                                    Obj.Counter = 1;
                                    FMatrix.ObjectPos(i, out fx, out fy, out dx, out dy);

                                    Out.Write("<table:table-cell table:style-name=\"ce" +
                                              Obj.StyleIndex.ToString() + "\" ");
                                    if (dx > 1)
                                    {
                                        Out.Write("table:number-columns-spanned=\"" + dx.ToString() + "\" ");
                                    }
                                    if (dy > 1)
                                    {
                                        Out.Write("table:number-rows-spanned=\"" + dy.ToString() + "\" ");
                                    }
                                    Out.WriteLine(">");
                                    if (Obj.IsText)
                                    {
                                        s = ExportUtils.XmlString(Obj.Text, Obj.HtmlTags);
                                        Out.Write("<text:p");
                                        if (FExportType == 1)
                                        {
                                            Out.Write(" text:style-name=\"p" + Obj.StyleIndex.ToString() + "\"");
                                        }
                                        Out.WriteLine(">" + s + "</text:p>");
                                    }
                                    else
                                    {
                                        if (Obj.Width > 0)
                                        {
                                            PicCount++;
                                            if (Config.FullTrust)
                                            {
                                                using (FileStream emfFile = new FileStream(FTempFolder + "\\Pictures\\pic" + PicCount.ToString() + ".emf", FileMode.Create))
                                                    emfFile.Write(Obj.PictureStream.ToArray(), 0, (int)Obj.PictureStream.Length);
                                            }
                                            else
                                            {
                                                using (FileStream pngFile = new FileStream(FTempFolder + "\\Pictures\\pic" + PicCount.ToString() + ".png", FileMode.Create))
                                                    pngFile.Write(Obj.PictureStream.ToArray(), 0, (int)Obj.PictureStream.Length);
                                            }
                                            if (FExportType == 1)
                                            {
                                                Out.WriteLine("<text:p>");
                                            }
                                            // need for fix of vertical position
                                            Out.WriteLine("<draw:frame draw:z-index=\"" + (PicCount - 1).ToString() + "\" " +
                                                          "draw:name=\"Pictures" + PicCount.ToString() + "\" " +
                                                          "draw:style-name=\"gr1\" " +
                                                          "draw:text-style-name=\"P1\" " +
                                                          "svg:width=\"" + ExportUtils.FloatToString(Obj.Width / odfDivider) + "cm\" " +
                                                          "svg:height=\"" + ExportUtils.FloatToString(Obj.Height / odfDivider) + "cm\" " +
                                                          "svg:x=\"0cm\" svg:y=\"0cm\">");
                                            s = Config.FullTrust ? ".emf" : ".png";
                                            Out.WriteLine("<draw:image " +
                                                          "xlink:href=\"Pictures/pic" + PicCount.ToString() + s + "\" " +
                                                          "text:anchor-type=\"frame\" xlink:type=\"simple\" xlink:show=\"embed\" xlink:actuate=\"onLoad\"/>");
                                            Out.WriteLine("</draw:frame>");
                                            if (FExportType == 1)
                                            {
                                                Out.WriteLine("</text:p>");
                                            }
                                        }
                                    }
                                    Out.WriteLine("</table:table-cell>");
                                }
                                else
                                {
                                    Out.Write("<table:covered-table-cell table:style-name=\"ceb\"");
                                    if (FExportType == 1)
                                    {
                                        Out.WriteLine("><text:p text:style-name=\"pb\"/></table:covered-table-cell>");
                                    }
                                    else
                                    {
                                        Out.WriteLine("/>");
                                    }
                                }
                            }
                            else
                            {
                                Out.Write("<table:table-cell");
                                if (FExportType == 1)
                                {
                                    Out.WriteLine("><text:p text:style-name=\"pb\"/></table:table-cell>");
                                }
                                else
                                {
                                    Out.WriteLine("/>");
                                }
                            }
                        }
                        Out.WriteLine("</table:table-row>");
                    }
                    Out.WriteLine("</table:table>");
                    Out.WriteLine("</office:spreadsheet>");
                    Out.WriteLine("</office:body>");
                    Out.WriteLine("</office:document-content>");
                }
            #endregion

            string ExportMime = FExportType == 0 ? "spreadsheet" : "text";
            OdfCreateManifest(FTempFolder + "\\META-INF\\manifest.xml", PicCount, ExportMime);
            OdfCreateMime(FTempFolder + "\\mimetype", ExportMime);
            OdfCreateMeta(FTempFolder + "\\meta.xml", Creator);

            ZipArchive zip = new ZipArchive();
            zip.AddDir(FTempFolder);
            zip.SaveToStream(Stream);
            Directory.Delete(FTempFolder, true);
        }
Example #14
0
        private string GetStyle(Font Font, Color TextColor, Color FillColor, bool RTL, HorzAlign HAlign, Border Border)
        {
            StringBuilder style = new StringBuilder(512);

            if (Font != null)
            {
                if (Zoom != 1)
                {
                    Font newFont = new Font(Font.FontFamily, Font.Size * Zoom, Font.Style, Font.Unit, Font.GdiCharSet, Font.GdiVerticalFont);
                    HTMLFontStyle(style, newFont);
                }
                else
                {
                    HTMLFontStyle(style, Font);
                }
            }

            style.Append("text-align:");
            if (HAlign == HorzAlign.Left)
            {
                style.Append(RTL ? "right" : "left");
            }
            else if (HAlign == HorzAlign.Right)
            {
                style.Append(RTL ? "left" : "right");
            }
            else if (HAlign == HorzAlign.Center)
            {
                style.Append("center");
            }
            else
            {
                style.Append("justify");
            }
            style.Append(";");

            style.Append(
                String.Join(String.Empty, new String[] {
                "position:absolute;overflow:hidden;color:",
                ExportUtils.HTMLColor(TextColor),
                ";background-color:",
                FillColor == Color.Transparent ? "transparent" : ExportUtils.HTMLColor(FillColor), ";",
                RTL ? "direction:rtl;" : String.Empty
            }));

            Border newBorder = Border; //.Clone();

            newBorder.LeftLine.Width *= Zoom;
            if (newBorder.LeftLine.Width > 0 && newBorder.LeftLine.Width < 1)
            {
                newBorder.LeftLine.Width = 1;
            }

            newBorder.RightLine.Width *= Zoom;
            if (newBorder.RightLine.Width > 0 && newBorder.RightLine.Width < 1)
            {
                newBorder.RightLine.Width = 1;
            }

            newBorder.TopLine.Width *= Zoom;
            if (newBorder.TopLine.Width > 0 && newBorder.TopLine.Width < 1)
            {
                newBorder.TopLine.Width = 1;
            }

            newBorder.BottomLine.Width *= Zoom;
            if (newBorder.BottomLine.Width > 0 && newBorder.BottomLine.Width < 1)
            {
                newBorder.BottomLine.Width = 1;
            }

            HTMLBorder(style, newBorder);

            return(style.ToString());
        }