From 6a2f81278dfdd924d6b6b761935d930e325b96d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Matox?= Date: Sat, 26 Jul 2003 21:53:54 +0000 Subject: [PATCH] add support for tables and figures (linuxdoc). git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@7371 a592a061-630c-0410-9148-cb99ea01b6c8 --- lib/ChangeLog | 4 ++++ lib/layouts/linuxdoc.layout | 22 ++++++++++++++++++++ src/ChangeLog | 4 ++++ src/insets/ChangeLog | 7 +++++++ src/insets/insetfloat.C | 37 +++++++++++++++++++++++++++++++++ src/insets/insetfloat.h | 2 ++ src/insets/insetgraphics.C | 9 ++++++-- src/insets/insettabular.C | 7 +------ src/insets/insettext.C | 19 +++++++++++++++++ src/insets/insettext.h | 2 +- src/tabular.C | 41 +++++++++++++++++++++++++++++++++++++ src/tabular.h | 2 ++ 12 files changed, 147 insertions(+), 9 deletions(-) diff --git a/lib/ChangeLog b/lib/ChangeLog index b7557aa57b..ac5d602982 100644 --- a/lib/ChangeLog +++ b/lib/ChangeLog @@ -1,3 +1,7 @@ +2003-07-27 José Matos + + * layouts/linuxdoc.layout: add support for tables and figures (linuxdoc). + 2003-07-22 John Levon * ui/stdmenu.ui: fix up mnemonics to not clash, standardise diff --git a/lib/layouts/linuxdoc.layout b/lib/layouts/linuxdoc.layout index 9112be9382..e5a1c3c876 100644 --- a/lib/layouts/linuxdoc.layout +++ b/lib/layouts/linuxdoc.layout @@ -12,6 +12,7 @@ OutputType linuxdoc DefaultStyle Standard Input stdcounters.inc +Input stdfloats.inc # Standard style definition Style Standard @@ -383,3 +384,24 @@ Style SGML FreeSpacing 1 PassThru 1 End + +# Caption style definition +Style Caption + Margin First_Dynamic + LatexType Paragraph + LatexName caption + NeedProtect 1 + LabelSep xx + ParSkip 0.4 + TopSep 0.5 + Align Center + AlignPossible Center + LabelType Sensitive + LabelString Caption + OptionalArgs 1 + + # label font definition + LabelFont + Series Bold + EndFont +End diff --git a/src/ChangeLog b/src/ChangeLog index 28a046a585..49ef22ee51 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,7 @@ +2003-07-27 José Matos + + * tabular.[Ch] (linuxdoc): add support for tables and figures (linuxdoc). + 2003-07-27 José Matos * buffer.[Ch] (makeLaTeXFile): changed name of arguments for diff --git a/src/insets/ChangeLog b/src/insets/ChangeLog index d155146562..9355d078a9 100644 --- a/src/insets/ChangeLog +++ b/src/insets/ChangeLog @@ -1,3 +1,10 @@ +2003-07-27 José Matos + + * insetfloat.[Ch] (linuxdoc): + * insetgraphics.C (linuxdoc): + * insettabular.C (linuxdoc): + * insettext.[Ch] (linuxdoc): add support for tables and figures (linuxdoc). + 2003-07-27 José Matos * insetinclude (latex): comply with makeLaTeXFile argument change. diff --git a/src/insets/insetfloat.C b/src/insets/insetfloat.C index c482c46df3..31c34d926b 100644 --- a/src/insets/insetfloat.C +++ b/src/insets/insetfloat.C @@ -316,6 +316,43 @@ int InsetFloat::latex(Buffer const * buf, ostream & os, } +int InsetFloat::linuxdoc(Buffer const * buf, ostream & os) const +{ + FloatList const & floats = buf->params.getLyXTextClass().floats(); + string const tmptype = params_.type; + // Figure out the float placement to use. + // From lowest to highest: + // - float default placement + // - document wide default placement + // - specific float placement + // This is the same as latex, as linuxdoc is modeled after latex. + + string placement; + string const buf_placement = buf->params.float_placement; + string const def_placement = floats.defaultPlacement(params_.type); + if (!params_.placement.empty() + && params_.placement != def_placement) { + placement = params_.placement; + } else if (params_.placement.empty() + && !buf_placement.empty() + && buf_placement != def_placement) { + placement = buf_placement; + } + + os << "\n<" << tmptype ; + // We only output placement if different from the def_placement. + if (!placement.empty()) { + os << " loc=\"" << placement << '"'; + } + os << ">"; + + int const i = inset.linuxdoc(buf, os); + os << "\n"; + + return i; +} + + int InsetFloat::docbook(Buffer const * buf, ostream & os, bool mixcont) const { os << '<' << params_.type << '>'; diff --git a/src/insets/insetfloat.h b/src/insets/insetfloat.h index 3485672a7d..36c63c2c1a 100644 --- a/src/insets/insetfloat.h +++ b/src/insets/insetfloat.h @@ -60,6 +60,8 @@ public: int latex(Buffer const *, std::ostream &, LatexRunParams const &) const; /// + int linuxdoc(Buffer const *, std::ostream &) const; + /// int docbook(Buffer const *, std::ostream &, bool mixcont) const; /// string const editMessage() const; diff --git a/src/insets/insetgraphics.C b/src/insets/insetgraphics.C index dcf759e982..afdaa35a9e 100644 --- a/src/insets/insetgraphics.C +++ b/src/insets/insetgraphics.C @@ -550,9 +550,14 @@ int InsetGraphics::ascii(Buffer const *, ostream & os, int) const } -int InsetGraphics::linuxdoc(Buffer const *, ostream &) const +int InsetGraphics::linuxdoc(Buffer const * buf, ostream & os) const { - // No graphics in LinuxDoc output. Should check how/what to add. + string const file_name = buf->niceFile ? + params().filename.relFilename(buf->filePath()): + params().filename.absFilename(); + + os << "\n"; + os << ""; return 0; } diff --git a/src/insets/insettabular.C b/src/insets/insettabular.C index af8799e15f..b78885e2b0 100644 --- a/src/insets/insettabular.C +++ b/src/insets/insettabular.C @@ -1179,12 +1179,7 @@ int InsetTabular::ascii(Buffer const * buf, ostream & os, int ll) const int InsetTabular::linuxdoc(Buffer const * buf, ostream & os) const { - os << "params().depth(), - false, 0); - os << "]]>"; - return ret; + return tabular.linuxdoc(buf,os); } diff --git a/src/insets/insettext.C b/src/insets/insettext.C index bc94cbd498..deff133a0b 100644 --- a/src/insets/insettext.C +++ b/src/insets/insettext.C @@ -1312,6 +1312,25 @@ int InsetText::ascii(Buffer const * buf, ostream & os, int linelen) const return lines; } +int InsetText::linuxdoc(Buffer const * buf, ostream & os) const +{ + ParagraphList::iterator pit = const_cast(paragraphs).begin(); + ParagraphList::iterator pend = const_cast(paragraphs).end(); + + // There is a confusion between the empty paragraph and the default paragraph + // The default paragraph is

, the empty paragraph is *empty* + // Since none of the floats of linuxdoc accepts standard paragraphs + // I disable them. I don't expect problems. (jamatos 2003/07/27) + for (; pit != pend; ++pit) { + const string name = pit->layout()->latexname(); + if (name != "p") + sgml::openTag(os, 1, 0, name); + buf->simpleLinuxDocOnePar(os, pit, 0); + if (name != "p") + sgml::closeTag(os, 1, 0, name); + } + return 0; +} int InsetText::docbook(Buffer const * buf, ostream & os, bool mixcont) const { diff --git a/src/insets/insettext.h b/src/insets/insettext.h index 9554f88b51..6716217082 100644 --- a/src/insets/insettext.h +++ b/src/insets/insettext.h @@ -114,7 +114,7 @@ public: /// int ascii(Buffer const *, std::ostream &, int linelen) const; /// - int linuxdoc(Buffer const *, std::ostream &) const { return 0; } + int linuxdoc(Buffer const *, std::ostream &) const ; /// int docbook(Buffer const *, std::ostream &, bool mixcont) const ; /// diff --git a/src/tabular.C b/src/tabular.C index 263b9ac22f..19804ffc79 100644 --- a/src/tabular.C +++ b/src/tabular.C @@ -2201,6 +2201,47 @@ int LyXTabular::latex(Buffer const * buf, ostream & os, } +int LyXTabular::linuxdoc(Buffer const * buf, ostream & os) const +{ + os << "\n"; + int cell = 0; + int ret = 0; + for (int i = 0; i < rows_; ++i) { + for (int j = 0; j < columns_; ++j) { + if (isPartOfMultiColumn(i, j)) + continue; + InsetText & inset = getCellInset(cell); + + ret += inset.linuxdoc(buf, os); + + if (isLastCellInRow(cell)) { + os << "@\n"; + ++ret; + } else { + os << "|"; + } + ++cell; + } + } + os << "\n"; + return ret; +} + + int LyXTabular::docbookRow(Buffer const * buf, ostream & os, int row) const { int ret = 0; diff --git a/src/tabular.h b/src/tabular.h index 45fcf0804f..2486a71e2d 100644 --- a/src/tabular.h +++ b/src/tabular.h @@ -280,6 +280,8 @@ public: /// int latex(Buffer const *, std::ostream &, LatexRunParams const &) const; + // + int linuxdoc(Buffer const * buf, std::ostream & os) const; /// int docbook(Buffer const * buf, std::ostream & os, bool mixcont) const; ///