diff --git a/aegisub/automation/autoload/clean-info.lua b/aegisub/automation/autoload/clean-info.lua new file mode 100644 index 000000000..6265f9384 --- /dev/null +++ b/aegisub/automation/autoload/clean-info.lua @@ -0,0 +1,51 @@ +-- Copyright (c) 2012, Thomas Goyne +-- +-- Permission to use, copy, modify, and distribute this software for any +-- purpose with or without fee is hereby granted, provided that the above +-- copyright notice and this permission notice appear in all copies. +-- +-- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +-- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +-- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +-- ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +-- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +-- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +-- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +-- +-- $Id$ + +local tr = aegisub.gettext + +script_name = tr"Clean Script Info" +script_description = tr"Removes all but the absolutely required fields from the Script Info section. You might want to run this on files that you plan to distribute in original form." +script_author = "Thomas Goyne" +script_version = "1" + +function clean_script_info(subs) + local keep_keys = { + ["collisions"] = true, + ["playresx"] = true, + ["playresy"] = true, + ["scaledborderandshadow"] = true, + ["scripttype"] = true, + ["video colorspace"] = true, + ["wrapstyle"] = true + } + + for i = 1, #subs do + if subs[i].class == "info" and not keep_keys[strlower(subs[i].key)] then + subs[i] = nil + i = i - 1 + end + end +end + +function clean_script_info_macro(subs) + clean_script_info(sub) + aegisub.set_undo_point(script_name) +end + +aegisub.register_macro(script_name, script_description, clean_script_info_macro) +aegisub.register_filter(script_name, script_description, 0, clean_script_info) + + diff --git a/aegisub/build/msbuild/Aegisub/Aegisub.vcxproj b/aegisub/build/msbuild/Aegisub/Aegisub.vcxproj index aa91a6be9..11b689c6f 100644 --- a/aegisub/build/msbuild/Aegisub/Aegisub.vcxproj +++ b/aegisub/build/msbuild/Aegisub/Aegisub.vcxproj @@ -130,7 +130,6 @@ - @@ -315,7 +314,6 @@ - diff --git a/aegisub/build/msbuild/Aegisub/Aegisub.vcxproj.filters b/aegisub/build/msbuild/Aegisub/Aegisub.vcxproj.filters index 0c808a32b..f1cd9c198 100644 --- a/aegisub/build/msbuild/Aegisub/Aegisub.vcxproj.filters +++ b/aegisub/build/msbuild/Aegisub/Aegisub.vcxproj.filters @@ -300,9 +300,6 @@ Features\Export - - Features\Export - Features\Export @@ -884,9 +881,6 @@ Features\Export - - Features\Export - Features\Export diff --git a/aegisub/src/Makefile b/aegisub/src/Makefile index 7f9c91fb6..820f8c70d 100644 --- a/aegisub/src/Makefile +++ b/aegisub/src/Makefile @@ -188,7 +188,6 @@ SRC += \ dialog_version_check.cpp \ dialog_video_details.cpp \ audio_provider_dummy.cpp \ - export_clean_info.cpp \ export_fixstyle.cpp \ export_framerate.cpp \ fft.cpp \ diff --git a/aegisub/src/export_clean_info.cpp b/aegisub/src/export_clean_info.cpp deleted file mode 100644 index c307552f3..000000000 --- a/aegisub/src/export_clean_info.cpp +++ /dev/null @@ -1,81 +0,0 @@ -// Copyright (c) 2005, Niels Martin Hansen -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright notice, -// this list of conditions and the following disclaimer in the documentation -// and/or other materials provided with the distribution. -// * Neither the name of the Aegisub Group nor the names of its contributors -// may be used to endorse or promote products derived from this software -// without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE -// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -// POSSIBILITY OF SUCH DAMAGE. -// -// Aegisub Project http://www.aegisub.org/ -// -// $Id$ - -/// @file export_clean_info.cpp -/// @brief Clean Script Info export filter -/// @ingroup export -/// - -#include "config.h" - -#include "ass_dialogue.h" -#include "ass_file.h" -#include "ass_override.h" -#include "export_clean_info.h" - -AssTransformCleanInfoFilter::AssTransformCleanInfoFilter() -: AssExportFilter(_("Clean Script Info"), _("Removes all but the absolutely required fields from the Script Info section. You might want to run this on files that you plan to distribute in original form.")) -{ -} - -void AssTransformCleanInfoFilter::ProcessSubs(AssFile *subs, wxWindow *) { - using std::list; - AssEntry *curEntry; - entryIter cur, next = subs->Line.begin(); - while (next != subs->Line.end()) { - cur = next++; - - curEntry = *cur; - if (curEntry->group != "[Script Info]") { - continue; - } - if (curEntry->GetEntryData().empty()) { - continue; - } - if (curEntry->GetEntryData() == "[Script Info]") { - continue; - } - if (curEntry->GetEntryData().Left(1) == ";") { - continue; - } - - wxString field = curEntry->GetEntryData().Left(curEntry->GetEntryData().Find(':')).Lower(); - if (field != "scripttype" && - field != "collisions" && - field != "playresx" && - field != "playresy" && - field != "wrapstyle" && - field != "scaledborderandshadow") { - delete curEntry; - subs->Line.erase(cur); - } - } -} diff --git a/aegisub/src/export_clean_info.h b/aegisub/src/export_clean_info.h deleted file mode 100644 index 4c07037fd..000000000 --- a/aegisub/src/export_clean_info.h +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright (c) 2005, Niels Martin Hansen -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright notice, -// this list of conditions and the following disclaimer in the documentation -// and/or other materials provided with the distribution. -// * Neither the name of the Aegisub Group nor the names of its contributors -// may be used to endorse or promote products derived from this software -// without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE -// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -// POSSIBILITY OF SUCH DAMAGE. -// -// Aegisub Project http://www.aegisub.org/ -// -// $Id$ - -/// @file export_clean_info.h -/// @see export_clean_info.cpp -/// @ingroup export -/// - -#include "ass_export_filter.h" - - -/// DOCME -/// @class AssTransformCleanInfoFilter -/// @brief Removes all but the absolutely required fields from the Script Info section -/// -/// DOCME -class AssTransformCleanInfoFilter : public AssExportFilter { -public: - void ProcessSubs(AssFile *subs, wxWindow *); - AssTransformCleanInfoFilter(); -}; diff --git a/aegisub/src/main.cpp b/aegisub/src/main.cpp index 28ecd574b..38dc6ec59 100644 --- a/aegisub/src/main.cpp +++ b/aegisub/src/main.cpp @@ -60,7 +60,6 @@ #include "auto4_base.h" #include "charset_conv.h" #include "compat.h" -#include "export_clean_info.h" #include "export_fixstyle.h" #include "export_framerate.h" #include "frame_main.h" @@ -246,7 +245,6 @@ bool AegisubApp::OnInit() { // Load export filters StartupLog("Register export filters"); AssExportFilterChain::Register(new AssFixStylesFilter); - AssExportFilterChain::Register(new AssTransformCleanInfoFilter); AssExportFilterChain::Register(new AssTransformFramerateFilter); // Get parameter subs