Fix interface problem in order to cleanly support "cursor position memory" in the preamble editor.

* ControlDocument::params(): replace BufferParams local copy with Buffer::params() direct access.


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@18186 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Abdelrazak Younes 2007-05-03 14:20:12 +00:00
parent a67a27e6de
commit 696b6a2167
2 changed files with 16 additions and 15 deletions

View File

@ -60,28 +60,30 @@ ControlDocument::~ControlDocument()
bool ControlDocument::initialiseParams(std::string const &) bool ControlDocument::initialiseParams(std::string const &)
{ {
bp_.reset(new BufferParams);
*bp_ = kernel().buffer().params();
return true; return true;
} }
void ControlDocument::clearParams() void ControlDocument::clearParams()
{ {
bp_.reset();
} }
BufferParams & ControlDocument::params() const BufferParams const & ControlDocument::params() const
{ {
BOOST_ASSERT(bp_.get()); return kernel().buffer().params();
return *bp_; }
BufferParams & ControlDocument::params()
{
return kernel().buffer().params();
} }
TextClass const & ControlDocument::textClass() const TextClass const & ControlDocument::textClass() const
{ {
return textclasslist[bp_->textclass]; return textclasslist[params().textclass];
} }
@ -108,14 +110,14 @@ void ControlDocument::dispatchParams()
// Set the document class. // Set the document class.
textclass_type const old_class = textclass_type const old_class =
kernel().buffer().params().textclass; kernel().buffer().params().textclass;
textclass_type const new_class = bp_->textclass; textclass_type const new_class = params().textclass;
if (new_class != old_class) { if (new_class != old_class) {
string const name = textclasslist[new_class].name(); string const name = textclasslist[new_class].name();
kernel().dispatch(FuncRequest(LFUN_TEXTCLASS_APPLY, name)); kernel().dispatch(FuncRequest(LFUN_TEXTCLASS_APPLY, name));
} }
int const old_secnumdepth = kernel().buffer().params().secnumdepth; int const old_secnumdepth = kernel().buffer().params().secnumdepth;
int const new_secnumdepth = bp_->secnumdepth; int const new_secnumdepth = params().secnumdepth;
// Apply the BufferParams. // Apply the BufferParams.
dispatch_bufferparams(kernel(), params(), LFUN_BUFFER_PARAMS_APPLY); dispatch_bufferparams(kernel(), params(), LFUN_BUFFER_PARAMS_APPLY);
@ -151,7 +153,7 @@ void ControlDocument::dispatchParams()
void ControlDocument::setLanguage() const void ControlDocument::setLanguage() const
{ {
Language const * const newL = bp_->language; Language const * const newL = params().language;
if (kernel().buffer().params().language == newL) if (kernel().buffer().params().language == newL)
return; return;

View File

@ -13,8 +13,8 @@
#define CONTROLDOCUMENT_H #define CONTROLDOCUMENT_H
#include "Dialog.h" #include "Dialog.h"
#include "support/types.h" #include "support/types.h"
#include <boost/scoped_ptr.hpp>
namespace lyx { namespace lyx {
@ -48,7 +48,9 @@ public:
/// ///
TextClass const & textClass() const; TextClass const & textClass() const;
/// ///
BufferParams & params() const; BufferParams const & params() const;
///
BufferParams & params();
/// ///
void setLanguage() const; void setLanguage() const;
/// ///
@ -63,9 +65,6 @@ public:
bool const providesSC(std::string const & font) const; bool const providesSC(std::string const & font) const;
/// does this font provide size adjustment? /// does this font provide size adjustment?
bool const providesScale(std::string const & font) const; bool const providesScale(std::string const & font) const;
private:
///
boost::scoped_ptr<BufferParams> bp_;
}; };
} // namespace frontend } // namespace frontend