/// <summary>
        /// Based on the current numbering creates and returns the appropriate ListItemNumberComponent along with a few other appropriate bits.
        /// </summary>
        /// <param name="item">The list item to build the Number component for</param>
        /// <param name="itemstyle">The full style of this list item</param>
        /// <param name="halign">The alignment as set, can be updated to explict item alignment</param>
        /// <param name="type">The current type of numbering</param>
        /// <param name="itemWidth">If an explicit width has been set then this is returned (otherwise -1)</param>
        /// <param name="text">If this item has explict text (e.g Definiton list) then this is returned, otherwise empty</param>
        /// <returns>The correct PDFListItemLabel for the item</returns>
        private Component BuildAListNumberComponent(ListItem item, Style itemstyle, ref HorizontalAlignment halign,
                                                    out ListNumberingGroupStyle type, out PDFUnit itemWidth, out string text)
        {
            PDFListNumbering numbers = this.Component.Document.ListNumbering;

            type      = numbers.CurrentGroup.Style;
            itemWidth = itemstyle.GetValue(StyleKeys.ListInsetKey, (PDFUnit)(-1));
            text      = itemstyle.GetValue(StyleKeys.ListLabelKey, string.Empty);
            halign    = itemstyle.GetValue(StyleKeys.ListAlignmentKey, halign);

            ListItemLabel label;

            if (type == ListNumberingGroupStyle.Labels)
            {
                PDFListDefinitionItemLabel defn = new PDFListDefinitionItemLabel();
                label = defn;
            }
            else if (type == ListNumberingGroupStyle.Bullet)
            {
                label = new PDFListBulletItemLabel();
            }
            else
            {
                label = new ListItemLabel();
            }

            label.StyleClass = item.StyleClass;



            return(label);
        }
        /// <summary>
        /// based on the numbering type - returns the expected output type and aslo and postfix for the string types.
        /// </summary>
        /// <param name="type"></param>
        /// <param name="postfix"></param>
        /// <returns></returns>
        private NumberingOutputType GetDefaultOutputTypeForNumbering(ListNumberingGroupStyle type, out string postfix)
        {
            switch (type)
            {
            case ListNumberingGroupStyle.None:
            case ListNumberingGroupStyle.Decimals:
            case ListNumberingGroupStyle.UppercaseRoman:
            case ListNumberingGroupStyle.LowercaseRoman:
            case ListNumberingGroupStyle.UppercaseLetters:
            case ListNumberingGroupStyle.LowercaseLetters:
                postfix = ".";
                return(NumberingOutputType.String);

            case ListNumberingGroupStyle.Bullet:
                postfix = null;
                return(NumberingOutputType.String);

            //case ListNumberingGroupStyle.Labels:
            //    postfix = null;
            //    return NumberingOutputType.Component;

            //case ListNumberingGroupStyle.Image:
            //    postfix = null;
            //    return NumberingOutputType.Component;

            default:
                throw new ArgumentOutOfRangeException("type");
            }
        }
        // instance methods

        #region public void Push(NumberingGroupType type, string prefix, string postfix, bool concatenate)

        public void Push(ListNumberingGroupStyle type, string prefix, string postfix, bool concatenate)
        {
            PDFListNumberingGroup group = new PDFListNumberingGroup(1, type, concatenate);

            group.PostFix = postfix;
            group.Prefix  = prefix;
            this.Push(group);
        }
예제 #4
0
 /// <summary>
 /// Creates a new number group with the spacified values
 /// </summary>
 /// <param name="name"></param>
 /// <param name="startindex"></param>
 /// <param name="style"></param>
 /// <param name="prefix"></param>
 /// <param name="postfix"></param>
 /// <param name="concat"></param>
 public PDFListNumberGroup(string name, int startindex, ListNumberingGroupStyle style, string prefix, string postfix, bool concat)
 {
     this.Name        = name;
     this.StartIndex  = startindex;
     this.NextIndex   = startindex;
     this.Style       = style;
     this.PreFix      = prefix;
     this.PostFix     = postfix;
     this.Concatenate = concat;
 }
        /// <summary>
        /// Creates a new instance of the numbering group with the spacified name, start index, numbering type and if values are con
        /// </summary>
        /// <param name="startIndex"></param>
        /// <param name="type"></param>
        /// <param name="concat"></param>
        public PDFListNumberingGroup(int startIndex, ListNumberingGroupStyle type, bool concat)
        {
            this.StartIndex            = startIndex;
            this.NextIndex             = startIndex;
            this.Type                  = type;
            this.ConcatenateWithParent = concat;
            string post;

            this.Output  = GetDefaultOutputTypeForNumbering(type, out post);
            this.PostFix = post;
        }
