]> git.lyx.org Git - lyx.git/blobdiff - src/insets/InsetBranch.cpp
Some things did not need to be mutable after all
[lyx.git] / src / insets / InsetBranch.cpp
index a87cf053379444f43973a0da4c5b4eb33f929a43..22f6bb10945aeb922dff9e750b7e6578c0d6c048 100644 (file)
@@ -189,7 +189,11 @@ void InsetBranch::doDispatch(Cursor & cur, FuncRequest & cmd)
                break;
        }
        case LFUN_BRANCH_INVERT:
+               cur.recordUndoInset(this);
                params_.inverted = !params_.inverted;
+               // what we really want here is a TOC update, but that means
+               // a full buffer update
+               cur.forceBufferUpdate();
                break;
        case LFUN_BRANCH_ADD:
                lyx::dispatch(FuncRequest(LFUN_BRANCH_ADD, params_.branch));
@@ -276,9 +280,15 @@ bool InsetBranch::isBranchSelected(bool const child) const
 }
 
 
+bool InsetBranch::producesOutput() const
+{
+       return isBranchSelected(false) != params_.inverted;
+}
+
+
 void InsetBranch::latex(otexstream & os, OutputParams const & runparams) const
 {
-       if (isBranchActive())
+       if (producesOutput())
                InsetText::latex(os, runparams);
 }
 
@@ -286,7 +296,7 @@ void InsetBranch::latex(otexstream & os, OutputParams const & runparams) const
 int InsetBranch::plaintext(odocstringstream & os,
                           OutputParams const & runparams, size_t max_length) const
 {
-       if (!isBranchActive())
+       if (!producesOutput())
                return 0;
 
        int len = InsetText::plaintext(os, runparams, max_length);
@@ -297,13 +307,13 @@ int InsetBranch::plaintext(odocstringstream & os,
 int InsetBranch::docbook(odocstream & os,
                         OutputParams const & runparams) const
 {
-       return isBranchActive() ?  InsetText::docbook(os, runparams) : 0;
+       return producesOutput() ?  InsetText::docbook(os, runparams) : 0;
 }
 
 
 docstring InsetBranch::xhtml(XHTMLStream & xs, OutputParams const & rp) const
 {
-       if (isBranchActive()) {
+       if (producesOutput()) {
                OutputParams newrp = rp;
                newrp.par_begin = 0;
                newrp.par_end = text().paragraphs().size();
@@ -315,7 +325,7 @@ docstring InsetBranch::xhtml(XHTMLStream & xs, OutputParams const & rp) const
 
 void InsetBranch::toString(odocstream & os) const
 {
-       if (isBranchActive())
+       if (producesOutput())
                InsetCollapsable::toString(os);
 }
 
@@ -323,14 +333,14 @@ void InsetBranch::toString(odocstream & os) const
 void InsetBranch::forOutliner(docstring & os, size_t const maxlen,
                                                          bool const shorten) const
 {
-       if (isBranchActive())
+       if (producesOutput())
                InsetCollapsable::forOutliner(os, maxlen, shorten);
 }
 
 
 void InsetBranch::validate(LaTeXFeatures & features) const
 {
-       if (isBranchActive())
+       if (producesOutput())
                InsetCollapsable::validate(features);
 }
 
@@ -344,7 +354,7 @@ string InsetBranch::contextMenuName() const
 bool InsetBranch::isMacroScope() const 
 {
        // Its own scope if not selected by buffer
-       return !isBranchActive();
+       return !producesOutput();
 }
 
 
@@ -384,7 +394,7 @@ void InsetBranch::addToToc(DocIterator const & cpit, bool output_active,
        toc->push_back(TocItem(pit, 0, str, output_active));
 
        // Proceed with the rest of the inset.
-       bool const doing_output = output_active && isBranchActive();
+       bool const doing_output = output_active && producesOutput();
        InsetCollapsable::addToToc(cpit, doing_output, utype);
 }