]> git.lyx.org Git - lyx.git/commitdiff
* src/format.[Ch]
authorGeorg Baum <Georg.Baum@post.rwth-aachen.de>
Sat, 20 May 2006 12:03:40 +0000 (12:03 +0000)
committerGeorg Baum <Georg.Baum@post.rwth-aachen.de>
Sat, 20 May 2006 12:03:40 +0000 (12:03 +0000)
(document_): new flag, telling whether this is a document format and
we want to show this format in the export and view menus
(documentFormat): accessor for document_

* src/format.h: Add some documentation

* src/frontends/qt3/QPrefsDialog.C
(QPrefsDialog::QPrefsDialog): handle new documentCB checkbox
(QPrefsDialog::switch_format): ditto
(QPrefsDialog::updateFormatsButtons): ditto
(QPrefsDialog::new_format): ditto
(QPrefsDialog::modify_format): ditto

* src/frontends/qt3/ui/QPrefFileformatsModule.ui: Add documentCB checkbox

* src/frontends/qt4/QPrefsDialog.C
(QPrefsDialog::QPrefsDialog): handle new documentCB checkbox
(QPrefsDialog::switch_format): ditto
(QPrefsDialog::updateFormatsButtons): ditto
(QPrefsDialog::new_format): ditto
(QPrefsDialog::modify_format): ditto

* src/frontends/qt4/ui/QPrefFileformatsUi.ui: Add documentCB checkbox

* src/frontends/xforms/FormPreferences.C
(FormPreferences::Formats::build): handle new check_document checkbox
(FormPreferences::Formats::input): ditto
(FormPreferences::Formats::Add): ditto
(FormPreferences::Formats::Browser): ditto

* src/frontends/xforms/forms/form_preferences.fd: Add check_document
checkbox

* src/lyxrc.C
(LyXRC::read): Remove compatibility code for 1.3 \format entries.
Read the new format flags (but don't require them for 1.4
compatibility)
(LyXRC::write): Write the new format flags

* src/MenuBackend.C
(expandFormats): Remove the hardcoded exception for image formats
and use Format::isDocument() instead

* lib/doc/Customization.lyx: Document auto viever/editor and the
"document format" flag

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@13887 a592a061-630c-0410-9148-cb99ea01b6c8

12 files changed:
lib/configure.py
lib/doc/Customization.lyx
src/MenuBackend.C
src/format.C
src/format.h
src/frontends/qt3/QPrefsDialog.C
src/frontends/qt3/ui/QPrefFileformatsModule.ui
src/frontends/qt4/QPrefsDialog.C
src/frontends/qt4/ui/QPrefFileformatsUi.ui
src/frontends/xforms/FormPreferences.C
src/frontends/xforms/forms/form_preferences.fd
src/lyxrc.C

index fe7f8abc1e847a8450e3df95324639c838423dce..bdcde5ae7824ff778fdc2735ba1cd6f3279a2e25 100644 (file)
@@ -194,76 +194,76 @@ def checkLatex():
 def checkFormatEntries():  
   ''' Check all formats (\Format entries) '''
   checkProg('a Tgif viewer and editor', ['tgif'],
-    rc_entry = [ r'\Format tgif       obj     Tgif                   "" "%%"   "%%"'])
+    rc_entry = [ r'\Format tgif       obj     Tgif                   "" "%%"   "%%"    ""'])
   #
   checkProg('a FIG viewer and editor', ['xfig'],
-    rc_entry = [ r'\Format fig        fig     FIG                    "" "%%"   "%%"'] )
+    rc_entry = [ r'\Format fig        fig     FIG                    "" "%%"   "%%"    ""'] )
   #
   checkProg('a Grace viewer and editor', ['xmgrace'],
-    rc_entry = [ r'\Format agr        agr     Grace                  "" "%%"   "%%"'] )
+    rc_entry = [ r'\Format agr        agr     Grace                  "" "%%"   "%%"    ""'] )
   #
   checkProg('a FEN viewer and editor', ['xboard -lpf $$i -mode EditPosition'],
-    rc_entry = [ r'\Format fen        fen     FEN                    "" "%%"   "%%"' ])
+    rc_entry = [ r'\Format fen        fen     FEN                    "" "%%"   "%%"    ""' ])
   #
   path, iv = checkProg('a raster image viewer', ['xv', 'kview', 'gimp'])
   path, ie = checkProg('a raster image editor', ['gimp'])
