KOffice – TDE office suite
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

100 lines
3.3KB

  1. /* This file is part of the KDE project
  2. Copyright 2004 Laurent Montel <montel@kde.org>
  3. This library is free software; you can redistribute it and/or
  4. modify it under the terms of the GNU Library General Public
  5. License as published by the Free Software Foundation; either
  6. version 2 of the License, or (at your option) any later version.
  7. This library is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  10. Library General Public License for more details.
  11. You should have received a copy of the GNU Library General Public License
  12. along with this library; see the file COPYING.LIB. If not, write to
  13. the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  14. * Boston, MA 02110-1301, USA.
  15. */
  16. #ifndef KSPREAD_GENVALIDATIONSTYLE
  17. #define KSPREAD_GENVALIDATIONSTYLE
  18. #include <tqdict.h>
  19. #include <tqmap.h>
  20. class KoXmlWriter;
  21. namespace KSpread
  22. {
  23. class Validity;
  24. class GenValidationStyle;
  25. class GenValidationStyles
  26. {
  27. public:
  28. GenValidationStyles();
  29. ~GenValidationStyles();
  30. TQString lookup( const GenValidationStyle& style );
  31. typedef TQMap<GenValidationStyle, TQString> StyleMap;
  32. void writeStyle( KoXmlWriter& writer );
  33. private:
  34. TQString makeUniqueName( const TQString& base ) const;
  35. /// style definition -> name
  36. StyleMap m_styles;
  37. /// name -> style (used to check for name uniqueness)
  38. typedef TQMap<TQString, bool> NameMap;
  39. NameMap m_names;
  40. };
  41. class GenValidationStyle
  42. {
  43. public:
  44. explicit GenValidationStyle(Validity *_val=0) { initVal( _val ); }
  45. bool operator<( const GenValidationStyle &other ) const {
  46. if ( allowEmptyCell != other.allowEmptyCell ) return ( allowEmptyCell < other.allowEmptyCell );
  47. if ( condition != other.condition ) return ( condition < other.condition );
  48. if ( titleInfo != other.titleInfo ) return ( titleInfo < other.titleInfo );
  49. if ( displayValidationInformation != other.displayValidationInformation ) return ( displayValidationInformation < other.displayValidationInformation );
  50. if ( messageInfo != other.messageInfo ) return ( messageInfo < other.messageInfo );
  51. if ( messageType != other.messageType ) return ( messageType < other.messageType );
  52. if ( displayMessage != other.displayMessage ) return ( displayMessage < other.displayMessage );
  53. if ( message != other.message ) return ( message < other.message );
  54. if ( title != other.title ) return ( title < other.title );
  55. return false;
  56. }
  57. private:
  58. TQString createValidationCondition( Validity* _val );
  59. TQString createTextValidationCondition( Validity* _val );
  60. TQString createTimeValidationCondition( Validity* _val );
  61. TQString createDateValidationCondition( Validity* _val );
  62. TQString createNumberValidationCondition( Validity* _val );
  63. TQString createListValidationCondition( Validity* _val );
  64. void initVal( Validity *_val );
  65. TQString allowEmptyCell;
  66. TQString condition;
  67. TQString titleInfo;
  68. TQString displayValidationInformation;
  69. TQString messageInfo;
  70. TQString messageType;
  71. TQString displayMessage;
  72. TQString message;
  73. TQString title;
  74. friend class GenValidationStyles;
  75. };
  76. } // namespace KSpread
  77. #endif