public void ContentStyle_ToString_wraps_style_url_in_html_tag_if_no_html_set()
        {
            // Arrange
            const string styleUrl = "http://wwww.google.com/styles.css";
            var contentStyle = new ContentStyle { Url = new Uri(styleUrl) };

            // Act
            var html = contentStyle.ToString();

            // Assert
            Assert.That(html, Is.StringContaining(styleUrl));
            Assert.That(html, Is.StringContaining("<style"));
        }
        public void ContentStyle_ToString_returns_empty_string_if_no_html_or_url_set()
        {
            // Arrange
            var contentStyle = new ContentStyle();

            // Act
            var html = contentStyle.ToString();

            // Assert
            Assert.That(html, Is.Empty);
        }
 public WordRepeatSectionDef(DataSet dataSet, ContentStyle style)
 {
     Datas = dataSet;
     Style = style;
 }
        public void ContentStyle_ToString_returns_html_if_set()
        {
            // Arrange
            const string styleHtml = "<style type=\"text/css\">.my-class { background: none; }</style>";
            var contentStyle = new ContentStyle { Html = styleHtml };

            // Act
            var html = contentStyle.ToString();

            // Assert
            Assert.That(html, Is.EqualTo(styleHtml));
        }
Example #5
0
 public ContentNode(ContentStyle style) : this()
 {
     SetStyle(style);
 }
Example #6
0
        private void SeedHomePage(string homePageId)
        {
            // init version & content tree
            var publishedVersion = new ContentVersion
            {
                ContentId    = homePageId,
                ContentType  = HtmlDbSeedConstants.ContentType_SitePage,
                VersionLabel = "Master Page Content Added",
                UserId       = "admin",
                Status       = ContentStatus.Published,
            };

            var contentTree = new ContentTree(publishedVersion);

            _dbContext.ContentVersions.Add(publishedVersion);
            _dbContext.ContentTrees.Add(contentTree);


            // styles
            var topImageStyle = new ContentStyle
            {
                FullWidth       = true,
                BackgroundClass = SiteTemplateConstants.Backgrounds.Default,
            };

            var topGridStyle = new ContentStyle
            {
                BackgroundClass = SiteTemplateConstants.Backgrounds.Default,
                PaddingTop      = SiteTemplateConstants.RootContentPaddingTop,
                PaddingBottom   = SiteTemplateConstants.RootContentPaddingBottom
            };

            var heroUnitStyle = new ContentStyle
            {
                BackgroundClass = SiteTemplateConstants.Backgrounds.Fancy,
                PaddingTop      = SiteTemplateConstants.RootContentPaddingTop,
                PaddingBottom   = SiteTemplateConstants.RootContentPaddingBottom
            };

            var bottomGridStyle = new ContentStyle
            {
                BackgroundClass = SiteTemplateConstants.Backgrounds.Contrast,
                PaddingTop      = SiteTemplateConstants.RootContentPaddingTop,
                PaddingBottom   = SiteTemplateConstants.RootContentPaddingBottom
            };


            // content nodes
            var homePageContentNodes = new ContentNode[]
            {
                // full width zone with image
                new ContentNode(topImageStyle)
                {
                    Id            = Guid.NewGuid().ToString(),
                    ContentTreeId = contentTree.Id,
                    Zone          = "body",
                    Index         = 0,
                    WidgetId      = HtmlDbSeedConstants.WidgetId_Image_GuidanceImageMain,
                    WidgetType    = "image",
                    ViewId        = "image-fitted",
                    Locked        = false,
                },

                // Hero Unit
                new ContentNode(heroUnitStyle)
                {
                    Id            = Guid.NewGuid().ToString(),
                    ContentTreeId = contentTree.Id,
                    ParentId      = null,
                    Zone          = "body",
                    Index         = 1,
                    WidgetId      = null,
                    WidgetType    = "zone",
                    ViewId        = "zone-1",
                    Locked        = false,

                    ChildNodes = new ContentNode[]
                    {
                        new ContentNode
                        {
                            Id            = Guid.NewGuid().ToString(),
                            ContentTreeId = contentTree.Id,
                            Zone          = "cell-1",
                            Index         = 1,
                            WidgetId      = HtmlDbSeedConstants.WidgetId_Hero_GuidanceWelcome,
                            WidgetType    = "hero",
                            ViewId        = "hero-hero1",
                            Locked        = false,
                        }
                    }
                },

                // 4 images in a grid
                new ContentNode(topGridStyle)
                {
                    Id            = Guid.NewGuid().ToString(),
                    ContentTreeId = contentTree.Id,
                    ParentId      = null,
                    Zone          = "body",
                    Index         = 2,
                    WidgetId      = null,
                    WidgetType    = "zone",
                    ViewId        = "zone-3",
                    Locked        = false,

                    ChildNodes = new ContentNode[]
                    {
                        new ContentNode
                        {
                            Id            = Guid.NewGuid().ToString(),
                            ContentTreeId = contentTree.Id,
                            Zone          = "cell-1",
                            Index         = 0,
                            WidgetId      = HtmlDbSeedConstants.WidgetId_Image_GuidanceImage1,
                            WidgetType    = "image",
                            ViewId        = "image-fitted",
                            Locked        = false
                        },
                        new ContentNode
                        {
                            Id            = Guid.NewGuid().ToString(),
                            ContentTreeId = contentTree.Id,
                            Zone          = "cell-2",
                            Index         = 1,
                            WidgetId      = HtmlDbSeedConstants.WidgetId_Image_GuidanceImage2,
                            WidgetType    = "image",
                            ViewId        = "image-fitted",
                            Locked        = false
                        },
                        new ContentNode
                        {
                            Id            = Guid.NewGuid().ToString(),
                            ContentTreeId = contentTree.Id,
                            Zone          = "cell-3",
                            Index         = 2,
                            WidgetId      = HtmlDbSeedConstants.WidgetId_Image_GuidanceImage3,
                            WidgetType    = "image",
                            ViewId        = "image-fitted",
                            Locked        = false
                        }
                    }
                },
            };


            _dbContext.ContentNodes.AddRange(homePageContentNodes);
            _dbContext.SaveChanges();
        }
