mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-09 18:31:04 +00:00
parent
cd4d54f76a
commit
d7ba7bceb3
13
config/qt.m4
13
config/qt.m4
@ -28,10 +28,10 @@ AC_DEFUN([QT_CHECK_COMPILE],
|
|||||||
qt_guilibs="'-lQtCore -lQtGui' '-lQtCore4 -lQtGui4'"
|
qt_guilibs="'-lQtCore -lQtGui' '-lQtCore4 -lQtGui4'"
|
||||||
if test $USE_QT6 = "yes" ; then
|
if test $USE_QT6 = "yes" ; then
|
||||||
qt_corelibs="-lQt6Core"
|
qt_corelibs="-lQt6Core"
|
||||||
qt_guilibs="-lQt6Core -lQt6Concurrent -lQt6Gui -lQt6Svg -lQt6Xml -lQt6Widgets"
|
qt_guilibs="-lQt6Core -lQt6Concurrent -lQt6Gui -lQt6Svg -lQt6Widgets"
|
||||||
else
|
else
|
||||||
qt_corelibs="-lQt5Core"
|
qt_corelibs="-lQt5Core"
|
||||||
qt_guilibs="-lQt5Core -lQt5Concurrent -lQt5Gui -lQt5Svg -lQt5Xml -lQt5Widgets"
|
qt_guilibs="-lQt5Core -lQt5Concurrent -lQt5Gui -lQt5Svg -lQt5Widgets"
|
||||||
fi
|
fi
|
||||||
for libname in $qt_corelibs '-framework QtCore'
|
for libname in $qt_corelibs '-framework QtCore'
|
||||||
do
|
do
|
||||||
@ -43,8 +43,8 @@ AC_DEFUN([QT_CHECK_COMPILE],
|
|||||||
done
|
done
|
||||||
qt_cv_libname=
|
qt_cv_libname=
|
||||||
for libname in $qt_guilibs \
|
for libname in $qt_guilibs \
|
||||||
'-framework QtCore -framework QtConcurrent -framework QtSvg -framework QtXml -framework QtWidgets -framework QtMacExtras -framework QtGui'\
|
'-framework QtCore -framework QtConcurrent -framework QtSvg -framework QtWidgets -framework QtMacExtras -framework QtGui'\
|
||||||
'-framework QtCore -framework QtConcurrent -framework QtSvg -framework QtSvgWidgets -framework QtXml -framework QtWidgets -framework QtGui'\
|
'-framework QtCore -framework QtConcurrent -framework QtSvg -framework QtSvgWidgets -framework QtWidgets -framework QtGui'\
|
||||||
'-framework QtCore -framework QtGui'
|
'-framework QtCore -framework QtGui'
|
||||||
do
|
do
|
||||||
QT_TRY_LINK($libname)
|
QT_TRY_LINK($libname)
|
||||||
@ -264,7 +264,7 @@ AC_DEFUN([QT_DO_PKG_CONFIG],
|
|||||||
export PKG_CONFIG_PATH
|
export PKG_CONFIG_PATH
|
||||||
fi
|
fi
|
||||||
qt_corelibs="Qt5Core"
|
qt_corelibs="Qt5Core"
|
||||||
qt_guilibs="Qt5Core Qt5Concurrent Qt5Gui Qt5Svg Qt5Widgets Qt5Xml"
|
qt_guilibs="Qt5Core Qt5Concurrent Qt5Gui Qt5Svg Qt5Widgets"
|
||||||
lyx_use_x11extras=false
|
lyx_use_x11extras=false
|
||||||
PKG_CHECK_EXISTS(Qt5X11Extras, [lyx_use_x11extras=true], [])
|
PKG_CHECK_EXISTS(Qt5X11Extras, [lyx_use_x11extras=true], [])
|
||||||
if $lyx_use_x11extras; then
|
if $lyx_use_x11extras; then
|
||||||
@ -339,7 +339,7 @@ AC_DEFUN([QT_DO_MANUAL_CONFIG],
|
|||||||
QT_CORE_LDFLAGS=
|
QT_CORE_LDFLAGS=
|
||||||
if test -n "$qt_cv_includes"; then
|
if test -n "$qt_cv_includes"; then
|
||||||
QT_INCLUDES="-I$qt_cv_includes"
|
QT_INCLUDES="-I$qt_cv_includes"
|
||||||
for i in Qt QtCore QtGui QtWidgets QtSvg QtConcurrent QtSvgWidgets QtXml QtMacExtras; do
|
for i in Qt QtCore QtGui QtWidgets QtSvg QtConcurrent QtSvgWidgets QtMacExtras; do
|
||||||
QT_INCLUDES="$QT_INCLUDES -I$qt_cv_includes/$i"
|
QT_INCLUDES="$QT_INCLUDES -I$qt_cv_includes/$i"
|
||||||
if test "$lyx_use_packaging" = "macosx" ; then
|
if test "$lyx_use_packaging" = "macosx" ; then
|
||||||
QT_INCLUDES="$QT_INCLUDES -I$qt_cv_libraries/${i}.framework/Headers"
|
QT_INCLUDES="$QT_INCLUDES -I$qt_cv_libraries/${i}.framework/Headers"
|
||||||
@ -435,7 +435,6 @@ qtHaveModule(concurrent) {QT += concurrent} else {MISSING += concurrent}
|
|||||||
qtHaveModule(gui) {QT += gui} else {MISSING += gui}
|
qtHaveModule(gui) {QT += gui} else {MISSING += gui}
|
||||||
qtHaveModule(gui-private) {QT += gui-private} else {MISSING += gui-private}
|
qtHaveModule(gui-private) {QT += gui-private} else {MISSING += gui-private}
|
||||||
qtHaveModule(svg) {QT += svg} else {MISSING += svg}
|
qtHaveModule(svg) {QT += svg} else {MISSING += svg}
|
||||||
qtHaveModule(xml) {QT += xml} else {MISSING += xml}
|
|
||||||
qtHaveModule(widgets) {QT += widgets} else {MISSING += widgets}
|
qtHaveModule(widgets) {QT += widgets} else {MISSING += widgets}
|
||||||
EOF2
|
EOF2
|
||||||
if test "$qt_major" = 6; then
|
if test "$qt_major" = 6; then
|
||||||
|
@ -28,10 +28,6 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <ostream>
|
#include <ostream>
|
||||||
|
|
||||||
#include <QtXml/QDomDocument>
|
|
||||||
#include <QtXml/QDomElement>
|
|
||||||
#include "support/qstring_helpers.h"
|
|
||||||
|
|
||||||
using namespace lyx::support;
|
using namespace lyx::support;
|
||||||
|
|
||||||
namespace lyx {
|
namespace lyx {
|
||||||
@ -66,10 +62,6 @@ namespace {
|
|||||||
void splitAndWrapInMText(MathMLStream & ms, MathData const & cell,
|
void splitAndWrapInMText(MathMLStream & ms, MathData const & cell,
|
||||||
const std::string & attributes)
|
const std::string & attributes)
|
||||||
{
|
{
|
||||||
// The goal of this function is to take an XML fragment and wrap
|
|
||||||
// anything that is outside of any tag in <mtext></mtext> tags,
|
|
||||||
// then wrap the whole thing in an <mrow></mrow> tag with attributes
|
|
||||||
|
|
||||||
// First, generate the inset into a string of its own.
|
// First, generate the inset into a string of its own.
|
||||||
docstring inset_contents;
|
docstring inset_contents;
|
||||||
{
|
{
|
||||||
@ -82,46 +74,53 @@ void splitAndWrapInMText(MathMLStream & ms, MathData const & cell,
|
|||||||
inset_contents = ostmp.str();
|
inset_contents = ostmp.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
// We use the QT XML library. It's easier if we deal with an XML "document"
|
// No tags are allowed within <m:mtext>: split the string if there are tags.
|
||||||
// rather than "fragment", so we wrap it in a fake root node (which we will
|
std::vector<docstring> parts;
|
||||||
// remove at the end).
|
while (true) {
|
||||||
docstring inset_contents_xml = "<root>" + inset_contents + "</root>";
|
std::size_t angle_pos = inset_contents.find('<');
|
||||||
|
if (angle_pos == docstring::npos)
|
||||||
|
break;
|
||||||
|
|
||||||
// Parse the XML into a DOM
|
// String structure:
|
||||||
QDomDocument xml;
|
// - prefix: pure text, no tag
|
||||||
xml.setContent(toqstr(inset_contents_xml));
|
// - tag to split: something like <m:mn>1</m:mn> or more complicated
|
||||||
|
// (like nested tags), with or without name space
|
||||||
|
// - rest to be taken care of in the next iteration
|
||||||
|
|
||||||
QDomElement docElem = xml.documentElement();
|
// Push the part before the tag.
|
||||||
|
parts.emplace_back(inset_contents.substr(0, angle_pos));
|
||||||
|
inset_contents = inset_contents.substr(angle_pos);
|
||||||
|
// Now, inset_contents starts with the tag to isolate, so that
|
||||||
|
// inset_contents[0] == '<'
|
||||||
|
|
||||||
// Iterate through the children of our fake root element.
|
// Push the tag, up to its end. Process: find the tag name (either
|
||||||
QDomNode n = docElem.firstChild();
|
// before > or the first attribute of the tag), then the matching end
|
||||||
while (!n.isNull()) {
|
// tag, then proceed with pushing.
|
||||||
// try to convert the child into a text element
|
const std::size_t tag_name_end =
|
||||||
// (i.e. some text that is outside of an XML tag)
|
std::min(inset_contents.find(' ', 1), inset_contents.find('>', 1));
|
||||||
QDomText text = n.toText();
|
const std::size_t tag_name_length = tag_name_end - 1;
|
||||||
if (!text.isNull()) {
|
const docstring tag_name = inset_contents.substr(1, tag_name_length);
|
||||||
// if the result is not null, then the child was indeed
|
|
||||||
// bare text, so we need to wrap it in mtext tags
|
|
||||||
// make an mtext element
|
|
||||||
QDomElement wrapper = xml.createElement(toqstr(ms.namespacedTag("mtext")));
|
|
||||||
// put the mtext element in the document right before the text
|
|
||||||
docElem.insertBefore(wrapper,n);
|
|
||||||
// move the text node inside the mtext element (this has the side
|
|
||||||
// effect of removing it from where it was as a child of the root)
|
|
||||||
wrapper.appendChild(n);
|
|
||||||
n = wrapper.nextSibling();
|
|
||||||
} else {
|
|
||||||
// if the text is null, then we have something besides a text
|
|
||||||
// element (i.e. a tag), so we don't need to do anything and just
|
|
||||||
// move onto the next child
|
|
||||||
n = n.nextSibling();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ms << MTag("mrow", attributes);
|
const std::size_t end_tag_start =
|
||||||
docstring interior = qstring_to_ucs4(xml.toString(-1));
|
inset_contents.find(tag_name, tag_name_end + 1);
|
||||||
ms << interior.substr(6,interior.length()-13); // chop off the initial <root> and final </root> tags
|
const std::size_t end_tag = inset_contents.find('>', end_tag_start);
|
||||||
ms << ETag("mrow");
|
|
||||||
|
parts.emplace_back(inset_contents.substr(0, end_tag + 1));
|
||||||
|
inset_contents = inset_contents.substr(end_tag + 1);
|
||||||
|
}
|
||||||
|
parts.emplace_back(inset_contents);
|
||||||
|
|
||||||
|
// Finally, output the complete inset: escape the test in <m:mtext>, leave
|
||||||
|
// the other tags untouched.
|
||||||
|
ms << MTag("mrow", attributes);
|
||||||
|
for (std::size_t i = 0; i < parts.size(); i += 2) {
|
||||||
|
ms << MTag("mtext")
|
||||||
|
<< parts[i]
|
||||||
|
<< ETag("mtext");
|
||||||
|
if (parts.size() > i + 1)
|
||||||
|
ms << parts[i + 1];
|
||||||
|
}
|
||||||
|
ms << ETag("mrow");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user