xlsxrichstring.h 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. /****************************************************************************
  2. ** Copyright (c) 2013-2014 Debao Zhang <hello@debao.me>
  3. ** All right reserved.
  4. **
  5. ** Permission is hereby granted, free of charge, to any person obtaining
  6. ** a copy of this software and associated documentation files (the
  7. ** "Software"), to deal in the Software without restriction, including
  8. ** without limitation the rights to use, copy, modify, merge, publish,
  9. ** distribute, sublicense, and/or sell copies of the Software, and to
  10. ** permit persons to whom the Software is furnished to do so, subject to
  11. ** the following conditions:
  12. **
  13. ** The above copyright notice and this permission notice shall be
  14. ** included in all copies or substantial portions of the Software.
  15. **
  16. ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  17. ** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  18. ** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  19. ** NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  20. ** LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  21. ** OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  22. ** WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  23. **
  24. ****************************************************************************/
  25. #ifndef XLSXRICHSTRING_H
  26. #define XLSXRICHSTRING_H
  27. #include "xlsxglobal.h"
  28. #include "xlsxformat.h"
  29. #include <QVariant>
  30. #include <QStringList>
  31. #include <QSharedDataPointer>
  32. QT_BEGIN_NAMESPACE_XLSX
  33. class RichStringPrivate;
  34. class RichString;
  35. // qHash is a friend, but we can't use default arguments for friends (§8.3.6.4)
  36. uint qHash(const RichString &rs, uint seed = 0) Q_DECL_NOTHROW;
  37. class RichString
  38. {
  39. public:
  40. RichString();
  41. explicit RichString(const QString& text);
  42. RichString(const RichString &other);
  43. ~RichString();
  44. bool isRichString() const;
  45. bool isNull() const;
  46. bool isEmtpy() const;
  47. QString toPlainString() const;
  48. QString toHtml() const;
  49. void setHtml(const QString &text);
  50. int fragmentCount() const;
  51. void addFragment(const QString &text, const Format &format);
  52. QString fragmentText(int index) const;
  53. Format fragmentFormat(int index) const;
  54. operator QVariant() const;
  55. RichString &operator=(const RichString &other);
  56. private:
  57. friend uint qHash(const RichString &rs, uint seed) Q_DECL_NOTHROW;
  58. friend bool operator==(const RichString &rs1, const RichString &rs2);
  59. friend bool operator!=(const RichString &rs1, const RichString &rs2);
  60. friend bool operator<(const RichString &rs1, const RichString &rs2);
  61. friend QDebug operator<<(QDebug dbg, const RichString &rs);
  62. QSharedDataPointer<RichStringPrivate> d;
  63. };
  64. bool operator==(const RichString &rs1, const RichString &rs2);
  65. bool operator!=(const RichString &rs1, const RichString &rs2);
  66. bool operator<(const RichString &rs1, const RichString &rs2);
  67. bool operator==(const RichString &rs1, const QString &rs2);
  68. bool operator==(const QString &rs1, const RichString &rs2);
  69. bool operator!=(const RichString &rs1, const QString &rs2);
  70. bool operator!=(const QString &rs1, const RichString &rs2);
  71. #ifndef QT_NO_DEBUG_STREAM
  72. QDebug operator<<(QDebug dbg, const RichString &rs);
  73. #endif
  74. QT_END_NAMESPACE_XLSX
  75. Q_DECLARE_METATYPE(QXlsx::RichString)
  76. #endif // XLSXRICHSTRING_H