Check for uses of styles other than "Default" in CanSave rather than customized styles

Customizable default styles makes the latter check awkward to implement,
and the previous logic of comparing against the hardcoded default wrong.
This commit is contained in:
Thomas Goyne 2014-05-12 08:34:28 -07:00
parent bc2f862909
commit 562a2259f5
2 changed files with 7 additions and 10 deletions

View File

@ -86,14 +86,9 @@ bool SubtitleFormat::CanSave(const AssFile *subs) const {
if (!subs->Attachments.empty())
return false;
std::string defstyle = AssStyle().GetEntryData();
for (auto const& line : subs->Styles) {
if (line.GetEntryData() != defstyle)
return false;
}
auto def = boost::flyweight<std::string>("Default");
for (auto const& line : subs->Events) {
if (line.GetStrippedText() != line.Text)
if (line.Style != def || line.GetStrippedText() != line.Text)
return false;
}

View File

@ -334,9 +334,7 @@ SRTSubtitleFormat::SRTSubtitleFormat()
}
std::vector<std::string> SRTSubtitleFormat::GetReadWildcards() const {
std::vector<std::string> formats;
formats.push_back("srt");
return formats;
return {"srt"};
}
std::vector<std::string> SRTSubtitleFormat::GetWriteWildcards() const {
@ -494,7 +492,11 @@ bool SRTSubtitleFormat::CanSave(const AssFile *file) const {
if (!file->Attachments.empty())
return false;
auto def = boost::flyweight<std::string>("Default");
for (auto const& line : file->Events) {
if (line.Style != def)
return false;
auto blocks = line.ParseTags();
for (auto ovr : blocks | agi::of_type<AssDialogueBlockOverride>()) {
// Verify that all overrides used are supported