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.

135 lines
4.1KB

  1. #include "conversion.h"
  2. #include <kdebug.h>
  3. #include <tdelocale.h>
  4. TQString Conversion::importAlignment( const TQString& align )
  5. {
  6. if ( align == "center" || align == "justify" )
  7. return align;
  8. if ( align == "start" )
  9. return "left";
  10. if ( align == "end" )
  11. return "right";
  12. kdWarning(30518) << "Conversion::importAlignment unknown alignment " << align << endl;
  13. return "auto";
  14. }
  15. TQString Conversion::exportAlignment( const TQString& align )
  16. {
  17. if ( align == "center" || align == "justify" )
  18. return align;
  19. if ( align == "left" || align == "auto" ) // auto handled by text-auto-align
  20. return "start";
  21. if ( align == "right" )
  22. return "end";
  23. kdWarning(30518) << "Conversion::exportAlignment unknown alignment " << align << endl;
  24. return "auto";
  25. }
  26. TQPair<int,TQString> Conversion::importWrapping( const TQString& oowrap )
  27. {
  28. if ( oowrap == "none" )
  29. // 'no wrap' means 'avoid horizontal space'
  30. return tqMakePair( 2, TQString() );
  31. if ( oowrap == "left" || oowrap == "right" )
  32. // Left and right, no problem
  33. return tqMakePair( 1, oowrap );
  34. if ( oowrap == "run-through" )
  35. return tqMakePair( 0, TQString() );
  36. if ( oowrap == "biggest" ) // OASIS extension
  37. return tqMakePair( 1, TQString::fromLatin1( "biggest" ) );
  38. ////if ( oowrap == "parallel" || oowrap == "dynamic" )
  39. // dynamic is called "optimal" in the OO GUI. It's different from biggest because it can lead to parallel.
  40. // Those are not supported in KWord, let's use biggest instead
  41. return tqMakePair( 1, TQString::fromLatin1( "biggest" ) );
  42. }
  43. TQString Conversion::exportWrapping( const TQPair<int,TQString>& runAroundAttribs )
  44. {
  45. switch( runAroundAttribs.first ) {
  46. case 0:
  47. return "run-through";
  48. case 1: // left, right, or biggest -> ok
  49. return runAroundAttribs.second;
  50. case 2:
  51. return "none";
  52. default:
  53. return "ERROR"; // ERROR
  54. }
  55. }
  56. int Conversion::importOverflowBehavior( const TQString& oasisOverflowBehavior )
  57. {
  58. if ( oasisOverflowBehavior == "auto-extend-frame" )
  59. return 0; // AutoExtendFrame
  60. if ( oasisOverflowBehavior == "auto-create-new-frame" )
  61. return 1; // AutoCreateNewFrame
  62. if ( oasisOverflowBehavior == "ignore" )
  63. return 2; // Ignore extra text
  64. kdWarning(30518) << "Invalid overflow behavior " << oasisOverflowBehavior << endl;
  65. return 0;
  66. }
  67. TQString Conversion::exportOverflowBehavior( const TQString& kwordAutoCreateNewFrame )
  68. {
  69. switch ( kwordAutoCreateNewFrame.toInt() ) {
  70. case 1:
  71. return "auto-create-new-frame";
  72. case 2:
  73. return "ignore";
  74. default:
  75. case 0:
  76. return "auto-extend-frame";
  77. }
  78. }
  79. int Conversion::importCounterType( const TQString& numFormat )
  80. {
  81. if ( numFormat == "1" )
  82. return 1;
  83. if ( numFormat == "a" )
  84. return 2;
  85. if ( numFormat == "A" )
  86. return 3;
  87. if ( numFormat == "i" )
  88. return 4;
  89. if ( numFormat == "I" )
  90. return 5;
  91. return 0;
  92. }
  93. TQString Conversion::headerTypeToFramesetName( const TQString& localName, bool hasEvenOdd )
  94. {
  95. if ( localName == "header" )
  96. return hasEvenOdd ? i18n("Odd Pages Header") : i18n( "Header" );
  97. if ( localName == "header-left" )
  98. return i18n("Even Pages Header");
  99. if ( localName == "footer" )
  100. return hasEvenOdd ? i18n("Odd Pages Footer") : i18n( "Footer" );
  101. if ( localName == "footer-left" )
  102. return i18n("Even Pages Footer");
  103. kdWarning(30518) << "Unknown tag in headerTypeToFramesetName: " << localName << endl;
  104. // ######
  105. //return i18n("First Page Header");
  106. //return i18n("First Page Footer");
  107. return TQString();
  108. }
  109. int Conversion::headerTypeToFrameInfo( const TQString& localName, bool /*hasEvenOdd*/ )
  110. {
  111. if ( localName == "header" )
  112. return 3; // odd headers
  113. if ( localName == "header-left" )
  114. return 2; // even headers
  115. if ( localName == "footer" )
  116. return 6; // odd footers
  117. if ( localName == "footer-left" )
  118. return 5; // even footers
  119. // ### return 1; // first header
  120. // ### return 4; // first footer
  121. return 0;
  122. }