From cdf13782003f6fca74b267c6b23d76bb9edaa65c Mon Sep 17 00:00:00 2001 From: Abdelrazak Younes Date: Wed, 7 Nov 2007 23:25:08 +0000 Subject: [PATCH] Introducing TextClassPtr.h to minimize header dependencies. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@21506 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/BufferParams.cpp | 12 ++++++------ src/BufferParams.h | 9 +++++---- src/CutAndPaste.h | 3 +-- src/LaTeXFeatures.cpp | 1 + src/LyXFunc.h | 2 +- src/Makefile.am | 1 + src/MenuBackend.cpp | 1 + src/Paragraph.cpp | 1 + src/ParagraphMetrics.cpp | 1 + src/Text2.cpp | 1 + src/Text3.cpp | 3 ++- src/TextClass.cpp | 8 ++++---- src/TextClass.h | 17 ++--------------- src/TextClassPtr.h | 28 ++++++++++++++++++++++++++++ src/TextMetrics.cpp | 1 + src/TocBackend.cpp | 1 + src/frontends/qt4/GuiDocument.cpp | 6 +++--- src/frontends/qt4/GuiToc.cpp | 1 + src/frontends/qt4/GuiToolbar.cpp | 1 + src/frontends/qt4/GuiToolbars.h | 4 +++- src/frontends/qt4/GuiView.cpp | 1 + src/insets/InsetBibitem.cpp | 1 + src/insets/InsetBibtex.cpp | 3 ++- src/insets/InsetBranch.cpp | 1 + src/insets/InsetCollapsable.cpp | 1 + src/insets/InsetEnvironment.cpp | 1 + src/insets/InsetFlex.h | 1 - src/insets/InsetFloat.cpp | 1 + src/insets/InsetFloatList.cpp | 1 + src/insets/InsetFoot.cpp | 1 + src/insets/InsetInclude.cpp | 1 + src/insets/InsetNote.cpp | 1 + src/insets/InsetTabular.cpp | 1 + src/insets/InsetText.cpp | 1 + src/insets/InsetWrap.cpp | 1 + src/output_docbook.cpp | 1 + src/output_latex.cpp | 1 + src/paragraph_funcs.cpp | 1 + src/sgml.cpp | 1 + src/support/types.h | 8 ++++++++ 40 files changed, 92 insertions(+), 39 deletions(-) create mode 100644 src/TextClassPtr.h diff --git a/src/BufferParams.cpp b/src/BufferParams.cpp index 0d78a53f2c..c4d3158d14 100644 --- a/src/BufferParams.cpp +++ b/src/BufferParams.cpp @@ -195,13 +195,13 @@ PaperOrientationTranslator const & paperorientationtranslator() // Page sides -typedef Translator SidesTranslator; +typedef Translator SidesTranslator; SidesTranslator const init_sidestranslator() { - SidesTranslator translator(1, TextClass::OneSide); - translator.addPair(2, TextClass::TwoSides); + SidesTranslator translator(1, OneSide); + translator.addPair(2, TwoSides); return translator; } @@ -352,7 +352,7 @@ BufferParams::BufferParams() fontsTypewriterScale = 100; inputenc = "auto"; graphicsDriver = "default"; - sides = TextClass::OneSide; + sides = OneSide; columns = 1; listings_params = string(); pagestyle = "default"; @@ -863,10 +863,10 @@ bool BufferParams::writeLaTeX(odocstream & os, LaTeXFeatures & features, // if needed if (sides != tclass.sides()) { switch (sides) { - case TextClass::OneSide: + case OneSide: clsoptions << "oneside,"; break; - case TextClass::TwoSides: + case TwoSides: clsoptions << "twoside,"; break; } diff --git a/src/BufferParams.h b/src/BufferParams.h index 049fc87ed3..347cf5d27a 100644 --- a/src/BufferParams.h +++ b/src/BufferParams.h @@ -18,7 +18,7 @@ #include "Font.h" #include "BiblioInfo.h" #include "paper.h" -#include "TextClass.h" +#include "TextClassPtr.h" #include "insets/InsetQuotes.h" @@ -34,13 +34,14 @@ class AuthorList; class BranchList; class Bullet; class Encoding; +class Language; class Lexer; class LatexFeatures; +class PDFOptions; class Spacing; +class TextClass; class TexRow; class VSpace; -class Language; -class PDFOptions; /** Buffer parameters. * This class contains all the parameters for this buffer's use. Some @@ -222,7 +223,7 @@ public: /// parameters for the listings package std::string listings_params; /// - TextClass::PageSides sides; + PageSides sides; /// std::string pagestyle; /// \param index should lie in the range 0 <= \c index <= 3. diff --git a/src/CutAndPaste.h b/src/CutAndPaste.h index 3864cb86b6..ce6c7ab8ef 100644 --- a/src/CutAndPaste.h +++ b/src/CutAndPaste.h @@ -14,7 +14,7 @@ #ifndef CUTANDPASTE_H #define CUTANDPASTE_H -#include "TextClass.h" +#include "TextClassPtr.h" #include "support/types.h" #include "support/docstring.h" @@ -26,7 +26,6 @@ namespace lyx { class Buffer; class ErrorList; class InsetText; -class TextClass; class Cursor; class ParagraphList; diff --git a/src/LaTeXFeatures.cpp b/src/LaTeXFeatures.cpp index 1e1b4b22a5..69ecf92cbe 100644 --- a/src/LaTeXFeatures.cpp +++ b/src/LaTeXFeatures.cpp @@ -26,6 +26,7 @@ #include "Layout.h" #include "Lexer.h" #include "LyXRC.h" +#include "TextClass.h" #include "support/docstream.h" #include "support/filetools.h" diff --git a/src/LyXFunc.h b/src/LyXFunc.h index 35f29388b6..137b533f53 100644 --- a/src/LyXFunc.h +++ b/src/LyXFunc.h @@ -17,7 +17,7 @@ #include "KeySequence.h" #include "lfuns.h" -#include "TextClass.h" +#include "TextClassPtr.h" #include "support/docstring.h" diff --git a/src/Makefile.am b/src/Makefile.am index 639834ed75..31b2162e77 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -259,6 +259,7 @@ liblyxcore_la_SOURCES = \ TextClass.h \ TextClassList.cpp \ TextClassList.h \ + TextClassPtr.h \ TextMetrics.cpp \ TextMetrics.h \ TocBackend.cpp \ diff --git a/src/MenuBackend.cpp b/src/MenuBackend.cpp index 25772dbde0..46cae67507 100644 --- a/src/MenuBackend.cpp +++ b/src/MenuBackend.cpp @@ -35,6 +35,7 @@ #include "LyXFunc.h" #include "Lexer.h" #include "Paragraph.h" +#include "TextClass.h" #include "TocBackend.h" #include "ToolbarBackend.h" diff --git a/src/Paragraph.cpp b/src/Paragraph.cpp index 1a1394d784..5a3a134386 100644 --- a/src/Paragraph.cpp +++ b/src/Paragraph.cpp @@ -40,6 +40,7 @@ #include "paragraph_funcs.h" #include "ParagraphParameters.h" #include "sgml.h" +#include "TextClass.h" #include "TexRow.h" #include "VSpace.h" diff --git a/src/ParagraphMetrics.cpp b/src/ParagraphMetrics.cpp index 9d6404dbe6..483620a8e7 100644 --- a/src/ParagraphMetrics.cpp +++ b/src/ParagraphMetrics.cpp @@ -35,6 +35,7 @@ #include "OutputParams.h" #include "paragraph_funcs.h" #include "sgml.h" +#include "TextClass.h" #include "TexRow.h" #include "VSpace.h" diff --git a/src/Text2.cpp b/src/Text2.cpp index 2a6abbfb39..03ff6d75fe 100644 --- a/src/Text2.cpp +++ b/src/Text2.cpp @@ -47,6 +47,7 @@ #include "ParIterator.h" #include "Server.h" #include "ServerSocket.h" +#include "TextClass.h" #include "TextMetrics.h" #include "VSpace.h" diff --git a/src/Text3.cpp b/src/Text3.cpp index 922a4752ea..026d51e839 100644 --- a/src/Text3.cpp +++ b/src/Text3.cpp @@ -44,9 +44,10 @@ #include "Paragraph.h" #include "paragraph_funcs.h" #include "ParagraphParameters.h" +#include "ParIterator.h" +#include "TextClass.h" #include "TextMetrics.h" #include "VSpace.h" -#include "ParIterator.h" #include "frontends/Clipboard.h" #include "frontends/Selection.h" diff --git a/src/TextClass.cpp b/src/TextClass.cpp index 38367c27b3..f1b1df7eaa 100644 --- a/src/TextClass.cpp +++ b/src/TextClass.cpp @@ -1181,7 +1181,7 @@ docstring const & TextClass::preamble() const } -TextClass::PageSides TextClass::sides() const +PageSides TextClass::sides() const { return sides_; } @@ -1253,13 +1253,13 @@ bool TextClass::hasTocLevels() const } -ostream & operator<<(ostream & os, TextClass::PageSides p) +ostream & operator<<(ostream & os, PageSides p) { switch (p) { - case TextClass::OneSide: + case OneSide: os << '1'; break; - case TextClass::TwoSides: + case TwoSides: os << '2'; break; } diff --git a/src/TextClass.h b/src/TextClass.h index 42e0b8e85e..2cecdb5751 100644 --- a/src/TextClass.h +++ b/src/TextClass.h @@ -18,6 +18,7 @@ #include "insets/InsetLayout.h" #include "support/docstring.h" +#include "support/types.h" #include @@ -140,13 +141,6 @@ public: /// unsigned int columns() const; /// - enum PageSides { - /// - OneSide, - /// - TwoSides - }; - /// PageSides sides() const; /// int secnumdepth() const; @@ -261,14 +255,7 @@ private: /// convert page sides option to text 1 or 2 -std::ostream & operator<<(std::ostream & os, TextClass::PageSides p); - -/** Shared pointer for possibly modular layout. Needed so that paste, - * for example, will still be able to retain the pointer, even when - * the buffer itself is closed. - */ -typedef boost::shared_ptr TextClassPtr; - +std::ostream & operator<<(std::ostream & os, PageSides p); } // namespace lyx diff --git a/src/TextClassPtr.h b/src/TextClassPtr.h new file mode 100644 index 0000000000..cb610b1bb0 --- /dev/null +++ b/src/TextClassPtr.h @@ -0,0 +1,28 @@ +// -*- C++ -*- +/** + * \file TextClassPtr.h + * This file is part of LyX, the document processor. + * Licence details can be found in the file COPYING. + * + * Full author contact details are available in file CREDITS. + */ + +#ifndef TEXTCLASS_PTR_H +#define TEXTCLASS_PTR_H + +#include + +namespace lyx { + +class TextClass; + +/// Global typedef +/** Shared pointer for possibly modular layout. Needed so that paste, + * for example, will still be able to retain the pointer, even when + * the buffer itself is closed. + */ +typedef boost::shared_ptr TextClassPtr; + +} // namespace lyx + +#endif diff --git a/src/TextMetrics.cpp b/src/TextMetrics.cpp index 93c5297f04..bc74d71efe 100644 --- a/src/TextMetrics.cpp +++ b/src/TextMetrics.cpp @@ -40,6 +40,7 @@ #include "ParIterator.h" #include "rowpainter.h" #include "Text.h" +#include "TextClass.h" #include "VSpace.h" #include "mathed/MacroTable.h" diff --git a/src/TocBackend.cpp b/src/TocBackend.cpp index ba72b747b9..87a909a1fd 100644 --- a/src/TocBackend.cpp +++ b/src/TocBackend.cpp @@ -23,6 +23,7 @@ #include "Layout.h" #include "LyXAction.h" #include "Paragraph.h" +#include "TextClass.h" #include "insets/InsetOptArg.h" diff --git a/src/frontends/qt4/GuiDocument.cpp b/src/frontends/qt4/GuiDocument.cpp index 2941113aeb..f095f5c0af 100644 --- a/src/frontends/qt4/GuiDocument.cpp +++ b/src/frontends/qt4/GuiDocument.cpp @@ -1244,9 +1244,9 @@ void GuiDocument::apply(BufferParams & params) pageLayoutModule->paperheightUnitCO); if (pageLayoutModule->facingPagesCB->isChecked()) - params.sides = TextClass::TwoSides; + params.sides = TwoSides; else - params.sides = TextClass::OneSide; + params.sides = OneSide; if (pageLayoutModule->landscapeRB->isChecked()) params.orientation = ORIENTATION_LANDSCAPE; @@ -1541,7 +1541,7 @@ void GuiDocument::updateParams(BufferParams const & params) pageLayoutModule->portraitRB->setChecked(!landscape); pageLayoutModule->facingPagesCB->setChecked( - params.sides == TextClass::TwoSides); + params.sides == TwoSides); lengthToWidgets(pageLayoutModule->paperwidthLE, diff --git a/src/frontends/qt4/GuiToc.cpp b/src/frontends/qt4/GuiToc.cpp index 160e7643a3..d804eb3222 100644 --- a/src/frontends/qt4/GuiToc.cpp +++ b/src/frontends/qt4/GuiToc.cpp @@ -29,6 +29,7 @@ #include "FloatList.h" #include "FuncRequest.h" #include "gettext.h" +#include "TextClass.h" #include "frontends/LyXView.h" diff --git a/src/frontends/qt4/GuiToolbar.cpp b/src/frontends/qt4/GuiToolbar.cpp index 2e77e6e874..28884b0f1e 100644 --- a/src/frontends/qt4/GuiToolbar.cpp +++ b/src/frontends/qt4/GuiToolbar.cpp @@ -23,6 +23,7 @@ #include "IconPalette.h" #include "Layout.h" #include "LyXFunc.h" +#include "TextClass.h" #include "ToolbarBackend.h" #include "GuiView.h" diff --git a/src/frontends/qt4/GuiToolbars.h b/src/frontends/qt4/GuiToolbars.h index 446f7eaabf..090c2f6d8a 100644 --- a/src/frontends/qt4/GuiToolbars.h +++ b/src/frontends/qt4/GuiToolbars.h @@ -14,7 +14,9 @@ #ifndef GUI_TOOLBARS_H #define GUI_TOOLBARS_H -#include "TextClass.h" +#include "TextClassPtr.h" + +#include "support/docstring.h" #include diff --git a/src/frontends/qt4/GuiView.cpp b/src/frontends/qt4/GuiView.cpp index f58e7be789..f57c564427 100644 --- a/src/frontends/qt4/GuiView.cpp +++ b/src/frontends/qt4/GuiView.cpp @@ -47,6 +47,7 @@ #include "MenuBackend.h" #include "Paragraph.h" #include "Session.h" +#include "TextClass.h" #include "ToolbarBackend.h" #include "version.h" diff --git a/src/insets/InsetBibitem.cpp b/src/insets/InsetBibitem.cpp index 310cec9b2c..535b8660b9 100644 --- a/src/insets/InsetBibitem.cpp +++ b/src/insets/InsetBibitem.cpp @@ -23,6 +23,7 @@ #include "Lexer.h" #include "Paragraph.h" #include "ParagraphList.h" +#include "TextClass.h" #include "support/lstrings.h" #include "support/docstream.h" diff --git a/src/insets/InsetBibtex.cpp b/src/insets/InsetBibtex.cpp index d5a076671f..f9c7dc506b 100644 --- a/src/insets/InsetBibtex.cpp +++ b/src/insets/InsetBibtex.cpp @@ -23,6 +23,7 @@ #include "LaTeXFeatures.h" #include "MetricsInfo.h" #include "OutputParams.h" +#include "TextClass.h" #include "frontends/alert.h" @@ -306,7 +307,7 @@ int InsetBibtex::latex(Buffer const & buffer, odocstream & os, // all well if (!contains(buffer.params().getTextClass().name(), "art")) { - if (buffer.params().sides == TextClass::OneSide) { + if (buffer.params().sides == OneSide) { // oneside os << "\\clearpage"; } else { diff --git a/src/insets/InsetBranch.cpp b/src/insets/InsetBranch.cpp index e053d75a89..d13393102e 100644 --- a/src/insets/InsetBranch.cpp +++ b/src/insets/InsetBranch.cpp @@ -24,6 +24,7 @@ #include "gettext.h" #include "Lexer.h" #include "OutputParams.h" +#include "TextClass.h" #include diff --git a/src/insets/InsetCollapsable.cpp b/src/insets/InsetCollapsable.cpp index 7e68f092d5..e031fe5856 100644 --- a/src/insets/InsetCollapsable.cpp +++ b/src/insets/InsetCollapsable.cpp @@ -30,6 +30,7 @@ #include "FuncRequest.h" #include "MetricsInfo.h" #include "ParagraphParameters.h" +#include "TextClass.h" #include "frontends/FontMetrics.h" #include "frontends/Painter.h" diff --git a/src/insets/InsetEnvironment.cpp b/src/insets/InsetEnvironment.cpp index 0c444af841..97ab8d026a 100644 --- a/src/insets/InsetEnvironment.cpp +++ b/src/insets/InsetEnvironment.cpp @@ -18,6 +18,7 @@ #include "OutputParams.h" #include "output_latex.h" #include "TexRow.h" +#include "TextClass.h" namespace lyx { diff --git a/src/insets/InsetFlex.h b/src/insets/InsetFlex.h index fbfbeb7eaf..0de70be84a 100644 --- a/src/insets/InsetFlex.h +++ b/src/insets/InsetFlex.h @@ -14,7 +14,6 @@ #define INSETFLEX_H #include "InsetCollapsable.h" -#include "TextClass.h" namespace lyx { diff --git a/src/insets/InsetFloat.cpp b/src/insets/InsetFloat.cpp index b710d9ae8c..edd2da65ad 100644 --- a/src/insets/InsetFloat.cpp +++ b/src/insets/InsetFloat.cpp @@ -28,6 +28,7 @@ #include "LaTeXFeatures.h" #include "Lexer.h" #include "OutputParams.h" +#include "TextClass.h" #include "support/lstrings.h" #include "support/docstream.h" diff --git a/src/insets/InsetFloatList.cpp b/src/insets/InsetFloatList.cpp index c7a2d71e8a..64336f6660 100644 --- a/src/insets/InsetFloatList.cpp +++ b/src/insets/InsetFloatList.cpp @@ -24,6 +24,7 @@ #include "Lexer.h" #include "MetricsInfo.h" #include "TocBackend.h" +#include "TextClass.h" #include "support/lstrings.h" diff --git a/src/insets/InsetFoot.cpp b/src/insets/InsetFoot.cpp index 1f6cd82c87..be8634f317 100644 --- a/src/insets/InsetFoot.cpp +++ b/src/insets/InsetFoot.cpp @@ -23,6 +23,7 @@ // paragraph. This seems a bit too much to me (JMarc) #include "OutputParams.h" #include "ParIterator.h" +#include "TextClass.h" #include "support/lstrings.h" diff --git a/src/insets/InsetInclude.cpp b/src/insets/InsetInclude.cpp index bc23d534ae..763ba15d71 100644 --- a/src/insets/InsetInclude.cpp +++ b/src/insets/InsetInclude.cpp @@ -32,6 +32,7 @@ #include "MetricsInfo.h" #include "OutputParams.h" #include "TocBackend.h" +#include "TextClass.h" #include "frontends/alert.h" #include "frontends/Painter.h" diff --git a/src/insets/InsetNote.cpp b/src/insets/InsetNote.cpp index 8e34adc33b..2c8096fd0f 100644 --- a/src/insets/InsetNote.cpp +++ b/src/insets/InsetNote.cpp @@ -30,6 +30,7 @@ #include "Lexer.h" #include "MetricsInfo.h" #include "OutputParams.h" +#include "TextClass.h" #include "support/docstream.h" #include "support/Translator.h" diff --git a/src/insets/InsetTabular.cpp b/src/insets/InsetTabular.cpp index 9a32bfd510..7924c3d86c 100644 --- a/src/insets/InsetTabular.cpp +++ b/src/insets/InsetTabular.cpp @@ -43,6 +43,7 @@ #include "Paragraph.h" #include "ParagraphParameters.h" #include "ParIterator.h" +#include "TextClass.h" #include "TextMetrics.h" #include "support/convert.h" diff --git a/src/insets/InsetText.cpp b/src/insets/InsetText.cpp index cc33329a97..d8cbd8eeb4 100644 --- a/src/insets/InsetText.cpp +++ b/src/insets/InsetText.cpp @@ -42,6 +42,7 @@ #include "ParIterator.h" #include "Row.h" #include "sgml.h" +#include "TextClass.h" #include "TextMetrics.h" #include "TexRow.h" diff --git a/src/insets/InsetWrap.cpp b/src/insets/InsetWrap.cpp index 35271bbf1e..4a420a4e0e 100644 --- a/src/insets/InsetWrap.cpp +++ b/src/insets/InsetWrap.cpp @@ -28,6 +28,7 @@ #include "LaTeXFeatures.h" #include "Lexer.h" #include "OutputParams.h" +#include "TextClass.h" #include "TocBackend.h" #include "support/convert.h" diff --git a/src/output_docbook.cpp b/src/output_docbook.cpp index b3bdae2d6b..f4cf212498 100644 --- a/src/output_docbook.cpp +++ b/src/output_docbook.cpp @@ -25,6 +25,7 @@ #include "ParagraphList.h" #include "ParagraphParameters.h" #include "sgml.h" +#include "TextClass.h" #include "support/lstrings.h" #include "support/lyxlib.h" diff --git a/src/output_latex.cpp b/src/output_latex.cpp index 52348c44cd..0e1e2ee5b9 100644 --- a/src/output_latex.cpp +++ b/src/output_latex.cpp @@ -24,6 +24,7 @@ #include "Paragraph.h" #include "paragraph_funcs.h" #include "ParagraphParameters.h" +#include "TextClass.h" #include "TexRow.h" #include "VSpace.h" diff --git a/src/paragraph_funcs.cpp b/src/paragraph_funcs.cpp index 9670338842..410d4abc5b 100644 --- a/src/paragraph_funcs.cpp +++ b/src/paragraph_funcs.cpp @@ -20,6 +20,7 @@ #include "Paragraph.h" #include "ParagraphParameters.h" #include "Text.h" +#include "TextClass.h" #include diff --git a/src/sgml.cpp b/src/sgml.cpp index 76e8ee0a4b..6568a35bcd 100644 --- a/src/sgml.cpp +++ b/src/sgml.cpp @@ -20,6 +20,7 @@ #include "OutputParams.h" #include "Paragraph.h" #include "Text.h" +#include "TextClass.h" #include "support/convert.h" #include "support/docstream.h" diff --git a/src/support/types.h b/src/support/types.h index cb1de177ac..206d2818b1 100644 --- a/src/support/types.h +++ b/src/support/types.h @@ -90,6 +90,14 @@ namespace lyx { NEXT_WORD }; + /// + enum PageSides { + /// + OneSide, + /// + TwoSides + }; + } // namespace lyx #endif // LYX_TYPES_H