Example #7
0
 public ContentRow(string szContent = "") : base(szContent)
 {
     Style = ContentStyle.Normal;
 }
Example #8
0
 public void SetStyle(ContentStyle style)
 {
     _style = style;
 }
Example #9
0
 public WordDocBuilder(WordDocDef def)
 {
     Def    = def;
     _style = new ContentStyle(def.Style);
 }
Example #10
0
 private void SetStyle(ContentStyle style)
 {
     _style = style;
 }
Example #11
0
        private void AssignStyle(CellStyle cellStyle, ContentStyle style)
        {
            if (style.HasFontName() || style.HasFontStyle() || style.HasFontDSize() || style.HasFontColor())
            {
                var font = GetFont(style); //Workbook.CreateFont();  // cellStyle.GetFont(Workbook);

                if (style.HasFontName())
                {
                    font.FontName = style.FontName;
                }
                if (style.HasFontDSize())
                {
                    font.FontHeightInPoints += style.FontDSize;
                }
                if (style.HasFontStyle())
                {
                    if (style.FontStyle.HasFlag(FontStyle.Bold))
                    {
                        font.Boldweight = (short)FontBoldWeight.BOLD;
                    }
                    else
                    {
                        font.Boldweight = (short)FontBoldWeight.NORMAL;
                    }
                    font.IsItalic  = style.FontStyle.HasFlag(FontStyle.Italic);
                    font.Underline = style.FontStyle.HasFlag(FontStyle.Underline)
                                         ? (byte)FontUnderlineType.SINGLE
                                         : (byte)FontUnderlineType.NONE;
                }
                if (style.HasFontColor())
                {
                    font.Color = style.FontColor;
                }

                cellStyle.SetFont(font);
            }
            if (style.HasBgColor())
            {
                cellStyle.FillForegroundColor = style.BgColor;
                cellStyle.FillPattern         = FillPatternType.SOLID_FOREGROUND;
            }
            switch (style.HAlign)
            {
            case HAlignment.Left:
                cellStyle.Alignment = HorizontalAlignment.LEFT;
                break;

            case HAlignment.Right:
                cellStyle.Alignment = HorizontalAlignment.RIGHT;
                break;

            case HAlignment.Center:
                cellStyle.Alignment = HorizontalAlignment.CENTER;
                break;
            }
            switch (style.VAlign)
            {
            case VAlignment.Top:
                cellStyle.VerticalAlignment = VerticalAlignment.TOP;
                break;

            case VAlignment.Bottom:
                cellStyle.VerticalAlignment = VerticalAlignment.BOTTOM;
                break;

            case VAlignment.Middle:
                cellStyle.VerticalAlignment = VerticalAlignment.CENTER;
                break;
            }

            if (style.Borders.HasFlag(TableCellBorder.Top) /* ?? false*/)
            {
                cellStyle.BorderTop      = CellBorderType.THIN;
                cellStyle.TopBorderColor = style.BorderColor; //HSSFColor.BLACK.index;
            }
            else
            {
                cellStyle.BorderTop = CellBorderType.NONE;
            }

            if (style.Borders.HasFlag(TableCellBorder.Left))
            {
                cellStyle.BorderLeft      = CellBorderType.THIN;
                cellStyle.LeftBorderColor = style.BorderColor; //HSSFColor.BLACK.index;
            }
            else
            {
                cellStyle.BorderLeft = CellBorderType.NONE;
            }

            if (style.Borders.HasFlag(TableCellBorder.Right))
            {
                cellStyle.BorderRight      = CellBorderType.THIN;
                cellStyle.RightBorderColor = style.BorderColor; //HSSFColor.BLACK.index;
            }
            else
            {
                cellStyle.BorderRight = CellBorderType.NONE;
            }

            if (style.Borders.HasFlag(TableCellBorder.Bottom))
            {
                cellStyle.BorderBottom      = CellBorderType.THIN;
                cellStyle.BottomBorderColor = style.BorderColor; //HSSFColor.BLACK.index;
            }
            else
            {
                cellStyle.BorderBottom = CellBorderType.NONE;
            }

            if (style.WrapText ?? false)
            {
                cellStyle.WrapText = (bool)style.WrapText;
            }
        }
