LyX file-format changes
-----------------------
+2008-05-06 Pavel Sanda <sanda@lyx.org>
+ * Format incremented to 332: Added groupId for graphics insets.
2008-25-04 Helge Hafting <helge.hafting@aitel.hist.no>
* Format incremented to 330: More horizontal fills
("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,332), minor_versions("1.6" , 0))]
+ ("1_6", range(277,333), minor_versions("1.6" , 0))]
def formats_list():
del document.header[i]
+def revert_graphics_group(document):
+ ' Revert group information from graphics insets '
+ 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, " groupId", i, j)
+ if k == -1:
+ i = i + 1
+ continue
+ del document.body[k]
+ i = i + 1
+
+
##
# Conversion hub
#
[329, []],
[330, []],
[331, [convert_ltcaption]],
+ [332, []],
]
-revert = [[330, [revert_ltcaption]],
+revert = [[331, [revert_graphics_group]],
+ [330, [revert_ltcaption]],
[329, [revert_leftarrowfill, revert_rightarrowfill, revert_upbracefill, revert_downbracefill]],
[328, [revert_master]],
[327, []],
Item "Settings...|S" "next-inset-toggle"
Separator
Item "Edit externally...|x" "inset-edit"
+ GraphicsGroups
End
#
namespace {
-int const LYX_FORMAT = 331;
+int const LYX_FORMAT = 332; //ps, graphgroups
typedef map<string, bool> DepClean;
typedef map<docstring, pair<InsetLabel const *, Buffer::References> > RefCache;
LFUN_COMPLETION_COMPLETE,
// 315
LFUN_NEXT_INSET_MODIFY, // JSpitzm 20080323
+ LFUN_GRAPHICS_GROUPS_UNIFY,
+ LFUN_SET_GRAPHICS_GROUP,
LFUN_LASTACTION // end of the table
};
* \endvar
*/
{ LFUN_ALL_INSETS_TOGGLE, "all-insets-toggle", ReadOnly, Edit },
+/*!
+ * \var lyx::FuncCode lyx::LFUN_GRAPHICS_GROUPS_UNIFY
+ * \li Action: Unify all graphics insets with the one given as an parameter.
+ * \li Notion: This is internally used for synchronize certain group of graphics insets.
+ * \li Syntax: graphics-groups-unigfy <GRAPHICS_PARAMS>
+ * \li Params: <GRAPHICS_PARAMS>: Parameters for graphics inset
+ (syntax can be seen in .lyx files).
+ * \li Origin: sanda, 6 May 2008
+ * \endvar
+ */
+ { LFUN_GRAPHICS_GROUPS_UNIFY, "graphics-groups-unify", ReadOnly, Edit },
+/*!
+ * \var lyx::FuncCode lyx::LFUN_SET_GRAPHICS_GROUP
+ * \li Action: Set the group for the graphics inset on the cursor position.
+ * \li Syntax: set-graphics-group [<GROUP>]
+ * \li Params: <GROUP>: Id for an existing group. In case tthe Id is an empty string,
+ the graphics inset is removed from the current group.
+ * \li Origin: sanda, 6 May 2008
+ * \endvar
+ */
+ { LFUN_SET_GRAPHICS_GROUP, "set-graphics-group", ReadOnly, Edit },
/*!
* \var lyx::FuncCode lyx::LFUN_FINISHED_FORWARD
case LFUN_MESSAGE:
case LFUN_INSET_EDIT:
case LFUN_ALL_INSETS_TOGGLE:
+ case LFUN_GRAPHICS_GROUPS_UNIFY:
case LFUN_BUFFER_LANGUAGE:
case LFUN_TEXTCLASS_APPLY:
case LFUN_TEXTCLASS_LOAD:
break;
}
+ case LFUN_GRAPHICS_GROUPS_UNIFY: {
+ LASSERT(lyx_view_, /**/);
+ if (argument.empty() || !lyx_view_->buffer()) break;
+ //view()->cursor().recordUndoFullDocument(); let inset-apply do that job
+ InsetGraphics::unifyGraphicsGroups(*lyx_view_->buffer(), argument);
+ lyx_view_->buffer()->markDirty();
+ updateFlags = Update::Force | Update::FitCursor;
+ break;
+ }
+
case LFUN_BUFFER_LANGUAGE: {
LASSERT(lyx_view_, /**/);
Buffer & buffer = *lyx_view_->buffer();
#include "insets/InsetSpecialChar.h"
#include "insets/InsetText.h"
#include "insets/InsetInfo.h"
+#include "insets/InsetGraphics.h"
+#include "insets/InsetGraphicsParams.h"
#include "support/convert.h"
#include "support/debug.h"
break;
}
+ case LFUN_SET_GRAPHICS_GROUP: {
+ Inset * instmp = &cur.inset();
+ if (instmp->lyxCode() != GRAPHICS_CODE) instmp = cur.nextInset();
+ if (!instmp || instmp->lyxCode() != GRAPHICS_CODE) break;
+
+ cur.recordUndoFullDocument();
+ Inset & inset = *instmp;
+ InsetGraphics & ins = static_cast<InsetGraphics &>(inset);
+
+ string id = to_utf8(cmd.argument());
+ string grp = InsetGraphics::getGroupParams(bv->buffer(), id);
+ InsetGraphicsParams tmp, inspar = ins.getParams();
+
+ if (id.empty())
+ inspar.groupId = to_utf8(cmd.argument());
+ else {
+ InsetGraphics::string2params(grp, bv->buffer(), tmp);
+ tmp.filename = inspar.filename;
+ inspar = tmp;
+ }
+
+ ins.setParams(inspar);
+ }
+
case LFUN_SPACE_INSERT:
if (cur.paragraph().layout().free_spacing)
insertChar(cur, ' ');
case LFUN_BUFFER_BEGIN_SELECT:
case LFUN_BUFFER_END_SELECT:
case LFUN_UNICODE_INSERT:
+ case LFUN_SET_GRAPHICS_GROUP:
// these are handled in our dispatch()
enable = true;
break;
scaleCB->blockSignals(false);
Scale->setEnabled(scaleChecked);
+ groupId->setText(toqstr(igp.groupId));
+
lengthAutoToWidgets(Width, widthUnit, igp.width,
unitDefault);
bool const widthChecked = !Width->text().isEmpty() &&
// more latex options
igp.special = fromqstr(latexoptions->text());
+
+ igp.groupId = fromqstr(groupId->text());
}
InsetGraphicsParams tmp_params(params_);
string const lfun = InsetGraphics::params2string(tmp_params, buffer());
dispatch(FuncRequest(getLfun(), lfun));
+ if (!params_.groupId.empty())
+ dispatch(FuncRequest(LFUN_GRAPHICS_GROUPS_UNIFY,
+ InsetGraphics::params2string(params_, buffer())));
}
}
case LFUN_INSET_APPLY: {
+ view()->cursor().recordUndoFullDocument();
string const name = cmd.getArg(0);
Inset * inset = getOpenInset(name);
if (inset) {
#include "insets/Inset.h"
#include "insets/InsetCitation.h"
+#include "insets/InsetGraphics.h"
#include "support/lassert.h"
#include "support/convert.h"
/** Available branches in document */
Branches,
/** Available citation styles for a given citation */
- CiteStyles
+ CiteStyles,
+ /** Available graphics groups */
+ GraphicsGroups
};
explicit MenuItem(Kind kind) : kind_(kind), optional_(false) {}
void expandToolbars();
void expandBranches(Buffer const * buf);
void expandCiteStyles(BufferView const *);
+ void expandGraphicsGroups(Buffer const * buf);
///
ItemList items_;
///
md_floatlistinsert,
md_floatinsert,
md_pasterecent,
- md_toolbars
+ md_toolbars,
+ md_graphicsgroups
};
LexerKeyword menutags[] = {
{ "exportformats", md_exportformats },
{ "floatinsert", md_floatinsert },
{ "floatlistinsert", md_floatlistinsert },
+ { "graphicsgroups", md_graphicsgroups },
{ "importformats", md_importformats },
{ "item", md_item },
{ "lastfiles", md_lastfiles },
add(MenuItem(MenuItem::CiteStyles));
break;
+ case md_graphicsgroups:
+ add(MenuItem(MenuItem::GraphicsGroups));
+ break;
+
case md_optsubmenu:
optional = true;
// fallback to md_submenu
}
+void MenuDefinition::expandGraphicsGroups(Buffer const * buf)
+{
+ set<string> grp;
+ InsetGraphics::getGraphicsGroups(*buf, grp);
+ set<string>::const_iterator it = grp.begin();
+ set<string>::const_iterator end = grp.end();
+ if (grp.empty()) return;
+
+ add(MenuItem(MenuItem::Separator));
+ add(MenuItem(MenuItem::Command, qt_("Clear group"), FuncRequest(LFUN_SET_GRAPHICS_GROUP)));
+ for (; it != end; it++) {
+ add(MenuItem(MenuItem::Command, toqstr(*it), FuncRequest(LFUN_SET_GRAPHICS_GROUP, *it)));
+ }
+}
+
void MenuDefinition::expandLastfiles()
{
LastFilesSection::LastFiles const & lf = LyX::cref().session().lastFiles().lastFiles();
tomenu.expandToc(buf);
break;
+ case MenuItem::GraphicsGroups:
+ tomenu.expandGraphicsGroups(buf);
+ break;
+
case MenuItem::Submenu: {
MenuItem item(*cit);
item.setSubmenu(MenuDefinition(cit->submenuname()));
<rect>
<x>0</x>
<y>0</y>
- <width>481</width>
- <height>354</height>
+ <width>584</width>
+ <height>373</height>
</rect>
</property>
<property name="sizePolicy" >
- <sizepolicy>
- <hsizetype>1</hsizetype>
- <vsizetype>1</vsizetype>
+ <sizepolicy vsizetype="Minimum" hsizetype="Minimum" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
<property name="spacing" >
<number>6</number>
</property>
+ <item row="1" column="0" >
+ <layout class="QHBoxLayout" >
+ <property name="spacing" >
+ <number>6</number>
+ </property>
+ <property name="margin" >
+ <number>0</number>
+ </property>
+ <item>
+ <widget class="QPushButton" name="restorePB" >
+ <property name="text" >
+ <string>&Restore</string>
+ </property>
+ <property name="autoDefault" >
+ <bool>false</bool>
+ </property>
+ <property name="default" >
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer>
+ <property name="orientation" >
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeType" >
+ <enum>QSizePolicy::MinimumExpanding</enum>
+ </property>
+ <property name="sizeHint" stdset="0" >
+ <size>
+ <width>20</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QPushButton" name="okPB" >
+ <property name="text" >
+ <string>&OK</string>
+ </property>
+ <property name="autoDefault" >
+ <bool>true</bool>
+ </property>
+ <property name="default" >
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="applyPB" >
+ <property name="sizePolicy" >
+ <sizepolicy vsizetype="Fixed" hsizetype="Minimum" >
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text" >
+ <string>&Apply</string>
+ </property>
+ <property name="autoDefault" >
+ <bool>false</bool>
+ </property>
+ <property name="default" >
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="closePB" >
+ <property name="sizePolicy" >
+ <sizepolicy vsizetype="Fixed" hsizetype="Minimum" >
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text" >
+ <string>Close</string>
+ </property>
+ <property name="autoDefault" >
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
<item row="0" column="0" >
- <widget class="QTabWidget" name="TabWidget" >
+ <widget class="QTabWidget" name="tabWidget" >
<property name="toolTip" >
<string/>
</property>
<number>0</number>
</property>
<widget class="QWidget" name="Graphics" >
+ <property name="geometry" >
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>562</width>
+ <height>293</height>
+ </rect>
+ </property>
<attribute name="title" >
<string>&Graphics</string>
</attribute>
<bool>true</bool>
</property>
<property name="sizePolicy" >
- <sizepolicy>
- <hsizetype>1</hsizetype>
- <vsizetype>0</vsizetype>
+ <sizepolicy vsizetype="Fixed" hsizetype="Minimum" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
- <property name="sizeHint" >
+ <property name="sizeHint" stdset="0" >
<size>
<width>61</width>
<height>20</height>
<bool>true</bool>
</property>
<property name="sizePolicy" >
- <sizepolicy>
- <hsizetype>1</hsizetype>
- <vsizetype>0</vsizetype>
+ <sizepolicy vsizetype="Fixed" hsizetype="Minimum" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
<item row="0" column="1" >
<widget class="QLineEdit" name="angle" >
<property name="sizePolicy" >
- <sizepolicy>
- <hsizetype>3</hsizetype>
- <vsizetype>0</vsizetype>
+ <sizepolicy vsizetype="Fixed" hsizetype="MinimumExpanding" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</layout>
</widget>
<widget class="QWidget" name="Clipping" >
+ <property name="geometry" >
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>100</width>
+ <height>30</height>
+ </rect>
+ </property>
<attribute name="title" >
<string>&Clipping</string>
</attribute>
<property name="orientation" >
<enum>Qt::Vertical</enum>
</property>
- <property name="sizeHint" >
+ <property name="sizeHint" stdset="0" >
<size>
<width>20</width>
<height>40</height>
<bool>true</bool>
</property>
<property name="sizePolicy" >
- <sizepolicy>
- <hsizetype>5</hsizetype>
- <vsizetype>1</vsizetype>
+ <sizepolicy vsizetype="Minimum" hsizetype="Preferred" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
- <property name="sizeHint" >
+ <property name="sizeHint" stdset="0" >
<size>
<width>181</width>
<height>20</height>
</layout>
</widget>
<widget class="QWidget" name="ExtraOptions" >
+ <property name="geometry" >
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>562</width>
+ <height>293</height>
+ </rect>
+ </property>
<attribute name="title" >
<string>LaTe&X and LyX options</string>
</attribute>
<layout class="QGridLayout" >
- <property name="margin" >
- <number>9</number>
- </property>
- <property name="spacing" >
- <number>6</number>
- </property>
- <item row="4" column="0" colspan="2" >
+ <item row="0" column="0" >
+ <widget class="QLabel" name="latexoptionsLA" >
+ <property name="toolTip" >
+ <string>Additional LaTeX options</string>
+ </property>
+ <property name="text" >
+ <string>LaTeX &options:</string>
+ </property>
+ <property name="buddy" >
+ <cstring>latexoptions</cstring>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1" >
+ <widget class="QLineEdit" name="latexoptions" >
+ <property name="sizePolicy" >
+ <sizepolicy vsizetype="Fixed" hsizetype="MinimumExpanding" >
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="toolTip" >
+ <string>Additional LaTeX options</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="0" colspan="2" >
+ <widget class="QCheckBox" name="draftCB" >
+ <property name="toolTip" >
+ <string>Draft mode</string>
+ </property>
+ <property name="text" >
+ <string>&Draft mode</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="0" colspan="2" >
+ <widget class="QCheckBox" name="unzipCB" >
+ <property name="toolTip" >
+ <string>Don't uncompress image before exporting to LaTeX</string>
+ </property>
+ <property name="text" >
+ <string>Don't un&zip on export</string>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="0" colspan="2" >
<widget class="QGroupBox" name="displayGB" >
<property name="focusPolicy" >
<enum>Qt::StrongFocus</enum>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
- <property name="sizeHint" >
+ <property name="sizeHint" stdset="0" >
<size>
<width>40</width>
<height>20</height>
<bool>true</bool>
</property>
<property name="sizePolicy" >
- <sizepolicy>
- <hsizetype>1</hsizetype>
- <vsizetype>0</vsizetype>
+ <sizepolicy vsizetype="Fixed" hsizetype="Minimum" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
<string>Screen display</string>
</property>
<property name="text" >
- <string>&Display:</string>
+ <string>Scr&een Display:</string>
</property>
<property name="buddy" >
<cstring>showCB</cstring>
</property>
</widget>
</item>
+ <item row="1" column="0" >
+ <widget class="QLabel" name="label" >
+ <property name="sizePolicy" >
+ <sizepolicy vsizetype="Preferred" hsizetype="Preferred" >
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text" >
+ <string>Initialize Group-Id:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1" >
+ <widget class="QLineEdit" name="groupId" >
+ <property name="minimumSize" >
+ <size>
+ <width>87</width>
+ <height>0</height>
+ </size>
+ </property>
+ <property name="toolTip" >
+ <string>Group-id to be set up from the current parameters</string>
+ </property>
+ </widget>
+ </item>
</layout>
</widget>
</item>
- <item row="5" column="1" >
+ <item row="4" column="1" >
<spacer>
<property name="orientation" >
<enum>Qt::Vertical</enum>
</property>
- <property name="sizeHint" >
+ <property name="sizeHint" stdset="0" >
<size>
- <width>20</width>
- <height>41</height>
+ <width>354</width>
+ <height>81</height>
</size>
</property>
</spacer>
</item>
- <item row="2" column="0" colspan="2" >
- <widget class="QCheckBox" name="unzipCB" >
- <property name="toolTip" >
- <string>Don't uncompress image before exporting to LaTeX</string>
- </property>
- <property name="text" >
- <string>Don't un&zip on export</string>
- </property>
- </widget>
- </item>
- <item row="0" column="1" >
- <widget class="QLineEdit" name="latexoptions" >
- <property name="sizePolicy" >
- <sizepolicy>
- <hsizetype>3</hsizetype>
- <vsizetype>0</vsizetype>
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="toolTip" >
- <string>Additional LaTeX options</string>
- </property>
- </widget>
- </item>
- <item row="0" column="0" >
- <widget class="QLabel" name="latexoptionsLA" >
- <property name="toolTip" >
- <string>Additional LaTeX options</string>
- </property>
- <property name="text" >
- <string>LaTeX &options:</string>
- </property>
- <property name="buddy" >
- <cstring>latexoptions</cstring>
- </property>
- </widget>
- </item>
- <item row="1" column="0" colspan="2" >
- <widget class="QCheckBox" name="draftCB" >
- <property name="toolTip" >
- <string>Draft mode</string>
- </property>
- <property name="text" >
- <string>&Draft mode</string>
- </property>
- </widget>
- </item>
</layout>
</widget>
</widget>
</item>
- <item row="1" column="0" >
- <layout class="QHBoxLayout" >
- <property name="margin" >
- <number>0</number>
- </property>
- <property name="spacing" >
- <number>6</number>
- </property>
- <item>
- <widget class="QPushButton" name="restorePB" >
- <property name="text" >
- <string>&Restore</string>
- </property>
- <property name="autoDefault" >
- <bool>false</bool>
- </property>
- <property name="default" >
- <bool>false</bool>
- </property>
- </widget>
- </item>
- <item>
- <spacer>
- <property name="orientation" >
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeType" >
- <enum>QSizePolicy::MinimumExpanding</enum>
- </property>
- <property name="sizeHint" >
- <size>
- <width>20</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
- </item>
- <item>
- <widget class="QPushButton" name="okPB" >
- <property name="text" >
- <string>&OK</string>
- </property>
- <property name="autoDefault" >
- <bool>true</bool>
- </property>
- <property name="default" >
- <bool>true</bool>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QPushButton" name="applyPB" >
- <property name="sizePolicy" >
- <sizepolicy>
- <hsizetype>1</hsizetype>
- <vsizetype>0</vsizetype>
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="text" >
- <string>&Apply</string>
- </property>
- <property name="autoDefault" >
- <bool>false</bool>
- </property>
- <property name="default" >
- <bool>false</bool>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QPushButton" name="closePB" >
- <property name="sizePolicy" >
- <sizepolicy>
- <hsizetype>1</hsizetype>
- <vsizetype>0</vsizetype>
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="text" >
- <string>Close</string>
- </property>
- <property name="autoDefault" >
- <bool>false</bool>
- </property>
- </widget>
- </item>
- </layout>
- </item>
</layout>
</widget>
<customwidgets>
</customwidget>
</customwidgets>
<tabstops>
- <tabstop>TabWidget</tabstop>
+ <tabstop>tabWidget</tabstop>
<tabstop>filename</tabstop>
<tabstop>browsePB</tabstop>
<tabstop>scaleCB</tabstop>
#include "OutputParams.h"
#include "sgml.h"
#include "TocBackend.h"
+#include "InsetIterator.h"
#include "frontends/alert.h"
#include "frontends/Application.h"
}
+void InsetGraphics::getGraphicsGroups(Buffer const & b, std::set<string> & ids)
+{
+ Inset & inset = b.inset();
+ InsetIterator it = inset_iterator_begin(inset);
+ InsetIterator const end = inset_iterator_end(inset);
+ for (; it != end; ++it)
+ if (it->lyxCode() == GRAPHICS_CODE) {
+ InsetGraphics & ins = static_cast<InsetGraphics &>(*it);
+ InsetGraphicsParams inspar = ins.getParams();
+ if (!inspar.groupId.empty()) {
+ ids.insert(inspar.groupId);
+ }
+ }
+}
+
+
+string InsetGraphics::getGroupParams(Buffer const & b, std::string const & groupId)
+{
+ if (groupId.empty()) return string();
+ Inset & inset = b.inset();
+ InsetIterator it = inset_iterator_begin(inset);
+ InsetIterator const end = inset_iterator_end(inset);
+ for (; it != end; ++it)
+ if (it->lyxCode() == GRAPHICS_CODE) {
+ InsetGraphics & ins = static_cast<InsetGraphics &>(*it);
+ InsetGraphicsParams inspar = ins.getParams();
+ if (inspar.groupId == groupId) {
+ InsetGraphicsParams tmp = inspar;
+ tmp.filename.erase();
+ return params2string(tmp, b);
+ }
+ }
+ return string();
+}
+
+void InsetGraphics::unifyGraphicsGroups(Buffer const & b, std::string const & argument)
+{
+ InsetGraphicsParams params;
+ InsetGraphics::string2params(argument, b, params);
+
+ Inset & inset = b.inset();
+ InsetIterator it = inset_iterator_begin(inset);
+ InsetIterator const end = inset_iterator_end(inset);
+ for (; it != end; ++it) {
+ if (it->lyxCode() == GRAPHICS_CODE) {
+ InsetGraphics & ins = static_cast<InsetGraphics &>(*it);
+ InsetGraphicsParams inspar = ins.getParams();
+ if (params.groupId == inspar.groupId) {
+ params.filename = inspar.filename;
+ ins.setParams(params);
+ }
+ }
+ }
+
+}
+
+
} // namespace lyx
#ifndef INSET_GRAPHICS_H
#define INSET_GRAPHICS_H
+#include <set>
#include "Inset.h"
#include "InsetGraphicsParams.h"
///
static std::string params2string(InsetGraphicsParams const &,
Buffer const &);
+ /// Saves the list of currently used groups in the document.
+ static void getGraphicsGroups(Buffer const &, std::set<std::string> &);
+ /// Returns parameters of a given graphics group (except filename).
+ static std::string getGroupParams(Buffer const &,
+ std::string const &);
+ /** Synchronize all Graphics insets of the group.
+ Both groupId and params are taken from argument.
+ */
+ static void unifyGraphicsGroups(Buffer const &, std::string const &);
+
/** Set the inset parameters, used by the GUIndependent dialog.
Return true of new params are different from what was so far.
*/
bool setParams(InsetGraphicsParams const & params);
+ InsetGraphicsParams getParams() const { return params_;}
+
private:
///
InsetGraphics(InsetGraphics const &);
rotateAngle = "0"; // angle of rotation in degrees
rotateOrigin.erase(); // Origin of rotation
special.erase(); // additional userdefined stuff
+ groupId.clear();
}
rotateAngle = igp.rotateAngle;
rotateOrigin = igp.rotateOrigin;
special = igp.special;
+ groupId = igp.groupId;
}
left.rotateAngle == right.rotateAngle &&
left.rotateOrigin == right.rotateOrigin &&
- left.special == right.special;
+ left.special == right.special &&
+ left.groupId == right.groupId;
}
os << "\trotateOrigin " << rotateOrigin << '\n';
if (!special.empty())
os << "\tspecial " << special << '\n';
+ if (!groupId.empty())
+ os << "\tgroupId "<< groupId << '\n';
}
} else if (token == "special") {
lex.eatLine();
special = lex.getString();
+ } else if (token == "groupId") {
+ lex.eatLine();
+ groupId = lex.getString();
// catch and ignore following two old-format tokens and their arguments.
// e.g. "size_kind scale" clashes with the setting of the
// to display or not.
graphics::Params as_grfxParams() const;
+ // Identification of the graphics template. No template equals empty string.
+ std::string groupId;
private:
/// Initialize the object to a default status.
void init();