]> git.lyx.org Git - features.git/commitdiff
First step toward fixing http://bugzilla.lyx.org/show_bug.cgi?id=3243
authorAbdelrazak Younes <younes@lyx.org>
Tue, 29 Jul 2008 07:53:08 +0000 (07:53 +0000)
committerAbdelrazak Younes <younes@lyx.org>
Tue, 29 Jul 2008 07:53:08 +0000 (07:53 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@25955 a592a061-630c-0410-9148-cb99ea01b6c8

src/BufferList.cpp
src/BufferList.h
src/LyXFunc.cpp
src/buffer_funcs.cpp

index 4512cae4abdd8e5fc521f3089f217b90425f8f12..7026cd8ea55c7a9beb177fe91183ce3bd69d18cf 100644 (file)
@@ -25,6 +25,7 @@
 #include "support/ExceptionMessage.h"
 #include "support/debug.h"
 #include "support/filetools.h"
+#include "support/FileName.h"
 #include "support/gettext.h"
 #include "support/lstrings.h"
 #include "support/Package.h"
@@ -273,8 +274,10 @@ docstring BufferList::emergencyWrite(Buffer * buf)
 }
 
 
-bool BufferList::exists(string const & s) const
+bool BufferList::exists(FileName const & fname) const
 {
+       //FIXME: use Buffer::fileName()!
+       string const s = fname.absFilename();
        return find_if(bstore.begin(), bstore.end(),
                       bind(equal_to<string>(),
                            bind(&Buffer::absFileName, _1),
index 1943c16ba3a5046e7f704e4bc86c8295c0a6ed2b..1f830f7d5a824b98389ca9d665c3e86d2d5337fc 100644 (file)
@@ -22,6 +22,10 @@ namespace lyx {
 class Buffer;
 class OutputParams;
 
+namespace support {
+class FileName;
+}
+
 /**
  * The class holds all all open buffers, and handles construction
  * and deletions of new ones.
@@ -79,7 +83,7 @@ public:
        Buffer * last();
 
        /// returns true if the buffer exists already
-       bool exists(std::string const &) const;
+       bool exists(support::FileName const &) const;
 
        /// returns true if the buffer is loaded
        bool isLoaded(Buffer const * b) const;
index f69f5f88826ff0803202e9d6c55137e3a02f8992..9269b6b48c46b914e5a58ce72e1d53d07ae216d9 100644 (file)
@@ -246,14 +246,14 @@ void LyXFunc::gotoBookmark(unsigned int idx, bool openFile, bool switchToBuffer)
        LASSERT(!bm.filename.empty(), /**/);
        string const file = bm.filename.absFilename();
        // if the file is not opened, open it.
-       if (!theBufferList().exists(file)) {
+       if (!theBufferList().exists(bm.filename)) {
                if (openFile)
                        dispatch(FuncRequest(LFUN_FILE_OPEN, file));
                else
                        return;
        }
        // open may fail, so we need to test it again
-       if (!theBufferList().exists(file))
+       if (!theBufferList().exists(bm.filename))
                return;
 
        // if the current buffer is not that one, switch to it.
@@ -1109,7 +1109,7 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
                                // and get full path
                                FileName const s = fileSearch(string(), changeExtension(file_name, ".lyx"), "lyx");
                                // Either change buffer or load the file
-                               if (theBufferList().exists(s.absFilename()))
+                               if (theBufferList().exists(s))
                                        buf = theBufferList().getBuffer(s.absFilename());
                                else {
                                        buf = lyx_view_->loadDocument(s);
@@ -1266,7 +1266,7 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
                        view()->saveBookmark(false);
                        Buffer * child = 0;
                        bool parsed = false;
-                       if (theBufferList().exists(filename.absFilename())) {
+                       if (theBufferList().exists(filename)) {
                                child = theBufferList().getBuffer(filename.absFilename());
                        } else {
                                setMessage(bformat(_("Opening child document %1$s..."),
index 0bf934c63c6f9fde0abb25c5ebd0af5c167b3482..21d9e1a9a00c38bf3d77877d8b397fbdbfacb9e6 100644 (file)
@@ -153,16 +153,15 @@ Buffer * newUnnamedFile(string const & templatename, FileName const & path)
 {
        static int newfile_number;
 
-       string document_path = path.absFilename();
-       string filename = addName(document_path,
+       FileName filename(path, 
                "newfile" + convert<string>(++newfile_number) + ".lyx");
        while (theBufferList().exists(filename)
-               || FileName(filename).isReadableFile()) {
+               || filename.isReadableFile()) {
                ++newfile_number;
-               filename = addName(document_path,
+               filename.set(path,
                        "newfile" +     convert<string>(newfile_number) + ".lyx");
        }
-       return newFile(filename, templatename, false);
+       return newFile(filename.absFilename(), templatename, false);
 }