----------------------------------------------- --------------------------------- -- -- -- OCARINA COMPONENTS -- -- -- -- O C A R I N A . D I A . P R I N T E R . A T T R I B U T E -- -- -- -- B o d y -- -- -- -- Copyright (C) 2005-2006, GET-Telecom Paris. -- -- -- -- Ocarina is free software; you can redistribute it and/or modify -- -- it under terms of the GNU General Public License as published by the -- -- Free Software Foundation; either version 2, or (at your option) any -- -- later version. Ocarina is distributed in the hope that it will be -- -- useful, but WITHOUT ANY WARRANTY; without even the implied warranty of -- -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General -- -- Public License for more details. You should have received a copy of the -- -- GNU General Public License distributed with Ocarina; see file COPYING. -- -- If not, write to the Free Software Foundation, 51 Franklin Street, Fifth -- -- Floor, Boston, MA 02111-1301, USA. -- -- -- -- As a special exception, if other files instantiate generics from this -- -- unit, or you link this unit with other files to produce an executable, -- -- this unit does not by itself cause the resulting executable to be -- -- covered by the GNU General Public License. This exception does not -- -- however invalidate any other reasons why the executable file might be -- -- covered by the GNU Public License. -- -- -- -- Ocarina is maintained by the Ocarina team -- -- (ocarina-users@listes.enst.fr) -- -- -- ------------------------------------------------------------------------------ with DOM.Core; with DOM.Core.Documents; with DOM.Core.Nodes; with DOM.Core.Elements; with Ocarina.Dia.Printer.Misc; use Ocarina.Dia.Printer.Misc; package body Ocarina.Dia.Printer.Attribute is -------------------- -- Add_Attr_Color -- -------------------- procedure Add_Attr_Color (Doc : DOM.Core.document; Parent_Node : DOM.Core.node; Name : String; Color : String) is use DOM.Core.Nodes; use DOM.Core.Documents; use DOM.Core.Elements; XML_Node : DOM.Core.node; pragma warnings (Off, XML_Node); -- Kills warning "useless assignment to "XML_Node", value never -- referenced" from GNAT. XML_Element : constant DOM.Core.element := Create_Element (Doc, "dia:attribute"); XML_Element2 : constant DOM.Core.element := Create_Element (Doc, "dia:color"); begin Set_Attribute (XML_Element, "name", Name); Set_Attribute (XML_Element2, "val", Color); XML_Node := Append_Child (Parent_Node, XML_Element); XML_Node := Append_Child (XML_Node, XML_Element2); end Add_Attr_Color; --------------------- -- Add_Attr_String -- --------------------- procedure Add_Attr_String (Doc : DOM.Core.document; Parent_Node : DOM.Core.node; Name : String; str : String) is use DOM.Core.Nodes; use DOM.Core.Documents; use DOM.Core.Elements; XML_Node : DOM.Core.node; pragma warnings (Off, XML_Node); -- Kills warning "useless assignment to "XML_Node", value never -- referenced" from GNAT. XML_Element : constant DOM.Core.element := Create_Element (Doc, "dia:attribute"); XML_Element2 : constant DOM.Core.element := Create_Element (Doc, "dia:string"); XML_Text : constant DOM.Core.text := Create_Text_Node (Doc, str); begin Set_Attribute (XML_Element, "name", Name); XML_Node := Append_Child (Parent_Node, XML_Element); XML_Node := Append_Child (XML_Node, XML_Element2); XML_Node := Append_Child (XML_Node, XML_Text); end Add_Attr_String; ------------------- -- Add_Attr_Real -- ------------------- procedure Add_Attr_Real (Doc : DOM.Core.document; Parent_Node : DOM.Core.node; Name : String; Real : Float) is use DOM.Core.Nodes; use DOM.Core.Documents; use DOM.Core.Elements; XML_Node : DOM.Core.node; pragma warnings (Off, XML_Node); -- Kills warning "useless assignment to "XML_Node", value never -- referenced" from GNAT. XML_Element : constant DOM.Core.element := Create_Element (Doc, "dia:attribute"); XML_Element2 : constant DOM.Core.element := Create_Element (Doc, "dia:real"); begin Set_Attribute (XML_Element, "name", Name); Set_Attribute (XML_Element2, "val", Float_To_String (Real)); XML_Node := Append_Child (Parent_Node, XML_Element); XML_Node := Append_Child (XML_Node, XML_Element2); end Add_Attr_Real; ---------------------- -- Add_Attr_Boolean -- ---------------------- procedure Add_Attr_Boolean (Doc : DOM.Core.document; Parent_Node : DOM.Core.node; Name : String; Bool : Boolean) is use DOM.Core.Nodes; use DOM.Core.Documents; use DOM.Core.Elements; XML_Node : DOM.Core.node; pragma warnings (Off, XML_Node); -- Kills warning "useless assignment to "XML_Node", value never -- referenced" from GNAT. XML_Element : constant DOM.Core.element := Create_Element (Doc, "dia:attribute"); XML_Element2 : constant DOM.Core.element := Create_Element (Doc, "dia:boolean"); begin Set_Attribute (XML_Element, "name", Name); Set_Attribute (XML_Element2, "val", Boolean'image (Bool)); XML_Node := Append_Child (Parent_Node, XML_Element); XML_Node := Append_Child (XML_Node, XML_Element2); end Add_Attr_Boolean; ------------------ -- Add_Attr_Int -- ------------------ procedure Add_Attr_Int (Doc : DOM.Core.document; Parent_Node : DOM.Core.node; Name : String; Int : Integer) is use DOM.Core.Nodes; use DOM.Core.Documents; use DOM.Core.Elements; XML_Node : DOM.Core.node; pragma warnings (Off, XML_Node); -- Kills warning "useless assignment to "XML_Node", value never -- referenced" from GNAT. XML_Element : constant DOM.Core.element := Create_Element (Doc, "dia:attribute"); XML_Element2 : constant DOM.Core.element := Create_Element (Doc, "dia:int"); begin Set_Attribute (XML_Element, "name", Name); Set_Attribute (XML_Element2, "val", Integer_To_String (Int)); XML_Node := Append_Child (Parent_Node, XML_Element); XML_Node := Append_Child (XML_Node, XML_Element2); end Add_Attr_Int; -------------------- -- Add_Attr_Point -- -------------------- procedure Add_Attr_Point (Doc : DOM.Core.document; Parent_Node : DOM.Core.node; Name : String; Point : Ocarina.Dia.Printer.Misc.point) is use DOM.Core.Nodes; use DOM.Core.Documents; use DOM.Core.Elements; XML_Node : DOM.Core.node; pragma warnings (Off, XML_Node); -- Kills warning "useless assignment to "XML_Node", value never -- referenced" from GNAT. XML_Element : constant DOM.Core.element := Create_Element (Doc, "dia:attribute"); XML_Element2 : constant DOM.Core.element := Create_Element (Doc, "dia:point"); begin Set_Attribute (XML_Element, "name", Name); Set_Attribute (XML_Element2, "val", Print_Point (Point)); XML_Node := Append_Child (Parent_Node, XML_Element); XML_Node := Append_Child (XML_Node, XML_Element2); end Add_Attr_Point; ------------------------ -- Add_Attr_Rectangle -- ------------------------ procedure Add_Attr_Rectangle (Doc : DOM.Core.document; Parent_Node : DOM.Core.node; Name : String; Rectangle : Ocarina.Dia.Printer.Misc.rectangle) is use DOM.Core.Nodes; use DOM.Core.Documents; use DOM.Core.Elements; XML_Node : DOM.Core.node; pragma warnings (Off, XML_Node); -- Kills warning "useless assignment to "XML_Node", value never -- referenced" from GNAT. XML_Element : constant DOM.Core.element := Create_Element (Doc, "dia:attribute"); XML_Element2 : constant DOM.Core.element := Create_Element (Doc, "dia:rectangle"); begin Set_Attribute (XML_Element, "name", Name); Set_Attribute (XML_Element2, "val", Print_Rectangle (Rectangle)); XML_Node := Append_Child (Parent_Node, XML_Element); XML_Node := Append_Child (XML_Node, XML_Element2); end Add_Attr_Rectangle; ------------------- -- Add_Attr_Enum -- ------------------- procedure Add_Attr_Enum (Doc : DOM.Core.document; Parent_Node : DOM.Core.node; Name : String; Enum : String) is use DOM.Core.Nodes; use DOM.Core.Documents; use DOM.Core.Elements; XML_Node : DOM.Core.node; pragma warnings (Off, XML_Node); -- Kills warning "useless assignment to "XML_Node", value never -- referenced" from GNAT. XML_Element : constant DOM.Core.element := Create_Element (Doc, "dia:attribute"); XML_Element2 : constant DOM.Core.element := Create_Element (Doc, "dia:enum"); begin Set_Attribute (XML_Element, "name", Name); Set_Attribute (XML_Element2, "val", Enum); XML_Node := Append_Child (Parent_Node, XML_Element); XML_Node := Append_Child (XML_Node, XML_Element2); end Add_Attr_Enum; ------------------- -- Add_Attr_Font -- ------------------- procedure Add_Attr_Font (Doc : DOM.Core.document; Parent_Node : DOM.Core.node; Name : String; Family : String; Style : String; Name_Font : String) is use DOM.Core.Nodes; use DOM.Core.Documents; use DOM.Core.Elements; XML_Node : DOM.Core.node; pragma warnings (Off, XML_Node); -- Kills warning "useless assignment to "XML_Node", value never -- referenced" from GNAT. XML_Element : constant DOM.Core.element := Create_Element (Doc, "dia:attribute"); XML_Element2 : constant DOM.Core.element := Create_Element (Doc, "dia:font"); begin Set_Attribute (XML_Element, "name", Name); Set_Attribute (XML_Element2, "Family", Family); Set_Attribute (XML_Element2, "style", Style); Set_Attribute (XML_Element2, "name", Name_Font); XML_Node := Append_Child (Parent_Node, XML_Element); XML_Node := Append_Child (XML_Node, XML_Element2); end Add_Attr_Font; --------------- -- Add_Point -- --------------- procedure Add_Point (Doc : DOM.Core.document; Parent_Node : DOM.Core.node; Point : Ocarina.Dia.Printer.Misc.point) is use DOM.Core.Nodes; use DOM.Core.Documents; use DOM.Core.Elements; XML_Node : DOM.Core.node; pragma warnings (Off, XML_Node); XML_Element : constant DOM.Core.element := Create_Element (Doc, "dia:point"); begin Set_Attribute (XML_Element, "val", Print_Point (Point)); XML_Node := Append_Child (Parent_Node, XML_Element); end Add_Point; -------------- -- Add_Enum -- -------------- procedure Add_Enum (Doc : DOM.Core.document; Parent_Node : DOM.Core.node; Enum : String) is use DOM.Core.Nodes; use DOM.Core.Documents; use DOM.Core.Elements; XML_Node : DOM.Core.node; pragma warnings (Off, XML_Node); XML_Element : constant DOM.Core.element := Create_Element (Doc, "dia:enum"); begin Set_Attribute (XML_Element, "val", Enum); XML_Node := Append_Child (Parent_Node, XML_Element); end Add_Enum; end Ocarina.Dia.Printer.Attribute;