TDE graphics utilities
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.

kpdocumentmetainfo.cpp 4.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. /*
  2. Copyright (c) 2003,2004,2005 Clarence Dang <dang@kde.org>
  3. All rights reserved.
  4. Redistribution and use in source and binary forms, with or without
  5. modification, are permitted provided that the following conditions
  6. are met:
  7. 1. Redistributions of source code must retain the above copyright
  8. notice, this list of conditions and the following disclaimer.
  9. 2. Redistributions in binary form must reproduce the above copyright
  10. notice, this list of conditions and the following disclaimer in the
  11. documentation and/or other materials provided with the distribution.
  12. THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
  13. IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  14. OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  15. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
  16. INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  17. NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  18. DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  19. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  20. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  21. THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  22. */
  23. #include <kpdocumentmetainfo.h>
  24. #include <tqpoint.h>
  25. #include <kdebug.h>
  26. struct kpDocumentMetaInfoPrivate
  27. {
  28. int m_dotsPerMeterX, m_dotsPerMeterY;
  29. TQPoint m_offset;
  30. TQMap <TQImageTextKeyLang, TQString> m_textMap;
  31. };
  32. // public
  33. kpDocumentMetaInfo::kpDocumentMetaInfo ()
  34. : d (new kpDocumentMetaInfoPrivate ())
  35. {
  36. d->m_dotsPerMeterX = 0;
  37. d->m_dotsPerMeterY = 0;
  38. d->m_offset = TQPoint (0, 0);
  39. }
  40. kpDocumentMetaInfo::kpDocumentMetaInfo (const kpDocumentMetaInfo &rhs)
  41. : d (new kpDocumentMetaInfoPrivate ())
  42. {
  43. d->m_dotsPerMeterX = rhs.dotsPerMeterX ();
  44. d->m_dotsPerMeterY = rhs.dotsPerMeterY ();
  45. d->m_offset = rhs.offset ();
  46. d->m_textMap = rhs.textMap ();
  47. }
  48. // public
  49. kpDocumentMetaInfo::~kpDocumentMetaInfo ()
  50. {
  51. delete d;
  52. }
  53. // public
  54. kpDocumentMetaInfo &kpDocumentMetaInfo::operator= (const kpDocumentMetaInfo &rhs)
  55. {
  56. d->m_dotsPerMeterX = rhs.dotsPerMeterX ();
  57. d->m_dotsPerMeterY = rhs.dotsPerMeterY ();
  58. d->m_offset = rhs.offset ();
  59. d->m_textMap = rhs.textMap ();
  60. return *this;
  61. }
  62. // public
  63. void kpDocumentMetaInfo::printDebug (const TQString &prefix) const
  64. {
  65. const TQString usedPrefix = !prefix.isEmpty () ?
  66. prefix + TQString::fromLatin1 (":") :
  67. TQString();
  68. kdDebug () << usedPrefix << endl;
  69. kdDebug () << "dotsPerMeter X=" << dotsPerMeterX ()
  70. << " Y=" << dotsPerMeterY ()
  71. << " offset=" << offset () << endl;
  72. TQValueList <TQImageTextKeyLang> keyList = textList ();
  73. for (TQValueList <TQImageTextKeyLang>::const_iterator it = keyList.begin ();
  74. it != keyList.end ();
  75. it++)
  76. {
  77. kdDebug () << "key=" << (*it).key.data()
  78. << " lang=" << (*it).lang.data()
  79. << " text=" << text (*it).ascii()
  80. << endl;
  81. }
  82. kdDebug () << usedPrefix << "ENDS" << endl;
  83. }
  84. // public
  85. int kpDocumentMetaInfo::dotsPerMeterX () const
  86. {
  87. return d->m_dotsPerMeterX;
  88. }
  89. // public
  90. void kpDocumentMetaInfo::setDotsPerMeterX (int val)
  91. {
  92. d->m_dotsPerMeterX = val;
  93. }
  94. // public
  95. int kpDocumentMetaInfo::dotsPerMeterY () const
  96. {
  97. return d->m_dotsPerMeterY;
  98. }
  99. // public
  100. void kpDocumentMetaInfo::setDotsPerMeterY (int val)
  101. {
  102. d->m_dotsPerMeterY = val;
  103. }
  104. // public
  105. TQPoint kpDocumentMetaInfo::offset () const
  106. {
  107. return d->m_offset;
  108. }
  109. // public
  110. void kpDocumentMetaInfo::setOffset (const TQPoint &point)
  111. {
  112. d->m_offset = point;
  113. }
  114. // public
  115. TQMap <TQImageTextKeyLang, TQString> kpDocumentMetaInfo::textMap () const
  116. {
  117. return d->m_textMap;
  118. }
  119. // public
  120. TQValueList <TQImageTextKeyLang> kpDocumentMetaInfo::textList () const
  121. {
  122. return d->m_textMap.keys ();
  123. }
  124. // public
  125. TQString kpDocumentMetaInfo::text (const TQImageTextKeyLang &itkl) const
  126. {
  127. return d->m_textMap [itkl];
  128. }
  129. // public
  130. TQString kpDocumentMetaInfo::text (const char *key, const char *lang) const
  131. {
  132. return text (TQImageTextKeyLang (key, lang));
  133. }
  134. // public
  135. void kpDocumentMetaInfo::setText (const TQImageTextKeyLang &itkl,
  136. const TQString &string)
  137. {
  138. d->m_textMap [itkl] = string;
  139. }
  140. // public
  141. void kpDocumentMetaInfo::setText (const char *key, const char *lang,
  142. const TQString &string)
  143. {
  144. setText (TQImageTextKeyLang (key, lang), string);
  145. }