diff --git a/aegilib/aegilib.vcproj b/aegilib/aegilib.vcproj index bdf9a8b9e..3506ce6d2 100644 --- a/aegilib/aegilib.vcproj +++ b/aegilib/aegilib.vcproj @@ -261,6 +261,10 @@ RelativePath=".\src\prec.h" > + + @@ -325,10 +329,22 @@ RelativePath=".\src\formats\format_ass_dialogue.cpp" > + + + + + + diff --git a/aegilib/include/aegilib/actionlist.h b/aegilib/include/aegilib/actionlist.h index f81509e2a..d29abdd43 100644 --- a/aegilib/include/aegilib/actionlist.h +++ b/aegilib/include/aegilib/actionlist.h @@ -59,13 +59,14 @@ namespace Gorgonsub { ActionList(Model &model,const String actionName,const String owner,bool undoAble); void Start(const String actionName); - void AddAction(const ActionPtr action); void AddActionStart(const ActionPtr action); public: ~ActionList(); + void AddAction(const ActionPtr action); void Finish(); + void InsertLine(SectionEntryPtr line,int position=-1,const String section=L""); void RemoveLine(int position,const String section); SectionEntryPtr ModifyLine(int position,const String section); diff --git a/aegilib/include/aegilib/serialize.h b/aegilib/include/aegilib/serialize.h new file mode 100644 index 000000000..905ffcca4 --- /dev/null +++ b/aegilib/include/aegilib/serialize.h @@ -0,0 +1,46 @@ +// Copyright (c) 2008, Rodrigo Braz Monteiro +// 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/GORGONSUB +// +// Website: http://www.aegisub.net +// Contact: mailto:amz@aegisub.net +// + +#pragma once +#include "gorgonstring.h" + +namespace Gorgonsub { + // Interface to serialize classes + class SerializeText { + public: + virtual ~SerializeText(){} + virtual String ToText(int param) const=0; + }; +}; diff --git a/aegilib/src/action.cpp b/aegilib/src/action.cpp index 2abfba709..4ea45f3f1 100644 --- a/aegilib/src/action.cpp +++ b/aegilib/src/action.cpp @@ -139,6 +139,6 @@ void ActionModify::Execute(Model &model) if (sectionName.IsEmpty()) sectionName = entry->GetDefaultGroup(); SectionPtr sect = GetSection(model,sectionName); - // Insert the line + // Modify the line sect->GetEntryRef(lineNumber) = entry; } diff --git a/aegilib/src/formats/format_ass.cpp b/aegilib/src/formats/format_ass.cpp index 92b5590d0..1d4edad4c 100644 --- a/aegilib/src/formats/format_ass.cpp +++ b/aegilib/src/formats/format_ass.cpp @@ -36,6 +36,7 @@ #include "section.h" #include "model.h" #include "format_ass.h" +#include "format_ass_plain.h" #include "version.h" #include "../text_file_reader.h" #include "../text_file_writer.h" diff --git a/aegilib/src/formats/format_ass.h b/aegilib/src/formats/format_ass.h index a42b7cb83..14139d0ce 100644 --- a/aegilib/src/formats/format_ass.h +++ b/aegilib/src/formats/format_ass.h @@ -36,6 +36,8 @@ #pragma once #include "format.h" #include "format_handler.h" +#include "format_ass_dialogue.h" +#include "format_ass_style.h" #include "section.h" #include "section_entry_dialogue.h" #include "section_entry_style.h" @@ -47,13 +49,6 @@ namespace Gorgonsub { class Model; class TextFileWriter; - // Interface to serialize classes - class SerializeText { - public: - virtual ~SerializeText(){} - virtual String ToText(int param) const=0; - }; - // Advanced Substation Alpha format handler class FormatHandlerASS : public FormatHandler { private: @@ -71,126 +66,6 @@ namespace Gorgonsub { void Save(wxOutputStream &file,const String encoding); }; - // Dialogue - class DialogueASS : public SectionEntryDialogue, public SerializeText { - private: - String text; - String style; - String effect; - String actor; - Time start,end; - array margin; - int layer; - bool isComment; - - bool Parse(String data,int version); - String ToText(int param) const; - - public: - // Constructors - DialogueASS(); - DialogueASS(const String &data,int version); - - // Basic features - String GetDefaultGroup() const { return L"Events"; } - SectionEntryPtr Clone() const { return SectionEntryPtr(new DialogueASS(*this)); } - - // Capabilities - bool HasText() const { return true; } - bool HasTime() const { return true; } - bool HasStyle() const { return true; } - bool HasMargins() const { return true; } - - // Read accessors - const String& GetText() const { return text; } - Time GetStartTime() const { return start; } - Time GetEndTime() const { return end; } - bool IsComment() const { return isComment; } - int GetLayer() const { return layer; } - int GetMargin(int n) const { return margin.at(n); } - const String& GetStyle() const { return style; } - const String& GetActor() const { return actor; } - const String& GetUserField() const { return effect; } - - // Write acessors - void SetText(const String &setText) { text = setText; } - void SetStartTime(Time setStart) { start = setStart; } - void SetEndTime(Time setEnd) { end = setEnd; } - void SetComment(bool _isComment) { isComment = _isComment; } - void SetLayer(int _layer) { layer = _layer; } - void SetMargin(int _margin,int value) { margin.at(_margin) = value; } - void SetStyle(const String &_style) { style = _style; } - void SetUserField(const String &userField) { effect = userField; } - }; - - // Style - class StyleASS : public SectionEntryStyle, public SerializeText { - private: - String name; - String font; - float fontSize; - int formatVersion; - - array colour; // 0 = Primary, 1 = Secondary, 2 = Tertiary, 3 = Outline, 4 = Shadow - array margin; - - bool bold; - bool italic; - bool underline; - bool strikeout; - - int borderStyle; - int alignment; - int encoding; - int relativeTo; - - float scalex; - float scaley; - float spacing; - float angle; - float outline_w; - float shadow_w; - - bool Parse(String data,int version); - int AlignSSAtoASS(int ssaAlignment) const; - int AlignASStoSSA(int assAlignment) const; - String ToText(int param) const; - - public: - // Constructors - StyleASS(); - StyleASS(String data,int version); - - // Basic features - String GetDefaultGroup() const; - SectionEntryPtr Clone() const { return SectionEntryPtr(new StyleASS(*this)); } - - // Read accessors - String GetName() const { return name; } - String GetFontName() const { return font; } - float GetFontSize() const { return fontSize; } - Colour GetColour(int n) const { return colour.at(n); } - int GetMargin(int n) const { return margin.at(n); } - }; - - // Raw line - class PlainASS : public SectionEntryPlain, public SerializeText { - private: - String data; - String ToText(int param) const { (void)param; return data; } - - public: - PlainASS(); - PlainASS(String _data) : data(_data) {} - - // Basic features - String GetDefaultGroup() const { return L"Events"; } - SectionEntryPtr Clone() const { return SectionEntryPtr(new PlainASS(*this)); } - - String GetText() const { return data; } - void SetText(const String &_data) { data = _data; } - }; - // Advanced Substation Alpha format base class class FormatASSFamily : public Format { public: diff --git a/aegilib/src/formats/format_ass_dialogue.cpp b/aegilib/src/formats/format_ass_dialogue.cpp index 14dcdde43..7b36ab2ff 100644 --- a/aegilib/src/formats/format_ass_dialogue.cpp +++ b/aegilib/src/formats/format_ass_dialogue.cpp @@ -33,7 +33,7 @@ // Contact: mailto:amz@aegisub.net // -#include "format_ass.h" +#include "format_ass_dialogue.h" #include "tokenizer.h" #include "utils.h" using namespace Gorgonsub; diff --git a/aegilib/src/formats/format_ass_dialogue.h b/aegilib/src/formats/format_ass_dialogue.h new file mode 100644 index 000000000..bd269e06e --- /dev/null +++ b/aegilib/src/formats/format_ass_dialogue.h @@ -0,0 +1,95 @@ +// Copyright (c) 2008, Rodrigo Braz Monteiro +// 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/GORGONSUB +// +// Website: http://www.aegisub.net +// Contact: mailto:amz@aegisub.net +// + +#pragma once +#include "gorgonstring.h" +#include "section_entry_dialogue.h" +#include "serialize.h" + +namespace Gorgonsub { + + // Dialogue + class DialogueASS : public SectionEntryDialogue, public SerializeText { + private: + String text; + String style; + String effect; + String actor; + Time start,end; + array margin; + int layer; + bool isComment; + + bool Parse(String data,int version); + String ToText(int param) const; + + public: + // Constructors + DialogueASS(); + DialogueASS(const String &data,int version); + + // Basic features + String GetDefaultGroup() const { return L"Events"; } + SectionEntryPtr Clone() const { return SectionEntryPtr(new DialogueASS(*this)); } + + // Capabilities + bool HasText() const { return true; } + bool HasTime() const { return true; } + bool HasStyle() const { return true; } + bool HasMargins() const { return true; } + + // Read accessors + const String& GetText() const { return text; } + Time GetStartTime() const { return start; } + Time GetEndTime() const { return end; } + bool IsComment() const { return isComment; } + int GetLayer() const { return layer; } + int GetMargin(int n) const { return margin.at(n); } + const String& GetStyle() const { return style; } + const String& GetActor() const { return actor; } + const String& GetUserField() const { return effect; } + + // Write acessors + void SetText(const String &setText) { text = setText; } + void SetStartTime(Time setStart) { start = setStart; } + void SetEndTime(Time setEnd) { end = setEnd; } + void SetComment(bool _isComment) { isComment = _isComment; } + void SetLayer(int _layer) { layer = _layer; } + void SetMargin(int _margin,int value) { margin.at(_margin) = value; } + void SetStyle(const String &_style) { style = _style; } + void SetUserField(const String &userField) { effect = userField; } + }; + +}; diff --git a/aegilib/src/formats/format_ass_plain.h b/aegilib/src/formats/format_ass_plain.h new file mode 100644 index 000000000..205a14130 --- /dev/null +++ b/aegilib/src/formats/format_ass_plain.h @@ -0,0 +1,60 @@ +// Copyright (c) 2008, Rodrigo Braz Monteiro +// 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/GORGONSUB +// +// Website: http://www.aegisub.net +// Contact: mailto:amz@aegisub.net +// + +#pragma once +#include "section_entry.h" +#include "serialize.h" + +namespace Gorgonsub { + + // Raw line + class PlainASS : public SectionEntryPlain, public SerializeText { + private: + String data; + String ToText(int param) const { (void)param; return data; } + + public: + PlainASS(); + PlainASS(String _data) : data(_data) {} + + // Basic features + String GetDefaultGroup() const { return L"Events"; } + SectionEntryPtr Clone() const { return SectionEntryPtr(new PlainASS(*this)); } + + String GetText() const { return data; } + void SetText(const String &_data) { data = _data; } + }; + +}; diff --git a/aegilib/src/formats/format_ass_style.cpp b/aegilib/src/formats/format_ass_style.cpp index 0a63fb048..e574ed28d 100644 --- a/aegilib/src/formats/format_ass_style.cpp +++ b/aegilib/src/formats/format_ass_style.cpp @@ -33,7 +33,7 @@ // Contact: mailto:amz@aegisub.net // -#include "format_ass.h" +#include "format_ass_style.h" #include "tokenizer.h" #include "utils.h" using namespace Gorgonsub; diff --git a/aegilib/src/formats/format_ass_style.h b/aegilib/src/formats/format_ass_style.h new file mode 100644 index 000000000..c31f77753 --- /dev/null +++ b/aegilib/src/formats/format_ass_style.h @@ -0,0 +1,93 @@ +// Copyright (c) 2008, Rodrigo Braz Monteiro +// 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/GORGONSUB +// +// Website: http://www.aegisub.net +// Contact: mailto:amz@aegisub.net +// + +#pragma once +#include "section_entry_style.h" +#include "serialize.h" +#include "tr1.h" + +namespace Gorgonsub { + + // Style + class StyleASS : public SectionEntryStyle, public SerializeText { + private: + String name; + String font; + float fontSize; + int formatVersion; + + array colour; // 0 = Primary, 1 = Secondary, 2 = Tertiary, 3 = Outline, 4 = Shadow + array margin; + + bool bold; + bool italic; + bool underline; + bool strikeout; + + int borderStyle; + int alignment; + int encoding; + int relativeTo; + + float scalex; + float scaley; + float spacing; + float angle; + float outline_w; + float shadow_w; + + bool Parse(String data,int version); + int AlignSSAtoASS(int ssaAlignment) const; + int AlignASStoSSA(int assAlignment) const; + String ToText(int param) const; + + public: + // Constructors + StyleASS(); + StyleASS(String data,int version); + + // Basic features + String GetDefaultGroup() const; + SectionEntryPtr Clone() const { return SectionEntryPtr(new StyleASS(*this)); } + + // Read accessors + String GetName() const { return name; } + String GetFontName() const { return font; } + float GetFontSize() const { return fontSize; } + Colour GetColour(int n) const { return colour.at(n); } + int GetMargin(int n) const { return margin.at(n); } + }; + +};