/*
 * SDK Pullenti Unitext, version 4.33, fabruary 2026. Copyright (c) 2013-2026, Pullenti. All rights reserved. 
 * Non-Commercial Freeware and Commercial Software. 
 * This class is generated using the converter UniSharping (www.unisharping.ru) from Pullenti C# project. 
 * The latest version of the code is available on the site www.pullenti.ru
 */

using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Text;

namespace Pullenti.Unitext.Internal.Pdf
{
    public class PdfObject
    {
        public PdfFile SourceFile = null;
        public int Id = 0;
        public int WriteId
        {
            get
            {
                if (m_WriteId == 0) 
                    return Id;
                return m_WriteId;
            }
            set
            {
                m_WriteId = value;
            }
        }
        int m_WriteId;
        public ushort Version = 0;
        internal long WritePos;
        public long ReadPos;
        public int ReadLen;
        public bool Deleted;
        public object Tag;
        public int TmpTag;
        public virtual bool IsSimple(int lev)
        {
            return false;
        }
        public virtual string ToStringEx(int lev)
        {
            return "?";
        }
        public override string ToString()
        {
            return this.ToStringEx(0);
        }
        public virtual void OutHtml(StringBuilder res)
        {
            Pullenti.Util.MiscHelper.CorrectHtmlValue(res, this.ToString(), false, false, false);
            this._outHtmlRefs(res);
        }
        protected void _outHtmlRefs(StringBuilder res)
        {
            if (SourceFile == null || Id == 0) 
                return;
            List<PdfObject> li = SourceFile.GetAllWhoRefObject0(Id);
            if (li.Count == 0) 
                return;
            res.Append("<hr/><div>На данный объект ссылаются:</div><ul>");
            foreach (PdfObject v in li) 
            {
                res.Append("<li>");
                if (v.Id > 0) 
                    res.AppendFormat("<a href=\"obj{0}\">", v.Id);
                Pullenti.Util.MiscHelper.CorrectHtmlValue(res, v.ToString(), false, false, false);
                if (v.Id > 0) 
                    res.Append("</a>");
                res.Append("</li>");
            }
            res.Append("</ul>");
        }
        public virtual double GetDouble()
        {
            return 0;
        }
        public virtual void Write(Stream s)
        {
        }
        public virtual void GetAllReferences(List<PdfReference> refs, List<int> ids)
        {
        }
        public virtual void GetAllWhoRefObject(int objId, PdfObject cur, List<PdfObject> res, List<int> ids)
        {
        }
    }
}