commit c7896cf922f8297ba9bbfc0fa13b99ccaf9168a5
Author: Thibaut Cuvelier <[email protected]>
Date:   Fri Apr 1 03:51:24 2022 +0200

    XHTML/DocBook: merge code duplicates for vertical alignment.
---
 src/insets/InsetTabular.cpp |   55 ++++++++++++------------------------------
 src/insets/InsetTabular.h   |    3 ++
 2 files changed, 19 insertions(+), 39 deletions(-)

diff --git a/src/insets/InsetTabular.cpp b/src/insets/InsetTabular.cpp
index 17d58dd..092c868 100644
--- a/src/insets/InsetTabular.cpp
+++ b/src/insets/InsetTabular.cpp
@@ -3626,6 +3626,19 @@ void Tabular::docbookRow(XMLStream & xs, row_type row,
 }
 
 
+std::string Tabular::getVAlignAsXmlAttribute(idx_type cell) const
+{
+       switch (getVAlignment(cell)) {
+       case LYX_VALIGN_TOP:
+               return "valign='top'";
+       case LYX_VALIGN_BOTTOM:
+               return "valign='bottom'";
+       case LYX_VALIGN_MIDDLE:
+               return "valign='middle'";
+       }
+}
+
+
 void Tabular::docbookRowAsHTML(XMLStream & xs, row_type row,
                   OutputParams const & runparams, bool header) const
 {
@@ -3666,19 +3679,7 @@ void Tabular::docbookRowAsHTML(XMLStream & xs, row_type 
row,
                        attr << "center";
                        break;
                }
-               attr << "'";
-               attr << " valign='";
-               switch (getVAlignment(cell)) {
-               case LYX_VALIGN_TOP:
-                       attr << "top";
-                       break;
-               case LYX_VALIGN_BOTTOM:
-                       attr << "bottom";
-                       break;
-               case LYX_VALIGN_MIDDLE:
-                       attr << "middle";
-               }
-               attr << "'";
+               attr << "' " << getVAlignAsXmlAttribute(cell);
 
                if (isMultiColumn(cell))
                        attr << " colspan='" << columnSpan(cell) << "'";
@@ -3733,19 +3734,7 @@ void Tabular::docbookRowAsCALS(XMLStream & xs, row_type 
row,
                        attr << "center";
                        break;
                }
-               attr << "'";
-               attr << " valign='";
-               switch (getVAlignment(cell)) {
-               case LYX_VALIGN_TOP:
-                       attr << "top";
-                       break;
-               case LYX_VALIGN_BOTTOM:
-                       attr << "bottom";
-                       break;
-               case LYX_VALIGN_MIDDLE:
-                       attr << "middle";
-               }
-               attr << "'";
+               attr << "' " << getVAlignAsXmlAttribute(cell);
 
                if (isMultiColumn(cell))
                        attr << " colspan='" << columnSpan(cell) << "'";
@@ -3897,19 +3886,7 @@ docstring Tabular::xhtmlRow(XMLStream & xs, row_type row,
                        attr << "center";
                        break;
                }
-               attr << "'";
-               attr << " valign='";
-               switch (getVAlignment(cell)) {
-               case LYX_VALIGN_TOP:
-                       attr << "top";
-                       break;
-               case LYX_VALIGN_BOTTOM:
-                       attr << "bottom";
-                       break;
-               case LYX_VALIGN_MIDDLE:
-                       attr << "middle";
-               }
-               attr << "'";
+               attr << "' " << getVAlignAsXmlAttribute(cell);
 
                if (isMultiColumn(cell))
                        attr << " colspan='" << columnSpan(cell) << "'";
diff --git a/src/insets/InsetTabular.h b/src/insets/InsetTabular.h
index 645da68..8420a48 100644
--- a/src/insets/InsetTabular.h
+++ b/src/insets/InsetTabular.h
@@ -946,6 +946,9 @@ public:
        docstring xhtmlRow(XMLStream & xs, row_type, OutputParams const &,
                           bool header = false) const;
 
+       /// Transforms the vertical alignment of the given cell as a prebaked 
XML attribute (for HTML and CALS).
+       std::string getVAlignAsXmlAttribute(idx_type cell) const;
+
        /// change associated Buffer
        void setBuffer(Buffer & buffer);
        /// retrieve associated Buffer
-- 
lyx-cvs mailing list
[email protected]
http://lists.lyx.org/mailman/listinfo/lyx-cvs

Reply via email to