-  addToRC(r'''\Format bmp        bmp     BMP                    "" "%s"        "%s"
-\Format gif        gif     GIF                    "" "%s"      "%s"
-\Format jpg        jpg     JPEG                   "" "%s"      "%s"
-\Format pbm        pbm     PBM                    "" "%s"      "%s"
-\Format pgm        pgm     PGM                    "" "%s"      "%s"
-\Format png        png     PNG                    "" "%s"      "%s"
-\Format ppm        ppm     PPM                    "" "%s"      "%s"
-\Format tiff       tif     TIFF                   "" "%s"      "%s"
-\Format xbm        xbm     XBM                    "" "%s"      "%s"
-\Format xpm        xpm     XPM                    "" "%s"      "%s"''' % \
+  addToRC(r'''\Format bmp        bmp     BMP                    "" "%s"        "%s"    ""
+\Format gif        gif     GIF                    "" "%s"      "%s"    ""
+\Format jpg        jpg     JPEG                   "" "%s"      "%s"    ""
+\Format pbm        pbm     PBM                    "" "%s"      "%s"    ""
+\Format pgm        pgm     PGM                    "" "%s"      "%s"    ""
+\Format png        png     PNG                    "" "%s"      "%s"    ""
+\Format ppm        ppm     PPM                    "" "%s"      "%s"    ""
+\Format tiff       tif     TIFF                   "" "%s"      "%s"    ""
+\Format xbm        xbm     XBM                    "" "%s"      "%s"    ""
+\Format xpm        xpm     XPM                    "" "%s"      "%s"    ""''' % \
     (iv, ie, iv, ie, iv, ie, iv, ie, iv, ie, iv, ie, iv, ie, iv, ie, iv, ie, iv, ie) )
   #
   checkProg('a text editor', ['xemacs', 'gvim', 'kedit', 'kwrite', 'kate', \
     'nedit', 'gedit', 'notepad'],
-    rc_entry = [ r'''\Format asciichess asc    "Plain text (chess output)"  "" ""      "%%"
-\Format asciiimage asc    "Plain text (image)"         "" ""   "%%"
-\Format asciixfig  asc    "Plain text (Xfig output)"   "" ""   "%%"
-\Format dateout    tmp    "date (output)"         "" ""        "%%"
-\Format docbook    sgml    DocBook                B  ""        "%%"
-\Format docbook-xml xml   "Docbook (XML)"         "" ""        "%%"
-\Format literate   nw      NoWeb                  N  ""        "%%"
-\Format latex      tex    "LaTeX (plain)"         L  ""        "%%"
-\Format linuxdoc   sgml    LinuxDoc               x  ""        "%%"
-\Format pdflatex   tex    "LaTeX (pdflatex)"      "" ""        "%%"
-\Format text       txt    "Plain text"            a  ""        "%%"
-\Format textparagraph txt "Plain text (paragraphs)"    "" ""   "%%"''' ])
+    rc_entry = [ r'''\Format asciichess asc    "Plain text (chess output)"  "" ""      "%%"    ""
+\Format asciiimage asc    "Plain text (image)"         "" ""   "%%"    ""
+\Format asciixfig  asc    "Plain text (Xfig output)"   "" ""   "%%"    ""
+\Format dateout    tmp    "date (output)"         "" ""        "%%"    ""
+\Format docbook    sgml    DocBook                B  ""        "%%"    "document"
+\Format docbook-xml xml   "Docbook (XML)"         "" ""        "%%"    "document"
+\Format literate   nw      NoWeb                  N  ""        "%%"    "document"
+\Format latex      tex    "LaTeX (plain)"         L  ""        "%%"    "document"
+\Format linuxdoc   sgml    LinuxDoc               x  ""        "%%"    "document"
+\Format pdflatex   tex    "LaTeX (pdflatex)"      "" ""        "%%"    "document"
+\Format text       txt    "Plain text"            a  ""        "%%"    "document"
+\Format textparagraph txt "Plain text (paragraphs)"    "" ""   "%%"    "document"''' ])
   #
   #checkProg('a Postscript interpreter', ['gs'],
   #  rc_entry = [ r'\ps_command "%%"' ])
   checkProg('a Postscript previewer', ['gv', 'ghostview -swap', 'kghostview'],
-    rc_entry = [ r'''\Format eps        eps     EPS                    "" "%%" ""
-\Format ps         ps      Postscript             t  "%%"      ""''' ])
+    rc_entry = [ r'''\Format eps        eps     EPS                    "" "%%" ""      ""
+\Format ps         ps      Postscript             t  "%%"      ""      "document"''' ])
   #
   checkProg('a PDF previewer', ['acrobat', 'acroread', 'gv', 'ghostview', \
               'xpdf', 'kpdf', 'kghostview'],
-    rc_entry = [ r'''\Format pdf        pdf    "PDF (ps2pdf)"          P  "%%" ""
-\Format pdf2       pdf    "PDF (pdflatex)"        F  "%%"      ""
-\Format pdf3       pdf    "PDF (dvipdfm)"         m  "%%"      ""''' ])
+    rc_entry = [ r'''\Format pdf        pdf    "PDF (ps2pdf)"          P  "%%" ""      "document"
+\Format pdf2       pdf    "PDF (pdflatex)"        F  "%%"      ""      "document"
+\Format pdf3       pdf    "PDF (dvipdfm)"         m  "%%"      ""      "document"''' ])
   #
   checkProg('a DVI previewer', ['xdvi', 'kdvi'],
-    rc_entry = [ r'\Format dvi        dvi     DVI                    D  "%%"   ""' ])
+    rc_entry = [ r'\Format dvi        dvi     DVI                    D  "%%"   ""      "document"' ])
   #
   checkProg('a HTML previewer', ['mozilla file://$$p$$i', 'netscape'],
-    rc_entry = [ r'\Format html       html    HTML                   H  "%%"   ""' ])
+    rc_entry = [ r'\Format html       html    HTML                   H  "%%"   ""      "document"' ])
   #
   # entried that do not need checkProg
