4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
7 * \author Lars Gullik Bjønnes
8 * \author Matthias Ettrich
10 * \author Jürgen Vigna
11 * \author Edwin Leuven
13 * \author Scott Kostyshak
15 * Full author contact details are available in file CREDITS.
18 // Things to think of when designing the new tabular support:
19 // - color support (colortbl, color)
20 // - decimal alignment (dcloumn)
21 // - custom lines (hhline)
24 #ifndef INSET_TABULAR_H
25 #define INSET_TABULAR_H
27 #include "BufferParams.h"
29 #include "InsetText.h"
31 #include "support/Length.h"
32 #include "support/types.h"
54 class InsetTableCell : public InsetText
58 explicit InsetTableCell(Buffer * buf);
59 /// We need this since generation of the default is deprecated
60 /// (since we declare the assignment constuctor below).
61 InsetTableCell(InsetTableCell const & in) = default;
63 InsetCode lyxCode() const override { return CELL_CODE; }
65 Inset * clone() const override { return new InsetTableCell(*this); }
67 bool getStatus(Cursor & cur, FuncRequest const & cmd,
68 FuncStatus & status) const override;
70 void toggleFixedWidth(bool fw) { isFixedWidth = fw; }
72 void toggleVarWidth(bool vw) { isVarwidth = vw; }
74 void toggleMultiCol(bool m) { isMultiColumn = m; }
76 void toggleMultiRow(bool m) { isMultiRow = m; }
78 void setContentAlignment(LyXAlignment al) { contentAlign = al; }
79 /// writes the contents of the cell as a string, optionally
80 /// descending into insets
81 docstring asString(bool intoInsets = true);
83 docstring xhtml(XMLStream &, OutputParams const &) const override;
85 void docbook(XMLStream &, OutputParams const &) const override;
87 void addToToc(DocIterator const & di, bool output_active,
88 UpdateType utype, TocBackend & backend) const override;
90 void metrics(MetricsInfo &, Dimension &) const override;
91 /// Needs to be same as InsetTabular
92 bool inheritFont() const override { return false; }
93 /// Can the cell contain several paragraphs?
94 bool allowMultiPar() const override { return !isMultiRow && (!isMultiColumn || isFixedWidth); }
96 bool canPaintChange(BufferView const &) const override { return false; }
97 /// This assures we never output \maketitle in table cells
98 bool isInTitle() const override { return true; }
101 InsetTableCell() = delete;
103 void operator=(InsetTableCell const &) = delete;
105 // These booleans are supposed to track whether the cell has had its
106 // width explicitly set and whether it is part of a multicolumn, respectively.
107 // We need to know this to determine whether
108 // layout changes and paragraph customization are allowed---that is,
109 // we need it in forcePlainLayout() and allowParagraphCustomization().
110 // Unfortunately, that information is not readily available in
111 // InsetTableCell. In the case of multicolumn cells, it is present
112 // in CellData, and so would be available here if CellData were to
113 // become a member of InsetTableCell. But in the other case, it isn't
114 // even available there, but is held in Tabular::ColumnData.
115 // So, the present solution uses this boolean to track the information
116 // we need to track, and tries to keep it updated. This is not ideal,
117 // but the other solutions are no better. These are:
118 // (i) Keep a pointer in InsetTableCell to the table;
119 // (ii) Find the table by iterating over the Buffer's insets.
120 // Solution (i) raises the problem of updating the pointer when an
121 // InsetTableCell is copied, and we'd therefore need a copy constructor
122 // in InsetTabular and then in Tabular, which seems messy, given how
123 // complicated those classes are. Solution (ii) involves a lot of
124 // iterating, since this information is needed quite often, and so may
126 // So, well, if someone can do better, please do!
136 // FIXME: Here the thoughts from the comment above also apply.
138 LyXAlignment contentAlign;
139 /// should paragraph indentation be omitted in any case?
140 bool neverIndent() const override { return true; }
142 LyXAlignment contentAlignment() const override { return contentAlign; }
144 bool usePlainLayout() const override { return true; }
146 bool allowParagraphCustomization(idx_type = 0) const override;
148 bool forceLocalFontSwitch() const override;
149 /// Is the width forced to some value?
150 bool hasFixedWidth() const override { return isFixedWidth; }
155 // A helper struct for tables
258 RESET_FORMAL_DEFAULT,
272 TOGGLE_VARWIDTH_COLUMN,
276 UNSET_ROTATE_TABULAR,
278 TOGGLE_ROTATE_TABULAR,
311 SET_SPECIAL_MULTICOLUMN,
329 TABULAR_VALIGN_MIDDLE,
331 TABULAR_VALIGN_BOTTOM,
333 LONGTABULAR_ALIGN_LEFT,
335 LONGTABULAR_ALIGN_CENTER,
337 LONGTABULAR_ALIGN_RIGHT,
358 CELL_BEGIN_OF_MULTICOLUMN,
360 CELL_PART_OF_MULTICOLUMN,
362 CELL_BEGIN_OF_MULTIROW,
364 CELL_PART_OF_MULTIROW
372 LYX_VALIGN_MIDDLE = 1,
374 LYX_VALIGN_BOTTOM = 2
380 LYX_LONGTABULAR_ALIGN_LEFT = 0,
382 LYX_LONGTABULAR_ALIGN_CENTER = 1,
384 LYX_LONGTABULAR_ALIGN_RIGHT = 2
425 // we have this header type (is set in the getLT... functions)
427 // double borders on top
429 // double borders on bottom
431 // used for FirstHeader & LastFooter and if this is true
432 // all the rows marked as FirstHeader or LastFooter are
433 // ignored in the output and it is set to be empty!
437 /// index indicating an invalid position
438 static const idx_type npos = static_cast<idx_type>(-1);
441 Tabular(Buffer * buf, col_type columns_arg, row_type rows_arg);
443 /// Returns true if there is a topline, returns false if not
444 bool topLine(idx_type cell) const;
445 /// Returns true if there is a topline, returns false if not
446 bool bottomLine(idx_type cell) const;
447 /// Returns true if there is a topline, returns false if not
448 /// If \p ignore_bt is true, we return the state as if booktabs was
450 bool leftLine(idx_type cell, bool const ignore_bt = false) const;
451 /// Returns true if there is a topline, returns false if not
452 /// If \p ignore_bt is true, we return the state as if booktabs was
454 bool rightLine(idx_type cell, bool const ignore_bt = false) const;
455 /// Returns true if there is an outside border around the selection
456 bool outsideBorders(row_type sel_row_start, row_type sel_row_end,
457 col_type sel_col_start, col_type sel_col_end) const;
458 /// Returns true if there are inside lines in the selection
459 bool innerBorders(row_type sel_row_start, row_type sel_row_end,
460 col_type sel_col_start, col_type sel_col_end) const;
461 /// Sets the grid lines in the selection
462 /// if \p setLinesInnerOnly is true, outside borders are excluded
463 /// if \p setLines is true the lines are set otherwise they are unset
464 void setLines(row_type const sel_row_start, row_type const sel_row_end,
465 col_type const sel_col_start, col_type const sel_col_end,
466 bool setLinesInnerOnly, bool setLines);
467 /// Returns whether the top line is trimmed left and/or right
468 std::pair<bool, bool> topLineTrim(idx_type const cell) const;
469 /// Returns whether the bottom line is trimmed left and/or right
470 std::pair<bool, bool> bottomLineTrim(idx_type const cell) const;
472 /// return space occupied by the second horizontal line and
473 /// interline space above row \p row in pixels
474 int interRowSpace(row_type row) const;
476 int interColumnSpace(idx_type cell) const;
478 /* returns the maximum over all rows */
480 int cellWidth(idx_type cell) const;
482 int cellHeight(idx_type cell) const;
488 row_type nrows() const {return row_info.size();}
490 col_type ncols() const {return column_info.size();}
492 int rowAscent(row_type row) const;
494 int rowDescent(row_type row) const;
496 void setRowAscent(row_type row, int height);
498 void setRowDescent(row_type row, int height);
500 void setTopLine(idx_type cell, bool line);
502 void setBottomLine(idx_type cell, bool line);
504 void setTopLineLTrim(idx_type cell, bool val);
506 void setBottomLineLTrim(idx_type cell, bool val);
508 void setTopLineRTrim(idx_type cell, bool val);
510 void setBottomLineRTrim(idx_type cell, bool val);
512 void setTopLineTrim(idx_type cell, std::pair<bool, bool>);
514 void setBottomLineTrim(idx_type cell, std::pair<bool, bool>);
516 void setLeftLine(idx_type cell, bool line);
518 void setRightLine(idx_type cell, bool line);
520 bool rowTopLine(row_type row) const;
522 bool rowBottomLine(row_type row) const;
524 bool columnLeftLine(col_type column) const;
526 bool columnRightLine(col_type column) const;
528 void setAlignment(idx_type cell, LyXAlignment align,
529 bool onlycolumn = false);
531 void setVAlignment(idx_type cell, VAlignment align,
532 bool onlycolumn = false);
534 void setTabularWidth(Length const & l) { tabular_width = l; }
536 Length tabularWidth() const { return tabular_width; }
538 void setColumnPWidth(Cursor &, idx_type, Length const &);
540 bool setMColumnPWidth(Cursor &, idx_type, Length const &);
542 bool toggleVarwidth(idx_type, bool const);
544 bool setMROffset(Cursor &, idx_type, Length const &);
546 void setAlignSpecial(idx_type cell, docstring const & special,
549 LyXAlignment getAlignment(idx_type cell,
550 bool onlycolumn = false) const;
552 VAlignment getVAlignment(idx_type cell,
553 bool onlycolumn = false) const;
554 /// The vertical offset of the table due to the vertical
555 /// alignment with respect to the baseline.
556 int offsetVAlignment() const;
558 Length const getPWidth(idx_type cell) const;
560 Length const getMROffset(idx_type cell) const;
562 int textHOffset(idx_type cell) const;
564 int textVOffset(idx_type cell) const;
566 void appendRow(row_type row);
568 void deleteRow(row_type row, bool const force = false);
570 void copyRow(row_type row);
572 void insertRow(row_type row, bool copy);
574 void moveColumn(col_type col_start, col_type col_end,
575 ColDirection direction);
577 void moveRow(row_type row_start, row_type row_end,
578 RowDirection direction);
580 void appendColumn(col_type column);
582 void deleteColumn(col_type column, bool const force = false);
584 void copyColumn(col_type column);
586 void insertColumn(col_type column, bool copy);
588 idx_type getFirstCellInRow(row_type row, bool const ct = false) const;
590 idx_type getLastCellInRow(row_type row, bool const ct = false) const;
592 idx_type getFirstRow(bool const ct = false) const;
594 idx_type getLastRow(bool const ct = false) const;
596 idx_type numberOfCellsInRow(row_type row) const;
598 void write(std::ostream &) const;
602 void latex(otexstream &, OutputParams const &) const;
603 /// serialise the table in DocBook, according to buffer parameters
604 void docbook(XMLStream &, OutputParams const &) const;
606 docstring xhtml(XMLStream &, OutputParams const &) const;
608 void plaintext(odocstringstream &,
609 OutputParams const & runparams, int const depth,
610 bool onlydata, char_type delim, size_t max_length = INT_MAX) const;
612 bool isMultiColumn(idx_type cell) const;
614 bool hasMultiColumn(col_type cell) const;
616 bool hasVarwidthColumn() const;
618 bool isVTypeColumn(col_type cell) const;
620 idx_type setMultiColumn(Cursor & cur, idx_type cell, idx_type number,
621 bool const right_border);
623 void unsetMultiColumn(idx_type cell);
625 bool isPartOfMultiColumn(row_type row, col_type column) const;
627 bool isPartOfMultiRow(row_type row, col_type column) const;
629 bool isMultiRow(idx_type cell) const;
631 bool hasMultiRow(row_type r) const;
633 idx_type setMultiRow(Cursor & cur, idx_type cell, idx_type number,
634 bool const bottom_border,
635 LyXAlignment const halign);
637 void unsetMultiRow(idx_type cell);
639 row_type cellRow(idx_type cell) const;
641 col_type cellColumn(idx_type cell) const;
643 void setRotateCell(idx_type cell, int);
645 int getRotateCell(idx_type cell) const;
647 bool needRotating() const;
649 bool isLastCell(idx_type cell) const;
651 idx_type cellAbove(idx_type cell) const;
653 idx_type cellBelow(idx_type cell) const;
654 /// \return the index of the VISIBLE cell at row, column
655 /// this will be the same as the cell in the previous row,
656 /// e.g., if the cell is part of a multirow
657 idx_type cellIndex(row_type row, col_type column) const;
659 void setUsebox(idx_type cell, BoxType);
661 BoxType getUsebox(idx_type cell) const;
663 // Long Tabular Options support functions
665 void setLTHead(row_type row, bool flag, ltType const &, bool first);
667 bool getRowOfLTHead(row_type row, ltType &) const;
669 bool getRowOfLTFirstHead(row_type row, ltType &) const;
671 void setLTFoot(row_type row, bool flag, ltType const &, bool last);
673 bool getRowOfLTFoot(row_type row, ltType &) const;
675 bool getRowOfLTLastFoot(row_type row, ltType &) const;
677 void setLTNewPage(row_type row, bool what);
679 bool getLTNewPage(row_type row) const;
681 idx_type setLTCaption(Cursor & cur, row_type row, bool what);
683 bool ltCaption(row_type row) const;
685 bool haveLTHead(bool withcaptions = true) const;
687 bool haveLTFirstHead(bool withcaptions = true) const;
689 bool haveLTFoot(bool withcaptions = true) const;
691 bool haveLTLastFoot(bool withcaptions = true) const;
693 bool haveLTCaption(CaptionType captiontype = CAPTION_ANY) const;
695 // end longtable support
698 /// there is a subtle difference between these two methods.
701 /// cellInset(cellIndex(r,c));
702 /// can return different things. this is because cellIndex(r,c)
703 /// returns the VISIBLE cell at r,c, which may be the same as the
704 /// cell at the previous row or column, if we're dealing with some
705 /// multirow or multicell.
706 std::shared_ptr<InsetTableCell> cellInset(idx_type cell);
707 std::shared_ptr<InsetTableCell> cellInset(row_type row, col_type column);
708 InsetTableCell const * cellInset(idx_type cell) const;
711 void setCellInset(row_type row, col_type column,
712 std::shared_ptr<InsetTableCell>);
713 /// Search for \param inset in the tabular, with the
715 void validate(LaTeXFeatures &) const;
718 // FIXME Now that cells have an InsetTableCell as their insets, rather
719 // than an InsetText, it'd be possible to reverse the relationship here,
720 // so that cell_vector was a vector<InsetTableCell> rather than a
721 // vector<CellData>, and an InsetTableCell had a CellData as a member,
722 // or perhaps just had its members as members.
727 explicit CellData(Buffer *);
729 CellData(CellData const &);
731 CellData & operator=(CellData const &);
743 LyXAlignment alignment;
745 VAlignment valignment;
746 /// width of the part before the decimal
748 /// width of the decimal part
761 bool top_line_rtrimmed;
763 bool top_line_ltrimmed;
765 bool bottom_line_rtrimmed;
767 bool bottom_line_ltrimmed;
773 docstring align_special;
775 Length p_width; // this is only set for multicolumn!!!
777 std::shared_ptr<InsetTableCell> inset;
780 CellData const & cellInfo(idx_type cell) const;
782 CellData & cellInfo(idx_type cell);
784 typedef std::vector<CellData> cell_vector;
786 typedef std::vector<cell_vector> cell_vvector;
797 /// Extra space between the top line and this row
799 /// Ignore top_space if true and use the default top space
800 bool top_space_default;
801 /// Extra space between this row and the bottom line
803 /// Ignore bottom_space if true and use the default bottom space
804 bool bottom_space_default;
805 /// Extra space between the bottom line and the next top line
806 Length interline_space;
807 /// Ignore interline_space if true and use the default interline space
808 bool interline_space_default;
809 /// This are for longtabulars only
812 /// a row of endfirsthead
816 /// row of endlastfoot
818 /// row for a newpage
826 typedef std::vector<RowData> row_vector;
834 LyXAlignment alignment;
836 VAlignment valignment;
842 docstring align_special;
844 docstring decimal_point;
851 typedef std::vector<ColumnData> column_vector;
854 // Determines the style of borders, per row.
855 class XmlRowWiseBorders {
857 // Whether to draw double bottom line.
858 bool completeBorder = true;
860 // Whether to draw booktabs' thicker lines.
861 bool completeBorderAbove = true;
862 bool completeBorderBelow = true;
864 // Size of the borders.
865 double borderBottomWidth = 1.0;
866 double borderBottomWidthComplete = 3.0;
867 double borderTopWidth = 1.0;
872 idx_type numberofcells;
874 std::vector<row_type> rowofcell;
876 std::vector<col_type> columnofcell;
880 column_vector column_info;
882 cell_vvector cell_info;
884 Length tabular_width;
890 VAlignment tabular_valignment;
894 HAlignment longtabular_alignment;
896 bool is_long_tabular;
899 /// endfirsthead data
907 void init(Buffer *, row_type rows_arg,
908 col_type columns_arg);
910 void updateIndexes();
912 bool setFixedWidth(row_type r, col_type c);
913 /// return true of update is needed
914 bool updateColumnWidths(MetricsInfo & mi);
916 idx_type columnSpan(idx_type cell) const;
918 idx_type rowSpan(idx_type cell) const;
920 BoxType useBox(idx_type cell) const;
922 bool isValidRow(row_type const row) const;
924 void TeXRow(otexstream &, row_type const row,
925 OutputParams const &, std::list<col_type>, std::list<col_type>) const;
927 /// change associated Buffer
928 void setBuffer(Buffer & buffer);
929 /// retrieve associated Buffer
930 Buffer const & buffer() const { return *buffer_; }
931 /// retrieve associated Buffer
932 Buffer & buffer() { return *buffer_; }
938 // helper function for DocBook
940 /// Determines whether the tabular item should be generated as DocBook or XHTML.
941 enum class XmlOutputFormat : bool {
946 /// Transforms the vertical alignment of the given cell as a prebaked XML attribute (for HTML and CALS).
947 std::string getHAlignAsXmlAttribute(idx_type cell, XmlOutputFormat output_format) const;
948 /// Transforms the vertical alignment of the given cell as a prebaked XML attribute (for HTML and CALS).
949 std::string getVAlignAsXmlAttribute(idx_type cell) const;
951 /// Helpers for XML tables (XHTML or DocBook).
952 docstring xmlRow(XMLStream & xs, row_type row, OutputParams const &,
953 bool header, XmlOutputFormat output_format,
954 BufferParams::TableOutput docbook_table_output = BufferParams::TableOutput::HTMLTable) const;
955 void xmlHeader(XMLStream & xs, OutputParams const &, XmlOutputFormat output_format) const;
956 void xmlFooter(XMLStream & xs, OutputParams const &, XmlOutputFormat output_format) const;
957 void xmlBody(XMLStream & xs, OutputParams const &, XmlOutputFormat output_format) const;
958 XmlRowWiseBorders computeXmlBorders(row_type row) const;
959 std::vector<std::string> computeCssStylePerCell(row_type row, col_type col, idx_type cell) const;
962 // helper functions for plain text
964 bool plaintextTopHLine(odocstringstream &, row_type row,
965 std::vector<unsigned int> const &) const;
967 bool plaintextBottomHLine(odocstringstream &, row_type row,
968 std::vector<unsigned int> const &) const;
970 void plaintextPrintCell(odocstringstream &,
971 OutputParams const &,
972 idx_type cell, row_type row, col_type column,
973 std::vector<unsigned int> const &,
974 bool onlydata, size_t max_length) const;
977 // helper function for LaTeX
979 void TeXTopHLine(otexstream &, row_type row, std::list<col_type>,
980 std::list<col_type>) const;
982 void TeXBottomHLine(otexstream &, row_type row, std::list<col_type>,
983 std::list<col_type>) const;
985 void TeXCellPreamble(otexstream &, idx_type cell, bool & ismulticol, bool & ismultirow,
986 bool const bidi) const;
988 void TeXCellPostamble(otexstream &, idx_type cell, bool ismulticol, bool ismultirow) const;
990 void TeXLongtableHeaderFooter(otexstream &, OutputParams const &, std::list<col_type>,
991 std::list<col_type>) const;
996 class InsetTabular : public Inset
1000 InsetTabular(Buffer *, row_type rows = 1,
1001 col_type columns = 1);
1005 void setBuffer(Buffer & buffer) override;
1008 static void string2params(std::string const &, InsetTabular &);
1010 static std::string params2string(InsetTabular const &);
1012 void read(Lexer &) override;
1014 void write(std::ostream &) const override;
1016 void metrics(MetricsInfo &, Dimension &) const override;
1018 void draw(PainterInfo & pi, int x, int y) const override;
1020 void drawSelection(PainterInfo & pi, int x, int y) const override;
1022 void drawBackground(PainterInfo & pi, int x, int y) const override;
1024 bool editable() const override { return true; }
1026 bool hasSettings() const override { return true; }
1028 bool insetAllowed(InsetCode code) const override;
1030 bool allowSpellCheck() const override { return true; }
1032 bool canTrackChanges() const override { return true; }
1034 bool canPaintChange(BufferView const &) const override { return true; }
1036 bool inheritFont() const override { return false; }
1038 bool allowMultiPar() const override;
1040 bool allowsCaptionVariation(std::string const &) const override;
1042 bool isTable() const override { return true; }
1044 int rowFlags() const override;
1046 void latex(otexstream &, OutputParams const &) const override;
1048 int plaintext(odocstringstream & ods, OutputParams const & op,
1049 size_t max_length = INT_MAX) const override;
1051 void docbook(XMLStream &, OutputParams const &) const override;
1053 docstring xhtml(XMLStream &, OutputParams const &) const override;
1055 void validate(LaTeXFeatures & features) const override;
1057 InsetCode lyxCode() const override { return TABULAR_CODE; }
1059 std::string contextMenu(BufferView const &, int, int) const override;
1061 std::string contextMenuName() const override;
1062 /// get offset of this cursor slice relative to our upper left corner
1063 void cursorPos(BufferView const & bv, CursorSlice const & sl,
1064 bool boundary, int & x, int & y) const override;
1065 /// Executes a space-separated sequence of tabular-features requests
1066 void tabularFeatures(Cursor & cur, std::string const & what);
1067 /// Change a single tabular feature; does not handle undo.
1068 void tabularFeatures(Cursor & cur, Tabular::Feature feature,
1069 std::string const & val = std::string());
1071 size_t nargs() const override { return tabular.numberofcells; }
1073 std::shared_ptr<InsetTableCell const> cell(idx_type) const;
1075 std::shared_ptr<InsetTableCell> cell(idx_type);
1077 Text * getText(int) const override;
1079 /// does the inset contain changes ?
1080 bool isChanged() const override;
1081 /// set the change for the entire inset
1082 void setChange(Change const & change) override;
1083 /// accept the changes within the inset
1084 void acceptChanges() override;
1085 /// reject the changes within the inset
1086 void rejectChanges() override;
1088 // this should return true if we have a "normal" cell, otherwise false.
1089 // "normal" means without width set!
1090 /// should all paragraphs be output with "Standard" layout?
1091 bool allowParagraphCustomization(idx_type cell = 0) const override;
1093 void addPreview(DocIterator const & inset_pos,
1094 graphics::PreviewLoader &) const override;
1096 /// lock cell with given index
1097 void edit(Cursor & cur, bool front, EntryDirection entry_from) override;
1098 /// get table row from x coordinate
1099 int rowFromY(Cursor & cur, int y) const;
1100 /// get table column from y coordinate
1101 int columnFromX(Cursor & cur, int x) const;
1103 Inset * editXY(Cursor & cur, int x, int y) override;
1104 /// can we go further down on mouse click?
1105 bool descendable(BufferView const &) const override { return true; }
1106 /// Update the counters of this inset and of its contents
1107 void updateBuffer(ParIterator const &, UpdateType, bool const deleted = false) override;
1109 void addToToc(DocIterator const & di, bool output_active,
1110 UpdateType utype, TocBackend & backend) const override;
1113 bool completionSupported(Cursor const &) const override;
1115 bool inlineCompletionSupported(Cursor const & cur) const override;
1117 bool automaticInlineCompletion() const override;
1119 bool automaticPopupCompletion() const override;
1121 bool showCompletionCursor() const override;
1123 CompletionList const * createCompletionList(Cursor const & cur) const override;
1125 docstring completionPrefix(Cursor const & cur) const override;
1127 bool insertCompletion(Cursor & cur, docstring const & s, bool finished) override;
1129 void completionPosAndDim(Cursor const &, int & x, int & y, Dimension & dim) const override;
1131 bool usePlainLayout() const override { return true; }
1133 docstring layoutName() const override { return from_ascii("Tabular"); }
1137 InsetTabular * asInsetTabular() override { return this; }
1139 InsetTabular const * asInsetTabular() const override { return this; }
1141 bool isRightToLeft(Cursor & cur) const;
1142 /// writes the cells between stidx and enidx as a string, optionally
1143 /// descending into the insets
1144 docstring asString(idx_type stidx, idx_type enidx, bool intoInsets = true);
1146 ParagraphList asParList(idx_type stidx, idx_type enidx);
1148 /// Returns whether the cell in the specified row and column is selected.
1149 bool isCellSelected(Cursor & cur, row_type row, col_type col) const;
1151 void setLayoutForHiddenCells(DocumentClass const & dc);
1153 // Public structures and variables
1155 mutable Tabular tabular;
1159 InsetTabular(InsetTabular const &);
1161 void doDispatch(Cursor & cur, FuncRequest & cmd) override;
1163 bool getFeatureStatus(Cursor & cur, std::string const & s,
1164 std::string const & argument, FuncStatus & status) const;
1166 bool getStatus(Cursor & cur, FuncRequest const & cmd, FuncStatus &) const override;
1168 Inset * clone() const override { return new InsetTabular(*this); }
1171 bool hitSelectRow(BufferView const & bv, int x) const;
1173 bool hitSelectColumn(BufferView const & bv, int y) const;
1174 /// Returns true if coordinates are on row/column selection zones
1175 bool clickable(BufferView const &, int x, int y) const override;
1178 void drawCellLines(PainterInfo &, int x, int y, row_type row,
1179 idx_type cell) const;
1181 void setCursorFromCoordinates(Cursor & cur, int x, int y) const;
1184 void moveNextCell(Cursor & cur,
1185 EntryDirection entry_from = ENTRY_DIRECTION_IGNORE);
1187 void movePrevCell(Cursor & cur,
1188 EntryDirection entry_from = ENTRY_DIRECTION_IGNORE);
1190 int cellXPos(idx_type cell) const;
1192 int cellYPos(idx_type cell) const;
1194 bool copySelection(Cursor & cur);
1196 bool pasteClipboard(Cursor & cur);
1198 void cutSelection(Cursor & cur);
1200 void getSelection(Cursor & cur, row_type & rs, row_type & re,
1201 col_type & cs, col_type & ce) const;
1203 bool insertPlaintextString(BufferView &, docstring const & buf, bool usePaste);
1205 /// return the "Manhattan distance" to nearest corner
1206 int dist(BufferView &, idx_type cell, int x, int y) const;
1207 /// return the cell nearest to x, y
1208 idx_type getNearestCell(BufferView &, int x, int y) const;
1210 /// test the rotation state of the given cell range.
1211 bool oneCellHasRotationState(bool rotated,
1212 row_type row_start, row_type row_end,
1213 col_type col_start, col_type col_end) const;
1215 /// true when selecting rows with the mouse
1217 /// true when selecting columns with the mouse
1221 std::string const featureAsString(Tabular::Feature feature);
1223 /// Split cell on decimal symbol
1224 InsetTableCell splitCell(InsetTableCell & head, docstring const & decimal_sym, bool & hassep);
1228 #endif // INSET_TABULAR_H