diff --git a/src/CutAndPaste.cpp b/src/CutAndPaste.cpp index f13664b35d..82ea982b44 100644 --- a/src/CutAndPaste.cpp +++ b/src/CutAndPaste.cpp @@ -555,9 +555,11 @@ void switchBetweenClasses(DocumentClass const * const oldone, } -vector availableSelections() +vector availableSelections(Buffer const * buf) { vector selList; + if (!buf) + return selList; CutStack::const_iterator cit = theCuts.begin(); CutStack::const_iterator end = theCuts.end(); @@ -569,7 +571,10 @@ vector 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(*buf)); + asciiSel += par.asString(AS_STR_INSETS); if (asciiSel.size() > 25) { asciiSel.replace(22, docstring::npos, from_ascii("...")); diff --git a/src/CutAndPaste.h b/src/CutAndPaste.h index c263a5c82a..3d6e3808f6 100644 --- a/src/CutAndPaste.h +++ b/src/CutAndPaste.h @@ -33,7 +33,7 @@ class ParagraphList; namespace cap { /// Get all elements of the cut buffer in plain text format. -std::vector availableSelections(); +std::vector 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. diff --git a/src/frontends/qt4/Menus.cpp b/src/frontends/qt4/Menus.cpp index a808444642..adf17d2428 100644 --- a/src/frontends/qt4/Menus.cpp +++ b/src/frontends/qt4/Menus.cpp @@ -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: