Esempio n. 1
0
        public static float GetBorderWidth(IPropertyContainer element)
        {
            Border border      = element.GetProperty <Border>(Property.BORDER);
            Border rightBorder = element.GetProperty <Border>(Property.BORDER_RIGHT);
            Border leftBorder  = element.GetProperty <Border>(Property.BORDER_LEFT);

            if (!element.HasOwnProperty(Property.BORDER_RIGHT))
            {
                rightBorder = border;
            }
            if (!element.HasOwnProperty(Property.BORDER_LEFT))
            {
                leftBorder = border;
            }
            float rightBorderWidth = rightBorder != null?rightBorder.GetWidth() : 0;

            float leftBorderWidth = leftBorder != null?leftBorder.GetWidth() : 0;

            return(rightBorderWidth + leftBorderWidth);
        }
Esempio n. 2
0
        /// <summary>Sets properties to top-level layout elements converted from HTML.</summary>
        /// <remarks>
        /// Sets properties to top-level layout elements converted from HTML.
        /// This enables features set by user via HTML converter API and also changes properties defaults
        /// to the ones specific to HTML-like behavior.
        /// </remarks>
        /// <param name="cssProperties">HTML document-level css properties.</param>
        /// <param name="context">processor context specific to the current HTML conversion.</param>
        /// <param name="propertyContainer">top-level layout element converted from HTML.</param>
        public static void SetConvertedRootElementProperties(IDictionary <String, String> cssProperties, ProcessorContext
                                                             context, IPropertyContainer propertyContainer)
        {
            propertyContainer.SetProperty(Property.COLLAPSING_MARGINS, true);
            propertyContainer.SetProperty(Property.RENDERING_MODE, RenderingMode.HTML_MODE);
            propertyContainer.SetProperty(Property.FONT_PROVIDER, context.GetFontProvider());
            if (context.GetTempFonts() != null)
            {
                propertyContainer.SetProperty(Property.FONT_SET, context.GetTempFonts());
            }
            // TODO DEVSIX-2534
            IList <String> fontFamilies = FontFamilySplitter.SplitFontFamily(cssProperties.Get(CssConstants.FONT_FAMILY
                                                                                               ));

            if (fontFamilies != null && !propertyContainer.HasOwnProperty(Property.FONT))
            {
                propertyContainer.SetProperty(Property.FONT, fontFamilies.ToArray(new String[0]));
            }
        }