]> git.lyx.org Git - features.git/commitdiff
Restore fix for #7517.
authorRichard Heck <rgheck@comcast.net>
Thu, 16 Jun 2011 14:22:43 +0000 (14:22 +0000)
committerRichard Heck <rgheck@comcast.net>
Thu, 16 Jun 2011 14:22:43 +0000 (14:22 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/branches/BRANCH_2_0_X@39090 a592a061-630c-0410-9148-cb99ea01b6c8

src/CutAndPaste.cpp
src/Text.cpp
src/TextClass.cpp
src/TextClass.h
status.20x

index 39b732fea6b2affdec2d3ab6d800c9b1bb010fe3..2bac66f8a6db2d2fe4d72f078fe13c20f6b10bbd 100644 (file)
@@ -647,13 +647,25 @@ void switchBetweenClasses(DocumentClass const * const oldone,
        DocumentClass const & newtc = *newone;
 
        // layouts
+       ParIterator it = par_iterator_begin(in);
        ParIterator end = par_iterator_end(in);
-       for (ParIterator it = par_iterator_begin(in); it != end; ++it) {
+       // for remembering which layouts we've had to add
+       set<docstring> newlayouts;
+       for (; it != end; ++it) {
                docstring const name = it->layout().name();
 
                // the pasted text will keep their own layout name. If this layout does
                // not exist in the new document, it will behave like a standard layout.
-               newtc.addLayoutIfNeeded(name);
+               bool const added_one = newtc.addLayoutIfNeeded(name);
+               if (added_one)
+                       newlayouts.insert(name);
+
+               if (added_one || newlayouts.find(name) != newlayouts.end()) {
+                       // Warn the user.
+                       docstring const s = bformat(_("Layout `%1$s' was not found."), name);
+                       errorlist.push_back(
+                               ErrorItem(_("Layout Not Found"), s, it->id(), 0, it->size()));
+               }
 
                if (in.usePlainLayout())
                        it->setLayout(newtc.plainLayout());
index 6cc6c520e677029b7638a68700d23b691c8b684e..7da48185c80f07bd0f2b9ffdc55f9daecf1fe7a4 100644 (file)
@@ -357,6 +357,14 @@ void Text::readParToken(Paragraph & par, Lexer & lex,
                // all unknown layouts such as frame will be added to document class article so that
                // these layouts can keep their original names.
                tclass.addLayoutIfNeeded(layoutname);
+               bool const added_one = tclass.addLayoutIfNeeded(layoutname);
+               if (added_one) {
+                       // Warn the user.
+                       docstring const s = bformat(_("Layout `%1$s' was not found."), layoutname);
+                       errorList.push_back(
+                               ErrorItem(_("Layout Not Found"), s, par.id(), 0, par.size()));
+               }
+
                par.setLayout(bp.documentClass()[layoutname]);
 
                // Test whether the layout is obsolete.
index 00558d586247ad870eda3fd58dae36306d4c04f6..c9cbcae5e0578f62b1326b69d3dae93383569c28 100644 (file)
@@ -1199,10 +1199,13 @@ bool TextClass::load(string const & path) const
 }
 
 
-void DocumentClass::addLayoutIfNeeded(docstring const & n) const
+bool DocumentClass::addLayoutIfNeeded(docstring const & n) const
 {
-       if (!hasLayout(n))
-               layoutlist_.push_back(createBasicLayout(n, true));
+       if (hasLayout(n))
+               return false;
+
+       layoutlist_.push_back(createBasicLayout(n, true));
+       return true;
 }
 
 
index f3d2197278b4617562ceea27195ef2acd25a94fd..6e20650cc23eec130731ecf5d7461f93e0bdc8cf 100644 (file)
@@ -373,7 +373,8 @@ public:
        /// a plain inset layout for use as a default
        static InsetLayout const & plainInsetLayout() { return plain_insetlayout_; }
        /// add a new layout \c name if it does not exist in layoutlist_
-       void addLayoutIfNeeded(docstring const & name) const;
+       /// \return whether we had to add one.
+       bool addLayoutIfNeeded(docstring const & name) const;
 
        ///////////////////////////////////////////////////////////////////
        // accessors
index b55983e1e77ed84cc8ef219e3c4e7b88fc219cb4..08f77642f4117e5f523e4440692496f27195d920 100644 (file)
@@ -83,6 +83,8 @@ What's new
 
 - Fix output of decimally aligned columns in unviewed (on screen) tables.
 
+- Inform user of unknown layouts caused by class change (bug 7571).
+
 - Avoid LaTeX errors if font changing commands are used in the wrong mode
   by assuring to switch to the right mode on export.