Ejemplo n.º 1
0
        /// <summary>Loads this counter systems symbols.</summary>
        protected override void LoadSymbols(Css.Style style)
        {
            // Get a set:
            Css.Value set=style[Css.Properties.AdditiveSymbols.GlobalProperty];

            if(set==null){
                return;
            }

            Symbols=new AdditiveTuple[set.Count];

            for(int i=0;i<Symbols.Length;i++){

                // Get both values:
                Css.Value a=set[i][0];
                Css.Value b=set[i][1];

                // Allow them to be defined either way around:
                int weight;
                string symbol;

                if(b is Css.Units.DecimalUnit){
                    weight=b.GetInteger(null,null);
                    symbol=a.Text;
                }else{
                    weight=a.GetInteger(null,null);
                    symbol=b.Text;
                }

                Symbols[i]=new AdditiveTuple(symbol,weight);

            }
        }
Ejemplo n.º 2
0
        public override void load(JSObject json)
        {
            // Get the selector (may be null):
            selector = json.String("selector");

            if (selector != null)
            {
                selector = selector.Trim();

                // Global selector?
                string globalSelector = json.String("global");

                global = (globalSelector != null && globalSelector == "true");

                if (selector == "")
                {
                    selector = null;
                }
            }

            // Get the style and/or animation:
            string style = json.String("style");

            if (style != null)
            {
                style = style.Trim();
            }

            string anim = json.String("animation");

            if (!string.IsNullOrEmpty(anim))
            {
                // Shortform:
                if (style == null)
                {
                    style = "";
                }
                else if (style != "")
                {
                    style += ";";
                }

                // Set name:
                style += "animation-name:" + anim;
            }

            if (style != null)
            {
                // Load the style:
                styleToApply = new Css.Style(style, null);
            }
            else
            {
                Dom.Log.Add("PowerSlide Style slide with no style in it!");
            }

            base.load(json);
        }
Ejemplo n.º 3
0
        /// <summary>Loads this counter systems symbols.</summary>
        protected override void LoadSymbols(Css.Style style)
        {
            string[] symbols=SymbolSet(style);

            if(Symbols!=null && symbols==null){
                return;
            }

            Symbols=symbols;
        }
        public override int RemapIndex(Css.Style style)
        {
            // Only remap if we've got a CS:
            ComputedStyle cs = style as ComputedStyle;

            if (cs == null)
            {
                return(LogicalIndex);
            }

            // Get the mapping (typically pulls a cached version):
            int[] mapping = Css.Properties.SparkWritingSystem.GlobalProperty.RequireMap(cs);

            // Map the index:
            return(mapping[LogicalIndex]);
        }
Ejemplo n.º 5
0
        /// <summary>Builds a string symbol set from the given 'symbols' value.</summary>
        public string[] SymbolSet(Css.Style style)
        {
            // Symbols:
            Css.Value value=style[Css.Properties.Symbols.GlobalProperty];

            if(value==null){
                return null;
            }

            string[] set=new string[value.Count];

            for(int i=0;i<value.Count;i++){
                set[i]=value[i].Text;
            }

            return set;
        }
Ejemplo n.º 6
0
        /// <summary>Loads this systems values from the given style.</summary>
        public void Load(Css.Style style, Css.ReflowDocument document)
        {
            // Get the range:
            Css.Value range = style[Css.Properties.RangeProperty.GlobalProperty];

            if (range != null && !range.IsAuto)
            {
                Css.ValueSet rangeSet = range as Css.ValueSet;

                int rangeSize = (rangeSet != null && rangeSet.Spacer == ",")?range.Count : 1;

                if (rangeSize > 1)
                {
                    AdditionalRanges = new CounterRange[rangeSize];

                    int overallMin = 0;
                    int overallMax = 0;

                    // For each one..
                    for (int i = 0; i < rangeSize; i++)
                    {
                        int min = range[i][0].GetInteger(null, null);
                        int max = range[i][1].GetInteger(null, null);

                        if (i == 0)
                        {
                            overallMin = min;
                            overallMax = max;
                        }
                        else
                        {
                            if (min < overallMin)
                            {
                                overallMin = min;
                            }

                            if (max > overallMax)
                            {
                                overallMax = max;
                            }
                        }

                        AdditionalRanges[i] = new CounterRange(min, max);
                    }

                    Min = overallMin;
                    Max = overallMax;
                }
                else
                {
                    AdditionalRanges = null;

                    // Set min/max:
                    Min = range[0].GetInteger(null, null);
                    Max = range[1].GetInteger(null, null);
                }
            }

            // Get the pad:
            Css.Value pad = style[Css.Properties.Pad.GlobalProperty];

            if (pad != null)
            {
                PadMin = pad[0].GetInteger(null, null);

                if (pad is Css.ValueSet)
                {
                    PadSymbol = pad[1].Text;
                }
                else
                {
                    PadSymbol = "";
                }
            }

            // Prefix:
            Css.Value prefix = style[Css.Properties.Prefix.GlobalProperty];

            if (prefix != null)
            {
                Prefix = prefix.Text;
            }

            // Suffix:
            Css.Value suffix = style[Css.Properties.Suffix.GlobalProperty];

            if (suffix != null)
            {
                Suffix = suffix.Text;
            }

            // Negative:
            Css.Value negative = style[Css.Properties.Negative.GlobalProperty];

            if (negative != null)
            {
                NegativePrefix = negative[0].Text;

                if (negative is Css.ValueSet)
                {
                    NegativeSuffix = negative[1].Text;
                }
                else
                {
                    NegativeSuffix = "";
                }
            }

            // Symbols:
            LoadSymbols(style);

            // Fallback:
            Css.Value fallback = style[Css.Properties.Fallback.GlobalProperty];

            if (fallback != null)
            {
                string fbName = fallback[0].Text;

                if (fbName == "none" || fbName == "decimal")
                {
                    fbName = null;
                }

                if (fbName != null)
                {
                    // Get by built in name:
                    Fallback = Counters.CounterSystems.Get(fbName);

                    if (Fallback == null)
                    {
                        // Get by doc name:
                        CounterStyleRule rule;
                        if (document.CssCounters.TryGetValue(fbName, out rule))
                        {
                            // Get the system:
                            Fallback = rule.System;
                        }
                    }
                }

                if (Fallback == null)
                {
                    // Default to decimal system:
                    Fallback = CounterSystems.Decimal;
                }
            }
        }
