USFSubtitles.h

00001 /* 
00002  *      Copyright (C) 2003-2005 Gabest
00003  *      http://www.gabest.org
00004  *
00005  *  This Program is free software; you can redistribute it and/or modify
00006  *  it under the terms of the GNU General Public License as published by
00007  *  the Free Software Foundation; either version 2, or (at your option)
00008  *  any later version.
00009  *   
00010  *  This Program is distributed in the hope that it will be useful,
00011  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00013  *  GNU General Public License for more details.
00014  *   
00015  *  You should have received a copy of the GNU General Public License
00016  *  along with GNU Make; see the file COPYING.  If not, write to
00017  *  the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 
00018  *  http://www.gnu.org/copyleft/gpl.html
00019  *
00020  */
00021 
00022 #pragma once
00023 
00024 #include <atlcoll.h>
00025 #include "STS.h"
00026 
00027 // metadata
00028 typedef struct {CStringW name, email, url;} author_t;
00029 typedef struct {CStringW code, text;} language_t;
00030 typedef struct {CStringW title, date, comment; author_t author; language_t language, languageext;} metadata_t;
00031 // style
00032 typedef struct {CStringW alignment, relativeto, horizontal_margin, vertical_margin, rotate[3];} posattriblist_t;
00033 typedef struct {CStringW face, size, color[4], weight, italic, underline, alpha, outline, shadow, wrap;} fontstyle_t;
00034 typedef struct {CStringW name; fontstyle_t fontstyle; posattriblist_t pal;} style_t;
00035 // effect
00036 typedef struct {CStringW position; fontstyle_t fontstyle; posattriblist_t pal;} keyframe_t;
00037 typedef struct {CStringW name; CAutoPtrList<keyframe_t> keyframes;} effect_t;
00038 // subtitle/text
00039 typedef struct {int start, stop; CStringW effect, style, str; posattriblist_t pal;} text_t;
00040 
00041 class CUSFSubtitles
00042 {
00043         bool ParseUSFSubtitles(CComPtr<IXMLDOMNode> pNode);
00044          void ParseMetadata(CComPtr<IXMLDOMNode> pNode, metadata_t& m);
00045          void ParseStyle(CComPtr<IXMLDOMNode> pNode, style_t* s);
00046           void ParseFontstyle(CComPtr<IXMLDOMNode> pNode, fontstyle_t& fs);
00047           void ParsePal(CComPtr<IXMLDOMNode> pNode, posattriblist_t& pal);
00048          void ParseEffect(CComPtr<IXMLDOMNode> pNode, effect_t* e);
00049           void ParseKeyframe(CComPtr<IXMLDOMNode> pNode, keyframe_t* k);
00050          void ParseSubtitle(CComPtr<IXMLDOMNode> pNode, int start, int stop);
00051           void ParseText(CComPtr<IXMLDOMNode> pNode, CStringW& assstr);
00052           void ParseShape(CComPtr<IXMLDOMNode> pNode);
00053 
00054 public:
00055         CUSFSubtitles();
00056         virtual ~CUSFSubtitles();
00057 
00058         bool Read(LPCTSTR fn);
00059 //      bool Write(LPCTSTR fn); // TODO
00060 
00061         metadata_t metadata;
00062         CAutoPtrList<style_t> styles;
00063         CAutoPtrList<effect_t> effects;
00064         CAutoPtrList<text_t> texts;
00065 
00066         bool ConvertToSTS(CSimpleTextSubtitle& sts);
00067 //      bool ConvertFromSTS(CSimpleTextSubtitle& sts); // TODO
00068 };

Generated on Tue Dec 13 14:47:56 2005 for guliverkli by  doxygen 1.4.5