Juergen Spitzmueller wrote:

> Juergen Spitzmueller wrote:
>> http://bugzilla.lyx.org/show_bug.cgi?id=1290
>>
>> This patch is on bugzilla for a while, but since there's no
>> discussion I thought I'd bring it up here.
> 
> really no objections?
> 
> Juergen.

Weelll, the idea looks fine. 

However, since you ask, is there any reason for noTrivlistCentering to be a 
paragraph member function? Why not:

namespace {

bool noTrivlistCentering(Inset const * inset)
{
        if (inset && inset->owner()) {
                InsetOld::Code const code = inset->owner()->lyxCode();
                return code == InsetOld::FLOAT_CODE ||
                       code == InsetOld::FLOAT_CODE;
        }
        return false;
}

} // namespace anon


Shame that your change messes up the code.

How about client code that looked like:

        case LYX_ALIGN_LEFT: {
                string output;
                if (getParLanguage(bparams)->babel() != "hebrew")
                        output = corrected_env("\\begin", flushleft, 
pimpl_->inset_owner);
                else
                        output = corrected_env("\\begin", flushright, 
pimpl_->inset_owner);
                os << output;
                column += output.size();
                break;
        } case LYX_ALIGN_RIGHT: {
                string output;
                if (getParLanguage(bparams)->babel() != "hebrew")
                        output = corrected_env("\\begin", flushright, 
pimpl_->inset_owner);
                else
                        output = corrected_env("\\begin", flushleft, 
pimpl_->inset_owner);
                os << output;
                column += output.size();
                break;
        } case LYX_ALIGN_CENTER: {
                string output;
                output = corrected_env("\\begin", centering, pimpl_->inset_ownner);
                column += output.size();
                break;
        }
@@ -777,24 +797,39 @@
                break;
        case LYX_ALIGN_LEFT: {
                string output;
                if (getParLanguage(bparams)->babel() != "hebrew")
                        output = corrected_env("\\par\\end", flushleft, 
pimpl_->inset_owner);
                else
                        output = corrected_env("\\par\\end", flushright, 
pimpl_->inset_owner);
                os << output;
                column += output.size();
                break;
        } ...

namespace {

bool noTrivlistCentering(Inset const * inset)
{
        if (inset && inset->owner()) {
                InsetOld::Code const code = inset->owner()->lyxCode();
                return code == InsetOld::FLOAT_CODE ||
                       code == InsetOld::FLOAT_CODE;
        }
        return false;
}

char const * const * const envs { { "flushleft", "raggedright" },
                                  { "flushright", "raggedleft" },
                                  { "center", "centering" }
string const corrected_env(string const & suffix, string const & env,
                           Inset const * inset)
{
        string output = suffix + "{";
        if (noTrivlistCentering(inset))
                // use envs[?][1]
        else
                // use envs[?][0]
        output += "}";
        return output;
}

} // namespace anon
                       
        
-- 
Angus

Reply via email to