mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-22 10:00:33 +00:00
** subfig support **
* src/Buffer.cpp: * development/FORMAT: - bump format to 316. * src/insets/InsetFloat.{cpp, h}: - let nested floats be subfloats NOTE: docbook support is missing. * src/insets/InsetCaption.{cpp, h}: - handle subfigure captions * src/insets/InsetGraphics.cpp: * src/insets/InsetGraphicsParams.{cpp, h}: - remove old subfigure support * lib/chkconfig.ltx: * lib/doc/LaTeXConfig.lyx: - check for subfig instead of subfigure. * lib/lyx2lyx/LyX.py: * lib/lyx2lyx/lyx_1_6.py: - conversion/reversion routines for subfig -> subfloats NOTE: the reversion routine still has bugs. * src/Counters.{cpp, h}: - add identifiers for subfloats * src/LaTeXFeatures.{cpp, h}: - support for subfig * src/TextClass.cpp: - set up subfloat counter for all custom floats. * src/frontends/qt4/GuiGraphics.cpp: * src/frontends/qt4/ui/GrahicsUi.ui: - remove subfigure UI. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@23381 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
bced544674
commit
ac1977018b
@ -1,6 +1,9 @@
|
||||
LyX file-format changes
|
||||
-----------------------
|
||||
|
||||
2008-03-01 Jürgen Spitzmüller <j.spitzmueller@gmx.de>
|
||||
* Format incremented to 316: support for subfloats (subfig package).
|
||||
|
||||
2008-02-18 Richard Heck <rgheck@comcast.net>
|
||||
* Format incremented to 315: support for column separation in page margins
|
||||
|
||||
|
@ -251,7 +251,7 @@
|
||||
\TestPackage{rotfloat}
|
||||
\TestPackage{setspace}
|
||||
\TestPackage{soul}
|
||||
\TestPackage{subfigure}
|
||||
\TestPackage{subfig}
|
||||
\TestPackage{textcomp}
|
||||
\TestPackage{units}
|
||||
\TestPackage{url}
|
||||
|
@ -1,5 +1,5 @@
|
||||
#LyX 1.6.0svn created this file. For more info see http://www.lyx.org/
|
||||
\lyxformat 315
|
||||
\lyxformat 316
|
||||
\begin_document
|
||||
\begin_header
|
||||
\textclass article
|
||||
@ -4307,14 +4307,14 @@ rotfloat
|
||||
\end_layout
|
||||
|
||||
\begin_layout Subsection
|
||||
subfigure
|
||||
subfig
|
||||
\end_layout
|
||||
|
||||
\begin_layout Description
|
||||
Found:
|
||||
\begin_inset Info
|
||||
type "package"
|
||||
arg "subfigure"
|
||||
arg "subfig"
|
||||
\end_inset
|
||||
|
||||
|
||||
@ -4323,17 +4323,18 @@ arg "subfigure"
|
||||
\begin_layout Description
|
||||
CTAN:
|
||||
\family typewriter
|
||||
macros/latex/contrib/subfigure
|
||||
macros/latex/contrib/subfig
|
||||
\end_layout
|
||||
|
||||
\begin_layout Description
|
||||
Notes: The package
|
||||
\family sans
|
||||
subfigure
|
||||
subfig
|
||||
\family default
|
||||
is used by LyX when you select ``subfigure'' in the EPS figure popup.
|
||||
Several figures marked in this way can be packed into a single float with
|
||||
individual subcaptions.
|
||||
is used by LyX to produce subfloats (i.\InsetSpace \thinspace{}
|
||||
e., subfigures, subtables, etc.).
|
||||
Subfloats are floats that are embedded inside other floats and that can
|
||||
have individual subcaptions.
|
||||
\end_layout
|
||||
|
||||
\begin_layout Subsection
|
||||
|
@ -80,7 +80,7 @@ format_relation = [("0_06", [200], minor_versions("0.6" , 4)),
|
||||
("1_3", [221], minor_versions("1.3" , 7)),
|
||||
("1_4", range(222,246), minor_versions("1.4" , 5)),
|
||||
("1_5", range(246,277), minor_versions("1.5" , 2)),
|
||||
("1_6", range(277,316), minor_versions("1.6" , 0))] # rgh: colsep
|
||||
("1_6", range(277,317), minor_versions("1.6" , 0))] # jspitzm: subfig
|
||||
|
||||
|
||||
def formats_list():
|
||||
|
@ -1241,6 +1241,127 @@ def revert_widesideways(document):
|
||||
i = i + 1
|
||||
|
||||
|
||||
def convert_subfig(document):
|
||||
" Convert subfigures to subfloats. "
|
||||
i = 0
|
||||
while 1:
|
||||
i = find_token(document.body, '\\begin_inset Graphics', i)
|
||||
if i == -1:
|
||||
return
|
||||
j = find_end_of_inset(document.body, i)
|
||||
if j == -1:
|
||||
document.warning("Malformed lyx document: Missing '\\end_inset'.")
|
||||
i = i + 1
|
||||
continue
|
||||
k = find_token(document.body, '\tsubcaption', i, j)
|
||||
if k == -1:
|
||||
i = i + 1
|
||||
continue
|
||||
l = find_token(document.body, '\tsubcaptionText', i, j)
|
||||
caption = get_value(document.body, '\tsubcaptionText', i, j).strip('"')
|
||||
savestr = document.body[i]
|
||||
document.body[i] = '\\begin_inset Float figure\nwide false\nsideways false\n' \
|
||||
'status open\n\n\\begin_layout PlainLayout\n\\begin_inset Caption\n\n\\begin_layout PlainLayout\n' \
|
||||
+ caption + '\n\\end_layout\n\n\\end_inset\n\n\\end_layout\n\n\\begin_layout PlainLayout\n' + savestr
|
||||
savestr = document.body[j]
|
||||
document.body[j] = '\n\\end_layout\n\n\\end_inset\n' + savestr
|
||||
del document.body[k]
|
||||
del document.body[l]
|
||||
|
||||
|
||||
def revert_subfig(document):
|
||||
" Revert subfloats. "
|
||||
i = 0
|
||||
while 1:
|
||||
i = find_token(document.body, '\\begin_inset Float', i)
|
||||
if i == -1:
|
||||
return
|
||||
while 1:
|
||||
j = find_end_of_inset(document.body, i)
|
||||
if j == -1:
|
||||
document.warning("Malformed lyx document: Missing '\\end_inset' (float).")
|
||||
i = i + 1
|
||||
continue
|
||||
# look for embedded float (= subfloat)
|
||||
k = find_token(document.body, '\\begin_inset Float', i + 1, j)
|
||||
if k == -1:
|
||||
break
|
||||
l = find_end_of_inset(document.body, k)
|
||||
if l == -1:
|
||||
document.warning("Malformed lyx document: Missing '\\end_inset' (embedded float).")
|
||||
i = i + 1
|
||||
continue
|
||||
m = find_token(document.body, "\\begin_layout PlainLayout", k + 1, l)
|
||||
# caption?
|
||||
cap = find_token(document.body, '\\begin_inset Caption', k + 1, l)
|
||||
caption = ''
|
||||
shortcap = ''
|
||||
if cap != -1:
|
||||
capend = find_end_of_inset(document.body, cap)
|
||||
if capend == -1:
|
||||
document.warning("Malformed lyx document: Missing '\\end_inset' (caption).")
|
||||
return
|
||||
# label?
|
||||
label = ''
|
||||
lbl = find_token(document.body, '\\begin_inset CommandInset label', cap, capend)
|
||||
if lbl != -1:
|
||||
lblend = find_end_of_inset(document.body, lbl + 1)
|
||||
if lblend == -1:
|
||||
document.warning("Malformed lyx document: Missing '\\end_inset' (label).")
|
||||
return
|
||||
for line in document.body[lbl:lblend + 1]:
|
||||
if line.startswith('name '):
|
||||
label = line.split()[1].strip('"')
|
||||
break
|
||||
else:
|
||||
lbl = capend
|
||||
lblend = capend
|
||||
label = ''
|
||||
# opt arg?
|
||||
opt = find_token(document.body, '\\begin_inset OptArg', cap, capend)
|
||||
if opt != -1:
|
||||
optend = find_end_of_inset(document.body, opt)
|
||||
if optend == -1:
|
||||
document.warning("Malformed lyx document: Missing '\\end_inset' (OptArg).")
|
||||
return
|
||||
optc = find_token(document.body, "\\begin_layout PlainLayout", opt, optend)
|
||||
if optc == -1:
|
||||
document.warning("Malformed LyX document: Missing `\\begin_layout PlainLayout' in Float inset.")
|
||||
return
|
||||
optcend = find_end_of(document.body, optc, "\\begin_layout", "\\end_layout")
|
||||
for line in document.body[optc:optcend]:
|
||||
if not line.startswith('\\'):
|
||||
shortcap += line.strip()
|
||||
else:
|
||||
opt = capend
|
||||
optend = capend
|
||||
for line in document.body[cap:capend]:
|
||||
if line in document.body[lbl:lblend]:
|
||||
continue
|
||||
elif line in document.body[opt:optend]:
|
||||
continue
|
||||
elif not line.startswith('\\'):
|
||||
caption += line.strip()
|
||||
if len(label) > 0:
|
||||
caption += "\\backslash\nlabel{" + label + "}"
|
||||
document.body[l] = '\\begin_layout PlainLayout\n\\begin_inset ERT\nstatus collapsed\n\n' \
|
||||
'\\begin_layout PlainLayout\n\n}\n\\end_layout\n\n\\end_inset\n\n\\end_layout\n\n\\begin_layout PlainLayout\n'
|
||||
del document.body[cap:capend+1]
|
||||
del document.body[k+1:m-1]
|
||||
insertion = '\\begin_inset ERT\nstatus collapsed\n\n' \
|
||||
'\\begin_layout PlainLayout\n\n\\backslash\n' \
|
||||
'subfloat'
|
||||
if len(shortcap) > 0:
|
||||
insertion = insertion + "[" + shortcap + "]"
|
||||
if len(caption) > 0:
|
||||
insertion = insertion + "[" + caption + "]"
|
||||
insertion = insertion + '{%\n\\end_layout\n\n\\end_inset\n\n\\end_layout\n'
|
||||
document.body[k] = insertion
|
||||
add_to_preamble(document,
|
||||
['\\usepackage{subfig}\n'])
|
||||
i = i + 1
|
||||
|
||||
|
||||
##
|
||||
# Conversion hub
|
||||
#
|
||||
@ -1284,10 +1405,12 @@ convert = [[277, [fix_wrong_tables]],
|
||||
[312, []],
|
||||
[313, [convert_module_names]],
|
||||
[314, []],
|
||||
[315, []]
|
||||
[315, []],
|
||||
[316, [convert_subfig]]
|
||||
]
|
||||
|
||||
revert = [[314, [revert_colsep]],
|
||||
revert = [[314, [revert_subfig]],
|
||||
[314, [revert_colsep]],
|
||||
[313, []],
|
||||
[312, [revert_module_names]],
|
||||
[311, [revert_rotfloat, revert_widesideways]],
|
||||
|
@ -115,7 +115,7 @@ namespace os = support::os;
|
||||
|
||||
namespace {
|
||||
|
||||
int const LYX_FORMAT = 315; // Richard Heck: column separation
|
||||
int const LYX_FORMAT = 316; // JSpitzm: subfig support
|
||||
|
||||
} // namespace anon
|
||||
|
||||
|
@ -171,6 +171,7 @@ void Counters::step(docstring const & ctr)
|
||||
void Counters::reset()
|
||||
{
|
||||
appendix_ = false;
|
||||
subfloat_ = false;
|
||||
current_float_.erase();
|
||||
CounterList::iterator it = counterList.begin();
|
||||
CounterList::iterator const end = counterList.end();
|
||||
|
@ -116,6 +116,10 @@ public:
|
||||
std::string const & current_float() const { return current_float_; }
|
||||
/// Sets the current enclosing float.
|
||||
void current_float(std::string const & f) { current_float_ = f; }
|
||||
/// Are we in a subfloat?
|
||||
bool isSubfloat() const { return subfloat_; }
|
||||
/// Set the state variable indicating whether we are in a subfloat.
|
||||
void isSubfloat(bool s) { subfloat_ = s; };
|
||||
private:
|
||||
/// returns the expanded string representation of the counter
|
||||
/// with recursion protection through callers.
|
||||
@ -137,6 +141,8 @@ private:
|
||||
bool appendix_;
|
||||
/// The current enclosing float.
|
||||
std::string current_float_;
|
||||
/// Are we in a subfloat?
|
||||
bool subfloat_;
|
||||
};
|
||||
|
||||
|
||||
|
@ -433,9 +433,12 @@ void LaTeXFeatures::addPreambleSnippet(string const & preamble)
|
||||
}
|
||||
|
||||
|
||||
void LaTeXFeatures::useFloat(string const & name)
|
||||
void LaTeXFeatures::useFloat(string const & name, bool subfloat)
|
||||
{
|
||||
usedFloats_.insert(name);
|
||||
if (!usedFloats_[name])
|
||||
usedFloats_[name] = subfloat;
|
||||
if (subfloat)
|
||||
require("subfig");
|
||||
// We only need float.sty if we use non builtin floats, or if we
|
||||
// use the "H" modifier. This includes modified table and
|
||||
// figure floats. (Lgb)
|
||||
@ -510,7 +513,7 @@ char const * simplefeatures[] = {
|
||||
"rotating",
|
||||
"latexsym",
|
||||
"pifont",
|
||||
"subfigure",
|
||||
"subfig",
|
||||
"varioref",
|
||||
"prettyref",
|
||||
/*For a successful cooperation of the `wrapfig' package with the
|
||||
@ -914,7 +917,7 @@ void LaTeXFeatures::getFloatDefinitions(ostream & os) const
|
||||
UsedFloats::const_iterator end = usedFloats_.end();
|
||||
// ostringstream floats;
|
||||
for (; cit != end; ++cit) {
|
||||
Floating const & fl = floats.getType((*cit));
|
||||
Floating const & fl = floats.getType((cit->first));
|
||||
|
||||
// For builtin floats we do nothing.
|
||||
if (fl.builtin()) continue;
|
||||
@ -959,6 +962,8 @@ void LaTeXFeatures::getFloatDefinitions(ostream & os) const
|
||||
// used several times, when the same style is still in
|
||||
// effect. (Lgb)
|
||||
}
|
||||
if (cit->second)
|
||||
os << "\n\\newsubfloat{" << fl.type() << "}\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -82,7 +82,7 @@ public:
|
||||
*/
|
||||
bool mustProvide(std::string const & name) const;
|
||||
///
|
||||
void useFloat(std::string const & name);
|
||||
void useFloat(std::string const & name, bool subfloat = false);
|
||||
///
|
||||
void useLanguage(Language const *);
|
||||
///
|
||||
@ -124,7 +124,7 @@ private:
|
||||
/// used languages (only those that are supported by babel)
|
||||
LanguageList UsedLanguages_;
|
||||
///
|
||||
typedef std::set<std::string> UsedFloats;
|
||||
typedef std::map<std::string, bool> UsedFloats;
|
||||
///
|
||||
UsedFloats usedFloats_;
|
||||
///
|
||||
|
@ -763,8 +763,12 @@ void TextClass::readFloat(Lexer & lexrc)
|
||||
style, name, listName, builtin);
|
||||
floatlist_->newFloat(fl);
|
||||
// each float has its own counter
|
||||
counters_->newCounter(from_ascii(type), from_ascii(within),
|
||||
counters_->newCounter(from_ascii(type), from_ascii(within),
|
||||
docstring(), docstring());
|
||||
// also define sub-float counters
|
||||
docstring const subtype = "sub-" + from_ascii(type);
|
||||
counters_->newCounter(subtype, from_ascii(type),
|
||||
"\\alph{" + subtype + "}", docstring());
|
||||
}
|
||||
|
||||
lexrc.popTable();
|
||||
|
@ -204,10 +204,6 @@ GuiGraphics::GuiGraphics(GuiView & lv)
|
||||
// setChecked(). Note, too, that clicked() would get called whenever it
|
||||
// is clicked, even right clicked (I think), not just whenever it is
|
||||
// toggled.
|
||||
connect(subfigure, SIGNAL(toggled(bool)),
|
||||
this, SLOT(change_adaptor()));
|
||||
connect(subcaption, SIGNAL(textChanged(const QString&)),
|
||||
this, SLOT(change_adaptor()));
|
||||
connect(displayGB, SIGNAL(toggled(bool)),
|
||||
this, SLOT(change_adaptor()));
|
||||
connect(showCB, SIGNAL(currentIndexChanged(int)),
|
||||
@ -223,7 +219,6 @@ GuiGraphics::GuiGraphics(GuiView & lv)
|
||||
bc().setCancel(closePB);
|
||||
|
||||
bc().addReadOnly(latexoptions);
|
||||
bc().addReadOnly(subfigure);
|
||||
bc().addReadOnly(filenameL);
|
||||
bc().addReadOnly(filename);
|
||||
bc().addReadOnly(browsePB);
|
||||
@ -500,10 +495,6 @@ void GuiGraphics::updateContents()
|
||||
clip->setChecked(igp.clip);
|
||||
unzipCB->setChecked(igp.noUnzip);
|
||||
|
||||
// Update the subcaption check button and input field
|
||||
subfigure->setChecked(igp.subcaption);
|
||||
subcaption->setText(toqstr(igp.subcaptionText));
|
||||
|
||||
int item = 0;
|
||||
switch (igp.display) {
|
||||
case graphics::DefaultDisplay: item = 0; break;
|
||||
@ -624,8 +615,6 @@ void GuiGraphics::applyView()
|
||||
|
||||
igp.draft = draftCB->isChecked();
|
||||
igp.clip = clip->isChecked();
|
||||
igp.subcaption = subfigure->isChecked();
|
||||
igp.subcaptionText = fromqstr(subcaption->text());
|
||||
|
||||
switch (showCB->currentIndex()) {
|
||||
case 0: igp.display = graphics::DefaultDisplay; break;
|
||||
|
@ -643,61 +643,6 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0" colspan="2" >
|
||||
<widget class="QGroupBox" name="subfigure" >
|
||||
<property name="focusPolicy" >
|
||||
<enum>Qt::StrongFocus</enum>
|
||||
</property>
|
||||
<property name="title" >
|
||||
<string>S&ubfigure</string>
|
||||
</property>
|
||||
<property name="flat" >
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="checkable" >
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="checked" >
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" >
|
||||
<property name="margin" >
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="spacing" >
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="CaptionLA" >
|
||||
<property name="toolTip" >
|
||||
<string>The caption for the sub-figure</string>
|
||||
</property>
|
||||
<property name="text" >
|
||||
<string>Ca&ption:</string>
|
||||
</property>
|
||||
<property name="buddy" >
|
||||
<cstring>subcaption</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="subcaption" >
|
||||
<property name="sizePolicy" >
|
||||
<sizepolicy>
|
||||
<hsizetype>3</hsizetype>
|
||||
<vsizetype>0</vsizetype>
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip" >
|
||||
<string>The caption for the sub-figure</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
@ -836,8 +781,6 @@
|
||||
<tabstop>latexoptions</tabstop>
|
||||
<tabstop>draftCB</tabstop>
|
||||
<tabstop>unzipCB</tabstop>
|
||||
<tabstop>subfigure</tabstop>
|
||||
<tabstop>subcaption</tabstop>
|
||||
<tabstop>displayGB</tabstop>
|
||||
<tabstop>showCB</tabstop>
|
||||
<tabstop>displayscale</tabstop>
|
||||
|
@ -220,6 +220,9 @@ bool InsetCaption::getStatus(Cursor & cur, FuncRequest const & cmd,
|
||||
int InsetCaption::latex(odocstream & os,
|
||||
OutputParams const & runparams_in) const
|
||||
{
|
||||
if (in_subfloat_)
|
||||
// caption is output as an optional argument
|
||||
return 0;
|
||||
// This is a bit too simplistic to take advantage of
|
||||
// caption options we must add more later. (Lgb)
|
||||
// This code is currently only able to handle the simple
|
||||
@ -282,6 +285,7 @@ void InsetCaption::updateLabels(ParIterator const & it)
|
||||
string const & type = cnts.current_float();
|
||||
// Memorize type for addToToc().
|
||||
type_ = type;
|
||||
in_subfloat_ = cnts.isSubfloat();
|
||||
if (type.empty())
|
||||
full_label_ = buffer().B_("Senseless!!! ");
|
||||
else {
|
||||
@ -292,11 +296,17 @@ void InsetCaption::updateLabels(ParIterator const & it)
|
||||
name = buffer().B_("Listing");
|
||||
else
|
||||
name = buffer().B_(tclass.floats().getType(type).name());
|
||||
if (cnts.hasCounter(from_utf8(type))) {
|
||||
cnts.step(from_utf8(type));
|
||||
docstring counter = from_utf8(type);
|
||||
if (in_subfloat_) {
|
||||
counter = "sub-" + from_utf8(type);
|
||||
name = bformat(_("Sub-%1$s"),
|
||||
buffer().B_(tclass.floats().getType(type).name()));
|
||||
}
|
||||
if (cnts.hasCounter(counter)) {
|
||||
cnts.step(counter);
|
||||
full_label_ = bformat(from_ascii("%1$s %2$s:"),
|
||||
name,
|
||||
cnts.theCounter(from_utf8(type)));
|
||||
name,
|
||||
cnts.theCounter(counter));
|
||||
} else
|
||||
full_label_ = bformat(from_ascii("%1$s #:"), name);
|
||||
}
|
||||
|
@ -87,6 +87,8 @@ private:
|
||||
///
|
||||
std::string type_;
|
||||
///
|
||||
bool in_subfloat_;
|
||||
///
|
||||
docstring custom_label_;
|
||||
};
|
||||
|
||||
|
@ -5,6 +5,7 @@
|
||||
*
|
||||
* \author Jürgen Vigna
|
||||
* \author Lars Gullik Bjønnes
|
||||
* \author Jürgen Spitzmüller
|
||||
*
|
||||
* Full author contact details are available in file CREDITS.
|
||||
*/
|
||||
@ -12,6 +13,7 @@
|
||||
#include <config.h>
|
||||
|
||||
#include "InsetFloat.h"
|
||||
#include "InsetCaption.h"
|
||||
|
||||
#include "Buffer.h"
|
||||
#include "BufferParams.h"
|
||||
@ -23,9 +25,11 @@
|
||||
#include "FloatList.h"
|
||||
#include "FuncRequest.h"
|
||||
#include "FuncStatus.h"
|
||||
#include "InsetList.h"
|
||||
#include "LaTeXFeatures.h"
|
||||
#include "Lexer.h"
|
||||
#include "OutputParams.h"
|
||||
#include "ParIterator.h"
|
||||
#include "TextClass.h"
|
||||
|
||||
#include "support/debug.h"
|
||||
@ -131,6 +135,7 @@ void InsetFloat::doDispatch(Cursor & cur, FuncRequest & cmd)
|
||||
params_.placement = params.placement;
|
||||
params_.wide = params.wide;
|
||||
params_.sideways = params.sideways;
|
||||
params_.subfloat = params.subfloat;
|
||||
wide(params_.wide, cur.buffer().params());
|
||||
sideways(params_.sideways, cur.buffer().params());
|
||||
break;
|
||||
@ -143,6 +148,8 @@ void InsetFloat::doDispatch(Cursor & cur, FuncRequest & cmd)
|
||||
|
||||
case LFUN_MOUSE_RELEASE: {
|
||||
if (cmd.button() == mouse_button::button3 && hitButton(cmd)) {
|
||||
if (params_.subfloat)
|
||||
break;
|
||||
InsetFloatMailer(*this).showDialog(&cur.bv());
|
||||
break;
|
||||
}
|
||||
@ -177,14 +184,23 @@ void InsetFloat::updateLabels(ParIterator const & it)
|
||||
{
|
||||
Counters & cnts = buffer().params().documentClass().counters();
|
||||
string const saveflt = cnts.current_float();
|
||||
bool const savesubflt = cnts.isSubfloat();
|
||||
|
||||
bool const subflt = it.innerInsetOfType(FLOAT_CODE);
|
||||
// floats can only embed subfloats of their own kind
|
||||
if (subflt)
|
||||
params_.type = saveflt;
|
||||
subfloat(subflt, buffer().params());
|
||||
|
||||
// Tell to captions what the current float is
|
||||
cnts.current_float(params().type);
|
||||
cnts.isSubfloat(subflt);
|
||||
|
||||
InsetCollapsable::updateLabels(it);
|
||||
|
||||
//reset afterwards
|
||||
cnts.current_float(saveflt);
|
||||
cnts.isSubfloat(savesubflt);
|
||||
}
|
||||
|
||||
|
||||
@ -250,6 +266,7 @@ void InsetFloat::read(Lexer & lex)
|
||||
params_.read(lex);
|
||||
wide(params_.wide, buffer().params());
|
||||
sideways(params_.sideways, buffer().params());
|
||||
subfloat(params_.subfloat, buffer().params());
|
||||
InsetCollapsable::read(lex);
|
||||
}
|
||||
|
||||
@ -263,7 +280,10 @@ void InsetFloat::validate(LaTeXFeatures & features) const
|
||||
if (params_.sideways)
|
||||
features.require("rotfloat");
|
||||
|
||||
features.useFloat(params_.type);
|
||||
if (params_.subfloat)
|
||||
features.require("subfig");
|
||||
|
||||
features.useFloat(params_.type, params_.subfloat);
|
||||
InsetCollapsable::validate(features);
|
||||
}
|
||||
|
||||
@ -282,6 +302,23 @@ docstring InsetFloat::editMessage() const
|
||||
|
||||
int InsetFloat::latex(odocstream & os, OutputParams const & runparams) const
|
||||
{
|
||||
if (params_.subfloat) {
|
||||
if (runparams.moving_arg)
|
||||
os << "\\protect";
|
||||
os << "\\subfloat";
|
||||
|
||||
OutputParams rp = runparams;
|
||||
docstring const caption = getCaption(rp);
|
||||
if (!caption.empty()) {
|
||||
os << caption;
|
||||
}
|
||||
os << '{';
|
||||
int const i = InsetText::latex(os, runparams);
|
||||
os << "}";
|
||||
|
||||
return i + 1;
|
||||
}
|
||||
|
||||
FloatList const & floats = buffer().params().documentClass().floats();
|
||||
string tmptype = params_.type;
|
||||
if (params_.sideways)
|
||||
@ -341,6 +378,7 @@ int InsetFloat::plaintext(odocstream & os, OutputParams const & runparams) const
|
||||
|
||||
int InsetFloat::docbook(odocstream & os, OutputParams const & runparams) const
|
||||
{
|
||||
// FIXME Implement subfloat!
|
||||
// FIXME UNICODE
|
||||
os << '<' << from_ascii(params_.type) << '>';
|
||||
int const i = InsetText::docbook(os, runparams);
|
||||
@ -352,9 +390,9 @@ int InsetFloat::docbook(odocstream & os, OutputParams const & runparams) const
|
||||
|
||||
bool InsetFloat::insetAllowed(InsetCode code) const
|
||||
{
|
||||
return code != FLOAT_CODE
|
||||
&& code != FOOT_CODE
|
||||
&& code != MARGIN_CODE;
|
||||
return code != FOOT_CODE
|
||||
&& code != MARGIN_CODE
|
||||
&& (code != FLOAT_CODE || !params_.subfloat);
|
||||
}
|
||||
|
||||
|
||||
@ -386,6 +424,42 @@ void InsetFloat::sideways(bool s, BufferParams const & bp)
|
||||
}
|
||||
|
||||
|
||||
void InsetFloat::subfloat(bool s, BufferParams const & bp)
|
||||
{
|
||||
params_.subfloat = s;
|
||||
docstring lab = _("float: ") + floatName(params_.type, bp);
|
||||
if (s)
|
||||
lab = _("subfloat: ") + floatName(params_.type, bp);
|
||||
setLabel(lab);
|
||||
}
|
||||
|
||||
|
||||
docstring InsetFloat::getCaption(OutputParams const & runparams) const
|
||||
{
|
||||
if (paragraphs().empty())
|
||||
return docstring();
|
||||
|
||||
ParagraphList::const_iterator pit = paragraphs().begin();
|
||||
for (; pit != paragraphs().end(); ++pit) {
|
||||
InsetList::const_iterator it = pit->insetList().begin();
|
||||
for (; it != pit->insetList().end(); ++it) {
|
||||
Inset & inset = *it->inset;
|
||||
if (inset.lyxCode() == CAPTION_CODE) {
|
||||
odocstringstream ods;
|
||||
InsetCaption * ins =
|
||||
static_cast<InsetCaption *>(it->inset);
|
||||
ins->getOptArg(ods, runparams);
|
||||
ods << '[';
|
||||
ins->getArgument(ods, runparams);
|
||||
ods << ']';
|
||||
return ods.str();
|
||||
}
|
||||
}
|
||||
}
|
||||
return docstring();
|
||||
}
|
||||
|
||||
|
||||
string const InsetFloatMailer::name_("float");
|
||||
|
||||
InsetFloatMailer::InsetFloatMailer(InsetFloat & inset)
|
||||
|
@ -23,7 +23,7 @@ namespace lyx {
|
||||
class InsetFloatParams {
|
||||
public:
|
||||
///
|
||||
InsetFloatParams() : wide(false), sideways(false) {}
|
||||
InsetFloatParams() : wide(false), sideways(false), subfloat(false) {}
|
||||
///
|
||||
void write(std::ostream & os) const;
|
||||
///
|
||||
@ -36,6 +36,8 @@ public:
|
||||
bool wide;
|
||||
///
|
||||
bool sideways;
|
||||
///
|
||||
bool subfloat;
|
||||
};
|
||||
|
||||
|
||||
@ -79,6 +81,8 @@ public:
|
||||
///
|
||||
void sideways(bool s, BufferParams const &);
|
||||
///
|
||||
void subfloat(bool s, BufferParams const &);
|
||||
///
|
||||
bool showInsetDialog(BufferView *) const;
|
||||
///
|
||||
InsetFloatParams const & params() const { return params_; }
|
||||
@ -92,6 +96,8 @@ private:
|
||||
///
|
||||
virtual Inset * clone() const;
|
||||
///
|
||||
docstring getCaption(OutputParams const &) const;
|
||||
///
|
||||
InsetFloatParams params_;
|
||||
///
|
||||
docstring name_;
|
||||
|
@ -22,8 +22,6 @@ TODO
|
||||
filename.
|
||||
* Add support for the 'picins' package.
|
||||
* Add support for the 'picinpar' package.
|
||||
* Improve support for 'subfigure' - Allow to set the various options
|
||||
that are possible.
|
||||
*/
|
||||
|
||||
/* NOTES:
|
||||
@ -764,13 +762,6 @@ int InsetGraphics::latex(odocstream & os,
|
||||
// after the actual includegraphics command.
|
||||
string before;
|
||||
string after;
|
||||
// Do we want subcaptions?
|
||||
if (params().subcaption) {
|
||||
if (runparams.moving_arg)
|
||||
before += "\\protect";
|
||||
before += "\\subfigure[" + params().subcaptionText + "]{";
|
||||
after = '}';
|
||||
}
|
||||
|
||||
if (runparams.moving_arg)
|
||||
before += "\\protect";
|
||||
@ -898,9 +889,6 @@ void InsetGraphics::validate(LaTeXFeatures & features) const
|
||||
if (contains(rel_file, "."))
|
||||
features.require("lyxdot");
|
||||
}
|
||||
|
||||
if (params().subcaption)
|
||||
features.require("subfigure");
|
||||
}
|
||||
|
||||
|
||||
|
@ -78,8 +78,6 @@ void InsetGraphicsParams::init()
|
||||
|
||||
rotateAngle = "0"; // angle of rotation in degrees
|
||||
rotateOrigin.erase(); // Origin of rotation
|
||||
subcaption = false; // subfigure
|
||||
subcaptionText.erase(); // subfigure caption
|
||||
special.erase(); // additional userdefined stuff
|
||||
}
|
||||
|
||||
@ -102,8 +100,6 @@ void InsetGraphicsParams::copy(InsetGraphicsParams const & igp)
|
||||
|
||||
rotateAngle = igp.rotateAngle;
|
||||
rotateOrigin = igp.rotateOrigin;
|
||||
subcaption = igp.subcaption;
|
||||
subcaptionText = igp.subcaptionText;
|
||||
special = igp.special;
|
||||
}
|
||||
|
||||
@ -127,8 +123,6 @@ bool operator==(InsetGraphicsParams const & left,
|
||||
|
||||
left.rotateAngle == right.rotateAngle &&
|
||||
left.rotateOrigin == right.rotateOrigin &&
|
||||
left.subcaption == right.subcaption &&
|
||||
left.subcaptionText == right.subcaptionText &&
|
||||
left.special == right.special;
|
||||
}
|
||||
|
||||
@ -180,10 +174,6 @@ void InsetGraphicsParams::Write(ostream & os, Buffer const & buffer) const
|
||||
os << "\trotateAngle " << rotateAngle << '\n';
|
||||
if (!rotateOrigin.empty())
|
||||
os << "\trotateOrigin " << rotateOrigin << '\n';
|
||||
if (subcaption)
|
||||
os << "\tsubcaption\n";
|
||||
if (!subcaptionText.empty())
|
||||
os << "\tsubcaptionText \"" << subcaptionText << '\"' << '\n';
|
||||
if (!special.empty())
|
||||
os << "\tspecial " << special << '\n';
|
||||
}
|
||||
@ -246,13 +236,6 @@ bool InsetGraphicsParams::Read(Lexer & lex, string const & token, string const &
|
||||
} else if (token == "rotateOrigin") {
|
||||
lex.next();
|
||||
rotateOrigin=lex.getString();
|
||||
} else if (token == "subcaption") {
|
||||
subcaption = true;
|
||||
} else if (token == "subcaptionText") {
|
||||
lex.eatLine();
|
||||
string sub = lex.getString();
|
||||
// strip surrounding " "
|
||||
subcaptionText = sub.substr(1, sub.length() - 2);
|
||||
} else if (token == "special") {
|
||||
lex.eatLine();
|
||||
special = lex.getString();
|
||||
|
@ -60,10 +60,6 @@ public:
|
||||
std::string rotateAngle;
|
||||
/// Origin point of rotation
|
||||
std::string rotateOrigin;
|
||||
/// Do we have a subcaption?
|
||||
bool subcaption;
|
||||
/// The text of the subcaption.
|
||||
std::string subcaptionText;
|
||||
/// any userdefined special command
|
||||
std::string special;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user