with GNATCOM.IInterface;

with GNATCOM.Errors;

package body MSHTML.IHTMLStyleSheet2_Interface is

   procedure Initialize (This : in out IHTMLStyleSheet2_Type) is
   begin
      Set_IID (This, IID_IHTMLStyleSheet2);
   end Initialize;

   function Pointer (This : IHTMLStyleSheet2_Type)
     return Pointer_To_IHTMLStyleSheet2
   is
   begin
      return To_Pointer_To_IHTMLStyleSheet2 (Address (This));
   end Pointer;

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

   function Get_pages
     (This : IHTMLStyleSheet2_Type)
     return Pointer_To_IHTMLStyleSheetPagesCollection
   is
       RetVal : aliased Pointer_To_IHTMLStyleSheetPagesCollection;
   begin
      GNATCOM.Errors.Error_Check
        (Pointer (This).Vtbl.Get_pages
         (Pointer (This),
          RetVal'Unchecked_Access));

      return RetVal;
   end Get_pages;

   function addPageRule
     (This         : IHTMLStyleSheet2_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.addPageRule
         (Pointer (This),
          bstrSelector,
          bstrStyle,
          lIndex,
          RetVal'Unchecked_Access));

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

      return RetVal;
   end addPageRule;

end MSHTML.IHTMLStyleSheet2_Interface;