Example #12
0
        private Font GetFont(ContentStyle style)
        {
            var curFont = Workbook.GetFontAt(0);

            for (short i = 1; i < Workbook.NumberOfFonts; i++)
            {
                var font = Workbook.GetFontAt(i);

                if (style.HasFontName())
                {
                    if (!String.Equals(font.FontName, style.FontName, StringComparison.OrdinalIgnoreCase))
                    {
                        continue;
                    }
                }
                else
                if (!String.Equals(font.FontName, curFont.FontName, StringComparison.OrdinalIgnoreCase))
                {
                    continue;
                }

                if (style.HasFontStyle())
                {
                    if (style.FontStyle.HasFlag(FontStyle.Italic) && !font.IsItalic)
                    {
                        continue;
                    }
                    if (style.FontStyle.HasFlag(FontStyle.Bold) && font.Boldweight != (short)FontBoldWeight.BOLD)
                    {
                        continue;
                    }
                    if (style.FontStyle.HasFlag(FontStyle.Underline) && font.Underline != (byte)FontUnderlineType.SINGLE)
                    {
                        continue;
                    }
                    if (style.FontStyle == FontStyle.Regular &&
                        (font.IsItalic || font.Boldweight != (short)FontBoldWeight.NORMAL || font.Underline != (byte)FontUnderlineType.NONE))
                    {
                        continue;
                    }
                }
                if (style.FontDSize == 0 && curFont.FontHeightInPoints != font.FontHeightInPoints)
                {
                    continue;
                }
                if (style.FontDSize != 0)
                {
                    var fs = curFont.FontHeightInPoints + style.FontDSize;
                    if (font.FontHeightInPoints != fs)
                    {
                        continue;
                    }
                }
                if (style.HasFontColor() && style.FontColor != font.Color)
                {
                    continue;
                }

                return(font);
            }
            return(Workbook.CreateFont());
        }
Example #13
0
 public WordParagraphDef(SqlQueryDataSet dataSet, string name, ContentStyle style = null, string format = null)
 {
     AddDataField(dataSet, name, style, format);
 }
Example #14
0
 public WordParagraphDef(DataSetField field, ContentStyle style = null, string format = null)
 {
     AddDataField(field, style, format);
 }
Example #15
0
 public WordParagraphDef(string text, ContentStyle style = null)
 {
     AddText(text, style);
 }