]> git.lyx.org Git - lyx.git/blobdiff - src/insets/insetparent.C
fix #832
[lyx.git] / src / insets / insetparent.C
index d94d1227a42194c1e875ee8fb9ea995ec212190d..7f1097ba6f7560743f59e9dac0e52ca20c81c460 100644 (file)
@@ -1,59 +1,63 @@
-/* This file is part of*
- * ======================================================
+/**
+ * \file insetparent.C
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
  *
- *           LyX, The Document Processor
- *      
- *         Copyright (C) 1997-1998 LyX Team
- * 
- *======================================================*/
+ * \author Alejandro Aguilar Sierra
+ *
+ * Full author contact details are available in file CREDITS
+ */
 
 
 // Created by asierra 970813
 
 #include <config.h>
 
-
-#ifdef __GNUG__
-#pragma implementation
-#endif
-
 #include "insetparent.h"
-#include "support/filetools.h"
 #include "BufferView.h"
-#include "LyXView.h"
-#include "lyxfunc.h"
-#include "commandtags.h"
+#include "frontends/LyXView.h"
+#include "support/LOstream.h"
+#include "funcrequest.h"
+#include "buffer.h"
+#include "gettext.h"
 
+#include "support/filetools.h"
+#include "support/lstrings.h"
 
-extern BufferView *current_view;
+using std::ostream;
 
 
-InsetParent::InsetParent(string fn, Buffer* owner): InsetCommand("lyxparent")
+InsetParent::InsetParent(InsetCommandParams const & p, Buffer const & bf, bool)
+       : InsetCommand(p)
 {
-    if (owner)
-       setContents(MakeAbsPath(fn, OnlyPath(owner->getFileName())));
-    else
-       setContents(fn);
+       string const fn = p.getContents();
+       setContents(MakeAbsPath(fn, bf.filePath()));
 }
 
-void InsetParent::Edit(int, int)
-{    
-    current_view->getOwner()->getLyXFunc()->Dispatch(LFUN_CHILDOPEN, 
-                                                    getContents().c_str());
+
+string const InsetParent::getScreenLabel(Buffer const *) const
+{
+       return bformat(_("Parent: %1$s"), getContents());
 }
 
-// LaTeX must just ignore this command
-int InsetParent::Latex(FILE *file, signed char fragile)
+
+dispatch_result InsetParent::localDispatch(FuncRequest const & cmd)
 {
-    fprintf(file, "%%#{lyx}");
-    InsetCommand::Latex(file, fragile);
-    return 0;
+       switch (cmd.action) {
+               case LFUN_INSET_EDIT:
+                       cmd.view()->owner()->dispatch(FuncRequest(LFUN_CHILDOPEN, getContents()));
+                       return DISPATCHED;
+               default:
+                       return UNDISPATCHED;
+       }
 }
 
+
 // LaTeX must just ignore this command
-int InsetParent::Latex(string &file, signed char fragile)
+int InsetParent::latex(Buffer const * buf, ostream & os,
+                      bool fragile, bool free_spc) const
 {
-    file += "%%#{lyx}";
-    InsetCommand::Latex(file, fragile);
-    return 0;
+       os << "%%#{lyx}";
+       InsetCommand::latex(buf, os, fragile, free_spc);
+       return 0;
 }