Ejemplo n.º 7
0
 /// <summary>Loads this counter systems symbols.</summary>
 protected virtual void LoadSymbols(Css.Style style)
 {
 }
Ejemplo n.º 8
0
 /// <summary>Loads this counter systems symbols.</summary>
 protected override void LoadSymbols(Css.Style style)
 {
     Symbols = SymbolSet(style);
 }
Ejemplo n.º 9
0
 /// <summary>Used to map a logical index to a physical one.</summary>
 public virtual int RemapIndex(Css.Style style)
 {
     return(0);
 }
Ejemplo n.º 10
0
        /// <summary>Gets the most suitable mapping to use for the given computed style.</summary>
        public int[] GetMap(Css.Style style)
        {
            // 1. Pull orientation and writing mode:
            Css.Units.IntegerUnit orientationValue = style[Css.Properties.TextOrientation.GlobalProperty] as Css.Units.IntegerUnit;
            Css.Units.IntegerUnit writingModeValue = style[Css.Properties.WritingMode.GlobalProperty] as Css.Units.IntegerUnit;

            bool ltr         = true;
            int  writingMode = Css.WritingMode.HorizontalTB; // horizontal-tb
            int  orientation = 0;                            // Mixed by default.

            // Got orient/ writing mode values?
            if (orientationValue != null)
            {
                orientation = (int)orientationValue.RawValue;
            }

            if (writingModeValue != null)
            {
                writingMode = (int)writingModeValue.RawValue;
            }

            // Set to upright?
            if (orientation != TextOrientationMode.Upright)
            {
                // Always forces LTR otherwise.

                Css.Value dirValue = style[Css.Properties.Direction.GlobalProperty];

                ltr = (dirValue == null || dirValue.Text == "ltr");
            }

            // Time to figure out what our mapping is going to be!
            // - We're all done with orientation already. It's just down to LTR and writingMode now.

            /*
             * horizontal-tb	top,right,bottom,left (Index 0)
             +RTL			top,left,bottom,right (Index 1)
             *
             * vertical-rl		left,top,right,bottom (Index 4)
             +RTL			right,top,left,bottom (Index 2)
             *
             * vertical-lr		left,bottom,right,top (Index 5)
             +RTL			right,bottom,left,top (Index 3)
             *
             * sideways-rl		left,top,right,bottom (Index 4)
             +RTL			right,top,left,bottom (Index 2)
             *
             * sideways-lr		right,bottom,left,top (Index 3)
             +RTL			left,bottom,right,top (Index 5)
             */

            int indexID;

            if (writingMode == Css.WritingMode.VerticalRL || writingMode == Css.WritingMode.SidewaysRL)
            {
                indexID = ltr?4:2;
            }
            else if (writingMode == Css.WritingMode.SidewaysLR)
            {
                indexID = ltr?3:5;
            }
            else if (writingMode == Css.WritingMode.VerticalLR)
            {
                indexID = ltr?5:3;
            }
            else               // Horizontal.

            {
                indexID = ltr?0:1;
            }

            if (Index == null)
            {
                // Index isn't ready yet - load now:
                LoadIndex();
            }

            // Get the index:
            return(Index[indexID]);
        }