-  addToRC(r'''\Format date       ""     "date command"          "" ""  ""
-\Format fax        ""      Fax                    "" ""        ""
-\Format lyx        lyx     LyX                    "" ""        ""
-\Format lyx13x     lyx13  "LyX 1.3.x"             "" ""        ""
-\Format lyxpreview lyxpreview "LyX Preview"       "" ""        ""
-\Format pdftex     pdftex_t PDFTEX                "" ""        ""
-\Format program    ""      Program                "" ""        ""
-\Format pstex      pstex_t PSTEX                  "" ""        ""
-\Format sxw        sxw    "OpenOffice.Org Writer" O  ""        ""
-\Format word       doc    "MS Word"               W  ""        ""
-\Format wordhtml   html   "MS Word (HTML)"        "" ""        ""
+  addToRC(r'''\Format date       ""     "date command"          "" ""  ""      ""
+\Format fax        ""      Fax                    "" ""        ""      "document"
+\Format lyx        lyx     LyX                    "" ""        ""      ""
+\Format lyx13x     lyx13  "LyX 1.3.x"             "" ""        ""      "document"
+\Format lyxpreview lyxpreview "LyX Preview"       "" ""        ""      ""
+\Format pdftex     pdftex_t PDFTEX                "" ""        ""      ""
+\Format program    ""      Program                "" ""        ""      ""
+\Format pstex      pstex_t PSTEX                  "" ""        ""      ""
+\Format sxw        sxw    "OpenOffice.Org Writer" O  ""        ""      "document"
+\Format word       doc    "MS Word"               W  ""        ""      "document"
+\Format wordhtml   html   "MS Word (HTML)"        "" ""        ""      "document"
 ''')
 
 
index 88668dcd162b4be7529cfb63891064840cc5ef6c..c674197fd47d44a4d0f769db6809a734ead6eb10 100644 (file)
@@ -1,4 +1,4 @@
-#LyX 1.4.0svn created this file. For more info see http://www.lyx.org/
+#LyX 1.5.0svn created this file. For more info see http://www.lyx.org/
 \lyxformat 245
 \begin_document
 \begin_header
@@ -1846,6 +1846,45 @@ For example, the file may reference other files with relative filenames,
  directory and may modify it in the process.
 \end_layout
 
+\begin_layout Standard
+With the checkbox 
+\family sans
+Document Format
+\family default
+ you can choose whether the format is a document format or not.
+ The difference between document and non--document formats is that you can
+ export your LyX document only to document formats.
+ Non--document formats are used for included graphics.
+ Examples for document formats are 
+\family typewriter
+dvi
+\family default
+ or 
+\family typewriter
+ps.
+\family default
+Examples for non--document formats are 
+\family typewriter
+png
+\family default
+ or 
+\family typewriter
+jpeg
+\family default
+.
+ Some formats like 
+\family typewriter
+pdf
+\family default
+ are both document formats and non--document formats.
+ The checkbox 
+\family sans
+Document Format
+\family default
+ should be checked for these formats.
+\end_layout
+
 \begin_layout Section
 BibTeX and makeindex
 \end_layout
@@ -2902,6 +2941,7 @@ status inlined
 
 \begin_layout Standard
 
+
 \backslash
 begin{sloppypar}
 \end_layout
@@ -3047,6 +3087,7 @@ status inlined
 
 \begin_layout Standard
 
+
 \backslash
 end{sloppypar}
 \end_layout
@@ -3474,6 +3515,7 @@ status inlined
 
 \begin_layout Standard
 
+
 \backslash
 b o
 \end_layout
@@ -3498,6 +3540,7 @@ status inlined
 
 \begin_layout Standard
 
+
 \backslash
 d o
 \end_layout
@@ -3530,6 +3573,7 @@ status inlined
 
 \begin_layout Standard
 
+
 \backslash
 t o
 \end_layout
@@ -3549,6 +3593,7 @@ status inlined
 
 \begin_layout Standard
 
+
 \backslash
 u o
 \end_layout
@@ -3591,6 +3636,7 @@ status inlined
 
 \begin_layout Standard
 
+
 \backslash
 .s
 \end_layout
@@ -5507,6 +5553,7 @@ status inlined
 
 \begin_layout Standard
 
+
 \backslash
 begin{sloppypar}
 \end_layout
@@ -5998,6 +6045,7 @@ status inlined
 
 \begin_layout Standard
 
+
 \backslash
 end{sloppypar}
 \end_layout
@@ -6148,6 +6196,7 @@ status inlined
 
 \begin_layout Standard
 
+
 \backslash
 begin{sloppypar}
 \end_layout
@@ -7442,6 +7491,7 @@ status inlined
 
 \begin_layout Standard
 
+
 \backslash
 end{sloppypar}
 \end_layout
index 3c334aadf1529a85955195797285ebac9b82c1e5..13c2e18f791126e38bf60e85dee0484682b549f9 100644 (file)
@@ -504,23 +504,22 @@ void expandFormats(MenuItem::Kind kind, Menu & tomenu, LyXView const * view)
                if ((*fit)->dummy())
                        continue;
                string label = (*fit)->prettyname();
-               // we need to hide the default graphic export formats
-               // from the external menu, because we need them only
-               // for the internal lyx-view and external latex run
-               if (label == "EPS" || label == "XPM" || label == "PNG")
-                       continue;
 
-               if (kind == MenuItem::ImportFormats) {
+               switch (kind) {
+               case MenuItem::ImportFormats:
                        if ((*fit)->name() == "text")
                                label = _("Plain Text as Lines");
                        else if ((*fit)->name() == "textparagraph")
                                label = _("Plain Text as Paragraphs");
                        label += "...";
-               } else if (kind == MenuItem::ExportFormats) {
-                       // exporting to LyX does not make sense
-                       // FIXME: Introduce noexport flag
-                       if ((*fit)->name() == "lyx")
+                       break;
+               case MenuItem::ViewFormats:
+               case MenuItem::ExportFormats:
+                       if (!(*fit)->documentFormat())
                                continue;
+                       break;
+               case MenuItem::UpdateFormats:
+                       break;
                }
                if (!(*fit)->shortcut().empty())
                        label += '|' + (*fit)->shortcut();
index e51358df6dafb42da824ce405b231c1a1c952a57..3cb3926f78d1cae0fe25a8846b7952e5caeea3ea 100644 (file)
@@ -92,9 +92,12 @@ bool operator<(Format const & a, Format const & b)
        return compare_ascii_no_case(a.prettyname(), b.prettyname()) < 0;
 }
 
+
 Format::Format(string const & n, string const & e, string const & p,
-              string const & s, string const & v, string const & ed)
-       : name_(n), extension_(e), prettyname_(p), shortcut_(s), viewer_(v), editor_(ed)
+              string const & s, string const & v, string const & ed,
+               bool d)
+       : name_(n), extension_(e), prettyname_(p), shortcut_(s), viewer_(v),
+         editor_(ed), document_(d)
 {}
 
 
@@ -208,22 +211,24 @@ int Formats::getNumber(string const & name) const
 void Formats::add(string const & name)
 {
        if (!getFormat(name))
-               add(name, name, name, string(), string(), string());
+               add(name, name, name, string(), string(), string(), true);
 }
 
 
 void Formats::add(string const & name, string const & extension,
                  string const & prettyname, string const & shortcut,
-                 string const & viewer, string const & editor)
+                 string const & viewer, string const & editor, bool document)
 {
        FormatList::iterator it =
                find_if(formatlist.begin(), formatlist.end(),
                        FormatNamesEqual(name));
        if (it == formatlist.end())
                formatlist.push_back(Format(name, extension, prettyname,
-                                           shortcut, viewer, editor));
+                                           shortcut, viewer, editor,
+                                           document));
        else
-               *it = Format(name, extension, prettyname, shortcut, viewer, editor);
+               *it = Format(name, extension, prettyname, shortcut, viewer,
+                            editor, document);
 }
 
 
index 85ad850de2dd9cc93930a6c86f6a76b201331b1e..1b025a60e8281d68dbfaf9e2c3c51954607534db 100644 (file)
@@ -21,12 +21,14 @@ class Format {
 public:
        ///
        Format(std::string const & n, std::string const & e, std::string const & p,
-              std::string const & s, std::string const & v, std::string const & ed);
+              std::string const & s, std::string const & v, std::string const & ed,
+              bool ex);
        ///
        bool dummy() const;
-       ///
+       /// Tell whether this format is a child format.
+       /// Child formats inherit settings like the viewer from their parent.
        bool isChildFormat() const;
-       ///
+       /// Name fo the parent format
        std::string const parentFormat() const;
        ///
        std::string const & name() const {
@@ -60,18 +62,32 @@ public:
        void setEditor(std::string const & v) {
                editor_ = v;
        }
+       ///
+       bool documentFormat() const {
+               return document_;
+       }
 private:
+       /// Internal name. Needs to be unique.
        std::string name_;
-       ///
+       /// Filename extension
        std::string extension_;
-       ///
+       /// Name presented to the user. Needs to be unique.
        std::string prettyname_;
-       ///
+       /// Keyboard shortcut for the View and Export menu.
        std::string shortcut_;
-       ///
+       /*!
+        * Viewer for this format. Needs to be in the PATH or an absolute
+        * filename.
+        * This format cannot be viewed if \c viewer_ is empty.
+        * If it is \c auto the default viewer of the OS for this format is
+        * used.
+        */
        std::string viewer_;
-       ///
+       /// Editor for this format. \sa viewer_.
        std::string editor_;
+       /// Is this format a document format? (as opposed to e.g. image formats)
+       /// Some formats are both (e.g. pdf), they have this flag set.
+       bool document_;
 };
 
 
@@ -106,8 +122,9 @@ public:
        void add(std::string const & name);
        ///
        void add(std::string const & name, std::string const & extension,
-                std::string const & prettyname, std::string const & shortcut,
-                std::string const & viewer, std::string const & editor);
+                std::string const & prettyname, std::string const & shortcut,
+                std::string const & viewer, std::string const & editor,
+                bool document);
        ///
        void erase(std::string const & name);
        ///
index 5393eb8a5f6fbb1aea4c315680ecb213d8482479..f17dfb3f05e23dfc5d8ac72eec2e0102c5880beb 100644 (file)
@@ -187,6 +187,7 @@ QPrefsDialog::QPrefsDialog(QPrefs * form)
        connect(fileformatsModule->extensionED, SIGNAL(textChanged(const QString&)), this, SLOT(fileformat_changed()));
        connect(fileformatsModule->viewerED, SIGNAL(textChanged(const QString&)), this, SLOT(fileformat_changed()));
        connect(fileformatsModule->editorED, SIGNAL(textChanged(const QString&)), this, SLOT(fileformat_changed()));
+       connect(fileformatsModule->documentCB, SIGNAL(toggled(bool)), this, SLOT(fileformat_changed()));
 
        connect(convertersModule->converterNewPB, SIGNAL(clicked()), this, SLOT(new_converter()));
        connect(convertersModule->converterRemovePB, SIGNAL(clicked()), this, SLOT(remove_converter()));
@@ -729,6 +730,7 @@ void QPrefsDialog::switch_format(int nr)
        fileformatsModule->shortcutED->setText(toqstr(f.shortcut()));
        fileformatsModule->viewerED->setText(toqstr(f.viewer()));
        fileformatsModule->editorED->setText(toqstr(f.editor()));
+       fileformatsModule->documentCB->setChecked(f.documentFormat());
        fileformatsModule->formatRemovePB->setEnabled(
                !form_->converters().formatIsUsed(f.name()));
 
@@ -770,16 +772,18 @@ void QPrefsDialog::updateFormatsButtons()
        string const old_extension(f.extension());
        string const old_viewer(f.viewer());
        string const old_editor(f.editor());
+       bool const old_document(f.documentFormat());
 
        string const new_pretty(fromqstr(gui_name));
        string const new_shortcut(fromqstr(fileformatsModule->shortcutED->text()));
        string const new_extension(fromqstr(fileformatsModule->extensionED->text()));
        string const new_viewer(fromqstr(fileformatsModule->viewerED->text()));
        string const new_editor(fromqstr(fileformatsModule->editorED->text()));
+       bool const new_document(fileformatsModule->documentCB->isChecked());
 
        bool modified = ((old_pretty != new_pretty) || (old_shortcut != new_shortcut)
                || (old_extension != new_extension) || (old_viewer != new_viewer)
-               || (old_editor != new_editor));
+               || (old_editor != new_editor)) || old_document != new_document;
 
        fileformatsModule->formatModifyPB->setEnabled(
                valid && known && modified && !known_otherwise);
@@ -796,8 +800,10 @@ void QPrefsDialog::new_format()
        string const shortcut = fromqstr(fileformatsModule->shortcutED->text());
        string const viewer = fromqstr(fileformatsModule->viewerED->text());
        string const editor = fromqstr(fileformatsModule->editorED->text());
+       bool const document = fileformatsModule->documentCB->isChecked();
 
-       form_->formats().add(name, extension, prettyname, shortcut, viewer, editor);
+       form_->formats().add(name, extension, prettyname, shortcut, viewer,
+                            editor, document);
        form_->formats().sort();
        updateFormats();
        fileformatsModule->formatsLB->setCurrentItem(form_->formats().getNumber(name));
@@ -825,8 +831,10 @@ void QPrefsDialog::modify_format()
        string const shortcut = fromqstr(fileformatsModule->shortcutED->text());
        string const viewer = fromqstr(fileformatsModule->viewerED->text());
        string const editor = fromqstr(fileformatsModule->editorED->text());
+       bool const document = fileformatsModule->documentCB->isChecked();
 
-       form_->formats().add(name, extension, prettyname, shortcut, viewer, editor);
+       form_->formats().add(name, extension, prettyname, shortcut, viewer,
+                            editor, document);
        form_->formats().sort();
 
        fileformatsModule->formatsLB->setUpdatesEnabled(false);
index a812962ffdd04d0c8da16c3c70cbb653833ef1e3..3e3216be8e2ca33e90a8625197ed7b488f005371 100644 (file)
@@ -9,7 +9,7 @@
             <x>0</x>
             <y>0</y>
             <width>419</width>
-            <height>261</height>
+            <height>286</height>
         </rect>
     </property>
     <property name="caption">
                         <cstring>editorED</cstring>
                     </property>
                 </widget>
+                <widget class="QCheckBox" row="6" column="1">
+                    <property name="name">
+                        <cstring>documentCB</cstring>
+                    </property>
+                    <property name="text">
+                        <string>&amp;Document format</string>
+                    </property>
+                    <property name="accel">
+                        <string>Alt+D</string>
+                    </property>
+                    <property name="toolTip" stdset="0">
+                        <string>Tell whether this format is a document format. A document can not be exported to or viewed in a non-document format.</string>
+                    </property>
+                </widget>
                 <widget class="QLineEdit" row="2" column="1">
                     <property name="name">
                         <cstring>shortcutED</cstring>
     <tabstop>extensionED</tabstop>
     <tabstop>viewerED</tabstop>
     <tabstop>editorED</tabstop>
+    <tabstop>documentCB</tabstop>
 </tabstops>
 <includes>
     <include location="global" impldecl="in implementation">config.h</include>
index dbba8dce80d247b345ae797eb67868a2e8cb01a0..01bb4ad5f6c8caa24f7d3ab5325e02c8696c1b2e 100644 (file)
@@ -1291,6 +1291,7 @@ PrefFileformats::PrefFileformats(QPrefs * form, QWidget * parent)
        connect(extensionED, SIGNAL(textChanged(const QString&)), this, SLOT(fileformat_changed()));
        connect(viewerED, SIGNAL(textChanged(const QString&)), this, SLOT(fileformat_changed()));
        connect(editorED, SIGNAL(textChanged(const QString&)), this, SLOT(fileformat_changed()));
+       connect(documentCB, SIGNAL(toggled(bool)), this, SLOT(fileformat_changed()));
        connect(formatNewPB, SIGNAL(clicked()),
                this, SIGNAL(changed()));
        connect(formatRemovePB, SIGNAL(clicked()),
@@ -1353,6 +1354,7 @@ void PrefFileformats::switch_format(int nr)
        shortcutED->setText(toqstr(f.shortcut()));
        viewerED->setText(toqstr(f.viewer()));
        editorED->setText(toqstr(f.editor()));
+       documentCB->setChecked((f.documentFormat()));
        formatRemovePB->setEnabled(
                !form_->converters().formatIsUsed(f.name()));
 
@@ -1394,16 +1396,18 @@ void PrefFileformats::updateButtons()
        string const old_extension(f.extension());
        string const old_viewer(f.viewer());
        string const old_editor(f.editor());
+       bool const old_document(f.documentFormat());
 
        string const new_pretty(fromqstr(gui_name));
        string const new_shortcut(fromqstr(shortcutED->text()));
        string const new_extension(fromqstr(extensionED->text()));
        string const new_viewer(fromqstr(viewerED->text()));
        string const new_editor(fromqstr(editorED->text()));
+       bool const new_document(documentCB->isChecked());
 
        bool modified = ((old_pretty != new_pretty) || (old_shortcut != new_shortcut)
                || (old_extension != new_extension) || (old_viewer != new_viewer)
-               || (old_editor != new_editor));
+               || (old_editor != new_editor) || old_document != new_document);
 
        formatModifyPB->setEnabled(
                valid && known && modified && !known_otherwise);
@@ -1424,8 +1428,10 @@ void PrefFileformats::new_format()
        string const shortcut = fromqstr(shortcutED->text());
        string const viewer = fromqstr(viewerED->text());
        string const editor = fromqstr(editorED->text());
+       bool const document = documentCB->isChecked();
 
-       form_->formats().add(name, extension, prettyname, shortcut, viewer, editor);
+       form_->formats().add(name, extension, prettyname, shortcut, viewer,
+                            editor, document);
        form_->formats().sort();
        update();
 
@@ -1457,8 +1463,10 @@ void PrefFileformats::modify_format()
        string const shortcut = fromqstr(shortcutED->text());
        string const viewer = fromqstr(viewerED->text());
        string const editor = fromqstr(editorED->text());
+       bool const document = documentCB->isChecked();
 
-       form_->formats().add(name, extension, prettyname, shortcut, viewer, editor);
+       form_->formats().add(name, extension, prettyname, shortcut, viewer,
+                            editor, document);
        form_->formats().sort();
 
        formatsLW->setUpdatesEnabled(false);
index df44ed98140eed1bf8326fcbec01cc31e1e6e692..5781a1d3a089474d74cf577696b1f008e08f6e9c 100644 (file)
      <item row="3" column="1" >
       <widget class="QLineEdit" name="extensionED" />
      </item>
+     <item row="6" column="0" >
+      <widget class="QCheckBox" name="documentCB" >
+       <property name="enabled" >
+        <bool>true</bool>
+       </property>
+       <property name="toolTip" >
+        <string>Tell whether this format is a document format. A document can not be exported to or viewed in a non-document format.</string>
+       </property>
+       <property name="text" >
+        <string>&amp;Document format</string>
+       </property>
+      </widget>
+     </item>
     </layout>
    </item>
    <item row="4" column="0" >
   <tabstop>extensionED</tabstop>
   <tabstop>viewerED</tabstop>
   <tabstop>editorED</tabstop>
+  <tabstop>documentCB</tabstop>
  </tabstops>
  <resources/>
  <connections/>
index 3cc85e50507d406a3b8f33fa7a1ab200317c3760..14f0c4b0a7d35f3144ab2489d4c3a7d2bd16b1b2 100644 (file)
@@ -1313,6 +1313,7 @@ void FormPreferences::Formats::build()
        setPrehandler(dialog_->input_viewer);
        setPrehandler(dialog_->input_editor);
        setPrehandler(dialog_->input_shrtcut);
+       setPrehandler(dialog_->check_document);
 }
 
 
@@ -1345,6 +1346,10 @@ FormPreferences::Formats::feedback(FL_OBJECT const * const ob) const
                return  _("Remove the current format from the list of available "
                          "formats. Note: you must then \"Apply\" the change.");
 
+       if (ob == dialog_->check_document)
+               return  _("Tell whether this format is a document format. "
+                         "A document can not be exported to or viewed in a non-document format.");
+
        if (ob == dialog_->button_add) {
                if (string(ob->label) == _("Add"))
                        return  _("Add the current format to the list of available "
@@ -1368,7 +1373,8 @@ bool FormPreferences::Formats::input(FL_OBJECT const * const ob)
            || ob == dialog_->input_shrtcut
            || ob == dialog_->input_extension
            || ob == dialog_->input_viewer
-           || ob == dialog_->input_editor)
+           || ob == dialog_->input_editor
+           || ob == dialog_->check_document)
                return Input();
 
        if (ob == dialog_->button_add)
@@ -1416,10 +1422,12 @@ bool FormPreferences::Formats::Add()
        string const shortcut =  getString(dialog_->input_shrtcut);
        string const viewer =  getString(dialog_->input_viewer);
        string const editor =  getString(dialog_->input_editor);
+       bool const document = fl_get_button(dialog_->check_document);
 
        Format const * old = formats().getFormat(name);
        string const old_prettyname = old ? old->prettyname() : string();
-       formats().add(name, extension, prettyname, shortcut, viewer, editor);
+       formats().add(name, extension, prettyname, shortcut, viewer, editor,
+                     document);
        if (!old || prettyname != old_prettyname) {
                UpdateBrowser();
                if (old)
@@ -1447,6 +1455,7 @@ bool FormPreferences::Formats::Browser()
        fl_set_input(dialog_->input_extension, f.extension().c_str());
        fl_set_input(dialog_->input_viewer, f.viewer().c_str());
        fl_set_input(dialog_->input_editor, f.editor().c_str());
+       fl_set_button(dialog_->check_document, f.documentFormat());
 
        fl_set_object_label(dialog_->button_add,
                            idex(_("Modify|#M")).c_str());
index 21a48de2dc54a0b4f3c9ce3ca887497f3f4f8367..2a29ce3aabbb96c7248249ec96fd8274deb8cd00 100644 (file)
@@ -1704,8 +1704,8 @@ argument:
 =============== FORM ===============
 Name: form_preferences_formats
 Width: 450
-Height: 400
-Number of Objects: 10
+Height: 440
+Number of Objects: 11
 
 --------------------
 class: FL_BOX
@@ -1851,10 +1851,28 @@ name: input_editor
 callback: C_FormDialogView_InputCB
 argument: 0
 
+--------------------
+class: FL_CHECKBUTTON
+type: PUSH_BUTTON
+box: 200 270 150 30
+boxtype: FL_NO_BOX
+colors: FL_COL1 FL_YELLOW
+alignment: FL_ALIGN_CENTER
+style: FL_NORMAL_STYLE
+size: FL_NORMAL_SIZE
+lcol: FL_BLACK
+label: Document format|#D
+shortcut:
+resize: FL_RESIZE_NONE
+gravity: FL_West FL_West
+name: check_document
+callback: C_FormDialogView_InputCB
+argument: 0
+
 --------------------
 class: FL_BUTTON
 type: NORMAL_BUTTON
-box: 240 300 90 30
+box: 240 340 90 30
 boxtype: FL_UP_BOX
 colors: FL_COL1 FL_COL1
 alignment: FL_ALIGN_CENTER
@@ -1872,7 +1890,7 @@ argument: 0
 --------------------
 class: FL_BUTTON
 type: NORMAL_BUTTON
-box: 340 300 90 30
+box: 340 340 90 30
 boxtype: FL_UP_BOX
 colors: FL_COL1 FL_COL1
 alignment: FL_ALIGN_CENTER
index 4263802a9a1afe705a15c4752b65301ccc8d733b..3b7a3d408a305822c658941f65d856eabaee6d72 100644 (file)
@@ -48,6 +48,7 @@ using lyx::support::expandPath;
 using lyx::support::getEnv;
 using lyx::support::libFileSearch;
 using lyx::support::token;
+using lyx::support::tokenPos;
 
 using std::cout;
 using std::endl;
@@ -1086,24 +1087,35 @@ int LyXRC::read(LyXLex & lexrc)
                                shortcut = lexrc.getString();
                        }
                        string viewer, editor;
+                       if (lexrc.next())
+                               viewer = lexrc.getString();
+                       if (lexrc.next())
+                               editor = lexrc.getString();
+                       // The only supported flag for now is "document".
+                       // More flags could be added in the future.
+                       // Therefore we use tokenPos below to read the flag.
+                       string flags;
                        // Hack to ensure compatibility with versions older
-                       // than 1.4.0
+                       // than 1.5.0
                        int le = lexrc.lex();
                        if (le != LyXLex::LEX_FEOF && le != LyXLex::LEX_UNDEF) {
-                               viewer = lexrc.getString();
-                               if (le == LyXLex::LEX_DATA) {
-                                       if (lexrc.next()) {
-                                               editor = lexrc.getString();
-                                       }
-                               } else {
+                               flags = lexrc.getString();
+                               if (le != LyXLex::LEX_DATA) {
                                        // We have got a known token.
                                        // Therefore this is an old style
                                        // format definition without
-                                       // viewer and editor.
-                                       lexrc.pushToken(viewer);
-                                       viewer.erase();
+                                       // flags.
+                                       lexrc.pushToken(flags);
+                                       flags.erase();
                                }
                        }
+                       bool const document =
+                               (tokenPos(flags, ',', "document") >= 0);
+                       if (!flags.empty() && flags != "document")
+                               lyxerr << "Ignoring flags other than "
+                                         "`document' in `" << flags
+                                      << "' for format `" << format << "'."
+                                      << endl;
                        if (prettyname.empty()) {
                                if (converters.formatIsUsed(format)) {
                                        lyxerr << "Can't delete format "
@@ -1113,7 +1125,7 @@ int LyXRC::read(LyXLex & lexrc)
                                }
                        } else {
                                formats.add(format, extension, prettyname,
-                                           shortcut, viewer, editor);
+                                           shortcut, viewer, editor, document);
                        }
                        break;
                }
@@ -2007,7 +2019,7 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc) const
                   << "#\n\n";
 
        case RC_FORMAT:
-               // New/modifed formats
+               // New/modified formats
                for (Formats::const_iterator cit = formats.begin();
                     cit != formats.end(); ++cit) {
                        Format const * format =
@@ -2017,13 +2029,18 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc) const
                            format->prettyname() != cit->prettyname() ||
                            format->shortcut() != cit->shortcut() ||
                            format->viewer() != cit->viewer() ||
-                           format->editor() != cit->editor())
+                           format->editor() != cit->editor() ||
+                           format->documentFormat() != cit->documentFormat()) {
                                os << "\\format \"" << cit->name() << "\" \""
                                   << cit->extension() << "\" \""
                                   << cit->prettyname() << "\" \""
                                   << cit->shortcut() << "\" \""
                                   << cit->viewer() << "\" \""
-                                  << cit->editor() << "\"\n";
+                                  << cit->editor() << "\" \"";
+                               if (cit->documentFormat())
+                                       os << "document";
+                               os << "\"\n";
+                       }
                }
 
                // Look for deleted formats
@@ -2031,7 +2048,7 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc) const
                     cit != system_formats.end(); ++cit)
                        if (!formats.getFormat(cit->name()))
                                os << "\\format \"" << cit->name()
-                                  << "\" \"\" \"\" \"\" \"\" \"\"\n";
+                                  << "\" \"\" \"\" \"\" \"\" \"\" \"\"\n";
        case RC_VIEWER:
                // Ignore it