[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    koffice/kword/part
From:       Thomas Zander <zander () kde ! org>
Date:       2010-08-29 21:02:30
Message-ID: 20100829210230.1AAF4AC879 () svn ! kde ! org
[Download RAW message or body]

SVN commit 1169678 by zander:

Make the KWPageSetttingsDialog more complete

The dialog uses the style when it can instead of the current
page so the first page in a page-spread doc (which can't be a
pagespread since only even numbered pages can be such) no
longer is marked as a non-page-spread style.

 M  +5 -1      KWPageStyle.cpp  
 M  +3 -0      KWPageStyle.h  
 M  +2 -1      commands/KWPagePropertiesCommand.h  
 M  +55 -10    dialogs/KWPageSettingsDialog.cpp  


--- trunk/koffice/kword/part/KWPageStyle.cpp #1169677:1169678
@@ -445,8 +445,12 @@
     return ((uint) d) + 1;
 }
 
+bool KWPageStyle::isPageSpread() const
+{
+    return d->pageLayout.leftMargin < 0;
+}
+
 uint qHash(const KWPageStyle &style)
 {
     return style.hash();
 }
-
--- trunk/koffice/kword/part/KWPageStyle.h #1169677:1169678
@@ -186,6 +186,9 @@
     /// return the pageLayout applied for these pages
     KoPageLayout pageLayout() const;
 
+    /// return true if pages of this style can turn into page-spreads
+    bool isPageSpread() const;
+
     /// set the pageLayout applied for these pages
     void setPageLayout(const KoPageLayout &layout);
 
--- trunk/koffice/kword/part/commands/KWPagePropertiesCommand.h #1169677:1169678
@@ -33,7 +33,8 @@
 
 /**
  * The undo / redo command for changing the properties of a KWPage
- * When altering the size of a page this command will also reposition all required \
frames to account for the changes. + * When altering the size of a page this command \
will also reposition all required + * frames to account for the changes.
  */
 class KWORD_TEST_EXPORT KWPagePropertiesCommand : public QUndoCommand
 {
--- trunk/koffice/kword/part/dialogs/KWPageSettingsDialog.cpp #1169677:1169678
@@ -23,8 +23,6 @@
 #include <KWDocument.h>
 #include <commands/KWPagePropertiesCommand.h>
 
-#include <QTimer>
-
 //#include <KDebug>
 
 KWPageSettingsDialog::KWPageSettingsDialog(QWidget *parent, KWDocument *document, \
const KWPage &page) @@ -34,20 +32,68 @@
 {
     Q_ASSERT(document);
     Q_ASSERT(page.isValid());
+    m_columns = new KWDocumentColumns(this, m_page.pageStyle().columns());
+    addPage(m_columns, i18n("Columns"));
+    showPageSpread(true);
+    showTextDirection(true); // TODO can we hide this in selected usecases? Use the \
resource manager bidi-check maybe? +    //showApplyToDocument(true); // TODO \
uncommand when we can handle it.  
-    showPageSpread(true);
+    bool simpleSetup = document->pageCount() == 1
+            || (document->pageCount() == 2 && page.pageSide() == \
KWPage::PageSpread); +    if (!simpleSetup) { // if there is one style, its still a \
simple doc +        bool onlyOneStyle = true;
+        foreach (const KWPage &p, document->pageManager()->pages()) {
+            if (p.pageStyle() != m_page.pageStyle()) {
+                onlyOneStyle = false;
+                break;
+            }
+        }
+        if (onlyOneStyle)
+            simpleSetup = true;
+    }
+
+    if (simpleSetup) {
+        /*
+          Simple setup means we have currently exactly one page style; so the common \
usecase +          is that that one will be changed, and it will apply to all pages \
in the document. +          Lets make that usecase as simple and as straight forward \
as possible +
+          Notice that if the user unchecks the "apply to document' checkbox we will \
automatically +          switch to the not simple setup and use page styles.
+         */
+        KWPageStyle pageStyle = m_page.pageStyle();
+        setPageSpread(pageStyle.isPageSpread());
+        setTextDirection(pageStyle.direction());
+    }
+    else {
+        /*
+          The document is already not simple anymore; there is more than one page \
style +          in use. We should show that fact and the user is allowed to use the \
power of +          page styles.
+         */
     setPageSpread(m_page.pageSide() == KWPage::PageSpread);
     setTextDirection(m_page.directionHint());
 
-    m_columns = new KWDocumentColumns(this, m_page.pageStyle().columns());
-    addPage(m_columns, i18n("Columns"));
+        /* TODO
+        fill the styles combobox and please be smart about it with an auto-generated
+        style being named after the pages its assigned to.
+        Make sure the current page style is the first entry.
+
+        */
 }
+}
 
 void KWPageSettingsDialog::accept()
 {
-    if (applyToDocument()) { // rename to section
-        // TODO
-    } else {
+    // TODO rename 'applyToDocument' to 'onlyThisPage'
+    if (!applyToDocument()) {
+        /* TODO
+            use new command to create a new page style
+           clone the current page' page style.
+           use new command to change a page to get a new style. (i.e. \
setPageStyle()) +        */
+    }
+
         KoText::Direction newDir = textDirection();
         KoPageLayout lay = pageLayout();
         if (lay.pageEdge >= 0 || lay.bindingSide >= 0) {
@@ -57,14 +103,13 @@
             Q_ASSERT(lay.leftMargin == -1);
             Q_ASSERT(lay.rightMargin == -1);
 
-            // its a page spread, which kword can handle, so we can savely set the
+        // its a page spread, which kword can handle, so we can safely set the
             // normal page size and assume that the page object will do the right \
thing  lay.width /= (qreal) 2;
         }
         KWPagePropertiesCommand *cmd = new KWPagePropertiesCommand(m_document, \
m_page,  lay, newDir, m_columns->columns());
         m_document->addCommand(cmd);
-    }
 
     KoPageLayoutDialog::accept();
 }


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic