# 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

import io
import typing
from pullenti.unisharp.Streams import Stream

from pullenti.util.MiscHelper import MiscHelper

class PdfObject:
    
    def __init__(self) -> None:
        self.source_file = None
        self.id0_ = 0
        self.__m_write_id = 0
        self.version = 0
        self._write_pos = 0
        self.read_pos = 0
        self.read_len = 0
        self.deleted = False
        self.tag = None;
        self.tmp_tag = 0
    
    @property
    def write_id(self) -> int:
        if (self.__m_write_id == 0): 
            return self.id0_
        return self.__m_write_id
    @write_id.setter
    def write_id(self, value) -> int:
        self.__m_write_id = value
        return value
    
    def is_simple(self, lev : int) -> bool:
        return False
    
    def to_string_ex(self, lev : int) -> str:
        return "?"
    
    def __str__(self) -> str:
        return self.to_string_ex(0)
    
    def out_html(self, res : io.StringIO) -> None:
        MiscHelper.correct_html_value(res, str(self), False, False, False)
        self._out_html_refs(res)
    
    def _out_html_refs(self, res : io.StringIO) -> None:
        if (self.source_file is None or self.id0_ == 0): 
            return
        li = self.source_file.get_all_who_ref_object0(self.id0_)
        if (len(li) == 0): 
            return
        print("<hr/><div>На данный объект ссылаются:</div><ul>", end="", file=res)
        for v in li: 
            print("<li>", end="", file=res)
            if (v.id0_ > 0): 
                print("<a href=\"obj{0}\">".format(v.id0_), end="", file=res, flush=True)
            MiscHelper.correct_html_value(res, str(v), False, False, False)
            if (v.id0_ > 0): 
                print("</a>", end="", file=res)
            print("</li>", end="", file=res)
        print("</ul>", end="", file=res)
    
    def get_double(self) -> float:
        return 0
    
    def write0_(self, s : Stream) -> None:
        pass
    
    def get_all_references(self, refs : typing.List['PdfReference'], ids : typing.List[int]) -> None:
        pass
    
    def get_all_who_ref_object(self, obj_id : int, cur : 'PdfObject', res : typing.List['PdfObject'], ids : typing.List[int]) -> None:
        pass