File:  [mozdev] / mozptch / moz_rdf_edit.pas
Revision 1.2: download - view: text, annotated - select for diffs - revision graph
Sun Apr 3 15:03:28 2005 UTC (13 years, 11 months ago) by oertel
Branches: MAIN
CVS tags: HEAD
win pre 10.2
new xmlpatch with openxml

(* Copyright (c) uib umwelt informatik buero gmbh (www.uib.de)
 This sourcecode is owned by uib
 and published under the Terms of the General Public License.
#*###CVS_HEAD_START###******************************************************
# $Id: moz_rdf_edit.pas,v 1.2 2005/04/03 15:03:28 oertel Exp $
#
#*###EXCLUDE_CVS_LOG###*****************************************************
# History:
# ========
#
# $Log: moz_rdf_edit.pas,v $
# Revision 1.2  2005/04/03 15:03:28  oertel
# win pre 10.2
# new xmlpatch with openxml
#
# Revision 1.1  2004/03/14 12:49:07  oertel
# Initial commit version 9.29
#
*)

unit moz_rdf_edit;

interface

uses
  SysUtils, Classes;


procedure openRdfFile(filename : string);
procedure saveRdfFile(filename : string);
procedure addMimeHandler(mime : string;
                         path : string;
                         exename : string;
                         extensions : string);
procedure delMimeHandler(mime : string);


implementation

uses
xmlpatch,  datamodul;


procedure openRdfFile(filename : string);
begin
 openXmlFile(FileName);
end;

procedure saveRdfFile(filename : string);
begin
 saveXmlFile(FileName);
end;

procedure checkFirstNode;
begin
 openNode('RDF:Description about="urn:mimetypes"');
 openNode('RDF:Description about="urn:mimetypes"'
          +'/RDF:MIME-types resource="urn:mimetypes:root"');
end;





procedure addMimeHandler(mime : string;       //mimetype
                         path : string;       // path ohne abschließenden slash
                         exename : string;    // reiner exename
                         extensions : string);// extension, mehrere ducrh komma separiert
var
 ext : string;

begin
 // vorher sicherheitshalber den ersten Knoten richtig einrichten....
 checkFirstNode;

 // 1. in Liste aufnehmen
 openNode('RDF:Seq about="urn:mimetypes:root"'
          +'/RDF:li resource="urn:mimetype:'+mime+'"');

(*
 <RDF:Description about="urn:mimetype:application/msexcel"
                   NC:value="application/msexcel"
                   NC:editable="true"
                   NC:fileExtensions="xlb"
                   NC:description="Microsoft Excel-Arbeitsblatt">
    <NC:handlerProp resource="urn:mimetype:handler:application/msexcel"/>
*)

 // 2. mimetype verweist auf handler
 openNode('RDF:Description about="urn:mimetypes:'+mime+'"');
 setAttribute('NC:value',mime);
 setAttribute('NC:editable','true');
 setAttribute('NC:description','');
 if length(trim(extensions)) >= 3 then
 begin
   extensions := ','+extensions;
 end;
 while pos(',',extensions)>0 do
 begin
  // vorderes komma und leerzeichen entfernen
  extensions := trim(copy(extensions,pos(',',extensions)+1,length(extensions)));
  // extension holen
  ext := copy(extensions,1,3);
  // geholte extension entfernen
  extensions := copy(extensions,4,length(extensions));
  openNode('RDF:Description about="urn:mimetypes:'+mime+'"');
  setNodeAtPosition('NC:fileExtensions','','',-1);
  setNodeText(ext);
 end;
 openNode('RDF:Description about="urn:mimetypes:'+mime+'"'
          +'/RDF:handlerProp resource="urn:mimetype:handler:'+mime+'"');


(*
 <RDF:Description about="urn:mimetype:handler:application/msexcel"
                   NC:alwaysAsk="true"
                   NC:saveToDisk="false"
                   NC:useSystemDefault="false"
                   NC:handleInternal="false">
    <NC:externalApplication resource="urn:mimetype:externalApplication:application/msexcel"/>
*)

 // 3. handler verweist auf externalApplication
 openNode('RDF:Description about="urn:mimetype:handler:'+mime+'"');
 setAttribute('NC:alwaysAsk','true');
 setAttribute('NC:saveToDisk','false');
 setAttribute('NC:useSystemDefault','false');
 setAttribute('NC:handleInternal','false');
 openNode('RDF:Description about="urn:mimetype:handler:'+mime+'"'
          +'/NC:externalApplication resource="urn:mimetype:externalApplication:'+mime+'"');


 // 4. externalApplication
 openNode('RDF:Description about="urn:mimetype:externalApplication:'+mime+'"');
 setAttribute('NC:path',path+'\'+exename);
 setAttribute('NC:prettyName',exename);

end;

procedure delMimeHandler(mime : string);
begin
 delNode('RDF:Seq about="urn:mimetypes:root"'
          +'/RDF:li resource="urn:mimetype:'+mime+'"');
 delNode('RDF:Description about="urn:mimetypes:'+mime+'"');
 delNode('RDF:Description about="urn:mimetype:handler:'+mime+'"');
 delNode('RDF:Description about="urn:mimetype:externalApplication:'+mime+'"');
end;

end.

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>