예제 #6
0
        //
        // public methods
        //

        #region public PDFListNumberingStack OpenNumberingStack(string name)

        /// <summary>
        /// Opens an existing stack if the names match, or begins a new stack (setting it as current)
        /// </summary>
        /// <param name="name">The name of the stack to open. If the name is not null or empty</param>
        /// <returns>The appropriate numbering stack.</returns>
        /// <remarks>Named stacks are remembered throughout the lisf of the document, so they can be re-opened at any point.
        /// Un-named stacks will only persist until they are completely colsed.</remarks>
        public PDFListNumberingStack OpenNumberingStack(string name, ListStyle initStyle)
        {
            //if we have a current stack and either both names are empty, or the names match - then this is the one.
            if (_currentStack != null && ((string.IsNullOrEmpty(name) && string.IsNullOrEmpty(_currentStack.Name)) || string.Equals(name, _currentStack.Name)))
            {
                return(_currentStack);
            }

            //otherwise if we do have a name, then lets chack and see if we have a reference.
            else if (_listStacks.Count > 0 && !string.IsNullOrEmpty(name))
            {
                foreach (PDFListNumberingStack stack in _listStacks)
                {
                    if (string.Equals(name, stack.Name))
                    {
                        _currentStack = stack;
                        return(stack);
                    }
                }
            }

            //we don't have an existing stack so if we are not a group then we want to be pushed onto the current stack (if there is one)
            PDFListNumberingStack newStack;

            if (null != _currentStack && string.IsNullOrEmpty(name))
            {
                newStack = _currentStack;
            }
            else //otherwise just create one.
            {
                newStack = new PDFListNumberingStack(name);

                //we only remember named stacks - so we can refer back to them.
                if (!string.IsNullOrEmpty(name))
                {
                    _listStacks.Add(newStack);
                }
            }
            ListNumberingGroupStyle type = initStyle.NumberingStyle;

            //TODO: Add pre, post and concat to style
            string prefix      = initStyle.NumberPrefix;
            string postfix     = initStyle.NumberPostfix;
            bool   concatenate = initStyle.ConcatenateWithParent;

            newStack.Push(type, prefix, postfix, concatenate);

            _currentStack = newStack;
            return(_currentStack);
        }
예제 #7
0
        public void PushGroup(string name, ListNumberingGroupStyle style, string prefix, string postfix, bool concat, int startIndex)
        {
            PDFListNumberGroup grp;

            if (string.IsNullOrEmpty(name) || this.TryGetNamedGroup(name, out grp) == false)
            {
                grp = new PDFListNumberGroup(name, startIndex, style, prefix, postfix, concat);

                //Add it to the named groups if we have a name
                if (!string.IsNullOrEmpty(name))
                {
                    _namedGroups.Add(grp);
                }
            }
            this._currentGroups.Add(grp);
        }
