[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: koffice
From: Sebastian Sauer <mail () dipe ! org>
Date: 2008-08-23 19:08:18
Message-ID: 1219518498.637455.22534.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 851479 by sebsauer:
made text:select-page=previous
M +2 -2 kword/part/KWDocument.h
M +15 -1 kword/part/frames/KWTextDocumentLayout.cpp
M +11 -1 libs/kotext/KoTextShapeData.cpp
M +28 -4 libs/kotext/KoTextShapeData.h
M +28 -11 plugins/variables/PageVariable.cpp
M +2 -1 plugins/variables/PageVariable.h
--- trunk/koffice/kword/part/KWDocument.h #851478:851479
@@ -78,7 +78,7 @@
/// reimplemented from KoDocument
KoView* createViewInstance(QWidget*);
/// reimplemented from KoDocument
- virtual int pageCount() const { pageManager()->pageCount(); }
+ virtual int pageCount() const { return pageManager()->pageCount(); }
// others
/**
@@ -88,7 +88,7 @@
/**
* Return the pageManager used in this document.
*/
- KWPageManager *pageManager() { return &m_pageManager; }
+ Q_SCRIPTABLE KWPageManager *pageManager() { return &m_pageManager; }
/// @return the data center map for this document.
QMap<QString, KoDataCenter *> dataCenterMap() { return m_dataCenterMap; }
--- trunk/koffice/kword/part/frames/KWTextDocumentLayout.cpp #851478:851479
@@ -410,8 +410,22 @@
KoTextShapeData *data = dynamic_cast<KoTextShapeData*> \
(currentShape->userData()); Q_ASSERT(data);
if(page) {
- data->setPageNumber( page->pageNumber() );
data->setPageDirection( page->directionHint() );
+
+ int pagenumber = page->pageNumber();
+ switch( data->pageNumberSelectType() ) {
+ case KoTextShapeData::PageNumberSelectPagePrev: // Select \
the "previous" page + if( KWPage* p = page->previous() )
+ pagenumber = p->pageNumber();
+ break;
+ case KoTextShapeData::PageNumberSelectPageNext: // Select \
the "next" page + if( KWPage* p = page->next() )
+ pagenumber = p->pageNumber();
+ break;
+ case KoTextShapeData::PageNumberSelectPageCurrent: // Select \
the "current" page, This is the default. + break;
+ }
+ data->setPageNumber( pagenumber );
}
}
}
--- trunk/koffice/libs/kotext/KoTextShapeData.cpp #851478:851479
@@ -57,7 +57,8 @@
position(-1),
endPosition(-1),
pageNumber(-1),
- direction(KoText::AutoDirection)
+ direction(KoText::AutoDirection),
+ pageNumberSelectType(KoTextShapeData::PageNumberSelectPageCurrent)
{
}
@@ -72,6 +73,7 @@
int position, endPosition, pageNumber;
KoInsets margins;
KoText::Direction direction;
+ PageNumberSelectType pageNumberSelectType;
};
@@ -171,6 +173,14 @@
return d->direction;
}
+KoTextShapeData::PageNumberSelectType KoTextShapeData::pageNumberSelectType() const \
{ + return d->pageNumberSelectType;
+}
+
+void KoTextShapeData::setPageNumberSelectType(KoTextShapeData::PageNumberSelectType \
selecttype) { + d->pageNumberSelectType = selecttype;
+}
+
bool KoTextShapeData::loadOdf(const KoXmlElement & element, KoShapeLoadingContext & \
context) { KoTextLoader loader( context );
--- trunk/koffice/libs/kotext/KoTextShapeData.h #851478:851479
@@ -96,7 +96,7 @@
/// mark shape as dirty triggering a re-layout of its text.
void foul();
-
+
/// mark shape as not-dirty
void wipe();
@@ -113,8 +113,9 @@
* @param margins the margins that shrink the text area.
*/
void setShapeMargins(const KoInsets &margins);
-
- /// returns the currently set margins for the shape.
+ /**
+ * returns the currently set margins for the shape.
+ */
KoInsets shapeMargins() const;
/**
@@ -127,6 +128,29 @@
int pageNumber() const;
/**
+ * Display Previous or Following Page Numbers. The PageNumberSelectType \
represents + * the text:select-page attribute which is used to display the number \
of the previous + * or the following page rather than the number of the current \
page. + *
+ * \note To display the current page number on all pages except the first or \
last + * page, use a combination of the text:select page and text:page adjust \
attributes. + *
+ * Example: Displaying the current page number on all pages except the first \
page + * \code
+ * <text:page-number text:select-page="previous" text:page-adjust="1" \
style:num-format="1"/> + * \endcode
+ */
+ enum PageNumberSelectType {
+ PageNumberSelectPageCurrent, ///< Select the "current" page.
+ PageNumberSelectPagePrev, ///< Select the "previous" page.
+ PageNumberSelectPageNext ///< Select the "next" page.
+ };
+ /// Returns the text:select-page value.
+ PageNumberSelectType pageNumberSelectType() const;
+ /// Sets the text:select-page value.
+ void setPageNumberSelectType(PageNumberSelectType selecttype);
+
+ /**
* Load the TextShape from ODF.
*
* @see the @a TextShape::loadOdf() method which calls this method.
@@ -134,7 +158,6 @@
* to load the ODF.
*/
bool loadOdf(const KoXmlElement & element, KoShapeLoadingContext & context);
-
/**
* Store the TextShape data as ODF.
* @param saveDefaultStyles If set to false, the default styles won't be saved. \
This way, you can have several @@ -155,6 +178,7 @@
* new paragraphs default direction.
*/
KoText::Direction pageDirection() const;
+
signals:
/**
* emitted when the shape thinks it should be relayouted, for example after
--- trunk/koffice/plugins/variables/PageVariable.cpp #851478:851479
@@ -25,7 +25,6 @@
#include <KoXmlWriter.h>
#include <KoProperties.h>
#include <kdebug.h>
-#include <KoTextShapeData.h>
#include <KoShape.h>
#include <KoShapeSavingContext.h>
#include <KoShapeLoadingContext.h>
@@ -35,6 +34,7 @@
: KoVariable(true),
m_type(PageCount),
m_pageadjust(0),
+ m_selectpage(KoTextShapeData::PageNumberSelectPageCurrent),
m_fixed(false)
{
}
@@ -66,18 +66,12 @@
case PageCount:
break;
case PageNumber:
- if (shape && ! m_fixed) {
+ if (shape && ( !m_fixed || value().isNull() )) {
KoTextShapeData *shapeData = dynamic_cast<KoTextShapeData \
*>(shape->userData()); if (shapeData) {
+ shapeData->setPageNumberSelectType(m_selectpage);
int pagenumber = shapeData->pageNumber();
- if(m_selectpage == "previous") {
- //TODO fetch prev page and use that pagenum
- }
- else if(m_selectpage == "next") {
- //TODO fetch next page and use that pagenum
- }
-
setValue(QString::number(pagenumber + m_pageadjust + 1));
}
}
@@ -98,11 +92,25 @@
case PageNumber:
// <text:page-number text:select-page="current" >3</text:page-number>
writer->startElement("text:page-number", false);
- writer->addAttribute("text:select-page", m_selectpage.isEmpty() ? \
"current" : m_selectpage); +
+ switch(m_selectpage) {
+ case KoTextShapeData::PageNumberSelectPagePrev:
+ writer->addAttribute("text:select-page", "previous");
+ break;
+ case KoTextShapeData::PageNumberSelectPageNext:
+ writer->addAttribute("text:select-page", "next");
+ break;
+ case KoTextShapeData::PageNumberSelectPageCurrent:
+ writer->addAttribute("text:select-page", "current");
+ break;
+ }
+
if(m_pageadjust != 0)
writer->addAttribute("text:page-adjust", m_pageadjust);
+
if(m_fixed)
writer->addAttribute("text:fixed", "true");
+
writer->addTextNode(value());
writer->endElement();
break;
@@ -126,7 +134,16 @@
// The text:select-page attribute is used to display the number of the \
previous or the following // page rather than the number of the current page.
- m_selectpage = element.attributeNS( KoXmlNS::text, "select-page", QString() \
); + QString selectpage = element.attributeNS( KoXmlNS::text, "select-page", \
QString() ); + if(selectpage == "previous") {
+ m_selectpage = KoTextShapeData::PageNumberSelectPagePrev;
+ }
+ else if(selectpage == "next") {
+ m_selectpage = KoTextShapeData::PageNumberSelectPageNext;
+ }
+ else {
+ m_selectpage = KoTextShapeData::PageNumberSelectPageCurrent;
+ }
// The text:fixed attribute specifies whether or not the value of a field \
element is fixed. If the
// value of a field is fixed, the value of the field element to which this \
attribute is attached is
--- trunk/koffice/plugins/variables/PageVariable.h #851478:851479
@@ -22,6 +22,7 @@
#define PAGEVARIABLE_H
#include <KoVariable.h>
+#include <KoTextShapeData.h>
class KoShapeSavingContext;
@@ -56,7 +57,7 @@
PageType m_type;
int m_pageadjust;
- QString m_selectpage;
+ KoTextShapeData::PageNumberSelectType m_selectpage;
bool m_fixed;
};
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic