diff --git a/ico/32x32/simplifyrichtext.png b/ico/32x32/simplifyrichtext.png new file mode 100644 index 000000000..e251cf7b9 Binary files /dev/null and b/ico/32x32/simplifyrichtext.png differ diff --git a/qelectrotech.qrc b/qelectrotech.qrc index 64bd3cf9c..117c83ad8 100644 --- a/qelectrotech.qrc +++ b/qelectrotech.qrc @@ -227,5 +227,6 @@ ico/22x22/applications-development-translation.png ico/48x48/view-pim-journal.png ico/24x16/nl.png + ico/32x32/simplifyrichtext.png diff --git a/sources/richtext/richtexteditor.cpp b/sources/richtext/richtexteditor.cpp index e7739265f..fa5e8eeaa 100644 --- a/sources/richtext/richtexteditor.cpp +++ b/sources/richtext/richtexteditor.cpp @@ -53,9 +53,9 @@ #include #include #include -#include -#include -#include +#include +#include +#include #include #include @@ -78,10 +78,103 @@ QT_BEGIN_NAMESPACE -//static const char *RichTextDialogC = "RichTextDialog"; -//static const char *Geometry = "Geometry"; +static const char RichTextDialogGroupC[] = "RichTextDialog"; +static const char GeometryKeyC[] = "Geometry"; +static const char TabKeyC[] = "Tab"; + +const bool simplifyRichTextDefault = true; namespace qdesigner_internal { + // Richtext simplification filter helpers: Elements to be discarded + static inline bool filterElement(const QStringRef &name) + { + return name != QLatin1String("meta") && name != QLatin1String("style"); + } + + // Richtext simplification filter helpers: Filter attributes of elements + static inline void filterAttributes(const QStringRef &name, + QXmlStreamAttributes *atts, + bool *paragraphAlignmentFound) + { + typedef QXmlStreamAttributes::iterator AttributeIt; + + if (atts->isEmpty()) + return; + + // No style attributes for + if (name == QLatin1String("body")) { + atts->clear(); + return; + } + + // Clean out everything except 'align' for 'p' + if (name == QLatin1String("p")) { + for (AttributeIt it = atts->begin(); it != atts->end(); ) { + if (it->name() == QLatin1String("align")) { + ++it; + *paragraphAlignmentFound = true; + } else { + it = atts->erase(it); + } + } + return; + } + } + + // Richtext simplification filter helpers: Check for blank QStringRef. + static inline bool isWhiteSpace(const QStringRef &in) + { + const int count = in.size(); + for (int i = 0; i < count; i++) + if (!in.at(i).isSpace()) + return false; + return true; + } + + // Richtext simplification filter: Remove hard-coded font settings, + //