From: Angus Leeming Date: Mon, 12 Aug 2002 20:17:41 +0000 (+0000) Subject: * Constify Buffer::getLabelList. X-Git-Tag: 1.6.10~18595 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=9681e21dae96d2152df6387ec2e8626ee5b0bd42;p=features.git * Constify Buffer::getLabelList. * reduce file dependencies of the controllers on the core. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@4947 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/ChangeLog b/src/ChangeLog index 436f45e518..82e5210ac8 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,6 @@ +2002-08-12 Angus Leeming + + * buffer.[Ch] (getLabelList): constify. 2002-08-07 André Pönitz diff --git a/src/buffer.C b/src/buffer.C index 73616d31c1..323c897849 100644 --- a/src/buffer.C +++ b/src/buffer.C @@ -3691,20 +3691,20 @@ string const Buffer::getIncludeonlyList(char delim) } -vector const Buffer::getLabelList() +vector const Buffer::getLabelList() const { /// if this is a child document and the parent is already loaded /// Use the parent's list instead [ale990407] if (!params.parentname.empty() && bufferlist.exists(params.parentname)) { - Buffer * tmp = bufferlist.getBuffer(params.parentname); + Buffer const * tmp = bufferlist.getBuffer(params.parentname); if (tmp) return tmp->getLabelList(); } vector label_list; - for (inset_iterator it = inset_iterator_begin(); - it != inset_iterator_end(); ++it) { + for (inset_iterator it = inset_const_iterator_begin(); + it != inset_const_iterator_end(); ++it) { vector const l = (*it)->getLabelList(); label_list.insert(label_list.end(), l.begin(), l.end()); } diff --git a/src/buffer.h b/src/buffer.h index 5f03cab458..438593e809 100644 --- a/src/buffer.h +++ b/src/buffer.h @@ -278,7 +278,7 @@ public: /// std::vector > const getBibkeyList() const; /// - std::vector const getLabelList(); + std::vector const getLabelList() const; /** This will clearly have to change later. Later we can have more than one user per buffer. */ diff --git a/src/frontends/controllers/ChangeLog b/src/frontends/controllers/ChangeLog index 4837f603b7..3fa784d00e 100644 --- a/src/frontends/controllers/ChangeLog +++ b/src/frontends/controllers/ChangeLog @@ -1,3 +1,12 @@ +2002-08-12 Angus Leeming + + * ControlConnections.[Ch]: (isReadonly): renamed as bufferIsReadonly. + (bufferIsAvailable, bufferview, buffer, lyxfunc): new methods. Wrappers + for the most commonly accessed core methods, to minimise code + dependiencies. + + * many files: use these wrappers and remove associated #includes. + 2002-08-12 Angus Leeming * ControlButtons.[Ch] (bc, view): no longer virtual. diff --git a/src/frontends/controllers/ControlAboutlyx.C b/src/frontends/controllers/ControlAboutlyx.C index f7815b97cc..c6f1310b9f 100644 --- a/src/frontends/controllers/ControlAboutlyx.C +++ b/src/frontends/controllers/ControlAboutlyx.C @@ -15,9 +15,7 @@ #endif #include "ControlAboutlyx.h" -#include "frontends/LyXView.h" #include "Lsstream.h" -#include "BufferView.h" #include "gettext.h" #include "support/filetools.h" // FileSearch #include "version.h" diff --git a/src/frontends/controllers/ControlBibitem.C b/src/frontends/controllers/ControlBibitem.C index 6a21aa0abb..df1a3f4273 100644 --- a/src/frontends/controllers/ControlBibitem.C +++ b/src/frontends/controllers/ControlBibitem.C @@ -32,16 +32,16 @@ void ControlBibitem::applyParamsToInset() // FIXME: // confirm, is this only necessary for FormBibTeX ??? if (params().getContents() != inset()->params().getContents()) - lv_.view()->ChangeCitationsIfUnique(inset()->params().getContents(), + bufferview()->ChangeCitationsIfUnique(inset()->params().getContents(), params().getContents()); inset()->setParams(params()); - lv_.view()->updateInset(inset(), true); + bufferview()->updateInset(inset(), true); // We need to do a redraw because the maximum // InsetBibKey width could have changed #warning please check you mean repaint() not update(), #warning and whether the repaint() is needed at all - lv_.view()->repaint(); - lv_.view()->fitCursor(); + bufferview()->repaint(); + bufferview()->fitCursor(); } diff --git a/src/frontends/controllers/ControlBibtex.C b/src/frontends/controllers/ControlBibtex.C index 832b86a4a1..cd2b96c8ca 100644 --- a/src/frontends/controllers/ControlBibtex.C +++ b/src/frontends/controllers/ControlBibtex.C @@ -20,6 +20,7 @@ #endif #include "ControlBibtex.h" +#include "buffer.h" #include "BufferView.h" #include "lyxrc.h" #include "helper_funcs.h" @@ -27,7 +28,6 @@ #include "gettext.h" #include "support/lstrings.h" -#include "frontends/LyXView.h" using std::pair; @@ -41,17 +41,17 @@ ControlBibtex::ControlBibtex(LyXView & lv, Dialogs & d) void ControlBibtex::applyParamsToInset() { if (params().getContents() != inset()->params().getContents()) - lv_.view()->ChangeCitationsIfUnique(inset()->params().getContents(), + bufferview()->ChangeCitationsIfUnique(inset()->params().getContents(), params().getContents()); inset()->setParams(params()); - lv_.view()->updateInset(inset(), true); + bufferview()->updateInset(inset(), true); // We need to do a redraw because the maximum // InsetBibKey width could have changed #warning are you sure you need this repaint() ? - lv_.view()->repaint(); - lv_.view()->fitCursor(); + bufferview()->repaint(); + bufferview()->fitCursor(); } @@ -64,7 +64,7 @@ string const ControlBibtex::Browse(string const & in_name, string const & pattern) { pair dir1(_("Documents|#o#O"), string(lyxrc.document_path)); - return browseRelFile(&lv_, in_name, lv_.buffer()->filePath(), + return browseRelFile(&lv_, in_name, buffer()->filePath(), title, pattern, dir1); } diff --git a/src/frontends/controllers/ControlCharacter.C b/src/frontends/controllers/ControlCharacter.C index 96de55bac5..92cfdb6b74 100644 --- a/src/frontends/controllers/ControlCharacter.C +++ b/src/frontends/controllers/ControlCharacter.C @@ -20,7 +20,6 @@ #include "bufferview_funcs.h" // ToggleAndShow #include "gettext.h" #include "language.h" -#include "BufferView.h" #include "frontends/LyXView.h" @@ -59,12 +58,12 @@ void ControlCharacter::apply() return; // Apply from the view if it's visible. Otherwise, use the stored values - if (lv_.view()->available()) + if (bufferIsAvailable()) view().apply(); - toggleAndShow(lv_.view().get(), *(font_.get()), toggleall_); + toggleAndShow(bufferview(), *(font_.get()), toggleall_); lv_.view_state_changed(); - lv_.buffer()->markDirty(); + buffer()->markDirty(); setMinibuffer(&lv_, _("Character set")); } @@ -223,7 +222,7 @@ void ControlCharacter::setLanguage(string const & val) font_->setLanguage(ignore_language); else if (val == "reset") - font_->setLanguage(lv_.buffer()->params.language); + font_->setLanguage(buffer()->params.language); else font_->setLanguage(languages.getLanguage(val)); diff --git a/src/frontends/controllers/ControlCitation.C b/src/frontends/controllers/ControlCitation.C index d1069ef90e..98928b5518 100644 --- a/src/frontends/controllers/ControlCitation.C +++ b/src/frontends/controllers/ControlCitation.C @@ -18,6 +18,7 @@ #endif #include "ControlCitation.h" +#include "buffer.h" using std::vector; using std::pair; @@ -38,7 +39,7 @@ void ControlCitation::clearDaughterParams() void ControlCitation::setDaughterParams() { - vector > blist = lv_.buffer()->getBibkeyList(); + vector > blist = buffer()->getBibkeyList(); typedef std::map::value_type InfoMapValue; @@ -65,7 +66,7 @@ biblio::InfoMap const & ControlCitation::bibkeysInfo() const bool ControlCitation::usingNatbib() const { - return lv_.buffer()->params.use_natbib; + return buffer()->params.use_natbib; } @@ -76,7 +77,7 @@ vector const ControlCitation::getCiteStrings(string const & key) const vector const cs = biblio::getCiteStyles(usingNatbib()); - if (lv_.buffer()->params.use_numerical_citations) + if (buffer()->params.use_numerical_citations) styles = biblio::getNumericalStrings(key, bibkeysInfo_, cs); else styles = biblio::getAuthorYearStrings(key, bibkeysInfo_, cs); diff --git a/src/frontends/controllers/ControlCommand.C b/src/frontends/controllers/ControlCommand.C index dd57990afc..869ad31c07 100644 --- a/src/frontends/controllers/ControlCommand.C +++ b/src/frontends/controllers/ControlCommand.C @@ -22,7 +22,6 @@ #include "ControlCommand.h" #include "buffer.h" #include "Dialogs.h" -#include "frontends/LyXView.h" #include "lyxfunc.h" #include "BufferView.h" #include "funcrequest.h" @@ -51,7 +50,7 @@ InsetCommandParams const ControlCommand::getParams(InsetCommand const & inset) void ControlCommand::applyParamsToInset() { inset()->setParams(params()); - lv_.view()->updateInset(inset(), true); + bufferview()->updateInset(inset(), true); } @@ -59,5 +58,5 @@ void ControlCommand::applyParamsNoInset() { if (action_ == LFUN_NOACTION) return; - lv_.getLyXFunc()->dispatch(FuncRequest(action_, params().getAsString())); + lyxfunc().dispatch(FuncRequest(action_, params().getAsString())); } diff --git a/src/frontends/controllers/ControlCommandBuffer.C b/src/frontends/controllers/ControlCommandBuffer.C index f8fd58f9d5..7dac06fd8b 100644 --- a/src/frontends/controllers/ControlCommandBuffer.C +++ b/src/frontends/controllers/ControlCommandBuffer.C @@ -8,6 +8,8 @@ * \author John Levon */ +#include + #ifdef __GNUG__ #pragma implementation #endif diff --git a/src/frontends/controllers/ControlCommandBuffer.h b/src/frontends/controllers/ControlCommandBuffer.h index 000786a1c4..8cd968aa9d 100644 --- a/src/frontends/controllers/ControlCommandBuffer.h +++ b/src/frontends/controllers/ControlCommandBuffer.h @@ -12,8 +12,6 @@ #ifndef CONTROLCOMMANDBUFFER_H #define CONTROLCOMMANDBUFFER_H -#include - #include "LString.h" #include diff --git a/src/frontends/controllers/ControlConnections.C b/src/frontends/controllers/ControlConnections.C index 5a5778ad1d..94cb89091d 100644 --- a/src/frontends/controllers/ControlConnections.C +++ b/src/frontends/controllers/ControlConnections.C @@ -21,6 +21,7 @@ #include "ViewBase.h" #include "Dialogs.h" #include "buffer.h" +#include "BufferView.h" #include "frontends/LyXView.h" @@ -50,7 +51,7 @@ void ControlConnectBase::redraw() } -bool ControlConnectBase::isReadonly() const +bool ControlConnectBase::bufferIsReadonly() const { if (!lv_.buffer()) return true; @@ -59,6 +60,51 @@ bool ControlConnectBase::isReadonly() const } +bool ControlConnectBase::bufferIsAvailable() const +{ + if (!lv_.view()) + return false; + + return lv_.view()->available(); +} + + +BufferView * ControlConnectBase::bufferview() +{ + return lv_.view().get(); +} + + +BufferView const * ControlConnectBase::bufferview() const +{ + return lv_.view().get(); +} + + +Buffer * ControlConnectBase::buffer() +{ + return lv_.buffer(); +} + + +Buffer const * ControlConnectBase::buffer() const +{ + return lv_.buffer(); +} + + +LyXFunc & ControlConnectBase::lyxfunc() +{ + return *lv_.getLyXFunc(); +} + + +LyXFunc const & ControlConnectBase::lyxfunc() const +{ + return *lv_.getLyXFunc(); +} + + ControlConnectBase::DocTypes ControlConnectBase::docType() const { if (!lv_.buffer()) diff --git a/src/frontends/controllers/ControlConnections.h b/src/frontends/controllers/ControlConnections.h index 6f73c28ace..6e5dcfbf6b 100644 --- a/src/frontends/controllers/ControlConnections.h +++ b/src/frontends/controllers/ControlConnections.h @@ -39,8 +39,11 @@ #include +class Buffer; +class BufferView; class Dialogs; class LyXView; +class LyXFunc; /** Base class to control connection/disconnection of signals with the LyX kernel. It is meant to be used solely as the parent class to @@ -63,7 +66,7 @@ public: /// ControlConnectBase(LyXView &, Dialogs &); /// The View may need to know if the buffer is read-only. - bool isReadonly() const; + bool bufferIsReadonly() const; /// DocTypes docType() const; @@ -81,7 +84,23 @@ protected: */ void redraw(); - /// Get at the kernel Dispatch methods we need to apply() parameters. + /// a wrapper for BufferView::avaliable() + bool bufferIsAvailable() const; + /// a wrapper for LyXView::view() + BufferView * bufferview(); + /// + BufferView const * bufferview() const; + /// a wrapper for LyXView::buffer() + Buffer * buffer(); + /// + Buffer const * buffer() const; + /// a wrapper for LyXView::getLyXFunc() + LyXFunc & lyxfunc(); + /// + LyXFunc const & lyxfunc() const; + + + /// LyXView & lv_; /// Contains the signals we have to connect to. Dialogs & d_; diff --git a/src/frontends/controllers/ControlDialog.tmpl b/src/frontends/controllers/ControlDialog.tmpl index ff4151d581..8a8ce459cb 100644 --- a/src/frontends/controllers/ControlDialog.tmpl +++ b/src/frontends/controllers/ControlDialog.tmpl @@ -11,12 +11,10 @@ */ #include "ControlDialog.h" + #include "ButtonControllerBase.h" -#include "ControlConnections.h" -#include "frontends/LyXView.h" -#include "BufferView.h" #include "ViewBase.h" -#include "debug.h" + template ControlDialog::ControlDialog(LyXView & lv, Dialogs & d) @@ -27,7 +25,7 @@ ControlDialog::ControlDialog(LyXView & lv, Dialogs & d) template void ControlDialog::show() { - if (isBufferDependent() && !lv_.view()->available()) + if (isBufferDependent() && !bufferIsAvailable()) return; connect(); @@ -43,14 +41,14 @@ void ControlDialog::show() dialog_built_ = true; } - bc().readOnly(isReadonly()); + bc().readOnly(bufferIsReadonly()); view().show(); } template void ControlDialog::update() { - if (isBufferDependent() && !lv_.view()->available()) + if (isBufferDependent() && !bufferIsAvailable()) return; setParams(); @@ -59,7 +57,7 @@ void ControlDialog::update() return; } - bc().readOnly(isReadonly()); + bc().readOnly(bufferIsReadonly()); view().update(); } diff --git a/src/frontends/controllers/ControlERT.C b/src/frontends/controllers/ControlERT.C index 76c87ce454..be67e66d43 100644 --- a/src/frontends/controllers/ControlERT.C +++ b/src/frontends/controllers/ControlERT.C @@ -30,7 +30,7 @@ ControlERT::ControlERT(LyXView & lv, Dialogs & d) void ControlERT::applyParamsToInset() { - inset()->status(lv_.view().get(), params().status); + inset()->status(bufferview(), params().status); } diff --git a/src/frontends/controllers/ControlExternal.C b/src/frontends/controllers/ControlExternal.C index 7a5d3c36f9..a2a96eaa47 100644 --- a/src/frontends/controllers/ControlExternal.C +++ b/src/frontends/controllers/ControlExternal.C @@ -20,6 +20,7 @@ #endif #include "ControlExternal.h" +#include "buffer.h" #include "BufferView.h" #include "gettext.h" #include "helper_funcs.h" @@ -50,7 +51,7 @@ ControlExternal::getParams(InsetExternal const & inset) void ControlExternal::applyParamsToInset() { inset()->setFromParams(params()); - lv_.view()->updateInset(inset(), true); + bufferview()->updateInset(inset(), true); } void ControlExternal::editExternal() @@ -62,7 +63,7 @@ void ControlExternal::editExternal() // Create a local copy of the inset and initialise it with this // params struct. boost::scoped_ptr ie; - ie.reset(static_cast(inset()->clone(*lv_.buffer()))); + ie.reset(static_cast(inset()->clone(*buffer()))); ie->setFromParams(params()); ie->editExternal(); @@ -73,7 +74,7 @@ void ControlExternal::viewExternal() view().apply(); boost::scoped_ptr ie; - ie.reset(static_cast(inset()->clone(*lv_.buffer()))); + ie.reset(static_cast(inset()->clone(*buffer()))); ie->setFromParams(params()); ie->viewExternal(); @@ -84,7 +85,7 @@ void ControlExternal::updateExternal() view().apply(); boost::scoped_ptr ie; - ie.reset(static_cast(inset()->clone(*lv_.buffer()))); + ie.reset(static_cast(inset()->clone(*buffer()))); ie->setFromParams(params()); ie->updateExternal(); @@ -139,7 +140,7 @@ string const ControlExternal::Browse(string const & input) const { string const title = _("Select external file"); - string const bufpath = lv_.buffer()->filePath(); + string const bufpath = buffer()->filePath(); /// Determine the template file extension ExternalTemplate const & et = params().templ; diff --git a/src/frontends/controllers/ControlFloat.C b/src/frontends/controllers/ControlFloat.C index c78ca8b671..2eb6cc47d5 100644 --- a/src/frontends/controllers/ControlFloat.C +++ b/src/frontends/controllers/ControlFloat.C @@ -28,7 +28,7 @@ void ControlFloat::applyParamsToInset() { inset()->placement(params().placement); inset()->wide(params().wide); - lv_.view()->updateInset(inset(), true); + bufferview()->updateInset(inset(), true); } diff --git a/src/frontends/controllers/ControlFloat.h b/src/frontends/controllers/ControlFloat.h index 29b810c856..73466f81b6 100644 --- a/src/frontends/controllers/ControlFloat.h +++ b/src/frontends/controllers/ControlFloat.h @@ -22,6 +22,9 @@ #include "ControlInset.h" +// needed to instatiate inset->hideDialog in ControlInset +#include "insets/insetfloat.h" + class InsetFloat; /// diff --git a/src/frontends/controllers/ControlForks.C b/src/frontends/controllers/ControlForks.C index bd31be6cfb..583a4923b1 100644 --- a/src/frontends/controllers/ControlForks.C +++ b/src/frontends/controllers/ControlForks.C @@ -15,8 +15,6 @@ #include "ControlForks.h" #include "ViewBase.h" -#include "BufferView.h" -#include "frontends/LyXView.h" #include "lyxfunc.h" #include "funcrequest.h" @@ -55,7 +53,7 @@ void ControlForks::kill(pid_t pid) void ControlForks::apply() { - if (!lv_.view()->available()) + if (!bufferIsAvailable()) return; view().apply(); @@ -66,7 +64,7 @@ void ControlForks::apply() for (vector::const_iterator it = pids_.begin(); it != pids_.end(); ++it) { - lv_.getLyXFunc()->dispatch(FuncRequest(LFUN_FORKS_KILL, *it)); + lyxfunc().dispatch(FuncRequest(LFUN_FORKS_KILL, *it)); } pids_.clear(); diff --git a/src/frontends/controllers/ControlGraphics.C b/src/frontends/controllers/ControlGraphics.C index c0a93a83a2..f096f51ea9 100644 --- a/src/frontends/controllers/ControlGraphics.C +++ b/src/frontends/controllers/ControlGraphics.C @@ -26,7 +26,6 @@ #include "buffer.h" #include "BufferView.h" #include "Dialogs.h" -#include "frontends/LyXView.h" #include "gettext.h" #include "lyxrc.h" @@ -67,11 +66,11 @@ void ControlGraphics::applyParamsToInset() { // Set the parameters in the inset, it also returns true if the new // parameters are different from what was in the inset already. - bool changed = inset()->setParams(params(), lv_.buffer()->filePath()); + bool changed = inset()->setParams(params(), buffer()->filePath()); // Tell LyX we've got a change, and mark the document dirty, // if it changed. - lv_.view()->updateInset(inset(), changed); + bufferview()->updateInset(inset(), changed); } @@ -97,14 +96,14 @@ string const ControlGraphics::Browse(string const & in_name) pair dir1(_("Clipart|#C#c"), clipdir); pair dir2(_("Documents|#o#O"), string(lyxrc.document_path)); // Show the file browser dialog - return browseRelFile(&lv_, in_name, lv_.buffer()->filePath(), + return browseRelFile(&lv_, in_name, buffer()->filePath(), title, "*.*", dir1, dir2); } string const ControlGraphics::readBB(string const & file) { - string const abs_file = MakeAbsPath(file, lv_.buffer()->filePath()); + string const abs_file = MakeAbsPath(file, buffer()->filePath()); // try to get it from the file, if possible. Zipped files are // unzipped in the readBB_from_PSFile-Function @@ -133,7 +132,7 @@ string const ControlGraphics::readBB(string const & file) bool ControlGraphics::isFilenameValid(string const & fname) const { // It may be that the filename is relative. - string const name = MakeAbsPath(fname, lv_.buffer()->filePath()); + string const name = MakeAbsPath(fname, buffer()->filePath()); return IsFileReadable(name); } diff --git a/src/frontends/controllers/ControlGraphics.h b/src/frontends/controllers/ControlGraphics.h index 3e5d4663af..013caea131 100644 --- a/src/frontends/controllers/ControlGraphics.h +++ b/src/frontends/controllers/ControlGraphics.h @@ -21,6 +21,10 @@ #endif #include "ControlInset.h" + +// needed to instatiate inset->hideDialog in ControlInset +#include "insets/insetgraphics.h" + #include #include diff --git a/src/frontends/controllers/ControlInclude.C b/src/frontends/controllers/ControlInclude.C index 2bac0f5fa2..0d16a4c219 100644 --- a/src/frontends/controllers/ControlInclude.C +++ b/src/frontends/controllers/ControlInclude.C @@ -38,7 +38,7 @@ ControlInclude::ControlInclude(LyXView & lv, Dialogs & d) void ControlInclude::applyParamsToInset() { inset()->set(params()); - lv_.view()->updateInset(inset(), true); + bufferview()->updateInset(inset(), true); } @@ -73,7 +73,7 @@ string const ControlInclude::Browse(string const & in_name, Type in_type) void ControlInclude::load(string const & file) { - lv_.getLyXFunc()->dispatch(FuncRequest(LFUN_CHILDOPEN, file)); + lyxfunc().dispatch(FuncRequest(LFUN_CHILDOPEN, file)); } diff --git a/src/frontends/controllers/ControlInset.tmpl b/src/frontends/controllers/ControlInset.tmpl index fe88747c36..c93476fb6b 100644 --- a/src/frontends/controllers/ControlInset.tmpl +++ b/src/frontends/controllers/ControlInset.tmpl @@ -11,13 +11,9 @@ */ #include "ControlInset.h" + #include "ButtonControllerBase.h" #include "ViewBase.h" -#include "buffer.h" -#include "debug.h" -#include "frontends/LyXView.h" -#include "insets/insetfloat.h" -#include "insets/insetgraphics.h" #include "support/LAssert.h" #include @@ -70,7 +66,7 @@ void ControlInset::show(Params const & params) dialog_built_ = true; } - bc().readOnly(isReadonly()); + bc().readOnly(bufferIsReadonly()); view().show(); } @@ -91,7 +87,7 @@ void ControlInset::update() return; } - bc().readOnly(isReadonly()); + bc().readOnly(bufferIsReadonly()); view().update(); } @@ -117,7 +113,7 @@ void ControlInset::hide() template void ControlInset::apply() { - if (lv_.buffer()->isReadonly()) + if (bufferIsReadonly()) return; view().apply(); diff --git a/src/frontends/controllers/ControlLog.C b/src/frontends/controllers/ControlLog.C index bcaa49bb67..a271d87768 100644 --- a/src/frontends/controllers/ControlLog.C +++ b/src/frontends/controllers/ControlLog.C @@ -19,9 +19,8 @@ #endif #include "ControlLog.h" -#include "BufferView.h" +#include "buffer.h" -#include "frontends/LyXView.h" ControlLog::ControlLog(LyXView & lv, Dialogs & d) @@ -31,7 +30,7 @@ ControlLog::ControlLog(LyXView & lv, Dialogs & d) void ControlLog::setParams() { - logfile_ = lv_.view()->buffer()->getLogName(); + logfile_ = buffer()->getLogName(); } diff --git a/src/frontends/controllers/ControlMinipage.C b/src/frontends/controllers/ControlMinipage.C index 2ebc759a4c..a96cd908c6 100644 --- a/src/frontends/controllers/ControlMinipage.C +++ b/src/frontends/controllers/ControlMinipage.C @@ -31,7 +31,7 @@ void ControlMinipage::applyParamsToInset() inset()->pageWidth(params().pageWidth); inset()->pos(params().pos); - lv_.view()->updateInset(inset(), true); + bufferview()->updateInset(inset(), true); } diff --git a/src/frontends/controllers/ControlParagraph.C b/src/frontends/controllers/ControlParagraph.C index c89f56b0ff..58738aed95 100644 --- a/src/frontends/controllers/ControlParagraph.C +++ b/src/frontends/controllers/ControlParagraph.C @@ -18,7 +18,6 @@ #include "ViewBase.h" #include "ParagraphParameters.h" #include "Liason.h" -#include "LyXView.h" #include "BufferView.h" #include "gettext.h" #include "buffer.h" @@ -64,13 +63,13 @@ LyXAlignment ControlParagraph::alignPossible() const void ControlParagraph::apply() { - if (!lv_.view()->available()) + if (!bufferIsAvailable()) return; view().apply(); - LyXText * text(lv_.view()->getLyXText()); - text->setParagraph(lv_.view().get(), + LyXText * text(bufferview()->getLyXText()); + text->setParagraph(bufferview(), pp_->lineTop(), pp_->lineBottom(), pp_->pagebreakTop(), @@ -83,12 +82,12 @@ void ControlParagraph::apply() pp_->noindent()); // Actually apply these settings - lv_.view()->update(text, - BufferView::SELECT | - BufferView::FITCUR | - BufferView::CHANGE); + bufferview()->update(text, + BufferView::SELECT | + BufferView::FITCUR | + BufferView::CHANGE); - lv_.buffer()->markDirty(); + buffer()->markDirty(); setMinibuffer(&lv_, _("Paragraph layout set")); } @@ -100,7 +99,7 @@ void ControlParagraph::setParams() pp_.reset(new ParagraphParameters()); /// get paragraph - Paragraph const * par_ = lv_.view()->getLyXText()->cursor.par(); + Paragraph const * par_ = bufferview()->getLyXText()->cursor.par(); /// Set the paragraph parameters *pp_ = par_->params(); @@ -123,7 +122,7 @@ void ControlParagraph::setParams() void ControlParagraph::changedParagraph() { /// get paragraph - Paragraph const * p = lv_.view()->getLyXText()->cursor.par(); + Paragraph const * p = bufferview()->getLyXText()->cursor.par(); if (p == 0) // this is wrong as we don't set par_ here! /* || p == par_) */ return; diff --git a/src/frontends/controllers/ControlPreamble.C b/src/frontends/controllers/ControlPreamble.C index 7f30834f55..b1eb78c120 100644 --- a/src/frontends/controllers/ControlPreamble.C +++ b/src/frontends/controllers/ControlPreamble.C @@ -14,12 +14,9 @@ #include "ControlPreamble.h" #include "ViewBase.h" -#include "frontends/LyXView.h" #include "buffer.h" #include "Liason.h" #include "gettext.h" -#include "BufferView.h" -#include "support/LAssert.h" ControlPreamble::ControlPreamble(LyXView & lv, Dialogs & d) @@ -30,13 +27,13 @@ ControlPreamble::ControlPreamble(LyXView & lv, Dialogs & d) void ControlPreamble::apply() { - if (!lv_.view()->available()) + if (!bufferIsAvailable()) return; view().apply(); - lv_.buffer()->params.preamble = params(); - lv_.buffer()->markDirty(); + buffer()->params.preamble = params(); + buffer()->markDirty(); Liason::setMinibuffer(&lv_, _("LaTeX preamble set")); } @@ -51,7 +48,7 @@ string & ControlPreamble::params() const void ControlPreamble::setParams() { delete params_; - params_ = new string(lv_.buffer()->params.preamble); + params_ = new string(buffer()->params.preamble); } diff --git a/src/frontends/controllers/ControlPrint.C b/src/frontends/controllers/ControlPrint.C index 8e5ba18f4f..0845ec8648 100644 --- a/src/frontends/controllers/ControlPrint.C +++ b/src/frontends/controllers/ControlPrint.C @@ -21,13 +21,11 @@ #include "ViewBase.h" #include "ButtonControllerBase.h" #include "buffer.h" -#include "frontends/LyXView.h" #include "PrinterParams.h" #include "Liason.h" #include "helper_funcs.h" #include "frontends/Alert.h" #include "gettext.h" -#include "BufferView.h" #include "support/LAssert.h" using Liason::printBuffer; @@ -42,12 +40,12 @@ ControlPrint::ControlPrint(LyXView & lv, Dialogs & d) void ControlPrint::apply() { - if (!lv_.view()->available()) + if (!bufferIsAvailable()) return; view().apply(); - if (!printBuffer(lv_.buffer(), params())) { + if (!printBuffer(buffer(), params())) { Alert::alert(_("Error:"), _("Unable to print"), _("Check that your parameters are correct")); @@ -65,7 +63,7 @@ PrinterParams & ControlPrint::params() const void ControlPrint::setParams() { if (params_) delete params_; - params_ = new PrinterParams(getPrinterParams(lv_.buffer())); + params_ = new PrinterParams(getPrinterParams(buffer())); bc().valid(); // so that the user can press Ok } @@ -86,6 +84,6 @@ string const ControlPrint::Browse(string const & in_name) string const pattern = "*.ps"; // Show the file browser dialog - return browseRelFile(&lv_, in_name, lv_.buffer()->filePath(), + return browseRelFile(&lv_, in_name, buffer()->filePath(), title, pattern); } diff --git a/src/frontends/controllers/ControlRef.C b/src/frontends/controllers/ControlRef.C index 3afb56b835..2470e55f0f 100644 --- a/src/frontends/controllers/ControlRef.C +++ b/src/frontends/controllers/ControlRef.C @@ -19,6 +19,7 @@ #include "ControlRef.h" #include "lyxfunc.h" +#include "buffer.h" #include "bufferlist.h" #include "funcrequest.h" @@ -36,29 +37,28 @@ ControlRef::ControlRef(LyXView & lv, Dialogs & d) vector const ControlRef::getLabelList(string const & name) const { - Buffer * buffer = bufferlist.getBuffer(MakeAbsPath(name)); - if (!buffer) - buffer = lv_.buffer(); - return buffer->getLabelList(); + Buffer const * buf = bufferlist.getBuffer(MakeAbsPath(name)); + if (!buf) + buf = buffer(); + return buf->getLabelList(); } -void ControlRef::gotoRef(string const & ref) const +void ControlRef::gotoRef(string const & ref) { - lv_.getLyXFunc()->dispatch(FuncRequest(LFUN_BOOKMARK_SAVE, "0"), false); - lv_.getLyXFunc()->dispatch(FuncRequest(LFUN_REF_GOTO, ref)); + lyxfunc().dispatch(FuncRequest(LFUN_BOOKMARK_SAVE, "0"), false); + lyxfunc().dispatch(FuncRequest(LFUN_REF_GOTO, ref)); } -void ControlRef::gotoBookmark() const +void ControlRef::gotoBookmark() { - lv_.getLyXFunc()->dispatch(FuncRequest(LFUN_BOOKMARK_GOTO, "0"), false); + lyxfunc().dispatch(FuncRequest(LFUN_BOOKMARK_GOTO, "0"), false); } vector const ControlRef::getBufferList() const { - vector buffers = bufferlist.getFileNames(); for (vector::iterator it = buffers.begin(); it != buffers.end(); ++it) { @@ -72,7 +72,7 @@ vector const ControlRef::getBufferList() const int ControlRef::getBufferNum() const { vector buffers = bufferlist.getFileNames(); - string const name = lv_.buffer()->fileName(); + string const name = buffer()->fileName(); vector::const_iterator cit = find(buffers.begin(), buffers.end(), name); if (cit == buffers.end()) diff --git a/src/frontends/controllers/ControlRef.h b/src/frontends/controllers/ControlRef.h index df6c4e9322..fdf4a25108 100644 --- a/src/frontends/controllers/ControlRef.h +++ b/src/frontends/controllers/ControlRef.h @@ -31,9 +31,9 @@ public: /// std::vector const getLabelList(string const &) const; /// - void gotoRef(string const &) const; + void gotoRef(string const &); /// - void gotoBookmark() const; + void gotoBookmark(); /// std::vector const getBufferList() const; /// diff --git a/src/frontends/controllers/ControlSearch.C b/src/frontends/controllers/ControlSearch.C index 22a012a7bf..0ccfd73f0c 100644 --- a/src/frontends/controllers/ControlSearch.C +++ b/src/frontends/controllers/ControlSearch.C @@ -19,12 +19,9 @@ #include "ControlSearch.h" #include "Liason.h" -#include "buffer.h" #include "lyxfind.h" #include "gettext.h" -#include "BufferView.h" -#include "frontends/LyXView.h" #include "support/lstrings.h" @@ -37,9 +34,9 @@ ControlSearch::ControlSearch(LyXView & lv, Dialogs & d) void ControlSearch::find(string const & search, - bool casesensitive, bool matchword, bool forward) const + bool casesensitive, bool matchword, bool forward) { - bool const found = lyxfind::LyXFind(lv_.view().get(), search, + bool const found = lyxfind::LyXFind(bufferview(), search, forward, casesensitive, matchword); @@ -49,14 +46,14 @@ void ControlSearch::find(string const & search, void ControlSearch::replace(string const & search, string const & replace, - bool casesensitive, bool matchword, bool all) const + bool casesensitive, bool matchword, bool all) { // If not replacing all instances of the word, then do not // move on to the next instance once the present instance has been // changed bool const once = !all; int const replace_count = - lyxfind::LyXReplace(lv_.view().get(), + lyxfind::LyXReplace(bufferview(), search, replace, true, casesensitive, matchword, all, once); diff --git a/src/frontends/controllers/ControlSearch.h b/src/frontends/controllers/ControlSearch.h index 8334e3a094..0b45b09b26 100644 --- a/src/frontends/controllers/ControlSearch.h +++ b/src/frontends/controllers/ControlSearch.h @@ -31,11 +31,11 @@ public: /// Searches occurence of string void find(string const & search, - bool casesensitive, bool matchword, bool forward) const; + bool casesensitive, bool matchword, bool forward); /// Replaces occurence of string void replace(string const & search, string const & replace, - bool casesensitive, bool matchword, bool all) const; + bool casesensitive, bool matchword, bool all); private: /// not needed. diff --git a/src/frontends/controllers/ControlSendto.C b/src/frontends/controllers/ControlSendto.C index 4fc80abe1e..1daf97a6bf 100644 --- a/src/frontends/controllers/ControlSendto.C +++ b/src/frontends/controllers/ControlSendto.C @@ -14,8 +14,6 @@ #include "ControlSendto.h" #include "ViewBase.h" -#include "frontends/LyXView.h" -#include "BufferView.h" #include "buffer.h" #include "converter.h" #include "exporter.h" @@ -43,13 +41,13 @@ vector const ControlSendto::allFormats() const exports.push_back("lyx"); exports.push_back("text"); - if (lv_.buffer()->isLatex()) + if (buffer()->isLatex()) exports.push_back("latex"); - if (lv_.buffer()->isLinuxDoc()) + if (buffer()->isLinuxDoc()) exports.push_back("linuxdoc"); - if (lv_.buffer()->isDocBook()) + if (buffer()->isDocBook()) exports.push_back("docbook"); - if (lv_.buffer()->isLiterate()) + if (buffer()->isLiterate()) exports.push_back("literate"); // Loop over these native formats and ascertain what formats we @@ -104,7 +102,7 @@ void ControlSendto::setCommand(string const & cmd) void ControlSendto::apply() { - if (!lv_.view()->available()) + if (!bufferIsAvailable()) return; view().apply(); @@ -117,15 +115,15 @@ void ControlSendto::apply() // Output to filename if (format_->name() == "lyx") { - filename = ChangeExtension(lv_.buffer()->getLatexName(false), + filename = ChangeExtension(buffer()->getLatexName(false), format_->extension()); - if (!lv_.buffer()->tmppath.empty()) - filename = AddName(lv_.buffer()->tmppath, filename); + if (!buffer()->tmppath.empty()) + filename = AddName(buffer()->tmppath, filename); - lv_.buffer()->writeFile(filename); + buffer()->writeFile(filename); } else { - Exporter::Export(lv_.buffer(), format_->name(), true, filename); + Exporter::Export(buffer(), format_->name(), true, filename); } // Substitute $$FName for filename diff --git a/src/frontends/controllers/ControlSpellchecker.C b/src/frontends/controllers/ControlSpellchecker.C index 78191572a2..488319605a 100644 --- a/src/frontends/controllers/ControlSpellchecker.C +++ b/src/frontends/controllers/ControlSpellchecker.C @@ -24,7 +24,6 @@ #include "Dialogs.h" #include "Liason.h" -#include "frontends/LyXView.h" #include "frontends/Alert.h" #include "support/lstrings.h" @@ -49,15 +48,15 @@ void ControlSpellchecker::setParams() #ifdef USE_PSPELL if (lyxrc.use_pspell) { tmp = (lyxrc.isp_use_alt_lang) ? - lyxrc.isp_alt_lang : lv_.buffer()->params.language->code(); + lyxrc.isp_alt_lang : buffer()->params.language->code(); - speller_ = new PSpell(lv_.view()->buffer()->params, tmp); + speller_ = new PSpell(buffer()->params, tmp); } else { #endif tmp = (lyxrc.isp_use_alt_lang) ? - lyxrc.isp_alt_lang : lv_.buffer()->params.language->lang(); + lyxrc.isp_alt_lang : buffer()->params.language->lang(); - speller_ = new ISpell(lv_.view()->buffer()->params, tmp); + speller_ = new ISpell(buffer()->params, tmp); #ifdef USE_PSPELL } #endif @@ -67,7 +66,7 @@ void ControlSpellchecker::setParams() if (lang) rtl_ = lang->RightToLeft(); } else { - rtl_ = lv_.buffer()->params.language->RightToLeft(); + rtl_ = buffer()->params.language->RightToLeft(); } if (!speller_->error().empty()) { @@ -86,12 +85,12 @@ void ControlSpellchecker::check() stop_ = false; // clear any old selection - LyXText * text = lv_.view()->getLyXText(); - lv_.view()->toggleSelection(true); - lv_.view()->update(text, BufferView::SELECT); + LyXText * text = bufferview()->getLyXText(); + bufferview()->toggleSelection(true); + bufferview()->update(text, BufferView::SELECT); while ((res == SpellBase::OK || res == SpellBase::IGNORE) && !stop_) { - word_ = lv_.view()->nextWord(newval_); + word_ = bufferview()->nextWord(newval_); if (word_.word().empty()) { clearParams(); @@ -118,7 +117,7 @@ void ControlSpellchecker::check() } if (!stop_ && !word_.word().empty()) - lv_.view()->selectLastWord(); + bufferview()->selectLastWord(); // set suggestions if (res != SpellBase::OK && res != SpellBase::IGNORE) { @@ -129,7 +128,7 @@ void ControlSpellchecker::check() void ControlSpellchecker::replace(string const & replacement) { - lv_.view()->replaceWord(replacement); + bufferview()->replaceWord(replacement); // fix up the count --count_; check(); @@ -180,7 +179,7 @@ void ControlSpellchecker::ignoreAll() void ControlSpellchecker::stop() { stop_ = true; - lv_.view()->endOfSpellCheck(); + bufferview()->endOfSpellCheck(); } @@ -215,7 +214,7 @@ void ControlSpellchecker::clearParams() delete speller_; - lv_.view()->endOfSpellCheck(); + bufferview()->endOfSpellCheck(); // show closing message if any words were checked. if (count_ > 0) diff --git a/src/frontends/controllers/ControlTabularCreate.C b/src/frontends/controllers/ControlTabularCreate.C index 58a7198e89..5ed7bebe2f 100644 --- a/src/frontends/controllers/ControlTabularCreate.C +++ b/src/frontends/controllers/ControlTabularCreate.C @@ -19,11 +19,9 @@ #include "ControlTabularCreate.h" #include "ViewBase.h" #include "ButtonControllerBase.h" -#include "BufferView.h" #include "lyxfunc.h" #include "funcrequest.h" -#include "frontends/LyXView.h" #include "support/lstrings.h" @@ -47,11 +45,11 @@ void ControlTabularCreate::setParams() void ControlTabularCreate::apply() { - if (!lv_.view()->available()) + if (!bufferIsAvailable()) return; view().apply(); string const val = tostr(params().first) + " " + tostr(params().second); - lv_.getLyXFunc()->dispatch(FuncRequest(LFUN_TABULAR_INSERT, val)); + lyxfunc().dispatch(FuncRequest(LFUN_TABULAR_INSERT, val)); } diff --git a/src/frontends/controllers/ControlTexinfo.C b/src/frontends/controllers/ControlTexinfo.C index b3d1d6c7c4..ac8faf1d60 100644 --- a/src/frontends/controllers/ControlTexinfo.C +++ b/src/frontends/controllers/ControlTexinfo.C @@ -19,7 +19,6 @@ #include "ControlTexinfo.h" #include "Dialogs.h" -#include "BufferView.h" #include "gettext.h" #include "helper_funcs.h" #include "tex_helpers.h" diff --git a/src/frontends/controllers/ControlThesaurus.C b/src/frontends/controllers/ControlThesaurus.C index 1dc8fc2509..51db250e52 100644 --- a/src/frontends/controllers/ControlThesaurus.C +++ b/src/frontends/controllers/ControlThesaurus.C @@ -15,11 +15,8 @@ #include "ControlThesaurus.h" #include "Liason.h" #include "lyxfind.h" -#include "buffer.h" #include "gettext.h" -#include "BufferView.h" -#include "frontends/LyXView.h" using Liason::setMinibuffer; @@ -43,7 +40,7 @@ void ControlThesaurus::replace(string const & newstr) * deletion/change ! */ int const replace_count = - lyxfind::LyXReplace(lv_.view().get(), oldstr_, newstr, + lyxfind::LyXReplace(bufferview(), oldstr_, newstr, true, true, true, false, true); oldstr_ = newstr; diff --git a/src/frontends/controllers/ControlToc.C b/src/frontends/controllers/ControlToc.C index 7af987fad6..ba57eb8d37 100644 --- a/src/frontends/controllers/ControlToc.C +++ b/src/frontends/controllers/ControlToc.C @@ -19,8 +19,6 @@ #include "ControlToc.h" #include "toc.h" -#include "Dialogs.h" -#include "BufferView.h" #include "support/lstrings.h" // tostr @@ -41,7 +39,7 @@ void ControlToc::goTo(toc::TocItem const & item) const vector const ControlToc::getTypes() const { - return toc::getTypes(lv_.view()->buffer()); + return toc::getTypes(buffer()); } @@ -50,11 +48,11 @@ toc::Toc const ControlToc::getContents(string const & type) const toc::Toc empty_list; // This shouldn't be possible... - if (!lv_.view()->available()) { + if (!bufferIsAvailable()) { return empty_list; } - toc::TocList tmp = toc::getTocList(lv_.view()->buffer()); + toc::TocList tmp = toc::getTocList(buffer()); toc::TocList::iterator it = tmp.find(type); if (it == tmp.end()) { return empty_list; diff --git a/src/frontends/controllers/ControlVCLog.C b/src/frontends/controllers/ControlVCLog.C index 2b5f13a254..0e13c4bae3 100644 --- a/src/frontends/controllers/ControlVCLog.C +++ b/src/frontends/controllers/ControlVCLog.C @@ -22,11 +22,9 @@ #include "Lsstream.h" #include "ButtonControllerBase.h" #include "buffer.h" -#include "BufferView.h" #include "lyxrc.h" #include "gettext.h" -#include "frontends/LyXView.h" #include "support/lyxlib.h" @@ -42,13 +40,13 @@ ControlVCLog::ControlVCLog(LyXView & lv, Dialogs & d) string const ControlVCLog::getBufferFileName() const { - return lv_.view()->buffer()->fileName(); + return buffer()->fileName(); } stringstream & ControlVCLog::getVCLogFile(stringstream & ss) const { - string const name = lv_.view()->buffer()->lyxvc.getLogFile(); + string const name = buffer()->lyxvc.getLogFile(); std::ifstream in(name.c_str()); diff --git a/src/frontends/xforms/ChangeLog b/src/frontends/xforms/ChangeLog index 11afc6e7a9..872db30711 100644 --- a/src/frontends/xforms/ChangeLog +++ b/src/frontends/xforms/ChangeLog @@ -1,3 +1,12 @@ +2002-08-12 Angus Leeming + + * FormCitation.C: + * FromRef.C: change due to change of ControlConnections method name, + isReadonly() -> bufferIsReadonly(). + + * FormIndex.C: + * FormPrint.C: no longer #include "frontends/LyXView.h". + 2002-08-12 Angus Leeming * Dialogs.C (c-tor): connect the Tooltips::toggleEnabled method to diff --git a/src/frontends/xforms/FormCitation.C b/src/frontends/xforms/FormCitation.C index 22ac62b05d..8b024de928 100644 --- a/src/frontends/xforms/FormCitation.C +++ b/src/frontends/xforms/FormCitation.C @@ -307,7 +307,7 @@ ButtonPolicy::SMInput FormCitation::input(FL_OBJECT * ob, long) fl_set_browser_topline(dialog_->browser_cite, n+1); } - if (!controller().isReadonly()) { + if (!controller().bufferIsReadonly()) { if (cit != citekeys.end()) { setBibButtons(OFF); setCiteButtons(ON); @@ -322,7 +322,7 @@ ButtonPolicy::SMInput FormCitation::input(FL_OBJECT * ob, long) if (sel < 1 || sel > citekeys.size()) return ButtonPolicy::SMI_NOOP; - if (!controller().isReadonly()) { + if (!controller().bufferIsReadonly()) { setBibButtons(OFF); setCiteButtons(ON); } diff --git a/src/frontends/xforms/FormIndex.C b/src/frontends/xforms/FormIndex.C index 7921e66cad..9802e856be 100644 --- a/src/frontends/xforms/FormIndex.C +++ b/src/frontends/xforms/FormIndex.C @@ -15,7 +15,6 @@ #include "xformsBC.h" #include "ControlIndex.h" #include "FormIndex.h" -#include "frontends/LyXView.h" #include "forms/form_index.h" #include FORMS_H_LOCATION diff --git a/src/frontends/xforms/FormPrint.C b/src/frontends/xforms/FormPrint.C index 7794204f5a..0e3f636766 100644 --- a/src/frontends/xforms/FormPrint.C +++ b/src/frontends/xforms/FormPrint.C @@ -18,8 +18,6 @@ #include "FormPrint.h" #include "forms/form_print.h" -#include "frontends/LyXView.h" - #include "PrinterParams.h" #include "input_validators.h" diff --git a/src/frontends/xforms/FormRef.C b/src/frontends/xforms/FormRef.C index 70640bd4bd..ccbe105b29 100644 --- a/src/frontends/xforms/FormRef.C +++ b/src/frontends/xforms/FormRef.C @@ -200,7 +200,7 @@ ButtonPolicy::SMInput FormRef::input(FL_OBJECT * ob, long) if (sel < 1 || sel > refs_.size()) return ButtonPolicy::SMI_NOOP; - if (!controller().isReadonly()) { + if (!controller().bufferIsReadonly()) { string s = fl_get_browser_line(dialog_->browser_refs, sel); fl_set_input(dialog_->input_ref, s.c_str()); }