+// This method requires a previous call to ComputeBidiTables()
+bool LyXText::IsBoundary(LyXParagraph * par, LyXParagraph::size_type pos) const
+{
+ if (!lyxrc.rtl_support)
+ return false; // This is just for speedup
+
+ if (!bidi_InRange(pos - 1) ||
+ (par->table && par->IsNewline(pos-1)) )
+ return false;
+
+ bool rtl = bidi_level(pos - 1) % 2;
+ bool rtl2 = rtl;
+ if (pos == par->Last() ||
+ (par->table && par->IsNewline(pos)))
+ rtl2 = par->isRightToLeftPar();
+ else if (bidi_InRange(pos))
+ rtl2 = bidi_level(pos) % 2;
+ return rtl != rtl2;
+}
+
+bool LyXText::IsBoundary(LyXParagraph * par, LyXParagraph::size_type pos,
+ LyXFont const & font) const
+{
+ if (!lyxrc.rtl_support)
+ return false; // This is just for speedup
+
+ bool rtl = font.isVisibleRightToLeft();
+ bool rtl2 = rtl;
+ if (pos == par->Last() ||
+ (par->table && par->IsNewline(pos)))
+ rtl2 = par->isRightToLeftPar();
+ else if (bidi_InRange(pos))
+ rtl2 = bidi_level(pos) % 2;
+ return rtl != rtl2;
+}
+
+