예제 #8
0
        private string GetStringValue(int value, int depth, ListNumberingGroupStyle style)
        {
            string s = null;

            switch (style)
            {
            case ListNumberingGroupStyle.None:
                break;

            case ListNumberingGroupStyle.Decimals:
                s = value.ToString();
                break;

            case ListNumberingGroupStyle.UppercaseRoman:
                s = Scryber.Utilities.NumberHelper.GetRomanUpper(value);
                break;

            case ListNumberingGroupStyle.LowercaseRoman:
                s = Scryber.Utilities.NumberHelper.GetRomanLower(value);
                break;

            case ListNumberingGroupStyle.UppercaseLetters:
                s = Scryber.Utilities.NumberHelper.GetLetterUpper(value);
                break;

            case ListNumberingGroupStyle.LowercaseLetters:
                s = Scryber.Utilities.NumberHelper.GetLetterLower(value);
                break;

            case ListNumberingGroupStyle.Bullet:
                s = Scryber.Utilities.NumberHelper.GetPointValue(depth);
                break;

            case ListNumberingGroupStyle.Labels:
                s = string.Empty;     //label style but does not have any text associated with the item
                break;

            //case ListNumberingGroupStyle.Image:
            //    throw new NotSupportedException();
            default:
                throw new ArgumentOutOfRangeException("style");
            }
            return(s);
        }
예제 #9
0
        /// <summary>
        /// Pushes either an existing known group with the specified name, or a new one (remembering it if there is a name) onto the current Numbering stack
        /// </summary>
        /// <param name="name">The name of the group to retireve or create</param>
        /// <param name="liststyle"></param>
        public void PushGroup(string name, Styles.Style liststyle)
        {
            PDFListNumberGroup grp;

            if (string.IsNullOrEmpty(name) || this.TryGetNamedGroup(name, out grp) == false)
            {
                int startindex = 1;
                ListNumberingGroupStyle style = liststyle.GetValue(StyleKeys.ListNumberStyleKey, ListNumberingGroupStyle.Decimals);
                string prefix  = liststyle.GetValue(StyleKeys.ListPrefixKey, String.Empty);
                string postfix = liststyle.GetValue(StyleKeys.ListPostfixKey, String.Empty);
                bool   concat  = liststyle.GetValue(StyleKeys.ListConcatKey, false);

                grp = new PDFListNumberGroup(name, startindex, style, prefix, postfix, concat);

                if (!string.IsNullOrEmpty(name))
                {
                    _namedGroups.Add(grp);
                }
            }
            this._currentGroups.Add(grp);
        }
 protected bool DoConvertListStyle(StyleBase style, object value, out ListNumberingGroupStyle num)
 {
     if (null == value)
     {
         num = ListNumberingGroupStyle.None;
         return(false);
     }
     else if (value is ListNumberingGroupStyle g)
     {
         num = g;
         return(true);
     }
     else if (CSSListStyleTypeParser.TryGetListTypeEnum(value.ToString(), out num))
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
        protected override void DoLayoutComponent()
        {
            bool restoreText = false;
            ListNumberingGroupStyle style = this.FullStyle.GetValue(StyleKeys.ListNumberStyleKey, ListNumberingGroupStyle.None);
            string grpname = this.FullStyle.GetValue(StyleKeys.ListGroupKey, string.Empty);

            if (style != ListNumberingGroupStyle.None && !string.IsNullOrEmpty(grpname))
            {
                PDFHeadingNumbers headingNumbers = this.GetOrCreateHeadingNumbersFromDocument();

                string listnumber = headingNumbers.PushHeading(this.Heading.HeadingDepth, grpname, this.FullStyle);
                Heading.SetHeadingNumber(listnumber);
                restoreText = true;
            }

            base.DoLayoutComponent();

            if (restoreText)
            {
                this.Heading.SetHeadingNumber(string.Empty);
            }
        }
예제 #12
0
        public void List_NumberingStyle()
        {
            ListStyle target = new ListStyle();
            ListNumberingGroupStyle expected = ListNumberingGroupStyle.None;
            ListNumberingGroupStyle actual   = target.NumberingStyle;

            Assert.AreEqual(expected, actual);

            expected = ListNumberingGroupStyle.Decimals;
            target.NumberingStyle = expected;
            actual = target.NumberingStyle;
            Assert.AreEqual(expected, actual);

            expected = ListNumberingGroupStyle.LowercaseRoman;
            target.NumberingStyle = expected;
            actual = target.NumberingStyle;
            Assert.AreEqual(expected, actual);

            target.RemoveNumberingStyle();
            expected = ListNumberingGroupStyle.None;
            actual   = target.NumberingStyle;
            Assert.AreEqual(expected, actual);
        }