with GNATCOM.IInterface;

with GNATCOM.Errors;

package body MSHTML.IHTMLStyleSheet_Interface is

   procedure Initialize (This : in out IHTMLStyleSheet_Type) is
   begin
      Set_IID (This, IID_IHTMLStyleSheet);
   end Initialize;

   function Pointer (This : IHTMLStyleSheet_Type)
     return Pointer_To_IHTMLStyleSheet
   is
   begin
      return To_Pointer_To_IHTMLStyleSheet (Address (This));
   end Pointer;

   procedure Attach (This    : in out IHTMLStyleSheet_Type;
                     Pointer : in     Pointer_To_IHTMLStyleSheet)
   is
   begin
      Attach (This, GNATCOM.IInterface.To_Pointer_To_IUnknown
              (Pointer.all'Address));
   end Attach;

   procedure Put_title
     (This : IHTMLStyleSheet_Type;
      p    : GNATCOM.Types.BSTR;
      Free : Boolean := True)
   is
   begin
      GNATCOM.Errors.Error_Check
        (Pointer (This).Vtbl.Put_title
         (Pointer (This),
          p));

      if Free then
               GNATCOM.IInterface.Free (p);
      
      end if;

   end Put_title;

   function Get_title
     (This : IHTMLStyleSheet_Type)
     return GNATCOM.Types.BSTR
   is
       RetVal : aliased GNATCOM.Types.BSTR;
   begin
      GNATCOM.Errors.Error_Check
        (Pointer (This).Vtbl.Get_title
         (Pointer (This),
          RetVal'Unchecked_Access));

      return RetVal;
   end Get_title;

   function Get_parentStyleSheet
     (This : IHTMLStyleSheet_Type)
     return Pointer_To_IHTMLStyleSheet
   is
       RetVal : aliased Pointer_To_IHTMLStyleSheet;
   begin
      GNATCOM.Errors.Error_Check
        (Pointer (This).Vtbl.Get_parentStyleSheet
         (Pointer (This),
          RetVal'Unchecked_Access));

      return RetVal;
   end Get_parentStyleSheet;

   function Get_owningElement
     (This : IHTMLStyleSheet_Type)
     return Pointer_To_IHTMLElement
   is
       RetVal : aliased Pointer_To_IHTMLElement;
   begin
      GNATCOM.Errors.Error_Check
        (Pointer (This).Vtbl.Get_owningElement
         (Pointer (This),
          RetVal'Unchecked_Access));

      return RetVal;
   end Get_owningElement;

   procedure Put_disabled
     (This : IHTMLStyleSheet_Type;
      p    : GNATCOM.Types.VARIANT_BOOL)
   is
   begin
      GNATCOM.Errors.Error_Check
        (Pointer (This).Vtbl.Put_disabled
         (Pointer (This),
          p));

   end Put_disabled;

   function Get_disabled
     (This : IHTMLStyleSheet_Type)
     return GNATCOM.Types.VARIANT_BOOL
   is
       RetVal : aliased GNATCOM.Types.VARIANT_BOOL;
   begin
      GNATCOM.Errors.Error_Check
        (Pointer (This).Vtbl.Get_disabled
         (Pointer (This),
          RetVal'Unchecked_Access));

      return RetVal;
   end Get_disabled;

   function Get_readOnly
     (This : IHTMLStyleSheet_Type)
     return GNATCOM.Types.VARIANT_BOOL
   is
       RetVal : aliased GNATCOM.Types.VARIANT_BOOL;
   begin
      GNATCOM.Errors.Error_Check
        (Pointer (This).Vtbl.Get_readOnly
         (Pointer (This),
          RetVal'Unchecked_Access));

      return RetVal;
   end Get_readOnly;

   function Get_imports
     (This : IHTMLStyleSheet_Type)
     return Pointer_To_IHTMLStyleSheetsCollection
   is
       RetVal : aliased Pointer_To_IHTMLStyleSheetsCollection;
   begin
      GNATCOM.Errors.Error_Check
        (Pointer (This).Vtbl.Get_imports
         (Pointer (This),
          RetVal'Unchecked_Access));

      return RetVal;
   end Get_imports;

   procedure Put_href
     (This : IHTMLStyleSheet_Type;
      p    : GNATCOM.Types.BSTR;
      Free : Boolean := True)
   is
   begin
      GNATCOM.Errors.Error_Check
        (Pointer (This).Vtbl.Put_href
         (Pointer (This),
          p));

      if Free then
               GNATCOM.IInterface.Free (p);
      
      end if;

   end Put_href;

   function Get_href
     (This : IHTMLStyleSheet_Type)
     return GNATCOM.Types.BSTR
   is
       RetVal : aliased GNATCOM.Types.BSTR;
   begin
      GNATCOM.Errors.Error_Check
        (Pointer (This).Vtbl.Get_href
         (Pointer (This),
          RetVal'Unchecked_Access));

      return RetVal;
   end Get_href;

   function Get_type
     (This : IHTMLStyleSheet_Type)
     return GNATCOM.Types.BSTR
   is
       RetVal : aliased GNATCOM.Types.BSTR;
   begin
      GNATCOM.Errors.Error_Check
        (Pointer (This).Vtbl.Get_type
         (Pointer (This),
          RetVal'Unchecked_Access));

      return RetVal;
   end Get_type;

   function Get_id
     (This : IHTMLStyleSheet_Type)
     return GNATCOM.Types.BSTR
   is
       RetVal : aliased GNATCOM.Types.BSTR;
   begin
      GNATCOM.Errors.Error_Check
        (Pointer (This).Vtbl.Get_id
         (Pointer (This),
          RetVal'Unchecked_Access));

      return RetVal;
   end Get_id;

   function addImport
     (This    : IHTMLStyleSheet_Type;
      bstrURL : GNATCOM.Types.BSTR;
      lIndex  : Interfaces.C.long;
      Free    : Boolean := True)
     return Interfaces.C.long
   is
       RetVal : aliased Interfaces.C.long;
   begin
      GNATCOM.Errors.Error_Check
        (Pointer (This).Vtbl.addImport
         (Pointer (This),
          bstrURL,
          lIndex,
          RetVal'Unchecked_Access));

      if Free then
               GNATCOM.IInterface.Free (bstrURL);
      
      end if;

      return RetVal;
   end addImport;

   function addRule
     (This         : IHTMLStyleSheet_Type;
      bstrSelector : GNATCOM.Types.BSTR;
      bstrStyle    : GNATCOM.Types.BSTR;
      lIndex       : Interfaces.C.long;
      Free         : Boolean := True)
     return Interfaces.C.long
   is
       RetVal : aliased Interfaces.C.long;
   begin
      GNATCOM.Errors.Error_Check
        (Pointer (This).Vtbl.addRule
         (Pointer (This),
          bstrSelector,
          bstrStyle,
          lIndex,
          RetVal'Unchecked_Access));

      if Free then
               GNATCOM.IInterface.Free (bstrSelector);
               GNATCOM.IInterface.Free (bstrStyle);
      
      end if;

      return RetVal;
   end addRule;

   procedure removeImport
     (This   : IHTMLStyleSheet_Type;
      lIndex : Interfaces.C.long)
   is
   begin
      GNATCOM.Errors.Error_Check
        (Pointer (This).Vtbl.removeImport
         (Pointer (This),
          lIndex));

   end removeImport;

   procedure removeRule
     (This   : IHTMLStyleSheet_Type;
      lIndex : Interfaces.C.long)
   is
   begin
      GNATCOM.Errors.Error_Check
        (Pointer (This).Vtbl.removeRule
         (Pointer (This),
          lIndex));

   end removeRule;

   procedure Put_media
     (This : IHTMLStyleSheet_Type;
      p    : GNATCOM.Types.BSTR;
      Free : Boolean := True)
   is
   begin
      GNATCOM.Errors.Error_Check
        (Pointer (This).Vtbl.Put_media
         (Pointer (This),
          p));

      if Free then
               GNATCOM.IInterface.Free (p);
      
      end if;

   end Put_media;

   function Get_media
     (This : IHTMLStyleSheet_Type)
     return GNATCOM.Types.BSTR
   is
       RetVal : aliased GNATCOM.Types.BSTR;
   begin
      GNATCOM.Errors.Error_Check
        (Pointer (This).Vtbl.Get_media
         (Pointer (This),
          RetVal'Unchecked_Access));

      return RetVal;
   end Get_media;

   procedure Put_cssText
     (This : IHTMLStyleSheet_Type;
      p    : GNATCOM.Types.BSTR;
      Free : Boolean := True)
   is
   begin
      GNATCOM.Errors.Error_Check
        (Pointer (This).Vtbl.Put_cssText
         (Pointer (This),
          p));

      if Free then
               GNATCOM.IInterface.Free (p);
      
      end if;

   end Put_cssText;

   function Get_cssText
     (This : IHTMLStyleSheet_Type)
     return GNATCOM.Types.BSTR
   is
       RetVal : aliased GNATCOM.Types.BSTR;
   begin
      GNATCOM.Errors.Error_Check
        (Pointer (This).Vtbl.Get_cssText
         (Pointer (This),
          RetVal'Unchecked_Access));

      return RetVal;
   end Get_cssText;

   function Get_rules
     (This : IHTMLStyleSheet_Type)
     return Pointer_To_IHTMLStyleSheetRulesCollection
   is
       RetVal : aliased Pointer_To_IHTMLStyleSheetRulesCollection;
   begin
      GNATCOM.Errors.Error_Check
        (Pointer (This).Vtbl.Get_rules
         (Pointer (This),
          RetVal'Unchecked_Access));

      return RetVal;
   end Get_rules;

end MSHTML.IHTMLStyleSheet_Interface;

