SVN commit 681931 by zander: New test and fix for KWPageManger::pageNumber in combination with page-spreads. Introduce directionality in a page. Move the Direction enum from the paragStyle to the KoText namespace. M +3 -0 kword/part/KWPage.cpp M +8 -2 kword/part/KWPage.h M +2 -2 kword/part/KWPageManager.cpp M +2 -0 kword/part/frames/KWTextFrameSet.h M +11 -1 kword/part/frames/tests/CMakeLists.txt A kword/part/frames/tests/TestTextFrameSorting.cpp [License: no copyright] A kword/part/frames/tests/TestTextFrameSorting.h [License: no copyright] M +11 -0 libs/kotext/KoText.h M +7 -7 libs/kotext/styles/KoParagraphStyle.cpp M +2 -12 libs/kotext/styles/KoParagraphStyle.h --- trunk/koffice/kword/part/KWPage.cpp #681930:681931 @@ -21,6 +21,7 @@ #include "KoZoomHandler.h" #include +#include KWPage::KWPage(KWPageManager *parent, int pageNum) { m_parent = parent; @@ -35,6 +36,8 @@ m_pageLayout.bindingSide = -1.0; m_pageLayout.orientation = parent->m_defaultPageLayout.orientation; m_pageSide = pageNum%2==0 ? Left : Right; + + m_textDirectionHint = QApplication::isLeftToRight() ? KoText::LeftRightTopBottom : KoText::RightLeftTopBottom; } double KWPage::width() const { --- trunk/koffice/kword/part/KWPage.h #681930:681931 @@ -1,5 +1,5 @@ /* This file is part of the KOffice project - * Copyright (C) 2005 Thomas Zander + * Copyright (C) 2005, 2007 Thomas Zander * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public @@ -21,7 +21,9 @@ #include "KWPageManager.h" #include "KoPageLayout.h" -#include +#include "kword_export.h" + +#include #include class KoZoomHandler; @@ -143,6 +145,9 @@ */ KoPageFormat::Orientation orientationHint() const; + void setDirectionHint(KoText::Direction direction) { m_textDirectionHint = direction; } + KoText::Direction directionHint() const { return m_textDirectionHint; } + private: /** private constructor, only for our friends * @param parent the KWPageManager that we belong to. @@ -153,6 +158,7 @@ int m_pageNum; PageSide m_pageSide; KoPageLayout m_pageLayout; + KoText::Direction m_textDirectionHint; KWPageManager *m_parent; --- trunk/koffice/kword/part/KWPageManager.cpp #681930:681931 @@ -45,9 +45,9 @@ if(startOfpage >= point.y()) break; startOfpage += page->height(); - pageNumber++; + pageNumber = page->pageNumber(); } - return pageNumber-1; + return pageNumber; } int KWPageManager::pageNumber(const KoShape *shape) const { --- trunk/koffice/kword/part/frames/KWTextFrameSet.h #681930:681931 @@ -98,6 +98,7 @@ protected: friend class KWTextDocumentLayout; + friend class TestTextFrameSorting; void setupFrame(KWFrame *frame); /** * Call this to make it know that the text we want to layout needs more space to be shown fully. @@ -125,6 +126,7 @@ const KWPageManager *m_pageManager; const KWDocument *m_kwordDocument; + // return true if frame1 is sorted before frame2 static bool sortTextFrames(const KWFrame *frame1, const KWFrame *frame2); }; --- trunk/koffice/kword/part/frames/tests/CMakeLists.txt #681930:681931 @@ -4,7 +4,9 @@ add_definitions(-DCOMPILING_TESTS) include_directories( ${KOMAIN_INCLUDES} ${FLAKE_INCLUDES} ${KOTEXT_INCLUDES} ${KDE4_INCLUDES} - ${QT_INCLUDES} ${CMAKE_SOURCE_DIR}/kword/part ${CMAKE_SOURCE_DIR}/kword/part/frames) + ${QT_INCLUDES} ${CMAKE_SOURCE_DIR}/kword/part ${CMAKE_SOURCE_DIR}/kword/part/frames + ${CMAKE_SOURCE_DIR}/libs/flake/tests +) ########### next target ############### @@ -24,4 +26,12 @@ ########### next target ############### +set(TestTextFrameSorting_test_SRCS TestTextFrameSorting.cpp) +kde4_automoc(${TestTextFrameSorting_test_SRCS}) +kde4_add_executable(TestTextFrameSorting RUN_UNINSTALLED ${TestTextFrameSorting_test_SRCS}) +target_link_libraries(TestTextFrameSorting kwordprivate ${QT_QTTEST_LIBRARY}) +add_test(kword-part-frame-TestTextFrameSorting ${EXECUTABLE_OUTPUT_PATH}/TestTextFrameSorting) + +########### next target ############### + endif(KDE4_BUILD_TESTS) --- trunk/koffice/libs/kotext/KoText.h #681930:681931 @@ -59,6 +59,17 @@ bool operator==(const Tab &tab) const; }; + + /// Text in this object will be positioned according to the direction. + enum Direction { + AutoDirection, ///< Take the direction from the text. + LeftRightTopBottom, ///< Text layout for most western languages + RightLeftTopBottom, ///< Text layout for langauges like Hebrew + TopBottomRightLeft, ///< Vertical text layout. + PerhapsLeftRightTopBottom, + PerhapsRightLeftTopBottom + }; + } Q_DECLARE_METATYPE( KoText::Tab ) --- trunk/koffice/libs/kotext/styles/KoParagraphStyle.cpp #681930:681931 @@ -734,11 +734,11 @@ return KoListStyle(0); // an invalid one } -KoParagraphStyle::Direction KoParagraphStyle::textProgressionDirection() const { - return static_cast (propertyInt(TextProgressionDirection)); +KoText::Direction KoParagraphStyle::textProgressionDirection() const { + return static_cast (propertyInt(TextProgressionDirection)); } -void KoParagraphStyle::setTextProgressionDirection(KoParagraphStyle::Direction dir) { +void KoParagraphStyle::setTextProgressionDirection(KoText::Direction dir) { setProperty(TextProgressionDirection, dir); } @@ -749,13 +749,13 @@ // LTR is lr-tb. RTL is rl-tb QString writingMode = styleStack.property( KoXmlNS::style, "writing-mode" ); if(writingMode == "lr" || writingMode == "lr-tb") - setTextProgressionDirection(LeftRightTopBottom); + setTextProgressionDirection(KoText::LeftRightTopBottom); else if(writingMode == "rl" || writingMode == "rl-tb") - setTextProgressionDirection(RightLeftTopBottom); + setTextProgressionDirection(KoText::RightLeftTopBottom); else if(writingMode == "tb" || writingMode == "tb-rl") - setTextProgressionDirection(TopBottomRightLeft); + setTextProgressionDirection(KoText::TopBottomRightLeft); else - setTextProgressionDirection(AutoDirection); + setTextProgressionDirection(KoText::AutoDirection); } // Alignment --- trunk/koffice/libs/kotext/styles/KoParagraphStyle.h #681930:681931 @@ -125,16 +125,6 @@ BorderDashDotDotPattern }; - /// Text in this paragraph will be positioned according to the direction. - enum Direction { - AutoDirection, ///< Take the direction from the text. - LeftRightTopBottom, ///< Text layout for most western languages - RightLeftTopBottom, ///< Text layout for langauges like Hebrew - TopBottomRightLeft, ///< Vertical text layout. - PerhapsLeftRightTopBottom, - PerhapsRightLeftTopBottom - }; - /// Constructor KoParagraphStyle(); /// Copy constructor @@ -338,8 +328,8 @@ void setBottomBorderColor(const QColor& color); QColor bottomBorderColor(); - Direction textProgressionDirection() const; - void setTextProgressionDirection(Direction dir); + KoText::Direction textProgressionDirection() const; + void setTextProgressionDirection(KoText::Direction dir); // ************ properties from QTextBlockFormat /// duplicated property from QTextBlockFormat