mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-23 05:25:26 +00:00
Fix crash with Menu->Edit->Paste recent
As an added bonus, the selection will be adapted to current Buffer (for quites, etc). git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@26001 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
236460445a
commit
3bbe1facb4
@ -555,9 +555,11 @@ void switchBetweenClasses(DocumentClass const * const oldone,
|
||||
}
|
||||
|
||||
|
||||
vector<docstring> availableSelections()
|
||||
vector<docstring> availableSelections(Buffer const * buf)
|
||||
{
|
||||
vector<docstring> selList;
|
||||
if (!buf)
|
||||
return selList;
|
||||
|
||||
CutStack::const_iterator cit = theCuts.begin();
|
||||
CutStack::const_iterator end = theCuts.end();
|
||||
@ -569,7 +571,10 @@ vector<docstring> availableSelections()
|
||||
ParagraphList::const_iterator pit = pars.begin();
|
||||
ParagraphList::const_iterator pend = pars.end();
|
||||
for (; pit != pend; ++pit) {
|
||||
asciiSel += pit->asString(AS_STR_INSETS);
|
||||
Paragraph par(*pit, 0, 26);
|
||||
// adapt paragraph to current buffer.
|
||||
par.setBuffer(const_cast<Buffer &>(*buf));
|
||||
asciiSel += par.asString(AS_STR_INSETS);
|
||||
if (asciiSel.size() > 25) {
|
||||
asciiSel.replace(22, docstring::npos,
|
||||
from_ascii("..."));
|
||||
|
@ -33,7 +33,7 @@ class ParagraphList;
|
||||
namespace cap {
|
||||
|
||||
/// Get all elements of the cut buffer in plain text format.
|
||||
std::vector<docstring> availableSelections();
|
||||
std::vector<docstring> availableSelections(Buffer const *);
|
||||
/// Get the number of available elements in the cut buffer.
|
||||
size_type numberOfSelections();
|
||||
/// Get the sel_index-th element of the cut buffer in plain text format.
|
||||
|
@ -291,7 +291,7 @@ public:
|
||||
void expandFlexInsert(Buffer const * buf, std::string s);
|
||||
void expandToc2(Toc const & toc_list, size_t from, size_t to, int depth);
|
||||
void expandToc(Buffer const * buf);
|
||||
void expandPasteRecent();
|
||||
void expandPasteRecent(Buffer const * buf);
|
||||
void expandToolbars();
|
||||
void expandBranches(Buffer const * buf);
|
||||
void expandCiteStyles(BufferView const *);
|
||||
@ -989,9 +989,9 @@ void MenuDefinition::expandToc(Buffer const * buf)
|
||||
}
|
||||
|
||||
|
||||
void MenuDefinition::expandPasteRecent()
|
||||
void MenuDefinition::expandPasteRecent(Buffer const * buf)
|
||||
{
|
||||
docstring_list const sel = cap::availableSelections();
|
||||
docstring_list const sel = cap::availableSelections(buf);
|
||||
|
||||
docstring_list::const_iterator cit = sel.begin();
|
||||
docstring_list::const_iterator end = sel.end();
|
||||
@ -1367,7 +1367,7 @@ void Menus::Impl::expand(MenuDefinition const & frommenu,
|
||||
break;
|
||||
|
||||
case MenuItem::PasteRecent:
|
||||
tomenu.expandPasteRecent();
|
||||
tomenu.expandPasteRecent(buf);
|
||||
break;
|
||||
|
||||
case MenuItem::Toolbars:
|
||||
|
Loading…
Reference in New Issue
Block a user