mirror of https://github.com/odrling/Aegisub
Replace AssDialogueBlock::GetAsOverride etc. with dynamic_cast
Originally committed to SVN as r4428.
This commit is contained in:
parent
fe65f778b1
commit
f001651865
|
@ -550,7 +550,7 @@ void AssDialogue::StripTag (wxString tagName) {
|
|||
// Look for blocks
|
||||
for (vector<AssDialogueBlock*>::iterator cur=Blocks.begin();cur!=Blocks.end();cur++) {
|
||||
if ((*cur)->GetType() == BLOCK_OVERRIDE) {
|
||||
AssDialogueBlockOverride *over = AssDialogueBlock::GetAsOverride(*cur);
|
||||
AssDialogueBlockOverride *over = dynamic_cast<AssDialogueBlockOverride*>(*cur);
|
||||
wxString temp;
|
||||
for (size_t i=0;i<over->Tags.size();i++) {
|
||||
if (over->Tags[i]->Name != tagName) temp += over->Tags[i]->ToString();
|
||||
|
@ -583,7 +583,7 @@ void AssDialogue::ConvertTagsToSRT () {
|
|||
// Iterate through blocks
|
||||
ParseASSTags();
|
||||
for (size_t i=0;i<Blocks.size();i++) {
|
||||
curBlock = AssDialogueBlock::GetAsOverride(Blocks.at(i));
|
||||
curBlock = dynamic_cast<AssDialogueBlockOverride*>(Blocks.at(i));
|
||||
if (curBlock) {
|
||||
// Iterate through overrides
|
||||
for (size_t j=0;j<curBlock->Tags.size();j++) {
|
||||
|
@ -646,7 +646,7 @@ void AssDialogue::ConvertTagsToSRT () {
|
|||
|
||||
// Plain text
|
||||
else {
|
||||
curPlain = AssDialogueBlock::GetAsPlain(Blocks.at(i));
|
||||
curPlain = dynamic_cast<AssDialogueBlockPlain*>(Blocks.at(i));
|
||||
if (curPlain) {
|
||||
final += curPlain->GetText();
|
||||
}
|
||||
|
@ -787,48 +787,14 @@ AssDialogueBlock::AssDialogueBlock () {
|
|||
}
|
||||
|
||||
/// @brief Destructor
|
||||
/// @return
|
||||
AssDialogueBlock::~AssDialogueBlock () {
|
||||
}
|
||||
|
||||
/// @brief If it isn't a plain block, returns NULL ---------------------- Returns as a plain block
|
||||
/// @param base
|
||||
/// @return
|
||||
AssDialogueBlockPlain *AssDialogueBlock::GetAsPlain(AssDialogueBlock *base) {
|
||||
if (!base) return NULL;
|
||||
if (base->GetType() == BLOCK_PLAIN) {
|
||||
return static_cast<AssDialogueBlockPlain*> (base);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/// @brief If it isn't an override block, returns NULL ---------------------------- Returns as an override block
|
||||
/// @param base
|
||||
/// @return
|
||||
AssDialogueBlockOverride *AssDialogueBlock::GetAsOverride(AssDialogueBlock *base) {
|
||||
if (!base) return NULL;
|
||||
if (base->GetType() == BLOCK_OVERRIDE) {
|
||||
return static_cast<AssDialogueBlockOverride*> (base);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/// @brief If it isn't an drawing block, returns NULL ---------------------------- Returns as a drawing block
|
||||
/// @param base
|
||||
/// @return
|
||||
AssDialogueBlockDrawing *AssDialogueBlock::GetAsDrawing(AssDialogueBlock *base) {
|
||||
if (!base) return NULL;
|
||||
if (base->GetType() == BLOCK_DRAWING) {
|
||||
return static_cast<AssDialogueBlockDrawing*> (base);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/// @brief Constructor AssDialogueBlockPlain //////////////////////
|
||||
/// @brief Constructor AssDialogueBlockPlain
|
||||
AssDialogueBlockPlain::AssDialogueBlockPlain () {
|
||||
}
|
||||
|
||||
/// @brief Constructor AssDialogueBlockDrawing //////////////////////
|
||||
/// @brief Constructor AssDialogueBlockDrawing
|
||||
AssDialogueBlockDrawing::AssDialogueBlockDrawing () {
|
||||
}
|
||||
|
||||
|
|
|
@ -113,9 +113,6 @@ public:
|
|||
/// @return
|
||||
///
|
||||
virtual wxString GetText() { return text; }
|
||||
static AssDialogueBlockPlain *GetAsPlain(AssDialogueBlock *base); // Returns a block base as a plain block if it is valid, null otherwise
|
||||
static AssDialogueBlockOverride *GetAsOverride(AssDialogueBlock *base); // Returns a block base as an override block if it is valid, null otherwise
|
||||
static AssDialogueBlockDrawing *GetAsDrawing(AssDialogueBlock *base); // Returns a block base as a drawing block if it is valid, null otherwise
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -83,7 +83,7 @@ void ParseAssKaraokeTags(const AssDialogue *line, AssKaraokeVector &syls)
|
|||
break;
|
||||
|
||||
case BLOCK_OVERRIDE: {
|
||||
AssDialogueBlockOverride *ovr = block->GetAsOverride(block);
|
||||
AssDialogueBlockOverride *ovr = dynamic_cast<AssDialogueBlockOverride*>(block);
|
||||
|
||||
for (int j = 0; j < (int)ovr->Tags.size(); j++) {
|
||||
AssOverrideTag *tag = ovr->Tags[j];
|
||||
|
|
|
@ -897,7 +897,7 @@ namespace Automation4 {
|
|||
|
||||
case BLOCK_OVERRIDE: {
|
||||
bool brackets_open = false;
|
||||
AssDialogueBlockOverride *ovr = block->GetAsOverride(block);
|
||||
AssDialogueBlockOverride *ovr = dynamic_cast<AssDialogueBlockOverride*>(block);
|
||||
|
||||
for (int j = 0; j < (int)ovr->Tags.size(); j++) {
|
||||
AssOverrideTag *tag = ovr->Tags[j];
|
||||
|
|
|
@ -275,7 +275,7 @@ void DialogResample::OnResample (wxCommandEvent &event) {
|
|||
size_t nblocks = curDiag->Blocks.size();
|
||||
AssDialogueBlockDrawing *curBlock;
|
||||
for (size_t i=0;i<nblocks;i++) {
|
||||
curBlock = AssDialogueBlock::GetAsDrawing(curDiag->Blocks.at(i));
|
||||
curBlock = dynamic_cast<AssDialogueBlockDrawing*>(curDiag->Blocks.at(i));
|
||||
if (curBlock) {
|
||||
curBlock->TransformCoords(m[0],m[2],rx,ry);
|
||||
}
|
||||
|
|
|
@ -1178,7 +1178,7 @@ void SubsEditBox::SetOverride (wxString tagname,wxString preValue,int forcePos,b
|
|||
AssOverrideTag *tag;
|
||||
if (isFont || isColor || isFlag) {
|
||||
for (size_t i=0;i<=blockn;i++) {
|
||||
override = AssDialogueBlock::GetAsOverride(line->Blocks.at(i));
|
||||
override = dynamic_cast<AssDialogueBlockOverride*>(line->Blocks.at(i));
|
||||
if (override) {
|
||||
for (size_t j=0;j<override->Tags.size();j++) {
|
||||
tag = override->Tags.at(j);
|
||||
|
@ -1278,8 +1278,8 @@ void SubsEditBox::SetOverride (wxString tagname,wxString preValue,int forcePos,b
|
|||
}
|
||||
|
||||
// Get current block as plain or override
|
||||
AssDialogueBlockPlain *plain = AssDialogueBlock::GetAsPlain(block);
|
||||
override = AssDialogueBlock::GetAsOverride(block);
|
||||
AssDialogueBlockPlain *plain = dynamic_cast<AssDialogueBlockPlain*>(block);
|
||||
override = dynamic_cast<AssDialogueBlockOverride*>(block);
|
||||
|
||||
// Plain
|
||||
if (plain) {
|
||||
|
@ -1321,8 +1321,8 @@ void SubsEditBox::SetOverride (wxString tagname,wxString preValue,int forcePos,b
|
|||
TextEdit->SetTextTo(line->Text);
|
||||
blockn = BlockAtPos(selstart);
|
||||
block = line->Blocks.at(blockn);
|
||||
plain = AssDialogueBlock::GetAsPlain(block);
|
||||
override = AssDialogueBlock::GetAsOverride(block);
|
||||
plain = dynamic_cast<AssDialogueBlockPlain*>(block);
|
||||
override = dynamic_cast<AssDialogueBlockOverride*>(block);
|
||||
|
||||
// Plain
|
||||
if (plain) {
|
||||
|
|
|
@ -451,7 +451,7 @@ void VisualTool<FeatureType>::GetLinePosition(AssDialogue *diag,int &x, int &y,
|
|||
for (size_t i=0;i<blockn;i++) {
|
||||
if (posSet && orgSet) break;
|
||||
|
||||
override = AssDialogueBlock::GetAsOverride(diag->Blocks.at(i));
|
||||
override = dynamic_cast<AssDialogueBlockOverride*>(diag->Blocks.at(i));
|
||||
if (override) {
|
||||
for (size_t j=0;j<override->Tags.size();j++) {
|
||||
tag = override->Tags.at(j);
|
||||
|
@ -540,7 +540,7 @@ void VisualTool<FeatureType>::GetLineMove(AssDialogue *diag,bool &hasMove,int &x
|
|||
|
||||
// For each block
|
||||
for (size_t i=0;i<blockn;i++) {
|
||||
override = AssDialogueBlock::GetAsOverride(diag->Blocks.at(i));
|
||||
override = dynamic_cast<AssDialogueBlockOverride*>(diag->Blocks.at(i));
|
||||
if (override) {
|
||||
for (size_t j=0;j<override->Tags.size();j++) {
|
||||
tag = override->Tags.at(j);
|
||||
|
@ -598,7 +598,7 @@ void VisualTool<FeatureType>::GetLineRotation(AssDialogue *diag,float &rx,float
|
|||
}
|
||||
|
||||
// Process override
|
||||
override = AssDialogueBlock::GetAsOverride(diag->Blocks.at(0));
|
||||
override = dynamic_cast<AssDialogueBlockOverride*>(diag->Blocks.at(0));
|
||||
if (override) {
|
||||
for (size_t j=0;j<override->Tags.size();j++) {
|
||||
tag = override->Tags.at(j);
|
||||
|
@ -636,7 +636,7 @@ void VisualTool<FeatureType>::GetLineScale(AssDialogue *diag,float &scalX,float
|
|||
}
|
||||
|
||||
// Process override
|
||||
override = AssDialogueBlock::GetAsOverride(diag->Blocks.at(0));
|
||||
override = dynamic_cast<AssDialogueBlockOverride*>(diag->Blocks.at(0));
|
||||
if (override) {
|
||||
for (size_t j=0;j<override->Tags.size();j++) {
|
||||
tag = override->Tags.at(j);
|
||||
|
@ -679,7 +679,7 @@ void VisualTool<FeatureType>::GetLineClip(AssDialogue *diag,int &x1,int &y1,int
|
|||
}
|
||||
|
||||
// Process override
|
||||
override = AssDialogueBlock::GetAsOverride(diag->Blocks.at(0));
|
||||
override = dynamic_cast<AssDialogueBlockOverride*>(diag->Blocks.at(0));
|
||||
if (override) {
|
||||
for (size_t j=0;j<override->Tags.size();j++) {
|
||||
tag = override->Tags.at(j);
|
||||
|
@ -725,7 +725,7 @@ wxString VisualTool<FeatureType>::GetLineVectorClip(AssDialogue *diag,int &scale
|
|||
}
|
||||
|
||||
// Process override
|
||||
override = AssDialogueBlock::GetAsOverride(diag->Blocks.at(0));
|
||||
override = dynamic_cast<AssDialogueBlockOverride*>(diag->Blocks.at(0));
|
||||
if (override) {
|
||||
for (size_t j=0;j<override->Tags.size();j++) {
|
||||
tag = override->Tags.at(j);
|
||||
|
|
Loading…
Reference in New Issue