As we require RTTI anyway, kill AssEntry::GetAsDialogue/Style/Attachment and just use dynamic_cast

Originally committed to SVN as r4308.
This commit is contained in:
Thomas Goyne 2010-05-19 00:44:52 +00:00
parent 2124a1dbd3
commit 008d59d71e
24 changed files with 54 additions and 93 deletions

View file

@ -63,42 +63,6 @@ AssEntry::AssEntry(wxString _data) {
AssEntry::~AssEntry() { AssEntry::~AssEntry() {
} }
/// @brief Returns an entry as dialogue if possible, else, returns NULL
/// @param base
/// @return
///
AssDialogue *AssEntry::GetAsDialogue(AssEntry *base) {
if (!base) return NULL;
if (base->GetType() == ENTRY_DIALOGUE) {
return static_cast<AssDialogue*> (base);
}
return NULL;
}
/// @brief Returns an entry as style if possible, else, returns NULL
/// @param base
/// @return
///
AssStyle *AssEntry::GetAsStyle(AssEntry *base) {
if (!base) return NULL;
if (base->GetType() == ENTRY_STYLE) {
return static_cast<AssStyle*> (base);
}
return NULL;
}
/// @brief Returns an entry as attachment if possible, else, returns NULL
/// @param base
/// @return
///
AssAttachment *AssEntry::GetAsAttachment(AssEntry *base) {
if (!base) return NULL;
if (base->GetType() == ENTRY_ATTACHMENT) {
return static_cast<AssAttachment*> (base);
}
return NULL;
}
/// @brief Get SSA conversion /// @brief Get SSA conversion
/// @return /// @return
/// ///

View file

@ -139,7 +139,4 @@ public:
virtual void SetEntryData(wxString newData) { if (newData.IsEmpty()) data.Clear(); else data = newData; } virtual void SetEntryData(wxString newData) { if (newData.IsEmpty()) data.Clear(); else data = newData; }
virtual wxString GetSSAText(); virtual wxString GetSSAText();
static AssDialogue *GetAsDialogue(AssEntry *base); // Returns an entry base as a dialogue if it is valid, null otherwise
static AssStyle *GetAsStyle(AssEntry *base); // Returns an entry base as a style if it is valid, null otherwise
static AssAttachment *GetAsAttachment(AssEntry *base);// Returns an entry base as an attachment if it is valid, null otherwise
}; };

View file

@ -256,17 +256,17 @@ bool AssFile::CanSave() {
AssAttachment *attach; AssAttachment *attach;
for (entryIter cur=Line.begin();cur!=Line.end();cur++) { for (entryIter cur=Line.begin();cur!=Line.end();cur++) {
// Check style, if anything non-default is found, return false // Check style, if anything non-default is found, return false
curstyle = AssEntry::GetAsStyle(*cur); curstyle = dynamic_cast<AssStyle*>(*cur);
if (curstyle) { if (curstyle) {
if (curstyle->GetEntryData() != defstyle.GetEntryData()) return false; if (curstyle->GetEntryData() != defstyle.GetEntryData()) return false;
} }
// Check for attachments, if any is found, return false // Check for attachments, if any is found, return false
attach = AssEntry::GetAsAttachment(*cur); attach = dynamic_cast<AssAttachment*>(*cur);
if (attach) return false; if (attach) return false;
// Check dialog // Check dialog
curdiag = AssEntry::GetAsDialogue(*cur); curdiag = dynamic_cast<AssDialogue*>(*cur);
if (curdiag) { if (curdiag) {
// Timed? // Timed?
if (!canTime && (curdiag->Start.GetMS() != 0 || curdiag->End.GetMS() != 0)) return false; if (!canTime && (curdiag->Start.GetMS() != 0 || curdiag->End.GetMS() != 0)) return false;
@ -542,7 +542,7 @@ void AssFile::InsertAttachment (AssAttachment *attach) {
std::list<AssEntry*>::iterator insPoint=Line.end(),cur; std::list<AssEntry*>::iterator insPoint=Line.end(),cur;
for (cur=Line.begin();cur!=Line.end();cur++) { for (cur=Line.begin();cur!=Line.end();cur++) {
// Check if it's another attachment // Check if it's another attachment
AssAttachment *att = AssEntry::GetAsAttachment(*cur); AssAttachment *att = dynamic_cast<AssAttachment*>(*cur);
if (att) { if (att) {
if (attach->group == att->group) insPoint = cur; if (attach->group == att->group) insPoint = cur;
} }
@ -771,7 +771,7 @@ wxArrayString AssFile::GetStyles() {
wxArrayString styles; wxArrayString styles;
AssStyle *curstyle; AssStyle *curstyle;
for (entryIter cur=Line.begin();cur!=Line.end();cur++) { for (entryIter cur=Line.begin();cur!=Line.end();cur++) {
curstyle = AssEntry::GetAsStyle(*cur); curstyle = dynamic_cast<AssStyle*>(*cur);
if (curstyle) { if (curstyle) {
styles.Add(curstyle->name); styles.Add(curstyle->name);
} }
@ -785,7 +785,7 @@ wxArrayString AssFile::GetStyles() {
AssStyle *AssFile::GetStyle(wxString name) { AssStyle *AssFile::GetStyle(wxString name) {
AssStyle *curstyle; AssStyle *curstyle;
for (entryIter cur=Line.begin();cur!=Line.end();cur++) { for (entryIter cur=Line.begin();cur!=Line.end();cur++) {
curstyle = AssEntry::GetAsStyle(*cur); curstyle = dynamic_cast<AssStyle*>(*cur);
if (curstyle) { if (curstyle) {
if (curstyle->name == name) return curstyle; if (curstyle->name == name) return curstyle;
} }
@ -814,7 +814,7 @@ wxString AssFile::GetWildcardList(int mode) {
void AssFile::CompressForStack(bool compress) { void AssFile::CompressForStack(bool compress) {
AssDialogue *diag; AssDialogue *diag;
for (entryIter cur=Line.begin();cur!=Line.end();cur++) { for (entryIter cur=Line.begin();cur!=Line.end();cur++) {
diag = AssEntry::GetAsDialogue(*cur); diag = dynamic_cast<AssDialogue*>(*cur);
if (diag) { if (diag) {
if (compress) { if (compress) {
diag->SetEntryData(_T("")); diag->SetEntryData(_T(""));

View file

@ -133,7 +133,7 @@ namespace Automation4 {
lua_pushstring(L, "format"); lua_pushstring(L, "format");
} else if (e->GetType() == ENTRY_DIALOGUE) { } else if (e->GetType() == ENTRY_DIALOGUE) {
AssDialogue *dia = e->GetAsDialogue(e); AssDialogue *dia = static_cast<AssDialogue*>(e);
lua_pushboolean(L, (int)dia->Comment); lua_pushboolean(L, (int)dia->Comment);
lua_setfield(L, -2, "comment"); lua_setfield(L, -2, "comment");
@ -172,7 +172,7 @@ namespace Automation4 {
lua_pushstring(L, "dialogue"); lua_pushstring(L, "dialogue");
} else if (e->GetType() == ENTRY_STYLE) { } else if (e->GetType() == ENTRY_STYLE) {
AssStyle *sty = e->GetAsStyle(e); AssStyle *sty = static_cast<AssStyle*>(e);
lua_pushstring(L, sty->name.mb_str(wxConvUTF8)); lua_pushstring(L, sty->name.mb_str(wxConvUTF8));
lua_setfield(L, -2, "name"); lua_setfield(L, -2, "name");
@ -858,14 +858,14 @@ namespace Automation4 {
int LuaAssFile::LuaParseKaraokeData(lua_State *L) int LuaAssFile::LuaParseKaraokeData(lua_State *L)
{ {
AssEntry *e = LuaToAssEntry(L); AssEntry *e = LuaToAssEntry(L);
if (e->GetType() != ENTRY_DIALOGUE) { AssDialogue *dia = dynamic_cast<AssDialogue*>(e);
if (!dia) {
delete e; delete e;
lua_pushstring(L, "Attempt to create karaoke table from non-dialogue subtitle line"); lua_pushstring(L, "Attempt to create karaoke table from non-dialogue subtitle line");
lua_error(L); lua_error(L);
return 0; return 0;
} }
AssDialogue *dia = e->GetAsDialogue(e);
dia->ParseASSTags(); dia->ParseASSTags();
int kcount = 0; int kcount = 0;

View file

@ -929,7 +929,7 @@ void BaseGrid::SetColumnWidths() {
if (false && AssFile::top) { if (false && AssFile::top) {
AssStyle *curStyle; AssStyle *curStyle;
for (entryIter curIter=AssFile::top->Line.begin();curIter!=AssFile::top->Line.end();curIter++) { for (entryIter curIter=AssFile::top->Line.begin();curIter!=AssFile::top->Line.end();curIter++) {
curStyle = AssEntry::GetAsStyle(*curIter); curStyle = dynamic_cast<AssStyle*>(*curIter);
if (curStyle) { if (curStyle) {
dc.GetTextExtent(curStyle->name, &fw, &fh, NULL, NULL, &font); dc.GetTextExtent(curStyle->name, &fw, &fh, NULL, NULL, &font);
if (fw > styleLen) styleLen = fw; if (fw > styleLen) styleLen = fw;
@ -975,7 +975,7 @@ AssDialogue *BaseGrid::GetDialogue(int n) {
if ((size_t)n >= diagMap.size()) return NULL; if ((size_t)n >= diagMap.size()) return NULL;
AssEntry *e = *diagMap.at(n); AssEntry *e = *diagMap.at(n);
if (e->GetType() != ENTRY_DIALOGUE) return NULL; if (e->GetType() != ENTRY_DIALOGUE) return NULL;
return AssEntry::GetAsDialogue(e); return dynamic_cast<AssDialogue*>(e);
} }
catch (...) { catch (...) {
return NULL; return NULL;
@ -1019,7 +1019,7 @@ void BaseGrid::UpdateMaps() {
int n = 0; int n = 0;
AssDialogue *curdiag; AssDialogue *curdiag;
for (entryIter cur=AssFile::top->Line.begin();cur != AssFile::top->Line.end();cur++) { for (entryIter cur=AssFile::top->Line.begin();cur != AssFile::top->Line.end();cur++) {
curdiag = AssEntry::GetAsDialogue(*cur); curdiag = dynamic_cast<AssDialogue*>(*cur);
if (curdiag) { if (curdiag) {
// Find old pos // Find old pos
bool sel = false; bool sel = false;

View file

@ -110,7 +110,7 @@ void DialogAttachments::UpdateList() {
// Fill list // Fill list
AssAttachment *attach; AssAttachment *attach;
for (std::list<AssEntry*>::iterator cur = AssFile::top->Line.begin();cur != AssFile::top->Line.end();cur++) { for (std::list<AssEntry*>::iterator cur = AssFile::top->Line.begin();cur != AssFile::top->Line.end();cur++) {
attach = AssEntry::GetAsAttachment(*cur); attach = dynamic_cast<AssAttachment*>(*cur);
if (attach) { if (attach) {
// Add item // Add item
int row = listView->GetItemCount(); int row = listView->GetItemCount();

View file

@ -447,14 +447,14 @@ void FontsCollectorThread::Collect() {
curLine = 0; curLine = 0;
for (std::list<AssEntry*>::iterator cur=subs->Line.begin();cur!=subs->Line.end();cur++) { for (std::list<AssEntry*>::iterator cur=subs->Line.begin();cur!=subs->Line.end();cur++) {
// Collect from style // Collect from style
curStyle = AssEntry::GetAsStyle(*cur); curStyle = dynamic_cast<AssStyle*>(*cur);
if (curStyle) { if (curStyle) {
AddFont(curStyle->font,0); AddFont(curStyle->font,0);
} }
// Collect from dialogue // Collect from dialogue
else { else {
curDiag = AssEntry::GetAsDialogue(*cur); curDiag = dynamic_cast<AssDialogue*>(*cur);
if (curDiag) { if (curDiag) {
curLine++; curLine++;
curDiag->ParseASSTags(); curDiag->ParseASSTags();

View file

@ -459,7 +459,7 @@ void KaraokeLineMatchDisplay::SetInputData(const AssDialogue *src, const AssDial
source_sel_length = 0; source_sel_length = 0;
if (src) if (src)
{ {
AssDialogue *varsrc = AssEntry::GetAsDialogue(src->Clone()); AssDialogue *varsrc = dynamic_cast<AssDialogue*>(src->Clone());
varsrc->ParseASSTags(); varsrc->ParseASSTags();
AssKaraokeVector kara; AssKaraokeVector kara;
ParseAssKaraokeTags(varsrc, kara); ParseAssKaraokeTags(varsrc, kara);
@ -941,7 +941,7 @@ void DialogKanjiTimer::OnClose(wxCommandEvent &event) {
while(LinesToChange.empty()==false) { while(LinesToChange.empty()==false) {
std::pair<entryIter,wxString> p = LinesToChange.back(); std::pair<entryIter,wxString> p = LinesToChange.back();
LinesToChange.pop_back(); LinesToChange.pop_back();
AssDialogue *line = AssEntry::GetAsDialogue(*p.first); AssDialogue *line = dynamic_cast<AssDialogue*>(*p.first);
line->Text = p.second; line->Text = p.second;
} }
if (modified) { if (modified) {
@ -1101,9 +1101,9 @@ void DialogKanjiTimer::ResetForNewLine()
AssDialogue *dst = 0; AssDialogue *dst = 0;
if (currentSourceLine != subs->Line.end()) if (currentSourceLine != subs->Line.end())
src = AssEntry::GetAsDialogue(*currentSourceLine); src = dynamic_cast<AssDialogue*>(*currentSourceLine);
if (currentDestinationLine != subs->Line.end()) if (currentDestinationLine != subs->Line.end())
dst = AssEntry::GetAsDialogue(*currentDestinationLine); dst = dynamic_cast<AssDialogue*>(*currentDestinationLine);
if (src == 0 || dst == 0) if (src == 0 || dst == 0)
{ {
@ -1139,7 +1139,7 @@ entryIter DialogKanjiTimer::FindNextStyleMatch(entryIter search_from, const wxSt
while (++search_from != subs->Line.end()) while (++search_from != subs->Line.end())
{ {
AssDialogue *dlg = AssEntry::GetAsDialogue(*search_from); AssDialogue *dlg = dynamic_cast<AssDialogue*>(*search_from);
if (dlg && dlg->Style == search_style) if (dlg && dlg->Style == search_style)
break; break;
} }
@ -1158,7 +1158,7 @@ entryIter DialogKanjiTimer::FindPrevStyleMatch(entryIter search_from, const wxSt
while (--search_from != subs->Line.begin()) while (--search_from != subs->Line.begin())
{ {
AssDialogue *dlg = AssEntry::GetAsDialogue(*search_from); AssDialogue *dlg = dynamic_cast<AssDialogue*>(*search_from);
if (dlg && dlg->Style == search_style) if (dlg && dlg->Style == search_style)
break; break;
} }

View file

@ -264,7 +264,7 @@ void DialogResample::OnResample (wxCommandEvent &event) {
AssDialogue *curDiag; AssDialogue *curDiag;
for (entryIter cur=subs->Line.begin();cur!=subs->Line.end();cur++) { for (entryIter cur=subs->Line.begin();cur!=subs->Line.end();cur++) {
// Apply to dialogues // Apply to dialogues
curDiag = AssEntry::GetAsDialogue(*cur); curDiag = dynamic_cast<AssDialogue*>(*cur);
if (curDiag && !(curDiag->Comment && (curDiag->Effect.StartsWith(_T("template")) || curDiag->Effect.StartsWith(_T("code"))))) { if (curDiag && !(curDiag->Comment && (curDiag->Effect.StartsWith(_T("template")) || curDiag->Effect.StartsWith(_T("code"))))) {
try { try {
// Override tags // Override tags
@ -302,7 +302,7 @@ void DialogResample::OnResample (wxCommandEvent &event) {
} }
// Apply to styles // Apply to styles
curStyle = AssEntry::GetAsStyle(*cur); curStyle = dynamic_cast<AssStyle*>(*cur);
if (curStyle) { if (curStyle) {
curStyle->fontsize = int(curStyle->fontsize * r + 0.5); curStyle->fontsize = int(curStyle->fontsize * r + 0.5);
curStyle->outline_w *= r; curStyle->outline_w *= r;

View file

@ -288,7 +288,7 @@ void DialogStyleManager::LoadCurrentStyles (AssFile *subs) {
styleMap.clear(); styleMap.clear();
for (list<AssEntry*>::iterator cur=subs->Line.begin();cur!=subs->Line.end();cur++) { for (list<AssEntry*>::iterator cur=subs->Line.begin();cur!=subs->Line.end();cur++) {
style = AssEntry::GetAsStyle(*cur); style = dynamic_cast<AssStyle*>(*cur);
if (style && style->Valid) { if (style && style->Valid) {
CurrentList->Append(style->name); CurrentList->Append(style->name);
styleMap.push_back(style); styleMap.push_back(style);
@ -1075,7 +1075,7 @@ void DialogStyleManager::MoveStyles(bool storage, int type) {
for (entryIter cur=subs->Line.begin();cur!=subs->Line.end();cur = next) { for (entryIter cur=subs->Line.begin();cur!=subs->Line.end();cur = next) {
next = cur; next = cur;
next++; next++;
AssStyle *style = AssEntry::GetAsStyle(*cur); AssStyle *style = dynamic_cast<AssStyle*>(*cur);
if (style) { if (style) {
subs->Line.insert(cur,styls[curn]); subs->Line.insert(cur,styls[curn]);
subs->Line.erase(cur); subs->Line.erase(cur);

View file

@ -319,7 +319,7 @@ void DialogTimingProcessor::OnApply(wxCommandEvent &event) {
AssDialogue *tempDiag; AssDialogue *tempDiag;
int i = 0; int i = 0;
for (std::list<AssEntry*>::iterator cur=grid->ass->Line.begin();cur!=grid->ass->Line.end();cur++) { for (std::list<AssEntry*>::iterator cur=grid->ass->Line.begin();cur!=grid->ass->Line.end();cur++) {
tempDiag = AssEntry::GetAsDialogue(*cur); tempDiag = dynamic_cast<AssDialogue*>(*cur);
if (tempDiag) { if (tempDiag) {
i++; i++;
if (tempDiag->Start.GetMS() > tempDiag->End.GetMS()) { if (tempDiag->Start.GetMS() > tempDiag->End.GetMS()) {

View file

@ -78,7 +78,7 @@ void AssFixStylesFilter::ProcessSubs(AssFile *subs, wxWindow *export_dialog) {
// Process lines // Process lines
entryIter cur; entryIter cur;
for (cur=subs->Line.begin();cur!=subs->Line.end();cur++) { for (cur=subs->Line.begin();cur!=subs->Line.end();cur++) {
AssDialogue *diag = AssEntry::GetAsDialogue(*cur); AssDialogue *diag = dynamic_cast<AssDialogue*>(*cur);
if (diag) { if (diag) {
// Try to find style and match case // Try to find style and match case
bool found = false; bool found = false;

View file

@ -285,7 +285,7 @@ void AssTransformFramerateFilter::TransformFrameRate(AssFile *subs) {
// compensate it AGAIN 20 lines down? I DO NOT GET IT // compensate it AGAIN 20 lines down? I DO NOT GET IT
// -Fluff // -Fluff
//curEntry->Start.SetMS(Input->GetTimeAtFrame(Output->GetFrameAtTime(curEntry->GetStartMS(),true),true)); //curEntry->Start.SetMS(Input->GetTimeAtFrame(Output->GetFrameAtTime(curEntry->GetStartMS(),true),true));
curDialogue = AssEntry::GetAsDialogue(curEntry); curDialogue = dynamic_cast<AssDialogue*>(curEntry);
// Update dialogue entries // Update dialogue entries
if (curDialogue) { if (curDialogue) {

View file

@ -87,7 +87,7 @@ void AssLimitToVisibleFilter::ProcessSubs(AssFile *subs, wxWindow *export_dialog
cur = next++; cur = next++;
// Is dialogue? // Is dialogue?
diag = AssEntry::GetAsDialogue(*cur); diag = dynamic_cast<AssDialogue*>(*cur);
if (diag) { if (diag) {
int f1 = VFR_Output.GetFrameAtTime(diag->Start.GetMS(),true); int f1 = VFR_Output.GetFrameAtTime(diag->Start.GetMS(),true);
int f2 = VFR_Output.GetFrameAtTime(diag->End.GetMS(),false); int f2 = VFR_Output.GetFrameAtTime(diag->End.GetMS(),false);

View file

@ -853,7 +853,7 @@ void SubtitlesGrid::LoadFromAss (AssFile *_ass,bool keepSelection,bool dontModif
AssDialogue *curdiag; AssDialogue *curdiag;
ready = false; ready = false;
for (entryIter cur=ass->Line.begin();cur != ass->Line.end();cur++) { for (entryIter cur=ass->Line.begin();cur != ass->Line.end();cur++) {
curdiag = AssEntry::GetAsDialogue(*cur); curdiag = dynamic_cast<AssDialogue*>(*cur);
if (curdiag) { if (curdiag) {
diagMap.push_back(cur); diagMap.push_back(cur);
diagPtrMap.push_back(curdiag); diagPtrMap.push_back(curdiag);

View file

@ -94,7 +94,7 @@ SubtitlesPreview::~SubtitlesPreview() {
/// ///
void SubtitlesPreview::SetStyle(AssStyle *_style) { void SubtitlesPreview::SetStyle(AssStyle *_style) {
// Prepare style // Prepare style
AssStyle *tmpStyle = AssEntry::GetAsStyle(_style->Clone()); AssStyle *tmpStyle = dynamic_cast<AssStyle*>(_style->Clone());
tmpStyle->name = _T("Preview"); tmpStyle->name = _T("Preview");
tmpStyle->alignment = 5; tmpStyle->alignment = 5;
for (int i=0;i<4;i++) tmpStyle->Margin[i] = 0; for (int i=0;i<4;i++) tmpStyle->Margin[i] = 0;

View file

@ -421,7 +421,7 @@ void SubtitleFormat::ConvertTags(int format,wxString lineEnd) {
using std::list; using std::list;
list<AssEntry*>::iterator next; list<AssEntry*>::iterator next;
for (list<AssEntry*>::iterator cur=Line->begin();cur!=Line->end();cur++) { for (list<AssEntry*>::iterator cur=Line->begin();cur!=Line->end();cur++) {
AssDialogue *current = AssEntry::GetAsDialogue(*cur); AssDialogue *current = dynamic_cast<AssDialogue*>(*cur);
if (current) { if (current) {
// Strip tags // Strip tags
if (format == 1) current->StripTags(); if (format == 1) current->StripTags();
@ -448,7 +448,7 @@ void SubtitleFormat::StripComments() {
next = cur; next = cur;
next++; next++;
AssDialogue *dlg = AssEntry::GetAsDialogue(*cur); AssDialogue *dlg = dynamic_cast<AssDialogue*>(*cur);
if (dlg && (dlg->Comment || dlg->Text.IsEmpty())) { if (dlg && (dlg->Comment || dlg->Text.IsEmpty())) {
delete *cur; delete *cur;
Line->erase(cur); Line->erase(cur);
@ -468,7 +468,7 @@ void SubtitleFormat::StripNonDialogue() {
next = cur; next = cur;
next++; next++;
if (!AssEntry::GetAsDialogue(*cur)) { if (!dynamic_cast<AssDialogue*>(*cur)) {
delete *cur; delete *cur;
Line->erase(cur); Line->erase(cur);
} }
@ -486,7 +486,7 @@ static void InsertLineSortedIntoList(std::list<AssEntry*> &list, std::list<AssEn
std::list<AssEntry*>::iterator insertpos = next; std::list<AssEntry*>::iterator insertpos = next;
bool inserted = false; bool inserted = false;
while (insertpos != list.end()) { while (insertpos != list.end()) {
AssDialogue *candidate = AssEntry::GetAsDialogue(*insertpos); AssDialogue *candidate = dynamic_cast<AssDialogue*>(*insertpos);
if (candidate && candidate->Start >= newdlg->Start) { if (candidate && candidate->Start >= newdlg->Start) {
list.insert(insertpos, newdlg); list.insert(insertpos, newdlg);
inserted = true; inserted = true;
@ -513,8 +513,8 @@ void SubtitleFormat::RecombineOverlaps() {
if (next == Line->end()) break; if (next == Line->end()) break;
AssDialogue *prevdlg = AssEntry::GetAsDialogue(*cur); AssDialogue *prevdlg = dynamic_cast<AssDialogue*>(*cur);
AssDialogue *curdlg = AssEntry::GetAsDialogue(*next); AssDialogue *curdlg = dynamic_cast<AssDialogue*>(*next);
if (curdlg && prevdlg && prevdlg->End > curdlg->Start) { if (curdlg && prevdlg && prevdlg->End > curdlg->Start) {
// Use names like in the algorithm description and prepare for erasing // Use names like in the algorithm description and prepare for erasing
@ -532,7 +532,7 @@ void SubtitleFormat::RecombineOverlaps() {
//Is there an A part before the overlap? //Is there an A part before the overlap?
if (curdlg->Start > prevdlg->Start) { if (curdlg->Start > prevdlg->Start) {
// Produce new entry with correct values // Produce new entry with correct values
AssDialogue *newdlg = AssEntry::GetAsDialogue(prevdlg->Clone()); AssDialogue *newdlg = dynamic_cast<AssDialogue*>(prevdlg->Clone());
newdlg->Start = prevdlg->Start; newdlg->Start = prevdlg->Start;
newdlg->End = curdlg->Start; newdlg->End = curdlg->Start;
newdlg->Text = prevdlg->Text; newdlg->Text = prevdlg->Text;
@ -542,7 +542,7 @@ void SubtitleFormat::RecombineOverlaps() {
// Overlapping A+B part // Overlapping A+B part
{ {
AssDialogue *newdlg = AssEntry::GetAsDialogue(prevdlg->Clone()); AssDialogue *newdlg = dynamic_cast<AssDialogue*>(prevdlg->Clone());
newdlg->Start = curdlg->Start; newdlg->Start = curdlg->Start;
newdlg->End = (prevdlg->End < curdlg->End) ? prevdlg->End : curdlg->End; newdlg->End = (prevdlg->End < curdlg->End) ? prevdlg->End : curdlg->End;
// Put an ASS format hard linewrap between lines // Put an ASS format hard linewrap between lines
@ -554,7 +554,7 @@ void SubtitleFormat::RecombineOverlaps() {
// Is there an A part after the overlap? // Is there an A part after the overlap?
if (prevdlg->End > curdlg->End) { if (prevdlg->End > curdlg->End) {
// Produce new entry with correct values // Produce new entry with correct values
AssDialogue *newdlg = AssEntry::GetAsDialogue(prevdlg->Clone()); AssDialogue *newdlg = dynamic_cast<AssDialogue*>(prevdlg->Clone());
newdlg->Start = curdlg->End; newdlg->Start = curdlg->End;
newdlg->End = prevdlg->End; newdlg->End = prevdlg->End;
newdlg->Text = prevdlg->Text; newdlg->Text = prevdlg->Text;
@ -565,7 +565,7 @@ void SubtitleFormat::RecombineOverlaps() {
// Is there a B part after the overlap? // Is there a B part after the overlap?
if (curdlg->End > prevdlg->End) { if (curdlg->End > prevdlg->End) {
// Produce new entry with correct values // Produce new entry with correct values
AssDialogue *newdlg = AssEntry::GetAsDialogue(prevdlg->Clone()); AssDialogue *newdlg = dynamic_cast<AssDialogue*>(prevdlg->Clone());
newdlg->Start = prevdlg->End; newdlg->Start = prevdlg->End;
newdlg->End = curdlg->End; newdlg->End = curdlg->End;
newdlg->Text = curdlg->Text; newdlg->Text = curdlg->Text;
@ -592,8 +592,8 @@ void SubtitleFormat::MergeIdentical() {
if (next == Line->end()) break; if (next == Line->end()) break;
AssDialogue *curdlg = AssEntry::GetAsDialogue(*cur); AssDialogue *curdlg = dynamic_cast<AssDialogue*>(*cur);
AssDialogue *nextdlg = AssEntry::GetAsDialogue(*next); AssDialogue *nextdlg = dynamic_cast<AssDialogue*>(*next);
if (curdlg && nextdlg && curdlg->End == nextdlg->Start && curdlg->Text == nextdlg->Text) { if (curdlg && nextdlg && curdlg->End == nextdlg->Start && curdlg->Text == nextdlg->Text) {
// Merge timing // Merge timing

View file

@ -106,7 +106,7 @@ void DVDSubtitleFormat::GetSubPictureList(std::vector<SubPicture> &pics) {
int count = 0; int count = 0;
std::vector<AssDialogue*> diags; std::vector<AssDialogue*> diags;
for (list<AssEntry*>::iterator cur=Line->begin();cur!=Line->end();cur++) { for (list<AssEntry*>::iterator cur=Line->begin();cur!=Line->end();cur++) {
AssDialogue *current = AssEntry::GetAsDialogue(*cur); AssDialogue *current = dynamic_cast<AssDialogue*>(*cur);
if (current) { if (current) {
diags.push_back(current); diags.push_back(current);
count++; count++;

View file

@ -102,7 +102,7 @@ void EncoreSubtitleFormat::WriteFile(wxString _filename,wxString encoding) {
FractionalTime ft(fps_rat.smpte_dropframe ? _T(";") : _T(":"), fps_rat.num, fps_rat.den, fps_rat.smpte_dropframe); FractionalTime ft(fps_rat.smpte_dropframe ? _T(";") : _T(":"), fps_rat.num, fps_rat.den, fps_rat.smpte_dropframe);
for (list<AssEntry*>::iterator cur=Line->begin();cur!=Line->end();cur++) { for (list<AssEntry*>::iterator cur=Line->begin();cur!=Line->end();cur++) {
AssDialogue *current = AssEntry::GetAsDialogue(*cur); AssDialogue *current = dynamic_cast<AssDialogue*>(*cur);
if (current && !current->Comment) { if (current && !current->Comment) {
++i; ++i;
file.WriteLineToFile(wxString::Format(_T("%i %s %s %s"), i, ft.FromAssTime(current->Start).c_str(), ft.FromAssTime(current->End).c_str(), current->Text.c_str())); file.WriteLineToFile(wxString::Format(_T("%i %s %s %s"), i, ft.FromAssTime(current->Start).c_str(), ft.FromAssTime(current->End).c_str(), current->Text.c_str()));

View file

@ -219,7 +219,7 @@ void MicroDVDSubtitleFormat::WriteFile(wxString filename,wxString encoding) {
// Write lines // Write lines
using std::list; using std::list;
for (list<AssEntry*>::iterator cur=Line->begin();cur!=Line->end();cur++) { for (list<AssEntry*>::iterator cur=Line->begin();cur!=Line->end();cur++) {
AssDialogue *current = AssEntry::GetAsDialogue(*cur); AssDialogue *current = dynamic_cast<AssDialogue*>(*cur);
if (current && !current->Comment) { if (current && !current->Comment) {
// Prepare data // Prepare data
int start = rate->GetFrameAtTime(current->Start.GetMS(),true); int start = rate->GetFrameAtTime(current->Start.GetMS(),true);

View file

@ -215,7 +215,7 @@ void SRTSubtitleFormat::WriteFile(wxString _filename,wxString encoding) {
int i=1; int i=1;
using std::list; using std::list;
for (list<AssEntry*>::iterator cur=Line->begin();cur!=Line->end();cur++) { for (list<AssEntry*>::iterator cur=Line->begin();cur!=Line->end();cur++) {
AssDialogue *current = AssEntry::GetAsDialogue(*cur); AssDialogue *current = dynamic_cast<AssDialogue*>(*cur);
if (current && !current->Comment) { if (current && !current->Comment) {
// Write line // Write line
file.WriteLineToFile(wxString::Format(_T("%i"),i)); file.WriteLineToFile(wxString::Format(_T("%i"),i));

View file

@ -108,7 +108,7 @@ void TranStationSubtitleFormat::WriteFile(wxString _filename,wxString encoding)
for (list<AssEntry*>::iterator cur=Line->begin();cur!=Line->end();cur++) { for (list<AssEntry*>::iterator cur=Line->begin();cur!=Line->end();cur++) {
if (next) if (next)
current = next; current = next;
next = AssEntry::GetAsDialogue(*cur); next = dynamic_cast<AssDialogue*>(*cur);
if (current && !current->Comment) { if (current && !current->Comment) {
// Write text // Write text

View file

@ -245,7 +245,7 @@ void TTXTSubtitleFormat::WriteFile(wxString filename,wxString encoding) {
using std::list; using std::list;
prev = NULL; prev = NULL;
for (list<AssEntry*>::iterator cur=Line->begin();cur!=Line->end();cur++) { for (list<AssEntry*>::iterator cur=Line->begin();cur!=Line->end();cur++) {
AssDialogue *current = AssEntry::GetAsDialogue(*cur); AssDialogue *current = dynamic_cast<AssDialogue*>(*cur);
if (current && !current->Comment) { if (current && !current->Comment) {
WriteLine(root,current); WriteLine(root,current);
i++; i++;
@ -359,7 +359,7 @@ void TTXTSubtitleFormat::ConvertToTTXT () {
// Find last line // Find last line
AssTime lastTime; AssTime lastTime;
for (std::list<AssEntry*>::reverse_iterator cur=Line->rbegin();cur!=Line->rend();cur++) { for (std::list<AssEntry*>::reverse_iterator cur=Line->rbegin();cur!=Line->rend();cur++) {
AssDialogue *prev = AssEntry::GetAsDialogue(*cur); AssDialogue *prev = dynamic_cast<AssDialogue*>(*cur);
if (prev) { if (prev) {
lastTime = prev->End; lastTime = prev->End;
break; break;

View file

@ -200,7 +200,7 @@ void TXTSubtitleFormat::WriteFile(wxString filename,wxString encoding) { using n
// Detect number of lines with Actor field filled out // Detect number of lines with Actor field filled out
for (list<AssEntry*>::iterator l = Line->begin(); l != Line->end(); ++l) { for (list<AssEntry*>::iterator l = Line->begin(); l != Line->end(); ++l) {
AssDialogue *dia = AssEntry::GetAsDialogue(*l); AssDialogue *dia = dynamic_cast<AssDialogue*>(*l);
if (dia && !dia->Comment) { if (dia && !dia->Comment) {
num_dialogue_lines++; num_dialogue_lines++;
if (!dia->Actor.IsEmpty()) if (!dia->Actor.IsEmpty())
@ -217,7 +217,7 @@ void TXTSubtitleFormat::WriteFile(wxString filename,wxString encoding) { using n
// Write the file // Write the file
for (list<AssEntry*>::iterator l = Line->begin(); l != Line->end(); ++l) { for (list<AssEntry*>::iterator l = Line->begin(); l != Line->end(); ++l) {
AssDialogue *dia = AssEntry::GetAsDialogue(*l); AssDialogue *dia = dynamic_cast<AssDialogue*>(*l);
if (dia) { if (dia) {
wxString out_line; wxString out_line;