Introduce groups for graphics insets. That includes:

- GuiGraphics dialog field for setup new groups.
- Graphics context menu for assigning to certain group.
- Fileformat change for groupId field in Graphics inset.
- Undo mechanism added to inset-apply, for catching changes
  in preference dialog.
- Qt designer 4.4 used now.



git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@24644 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Pavel Sanda 2008-05-06 21:13:09 +00:00
parent 99b12faae4
commit 13e42a8c73
17 changed files with 413 additions and 183 deletions

View File

@ -1,5 +1,7 @@
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

View File

@ -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,332), minor_versions("1.6" , 0))]
("1_6", range(277,333), minor_versions("1.6" , 0))]
def formats_list():

View File

@ -2188,6 +2188,26 @@ def revert_master(document):
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
#
@ -2248,9 +2268,11 @@ convert = [[277, [fix_wrong_tables]],
[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, []],

View File

@ -300,6 +300,7 @@ Menuset
Item "Settings...|S" "next-inset-toggle"
Separator
Item "Edit externally...|x" "inset-edit"
GraphicsGroups
End
#

View File

@ -115,7 +115,7 @@ namespace os = support::os;
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;

View File

@ -409,6 +409,8 @@ enum FuncCode
LFUN_COMPLETION_COMPLETE,
// 315
LFUN_NEXT_INSET_MODIFY, // JSpitzm 20080323
LFUN_GRAPHICS_GROUPS_UNIFY,
LFUN_SET_GRAPHICS_GROUP,
LFUN_LASTACTION // end of the table
};

View File

@ -1239,6 +1239,27 @@ void LyXAction::init()
* \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

View File

@ -621,6 +621,7 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & cmd) const
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:
@ -1462,6 +1463,16 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
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();

View File

@ -57,6 +57,8 @@
#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"
@ -890,6 +892,30 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
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, ' ');
@ -2251,6 +2277,7 @@ bool Text::getStatus(Cursor & cur, FuncRequest const & cmd,
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;

View File

@ -539,6 +539,8 @@ void GuiGraphics::paramsToDialog(InsetGraphicsParams const & igp)
scaleCB->blockSignals(false);
Scale->setEnabled(scaleChecked);
groupId->setText(toqstr(igp.groupId));
lengthAutoToWidgets(Width, widthUnit, igp.width,
unitDefault);
bool const widthChecked = !Width->text().isEmpty() &&
@ -682,6 +684,8 @@ void GuiGraphics::applyView()
// more latex options
igp.special = fromqstr(latexoptions->text());
igp.groupId = fromqstr(groupId->text());
}
@ -732,6 +736,9 @@ void GuiGraphics::dispatchParams()
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())));
}

View File

@ -1844,6 +1844,7 @@ bool GuiView::dispatch(FuncRequest const & cmd)
}
case LFUN_INSET_APPLY: {
view()->cursor().recordUndoFullDocument();
string const name = cmd.getArg(0);
Inset * inset = getOpenInset(name);
if (inset) {

View File

@ -49,6 +49,7 @@
#include "insets/Inset.h"
#include "insets/InsetCitation.h"
#include "insets/InsetGraphics.h"
#include "support/lassert.h"
#include "support/convert.h"
@ -137,7 +138,9 @@ public:
/** 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) {}
@ -290,6 +293,7 @@ public:
void expandToolbars();
void expandBranches(Buffer const * buf);
void expandCiteStyles(BufferView const *);
void expandGraphicsGroups(Buffer const * buf);
///
ItemList items_;
///
@ -390,7 +394,8 @@ void MenuDefinition::read(Lexer & lex)
md_floatlistinsert,
md_floatinsert,
md_pasterecent,
md_toolbars
md_toolbars,
md_graphicsgroups
};
LexerKeyword menutags[] = {
@ -405,6 +410,7 @@ void MenuDefinition::read(Lexer & lex)
{ "exportformats", md_exportformats },
{ "floatinsert", md_floatinsert },
{ "floatlistinsert", md_floatlistinsert },
{ "graphicsgroups", md_graphicsgroups },
{ "importformats", md_importformats },
{ "item", md_item },
{ "lastfiles", md_lastfiles },
@ -513,6 +519,10 @@ void MenuDefinition::read(Lexer & lex)
add(MenuItem(MenuItem::CiteStyles));
break;
case md_graphicsgroups:
add(MenuItem(MenuItem::GraphicsGroups));
break;
case md_optsubmenu:
optional = true;
// fallback to md_submenu
@ -623,6 +633,21 @@ QString limitStringLength(docstring const & str)
}
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();
@ -1396,6 +1421,10 @@ void Menus::Impl::expand(MenuDefinition const & frommenu,
tomenu.expandToc(buf);
break;
case MenuItem::GraphicsGroups:
tomenu.expandGraphicsGroups(buf);
break;
case MenuItem::Submenu: {
MenuItem item(*cit);
item.setSubmenu(MenuDefinition(cit->submenuname()));

View File

@ -5,14 +5,12 @@
<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>
@ -30,8 +28,95 @@
<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>&amp;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>&amp;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>&amp;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>
@ -39,6 +124,14 @@
<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>&amp;Graphics</string>
</attribute>
@ -86,9 +179,7 @@
<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>
@ -103,7 +194,7 @@
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" >
<property name="sizeHint" stdset="0" >
<size>
<width>61</width>
<height>20</height>
@ -120,9 +211,7 @@
<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>
@ -229,9 +318,7 @@
<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>
@ -280,6 +367,14 @@
</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>&amp;Clipping</string>
</attribute>
@ -295,7 +390,7 @@
<property name="orientation" >
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" >
<property name="sizeHint" stdset="0" >
<size>
<width>20</width>
<height>40</height>
@ -319,9 +414,7 @@
<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>
@ -423,7 +516,7 @@
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" >
<property name="sizeHint" stdset="0" >
<size>
<width>181</width>
<height>20</height>
@ -444,17 +537,65 @@
</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&amp;X and LyX options</string>
</attribute>
<layout class="QGridLayout" >
<property name="margin" >
<number>9</number>
<item row="0" column="0" >
<widget class="QLabel" name="latexoptionsLA" >
<property name="toolTip" >
<string>Additional LaTeX options</string>
</property>
<property name="spacing" >
<number>6</number>
<property name="text" >
<string>LaTeX &amp;options:</string>
</property>
<item row="4" column="0" colspan="2" >
<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>&amp;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&amp;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>
@ -480,7 +621,7 @@
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" >
<property name="sizeHint" stdset="0" >
<size>
<width>40</width>
<height>20</height>
@ -494,9 +635,7 @@
<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>
@ -552,172 +691,59 @@
<string>Screen display</string>
</property>
<property name="text" >
<string>&amp;Display:</string>
<string>Scr&amp;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&amp;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 &amp;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>&amp;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>&amp;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>&amp;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>&amp;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>
@ -728,7 +754,7 @@
</customwidget>
</customwidgets>
<tabstops>
<tabstop>TabWidget</tabstop>
<tabstop>tabWidget</tabstop>
<tabstop>filename</tabstop>
<tabstop>browsePB</tabstop>
<tabstop>scaleCB</tabstop>

View File

@ -67,6 +67,7 @@ TODO
#include "OutputParams.h"
#include "sgml.h"
#include "TocBackend.h"
#include "InsetIterator.h"
#include "frontends/alert.h"
#include "frontends/Application.h"
@ -949,4 +950,61 @@ string InsetGraphics::params2string(InsetGraphicsParams const & params,
}
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

View File

@ -13,6 +13,7 @@
#ifndef INSET_GRAPHICS_H
#define INSET_GRAPHICS_H
#include <set>
#include "Inset.h"
#include "InsetGraphicsParams.h"
@ -47,11 +48,23 @@ public:
///
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 &);

View File

@ -79,6 +79,7 @@ void InsetGraphicsParams::init()
rotateAngle = "0"; // angle of rotation in degrees
rotateOrigin.erase(); // Origin of rotation
special.erase(); // additional userdefined stuff
groupId.clear();
}
@ -101,6 +102,7 @@ void InsetGraphicsParams::copy(InsetGraphicsParams const & igp)
rotateAngle = igp.rotateAngle;
rotateOrigin = igp.rotateOrigin;
special = igp.special;
groupId = igp.groupId;
}
@ -123,7 +125,8 @@ bool operator==(InsetGraphicsParams const & left,
left.rotateAngle == right.rotateAngle &&
left.rotateOrigin == right.rotateOrigin &&
left.special == right.special;
left.special == right.special &&
left.groupId == right.groupId;
}
@ -174,6 +177,8 @@ void InsetGraphicsParams::Write(ostream & os, Buffer const & buffer) const
os << "\trotateOrigin " << rotateOrigin << '\n';
if (!special.empty())
os << "\tspecial " << special << '\n';
if (!groupId.empty())
os << "\tgroupId "<< groupId << '\n';
}
@ -227,6 +232,9 @@ bool InsetGraphicsParams::Read(Lexer & lex, string const & token, string const &
} 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

View File

@ -83,6 +83,8 @@ public:
// 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();