[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:36
Message-ID: 20100829210236.2378EAC86C () svn ! kde ! org
[Download RAW message or body]

SVN commit 1169680 by zander:

Add and use KWChangePageStyleCommand

This new command is there to allow undo/redo of changing which
style a page follows.

 M  +1 -0      CMakeLists.txt  
 M  +10 -0     KWPageStyle.cpp  
 M  +5 -0      KWPageStyle.h  
 A             commands/KWChangePageStyleCommand.cpp   [License: LGPL (v2+)]
 A             commands/KWChangePageStyleCommand.h   [License: LGPL (v2+)]
 M  +12 -7     dialogs/KWPageSettingsDialog.cpp  


--- trunk/koffice/kword/part/CMakeLists.txt #1169679:1169680
@@ -67,6 +67,7 @@
     commands/KWCreateOutlineCommand.cpp
     commands/KWClipFrameCommand.cpp
     commands/KWRemoveFrameClipCommand.cpp
+    commands/KWChangePageStyleCommand.cpp
 )
 if( Soprano_FOUND )
     set(kwordprivate_LIB_SRCS ${kwordprivate_LIB_SRCS}
--- trunk/koffice/kword/part/KWPageStyle.cpp #1169679:1169680
@@ -435,6 +435,11 @@
     return d == other.d;
 }
 
+KWPageStylePrivate *KWPageStyle::priv()
+{
+    return d.data();
+}
+
 const KWPageStylePrivate *KWPageStyle::priv() const
 {
     return d.data();
@@ -454,3 +459,8 @@
 {
     return style.hash();
 }
+
+void KWPageStyle::detach()
+{
+    d.detach();
+}
--- trunk/koffice/kword/part/KWPageStyle.h #1169679:1169680
@@ -224,8 +224,13 @@
     inline bool operator!=(const KWPageStyle &other) const { return ! operator==(other); }
     uint hash() const;
 
+    /// internal
     const KWPageStylePrivate *priv() const;
+    /// internal
+    KWPageStylePrivate *priv();
 
+    void detach();
+
 private:
     QExplicitlySharedDataPointer<KWPageStylePrivate> d;
 };
--- trunk/koffice/kword/part/dialogs/KWPageSettingsDialog.cpp #1169679:1169680
@@ -18,10 +18,14 @@
  */
 
 #include "KWPageSettingsDialog.h"
+#include "KWPageStyle.h"
+#include "KWPageStyle_p.h"
 #include "KWDocumentColumns.h"
 
 #include <KWDocument.h>
 #include <commands/KWPagePropertiesCommand.h>
+#include <commands/KWNewPageStyleCommand.h>
+#include <commands/KWChangePageStyleCommand.h>
 
 //#include <KDebug>
 
@@ -85,13 +89,15 @@
 
 void KWPageSettingsDialog::accept()
 {
+    QUndoCommand *cmd = new QUndoCommand(i18n("Change Page Properties"));;
     // 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())
-        */
+        KWPageStyle newStyle = m_page.pageStyle();
+        newStyle.detach();
+        newStyle.priv()->name = QString("AutogeneratedStyle%1").arg(m_page.pageNumber());
+        Q_ASSERT(newStyle.name() != m_page.pageStyle().name());
+        new KWNewPageStyleCommand(m_document, newStyle, cmd);
+        new KWChangePageStyleCommand(m_page, newStyle, cmd);
     }
 
     KoText::Direction newDir = textDirection();
@@ -107,8 +113,7 @@
         // 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());
+    new KWPagePropertiesCommand(m_document, m_page, lay, newDir, m_columns->columns(), cmd);
     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