View Issue Details

IDProjectCategoryView StatusLast Update
0007812ScribusInternalpublic2018-04-30 13:22
Reporterivro Assigned To 
PrioritynormalSeveritytweakReproducibilityN/A
Status acknowledgedResolutionopen 
Product Version1.3.5svn 
Summary0007812: [PATCH] Some source documentation patches
DescriptionHello,

I would like to use Scribus to make book with vertical layout. I find that
scribus can't handle this (yet). As I have some scales in programming, I said
to myself why not doing it.

I start by trying to modify the code to allow scribus to accept vertical
layout, but I stop in the mood as I find difficult to understand all the code
usage (especially variable).
I revert all my changes and start to look deep into the code. In my trip, I
slowly understand more and more about scribus internal, and to remember to
myself what I've find I write some code documentation.

Are you interested by this kind of contributions ?
If yes can you give me some feedback ?

I'm a French so my English is not perfect, but I'll like to correct it. I've
add some questions in the code (look at the comments starting by //ivro:) I
will be pleased If you find time to answer them.

Do you prefer Javadoc or Qt style documentation marks ?
For now, I use Qt style with autobrief mode. (I find it more readable for one variable - one line description, mostly). Are you okay with this ?


You can contact me at ivro@ymail.fr or ivro on freenode.

Bye
TagsNo tags attached.
PatchYes

Activities

2009-02-21 19:06

 

scribusdoc.h (55,998 bytes)   
/*
For general Scribus (>=1.3.2) copyright and licensing information please refer
to the COPYING file provided with the program. Following this notice may exist
a copyright and/or license notice that predates the release of Scribus 1.3.2
for which a new license (GPL+exception) is in place.
*/
/*!*************************************************************************
                          scribusdoc.h  -  description
                             -------------------
    begin                : Fre Apr  6 21:47:55 CEST 2001
    copyright            : (C) 2001 by Franz Schmid
    email                : Franz.Schmid@altmuehlnet.de
 ***************************************************************************/

/*!*************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/
#ifndef SCRIBUSDOC_H
#define SCRIBUSDOC_H
#ifdef HAVE_CONFIG_H
#include "scconfig.h"
#endif
// include files for QT
#include <QColor>
#include <QFont>
#include <QList>
#include <QMap>
#include <QObject>
#include <QPixmap>
#include <QRectF>
#include <QStringList>
#include <QTimer>


#include "gtgettext.h" //CB For the ImportSetup struct and itemadduserframe
#include "scribusapi.h"
#include "observable.h"
#include "prefsstructs.h"
#include "documentinformation.h"
#include "undoobject.h"
#include "page.h"
#include "pageitem.h"
#include "pagestructs.h"
#include "usertaskstructs.h"
#include "styles/styleset.h"
#include "scguardedptr.h"
#include "updatemanager.h"
#include "sclayer.h"

#include CMS_INC

#include <ft2build.h>
#include FT_FREETYPE_H

class DocUpdater;
class UndoManager;
class UndoState;
class PDFOptions;
class Hyphenator;
class Selection;
class ScribusView;
class ScribusMainWindow;
class ResourceCollection;
class PageSize;
class ScPattern;
class UndoTransaction;

class QProgressBar;

struct SCRIBUS_API NodeEditContext : public MassObservable<QPointF>
{
	enum SubMode { MOVE_POINT = 0, ADD_POINT = 1, DEL_POINT = 2, SPLIT_PATH = 3 };
	int submode;
	bool isContourLine;
	FPointArray *oldClip;
	UndoTransaction* nodeTransaction;
	double oldItemX;
	double oldItemY;
		
	int ClRe;
	int ClRe2;
	int SegP1;
	int SegP2;
	bool EdPoints;
	bool MoveSym;
	QList<int> SelNode;	
	
	NodeEditContext();
	
	bool hasNodeSelected();
	void deselect();
	
	void reset();
	
	void reset1Control(PageItem* currItem);
	void resetControl(PageItem* currItem);
	FPointArray beginTransaction(PageItem* currItem);
	void finishTransaction(PageItem* currItem);
	ItemState<QPair<FPointArray, FPointArray> >* finishTransaction1(PageItem* currItem);
	void finishTransaction2(PageItem* currItem, ItemState<QPair<FPointArray, FPointArray> >* state);
	void moveClipPoint(PageItem *currItem, FPoint ip);
};


/*!
 * @brief The Scribus Document Class
 *
 * TODO: Write some introduction
 */
class SCRIBUS_API ScribusDoc : public QObject, public UndoObject, public Observable<ScribusDoc>
{
	Q_OBJECT

public:
	// Constructors, destructor

	/*!
	 *  Create a new scribus document
	 */
	ScribusDoc();
	/*!
	 * Create a new scribus document
	 * @param docName name for the new document
	 * @param unitIndex
	 * @param pageSize
	 * @param margins initial margins for the document
	 * @param pageSetup
	 */
	ScribusDoc(const QString& docName, int unitIndex, const PageSize& pagesize, const MarginStruct& margins, const DocPagesSetup& pagesSetup);
	~ScribusDoc();

	void init();
	void setup(const int unitIndex, const int fp, const int firstLeft, const int orientation, const int firstPageNumber, const QString& defaultPageSize, const QString& documentName);




public:

// Document states

	/*!
	 * Set the loading state of the document
	 * See ScribusDoc.isLoading()
	 */
	void setLoading(const bool);
	/*!
	 * Is the document loading ?
	 * See ScribusDoc.setLoading()
	 */
	bool isLoading() const;
	/*!
	 * Set modified state of the document
	 * If state changed, update the document
	 * See ScribusDoc.isModified()
	 */
	void setModified(const bool);
	/*!
	 * Is the document modified ?
	 * See ScribusDoc.setModified()
	 */
	bool isModified() const;
	/*!
	 * Call whenever the document needs to know it has been changed.
	 * If the document is the primary document in a main window,
	 * it will emit the DocChanged signal to enable/disable certain operations.
	 */
	void changed();

// GUI 
	/*!
	 * Associate document and GUI.
	 * See ScribusDoc.hasGUI(), ScribusDoc.scMW() and ScribusDoc.view()
	 * @param hasgui Is document associated with gui ?
	 * @param mainWindow scribus main window
	 * @param view scribus view
	 */
	void setGUI(bool hasgui, ScribusMainWindow* mainWindow, ScribusView* view);
	/*!
	 * Is the document associated with GUI ?
	 * See Scribus.setGUI()
	 */
	bool hasGUI() const {return m_hasGUI;}
	/*!
	  * Get the scribus main window associated with the document.
	  * See Scribus.setGUI()
	  * @return the scribus man window
	  */
//ivro: rename this function (mainWindow or scribusMainWindow) ?
	ScribusMainWindow* scMW() const {return m_ScMW;}
	/*!
	 * Get the view associated with the document.
	 * See Scribus.setGUI()
	 * @return the scribus view
	 */
	ScribusView* view() const;

// Automatic Text Frames
	/*!
	 * Set if doc uses automatic text frames.
	 * See ScribusDoc.usesAutomaticTextFrames(), ScribusDoc.PageSp and ScribusDoc.PageSpa
	 */
	void setUsesAutomaticTextFrames(const bool);
	/*!
	 * Is document using automatic text frames ?
	 * See ScribusDoc.setUsesAutomaticTextFrames
	 */
	bool usesAutomaticTextFrames() const;

// Grid and Guides
	/*!
	 * Should guides be locked or not ?
	 * @param isLocked If true guides on pages cannot be moved if false they
	 * can be dragged to new positions.
	 * @author Riku Leino
	 */
	void lockGuides(bool isLocked);

// Current Page
	/*!
	 * Set new current page.
	 */
	void setCurrentPage(Page*);
	/*!
	 * Get the current page.
	 */
	Page* currentPage();
	/*!
	 * Get the current page number.
	 */
	int currentPageNumber();

// Unit index and unit ratio
	/*!
	 * Set the document's unit index and update the document's unit ratio.
	 * See ScribusDoc.unitIndex() and ScribusDoc.unitRatio()
	 */
	void setUnitIndex(const int);
	/*!
	 * Get the document's unit index.
	 * See ScribusDoc.setUnitIndex()
	 */
	int unitIndex() const;
	/*!
	 * Get the document's unit ratio.
	 * See ScribusDoc.setUnitIndex()
	 */
	double unitRatio() const;
// Document's properties
	/*!
	 * Sets the name of the document.
	 * See ScribusDoc.DocName
	 * @param name Name for the document
	 * @author Riku Leino
	 */
	void setName(const QString& name);

/*! @name Master Page
 * Master page related functions.
 *
 * A master page is a model for page. It is used to use common item on multiple page.
 * Use applyMasterPage() to associate a master page to a page.
 * The master page mode (see masterPageMode()) allow to work with master pages and items with the same functions that use for pages and items.
 */ //@{
	/*!
	 * Is the document in master page mode ?
	 * In master page mode
	 *      ScribusDoc.Pages = &ScribusDoc.MasterPages
	 *      ScribusDoc.Items = &ScribusDoc.MasterItems
	 * In normal mode (ie not in master mode)
	 *      ScribusDoc.Pages = &ScribusDoc.DocPages
	 *      ScribusDoc.Items = &ScribusDoc.DocItems
	 */
	bool masterPageMode() const { return m_masterPageMode; }
	/*!
	 * Set the doc into Master page mode.
	 */
// Do we need to return if the move to master page mode was successful?
	void setMasterPageMode(bool);

	/*!
	 * Add a master page.
	 * Use this function to add a master page, do not use addPage
	 * @param pageNumber index for the master page
	 * @param pageName name of the master page
	 * @return added page
	 */
	Page* addMasterPage(const int pageNumber, const QString& pageName);
	/*!
	 * Delete a master page.
	 * @param pageNumber index of the master page
	 */
	void deleteMasterPage(const int pageNumber);
	/*!
	 * Copies a normal page to be a master pages.
	 * @param pageNumber index of the page to copy
	 * @param leftPage
         * @param maxLeftPage
	 * @param masterPageName name for the master page
	 * @param copyFromAppliedMaster
	 */
	bool copyPageToMasterPage(const int pageNumber, const int leftPage, const int maxLeftPage, const QString& masterPageName, bool copyFromAppliedMaster);
	/*!
	 * Replace a master page by default one.
	 * @param oldMasterPage name of the master page to remplace
	 */
	void replaceMasterPage(const QString& oldMasterPage);
	/*!
	 * Rename a master page.
	 * @param oldPageName old name of the master page
	 * @param newPageName new name for the master page
	 */
	bool renameMasterPage(const QString& oldPageName, const QString& newPageName);
	/*!
	 * Apply a master page.
	 * @param masterPageName name of the master page
	 * @param pageNumber index of the page
	 */
	bool applyMasterPage(const QString& masterPageName, const int pageNumber);
	/*!
	 * Rebuild master name list.
	 * Rebuild ScribusDoc.MasterName list from the master page name
	 */
	void rebuildMasterNames(void);
//@} //End of masterpage group

/*! @name Page
 * Page related functions.
 *
 * A page represents a paper page. See Page::Page
 */ //@{
	// Add, delete and move page

	/*!
	 * Add a page.
	 * Do not use this to add a master page, use addMasterPage instead
	 * @param pageNumber index for the page
	 * @param masterPageName master page to use
	 * @param addAutoFrame add automatic text frame
	 * @return addedpage
	 */
	Page* addPage(const int pageNumber, const QString& masterPageName=QString::null, const bool addAutoFrame=false);
	/*!
	 * Delete a page.
	 * @param pageNumber index of the page
	 */
	void deletePage(const int pageNumber);
	/*!
	 * Move page(s) within the document.
	 * @param from page index
	 * @param to page index
	 * @param ziel page index of the target to move to
	 * @param art Before (0), After (1) or At the end (2)
	 */
//ivro: create typedef for param art (like whereToMove) ?
	void movePage(const int from, const int to, const int ziel, const int art);
	/*!
	 * Copy a page.
	 * Copy a page (pageNumberToCopy) copyCount times, whereToInsert(before or after) the existingPage or at the end.
	 * @param pageNumberToCopy index of the page
	 * @param existingPage where to copy (page index)
	 * @param whereToInsert Before (0), After (1) or At the end (2)
	 * @param copyCount number of copy
	 */
//ivro: use typedef whereToMove for param whereToInsert ?
	void copyPage(int pageNumberToCopy, int existingPage, int whereToInsert, int copyCount);

	// Properties of page

	/*!
	 * Set page properties.
	 * @param width page width
	 * @param height page height
	 * @param marginsTop page margins top
	 * @param marginsLeft page margins left
	 * @param marginsRight page margins right
	 * @param marginsBottom page margins bottom
	 * @param numberOfColumns number of automaticTextFrames columns
	 * @param distanceOfColumns distance between automaticTextFrams columns 
	 * @param automaticTextFrames is automaticTextFrames enabled ?
	 * @param pageLayout index of the page layout in ScribusDoc.pageSets
	 */
	void setPage(double width, double height, double marginsTop, double marginsLeft, double marginsRight, double marginsBottom, double numberOfColums, double distanceOfColumns, bool automatictTextFrames, int pageLayout);
	/*!
	 * Reset the page properties.
	 * @param newMargins margins to apply
	 * @param pageLayout index of the page layout in Scribus.pageSets
	 */
	void resetPage(MarginStruct& newMargins, int pageLayout);

	/*!
	 * Add the automatic text frame to the page.
	 * @param pageNumber index of page
	 * @return number of text frame created, -1 on error
	 */
	int addAutomaticTextFrame(const int pageNumber);

	/*!
	 * Set the page margins. Current code uses current page only, also provide a (currently, TODO) option for this.
	 * @param initialTop
	 * @param initialBottom
	 * @param initialLeft
	 * @param initialRight
	 * @param initialHeight
	 * @param initialWight
	 * @param height
	 * @param width
	 * @param orientation
	 * @param pageSize
	 * @param pageNumber if equal to -1, do nothing and return false. Caution default is -1.
	 * @param pageType see Page.LeftPg, default to 0 (Right page)
	 */
//ivro: is this fuction name goods as it does things that not only about margins ?
	bool changePageMargins(const double initialTop, const double initialBottom, const double initialLeft, const double initialRight, const double initialHeight, const double initialWidth, const double height, const double width, const int orientation, const QString& pageSize, const int pageNumber=-1, const int pageType = 0);

	/*!
	 * Get page's bleeds.
	 * @param pageNumber index of the page
	 * @param bleedData struct to get the bleed
	 */
//ivro: is this not better in Page ?
	void getBleeds(int pageNumber, MarginStruct& bleedData);
	/*!
	 * Get page's bleeds.
	 * @param page page to look at
	 * @param bleedData struct to get the bleed
	 */
	void getBleeds(Page* page, MarginStruct& bleedData);


	// Canvas

	/*!
	 * Get the location of the page on the canvas, ie, left, middle, or right.
	 * Does not give information about middle left, etc.
	 * @param pageIndex Index of page to find location for
	 * @return LeftPage, MiddlePage, RightPage, enum from pagestructs.h
	 */
	PageLocation locationOfPage(int pageIndex) const;
	/*!
	 * Get the column of the page on the canvas, ie, left, middle, or right.
	 * @param pageIndex Index of page to find location for
	 * @return int of 0,1,2,3
	 */
	int columnOfPage(int pageIndex) const;
	/*!
	 * Return the x offset for a page on the canvas.
	 * @retval double containing the offset. Returns -1.0 if page not in Pages list (as -ve is not possible).
	 * Mostly saves bringing in extra includes into files that already have scribusdoc.h
	 */
	double getXOffsetForPage(const int);
	/*!
	 * Return the y offset for a page on the canvas.
	 * @retval double coutaining the offset. Returns -1.0 if page not in pages list (as -ve is not possible).
	 */
	double getYOffsetForPage(const int);

	/*!
	 * Set the left and right margins based on the location of the page.
	 * @param pageIndex index of the page
	 */
	void setLocationBasedPageLRMargins(uint pageIndex);
//@} // End of pages groups

/*! @name Layer
 * layer related functions.
 */ //@{
	// Add, delete and move layers

	/*!
	 * Add a layer to the current document.
	 * @param layerName name of layer
	 * @param activate the layer active
	 * @return Number of the layer created
	 */
	int addLayer(const QString& layerName=QString::null, const bool activate=false);
	/*!
	 * Copies a layer from the current document.
	 * @param layerNumberToCopy source layer
	 * @param whereToInsert target layer
	 * @return Success or failure
	 */
	void copyLayer(int layerNumberToCopy, int whereToInsert);
	/*!
	 * Delete a layer from the current document.
	 * @param layerNumber of layer
	 * @param deleteItems the items on the layer too?
	 * @return Success or failure
	 */
	bool deleteLayer(const int layerNumber, const bool deleteItems);
	/*!
	 * FIXME: Make protected once scripter function no longer uses this directly
	 */
	void removeLayer(int l, bool dl = false);

	// Active layer

	/*!
	 * Set the active layer via the layer number.
	 * @param layerToActivate Number of the layer
	 * @return Success or failure
	 */
	bool setActiveLayer(const int layerToActivate);
	/*!
	 * Set the active layer via the layer name.
	 * @param layerNameToActivate Name of the layer
	 * @return Success or failure
	 */
	bool setActiveLayer(const QString & layerNameToActivate);
	/*!
	 * Return the number of the current layer.
	 * @return Active layer number
	 */
	int activeLayer();
	/*!
	 * Return the name of the current layer.
	 * @return Name of the layer
	 */
	const QString& activeLayerName();

	// Layer properties

	/*!
	 * Return the layer name.
	 * @param layerNumber Number of the layer
	 * @return Name of the layer
	 */
	QString layerName(const int layerNumber) const;
	/*!
	 * Change the name of a layer.
	 * @param layerNumber number of the layer
	 * @param newName new name of the layer
	 * @return Success or failure
	 */
	bool changeLayerName(const int layerNumber, const QString& newName);
	/*!
	 * Set the layer printable via the layer number.
	 * @param layerNumber Number of the layer
	 * @param isPrintable bool true = layer is prantable
	 * @return Success or failure
	 */
	bool setLayerPrintable(const int layerNumber, const bool isPrintable);
	/*!
	 * Is the layer printable ?
	 * @param layerNumber Number of the layer
	 * @return Printable or not
	 */
	bool layerPrintable(const int layerNumber);  
	/*!
	 * Set the layer visible via the layer number.
	 * @param layerNumber Number of the layer
	 * @param isViewable true = layer is visible
	 * @return Success or failure
	 */
	bool setLayerVisible(const int layerNumber, const bool isViewable);
	/*!
	 * Is the layer visible ?
	 * @param layerNumber Number of the layer
	 * @return Visible or not
	 */
	bool layerVisible(const int layerNumber);
	/*!
	 * Set the layer locked via the layer number.
	 * @param layerNumber Number of the layer
	 * @param isLocked true = layer is locked
	 * @return Success or failure
	 */
	bool setLayerLocked(const int layerNumber, const bool isLocked);
	/*!
	 * Is the layer locked ?
	 * @param layerNumber Number of the layer
	 * @return Locked or not
	 */
	bool layerLocked(const int layerNumber);
	/*!
	 * Set the layer flow via the layer number.
	 * @param layerNumber Number of the layer
	 * @param flow true = Text flows around objects on this layer
	 * @return Success or failure
	 */
	bool setLayerFlow(const int layerNumber, const bool flow);
	/*!
	 * does text flow around objects on this layer ?
	 * @param layerNumber Number of the layer
	 * @return flow or not
	 */
	bool layerFlow(const int layerNumber);
	/*!
	 * Set the layer transparency via the layer number.
	 * @param layerNumber Number of the layer
	 * @param trans transparency value 0.0 - 1.0
	 * @return Success or failure
	 */
	bool setLayerTransparency(const int layerNumber, double trans);
	/*!
	 * returns the layer transparency.
	 * @param layerNumber Number of the layer
	 * @return transparency value 0.0 - 1.0
	 */
	double layerTransparency(const int layerNumber);
	/*!
	 * Set the layer layerBlendMode via the layer number.
	 * @param layerNumber Number of the layer
	 * @param blend layerBlendMode
	 * @return Success or failure
	 */
	bool setLayerBlendMode(const int layerNumber, int blend);
	/*!
	 * Returns the layer BlendMode.
	 * @param layerNumber Number of the layer
	 * @return layerBlendMode
	 */
	int layerBlendMode(const int layerNumber);
	/*!
	 * Set the layer outline mode via the layer number.
	 * @param layerNumber Number of the layer
	 * @param outline true = layer is displayed in outlines only
	 * @return Success or failure
	 */
	bool setLayerOutline(const int layerNumber, const bool outline);
	/*!
	 * Is this layer in outline mode ?
	 * @param layerNumber Number of the layer
	 * @return outline or not
	 */
	bool layerOutline(const int layerNumber);

	// Layer marker color

	/*!
	 * Set the layer marker color.
	 * @param layerNumber Number of the layer
	 * @param color color of the marker
	 * @return Success or failure
	 */
	bool setLayerMarker(const int layerNumber, QColor color);
	/*!
	 * Returns the layer marker color.
	 * @param layerNumber Number of the layer
	 * @return marker color
	 */
	QColor layerMarker(const int layerNumber);

	// Layer level

	/*!
	 * Returns the level of the requested layer.
	 * @param layerNumber Number of the layer
	 * @return Level of the layer
	 */
	int layerLevelFromNumber(const int layerNumber);
	/*!
	 * Returns the number of the layer at a certain level.
	 * @param layerLevel Layer level
	 * @return Layer number
	 */
	int layerNumberFromLevel(const int layerLevel);

	// Lower and Raise Layer

	/*!
	 * Lowers a layer.
	 * @param layerNumber Number of the layer
	 * @return Success or failure
	 */
	bool lowerLayer(const int layerNumber);
	/*!
	 * Lowers a layer using the level.
	 * @param layerLevel Level of the layer
	 * @return Success or failure
	 */
	bool lowerLayerByLevel(const int layerLevel);
	/*!
	 * Raises a layer.
	 * @param layerNumber Number of the layer
	 * @return Success or failure
	 */
	bool raiseLayer(const int layerNumber);
	/*!
	 * Raises a layer using the level.
	 * @param layerLevel Level of the layer
	 * @return Success or failure
	 */
	bool raiseLayerByLevel(const int layerLevel);

	// Various functions on layer

	/*!
	 * Returns the layer count.
	 * @return Number of layers in doc
	 */
	int layerCount() const;
	/*!
	 * Does the layer have items on it ?
	 * @param layerNumber Number of the layer
	 * @return Layer contains items bool
	 */
	bool layerContainsItems(const int layerNumber);
	/*!
	 * Renumbers a layer. Used in particular for reinsertion for undo/redo.
	 * @param layerNumber old layer number
	 * @param newLayerNumber New layer number
	 * @return Success or failure
	 */
	bool renumberLayer(const int layerNumber, const int newLayerNumber);
	/*!
	 * Returns a list of the layers in their order.
	 * @param list QStringList to insert the layer names into
	 */
	void orderedLayerList(QStringList* list);
//@} // End of Layer function

/*! @name Item
 * Item related functions.
 */ //@{
	// Add

	/*!
	 * Add an Item to the document.
	 * A simple function to create an item of a defined type and add it to the document
	 * Will need extensive rewriting once we have various classes of PageItems, at a guess.
	 *
	 * @param itemType type
	 * @param frameType frame type
	 * @param x X pos
	 * @param y Y pos
	 * @param b width
	 * @param h height
	 * @param w ?
	 * @param fill fill color name
	 * @param outline outline color name
	 * @param itemFinalised Used to handle item creation for undo while the user is still dragging.
	 * @return Number of created item, -1 on failure.
	 */
	int itemAdd(const PageItem::ItemType itemType, const PageItem::ItemFrameType frameType, const double x, const double y, const double b, const double h, const double w, const QString& fill, const QString& outline, const bool itemFinalised);
	/*!
	 * Add an Item to the page.
	 * Item will be fitted to the closest guides/margins of the x/y position.
	 *
	 * @param itemType type
	 * @param itemFramType frame type
	 * @param x X pos
	 * @param y Y pos
	 * @param w ?
	 * @param fill fill color name
	 * @param outline outline color name
	 * @param itemFinalised Used to handle item creation for undo while the user is still dragging
	 * @return Number of created item, -1 on failure.
	 */
	int itemAddArea(const PageItem::ItemType itemType, const PageItem::ItemFrameType frameType, const double x, const double y, const double w, const QString& fill, const QString& outline, const bool itemFinalised);
	/*!
	 * Allow the user to create a frame easily with some simple placement and sizing options.
	 * @param iafData a InsertAFrameData structure with params
	 * @return int item id? FIXME
	 */
	int itemAddUserFrame(InsertAFrameData &iafData);
	/*!
	 * Commit item creation when a user has click-drag created an item.
	 * Only called from ScribusView. Note the undo target is the page, so the undo code remains their for now.
	 *
	 * @return If an item was committed and the view must emit its signal, which needs removing from here, TODO.
	 */
	bool itemAddCommit(const int itemNumber);
	/*!
	 * Finalise item creation, only to be called from itemAdd().
	 * Simply split off code from itemAdd.
	 * 
	 * @param itemType type
	 * @param frameType frame type
	 * @param itemNumber item index
	 */
	void itemAddDetails(const PageItem::ItemType itemType, const PageItem::ItemFrameType frameType, const int itemNumber);
	/*!
	 * Item type conversion functions.
	 * @param currItem item to convert
	 * @param newType
	 * @param secondaryItem ?
	 */
	PageItem* convertItemTo(PageItem *currItem, PageItem::ItemType newType, PageItem* secondaryItem=NULL);
	/*!
	 * Paste an item to the document.
	 * The bulk of a paste item process runs here for want of a better place, but its a better place
	 * than the view where it used to be. 
	 * TODO Once the pageitem restructure is done, this is probably unnecessary but it removes the 
	 * unnecessary part from the view for now which is overloaded with non ScrollView code.
	 */
	//TODO: void PasteItem(struct CopyPasteBuffer *Buffer, bool loading, bool drag = false);

	//itemDelete
	//itemBlah...

	// move, rotate, resize items

	/*!
	 * Move item.
	 * @param newX new X coord
	 * @param newY new Y coord
	 * @param item page item to move
	 * @param fromMP ?
	 */
//ivro: standardize param order as PageItem changed each function ?
//	something like item, args, options ?
	bool MoveItem(double newX, double newY, PageItem* ite, bool fromMP = false);
	/*!
	 * Rotate Item.
	 * @param angle angle to rotate
	 * @param itemNumber index of the item to rotate
	 */
	void RotateItem(double angle, int itemNumber);
	/*!
	 * Rotate Item.
	 * @param angle angle to rotate
	 * @param currItem page item to rotate
	 */
	void RotateItem(double angle, PageItem *currItem);
	/*!
	 * Move and Rotate Item.
	 * @param currItem page item to transform
	 * @param npv ?
	 * @param fromMP ?
	 */
	void MoveRotated(PageItem *currItem, FPoint npv, bool fromMP = false);
	/*!
	 * Resize item.
	 * @param newX new X coord
	 * @param newY new Y coord
	 * @param ite index of page item to resize
	 * @param fromMp ?
	 * @param DoUpdateClip ?
	 * @param redraw ?
	 */
	bool SizeItem(double newX, double newY, int ite, bool fromMP = false, bool DoUpdateClip = true, bool redraw = true);
	/*!
	 * Resize item.
	 * @param newX new X coord
	 * @param newY new Y coord
	 * @param pi page item to resize
	 * @param fromMp ?
	 * @param DoUpdateClip ?
	 * @param redraw ?
	 */
	bool SizeItem(double newX, double newY, PageItem *pi, bool fromMP = false, bool DoUpdateClip = true, bool redraw = true);
	/*!
	 * Size and Move item.
	 * @param newX new X coord
	 * @param newY new Y coord
	 * @param ite index of page item to transform
	 * @param fromMp ?
	 * @param constrainRotation ?
	 */
	bool MoveSizeItem(FPoint newX, FPoint newY, int ite, bool fromMP = false, bool constrainRotation=false);
//ivro: don't know what it does
	void AdjustItemSize(PageItem *currItem);

	//void FlipImageH();
	//void FlipImageV();
	void MirrorPolyH(PageItem *currItem);
	void MirrorPolyV(PageItem *currItem);

	// Various

	/*!
	 * Delete the tagged items.
	 * Currently does nothing
	 */
	bool deleteTaggedItems();
	/*!
	 * Get the item index from a unique ID.
	 * @param unique ID of item
	 * @return index of the item
	 */
	uint getItemNrfromUniqueID(uint unique);
	/*!
	 * Run this common frame item update code.
	 */
	void updateFrameItems();
	/*!
	 * Renumbers the items into the order they are stored in in the lists.
	 * Utility function used in various places, basically handles keeping items numbered in the way
	 * they are layered. When layer is a property and not a fuction of storage, this should be removed.
	 * Depends on the Items pointer pointing to the correct item list (doc, master, etc).
	 * @sa updateFrameItems();
	 */
	void renumberItemsInListOrder();
	/*!
	 * Rebuild item lists taking into account layer order.
	 * Utility function used in various places, basically handles keeping items numbered in the way
	 * they are layered. When layer is a property and not a fuction of storage, this should be removed.
	 * @sa updateFrameItems();
	 */
	void rebuildItemLists();
	/*!
	 * Find if item is not an already used item.
	 * Return true if the passed name is not used by any existing PageItem
	 *        in the same document as this PageItem.
	 * @author Craig Ringer
	 ** CB Moved from PageItem
	 */
//ivro: is returning true if the passed name exists not better ? (or rename to itemNameDontUses ?)
	bool itemNameExists(const QString itemName);
	/*!
	 * Returns a stringlist of the item attributes within the document.
	 */
	QStringList getItemAttributeNames();

	/*! Get a list of frames of certain type. */
	QMap<PageItem*, QString> getDocItemNames(PageItem::ItemType itemType);
//@} //End Items group

/*! @name Sections
 * Sections related functions
 */ //@{
	// add, delete, use sections

	/*!
	 * Add a section to the document sections list.
	 * Set number to -1 to add in the default section if the map is empty
	 */
	void addSection(const int number=0, const QString& name=QString::null, const uint fromindex=0, const uint toindex=0, const  DocumentSectionType type=Type_1_2_3, const uint sectionstartindex=0, const bool reversed=false, const bool active=true);
	/*!
	 * Delete a section from the document sections list.
	 */
	bool deleteSection(const uint);
	/*!
	 * Gets the page number to be printed based on the section it is in.
	 * Returns QString::null on failure to find the pageIndex
	 */
	const QString getSectionPageNumberForPageIndex(const uint) const;
	/*!
	 * Gets the key of the sections map based on the section the page index is in.
	 * Returns -1 on failure to find the pageIndex
	 */
	int getSectionKeyForPageIndex(const uint pageIndex) const;
	/*!
	 *
	 *
	 */
	void updateSectionPageNumbersToPages();
	/*!
	 * 
	 * @param otherPageIndex 
	 * @param location 
	 * @param count 
	 */
	void addPageToSection(const uint otherPageIndex, const uint location, const uint count=1);
	/*!
	 * 
	 * @param pageIndex 
	 */
	void removePageFromSection(const uint pageIndex);
	/*!
	 * 
	 */
	void setFirstSectionFromFirstPageNumber();
//@} // End of Sections group

/*! @name Align
 * Align related functions
 */ //@{
	void buildAlignItemList(Selection* customSelection=0);
	bool startAlign();
	void endAlign();
//@} // End of align functions

/*! @name Color Management
 * Color Management related functions.
 */ //@{
	/*!
	 * Builds a qmap of the icc profiles used within the document.
	 */
	void getUsedProfiles(ProfilesL& usedProfiles);
	bool OpenCMSProfiles(ProfilesL InPo, ProfilesL InPoCMYK, ProfilesL MoPo, ProfilesL PrPo);
	void CloseCMSProfiles();
	void SetDefaultCMSParams();
	/*!
	 * Switch Colormanagement on or of.
	 * @param enable bool, if true Colormanagement is switched on, else off
	 */
	void enableCMS(bool enable);
	/*!
	 * Recalculate the colors after CMS settings change. Update the items in the doc accordingly.
	 */
	void recalculateColors();

	/*!
	 * Insert a color into the documents color list.
	 * @param colorList Name of the color list
	 * @param cyan Cyan component
	 * @param magenta Magenta component
	 * @param yellow Yellow component
	 * @param black Black component
	 */
	void insertColor(QString colorList, double cryan, double magenta, double yellow, double black);
//@} // End of color functions

/*! @name Styles
 * Style related functions
 */ //@{
	// Paragraphe style

	/*!
	 * Get a paragraph style by its name.
	 */
	const ParagraphStyle& paragraphStyle(QString name) { return docParagraphStyles.get(name); }
	/*!
	 * Get all the paragraph style.
	 */
	const StyleSet<ParagraphStyle>& paragraphStyles()   { return docParagraphStyles; }
	/*!
	 * Redefine Paragraphes style.
	 */
//ivro: rename rededineParaStyles ?
	void redefineStyles(const StyleSet<ParagraphStyle>& newStyles, bool removeUnused=false);
	/*!
	 * Remove any reference to old styles and replace with new name.
	 * This needs to be called when a style was removed. New name may be "".
	 * @param newNameForOld a map which maps the name of any style to remove to a new stylename
	 */
//ivro: rename replaceParaStyles ?
	void replaceStyles(const QMap<QString,QString>& newNameForOld);
	/*!
	 * Is the default paragraph style ?
	 * @param p paragraph style to test
	 */
//ivro: is this must be with the one for char style ?
	bool isDefaultStyle( const ParagraphStyle& p ) const { return docParagraphStyles.isDefault(p); }

	// Character style

	/*!
	 * Get a character style by name.
	 * @param name char style name
	 */
	const CharStyle& charStyle(QString name) { return docCharStyles.get(name); }
	/*!
	 * Get all the Character styles.
	 */
	const StyleSet<CharStyle>& charStyles()  { return docCharStyles; }
	/*!
	 * Redefine Character styles.
	 * @param newStyle character styles
	 * @param removeUnused
	 */
	void redefineCharStyles(const StyleSet<CharStyle>& newStyles, bool removeUnused=false);
	/*!
	 * Remove any reference to old styles and replace with new name.
	 * This needs to be called when a style was removed. New name may be "".
	 * @param newNameForOld a map which maps the name of any style to remove to a new stylename
	 */
	void replaceCharStyles(const QMap<QString,QString>& newNameForOld);
	/*!
	 * Is the default character style ?
	 * @param c character style to test
	 */
	bool isDefaultStyle( const CharStyle& c ) const { return docCharStyles.isDefault(c); }
// 	bool isDefaultStyle( LineStyle& l ) const { return MLineStyles......; }

	// Load Style

	/*!
	 * Insert styles from another document in this document.
	 * @param fileName The path of the document we want to extract its styles
	 */
	void loadStylesFromFile(QString fileName);
	/*!
	 * Gather styles from another document.       
	 * @param fileName The path of the document we want to extract its styles
	 * @param tempStyles A pointer to a StyleSet which will be filled by paragraph styles
	 * @param tempCharStyles A pointer to a StyleSet which will be filled by character styles
	 * @param tempLineStyles A map which will be filled by line styles
	 */
	void loadStylesFromFile(QString fileName, StyleSet<ParagraphStyle> *tempStyles,
	                                          StyleSet<CharStyle> *tempCharStyles,
	                                          QMap<QString, multiLine> *tempLineStyles);
//@} // End of style group

/*! @name Font
 * font related funtions.
 */ //@{
	/*!
	 * Add a font
	 */
	bool AddFont(QString name, int fsize = 10);
	/*!
	 * TODO: Reorganise the fonts.. how? Moved from scribus.cpp
	 * CB: almost the same as getUsedFonts???
	 */
	QMap<QString,int> reorganiseFonts();
	/*!
	 * Returns a qmap of the fonts and  their glyphs used within the document.
	 */
	void getUsedFonts(QMap<QString,QMap<uint, FPointArray> > &Really);
	void checkItemForFonts(PageItem *it, QMap<QString, QMap<uint, FPointArray> > & Really, uint lc);

	/*!
	 * Replace line style colors.
	 */
	void replaceLineStyleColors(const QMap<QString, QString>& colorMap);
	/*!
	* Builds a qmap of the colours used within the document.
	*/
	void getUsedColors(ColorList &colorsToUse, bool spot = false);
	/*!
	* Is this specific color is used by line styles.
	*/
	bool lineStylesUseColor(const QString& colorName);
//@} // End of font functions

/*! @name Pattern
 * Pattern related functions
 */ //@{
	/*!
	* Set the patterns for a document.
	*/
	bool addPattern(QString &name, ScPattern& pattern);
	void setPatterns(QMap<QString, ScPattern> &patterns);
	/*!
	* Builds a QStringList of the patterns used within the document.
	*/
	QStringList getUsedPatterns();
	QStringList getUsedPatternsSelection(Selection* customSelection);
	QStringList getUsedPatternsHelper(QString pattern, QStringList &results);
//@} // End of pattern functions

/*! @name Item selection
 * Item selection related functions.
 *
 * Item selection is used to modify items.
 */ //@{
	bool sendItemSelectionToBack();
	bool bringItemSelectionToFront();

	void itemSelection_GroupObjects  (bool changeLock, bool lock, Selection* customSelection=0);
	void itemSelection_UnGroupObjects(Selection* customSelection=0);
	void itemSelection_convertItemsTo(const PageItem::ItemType newType, Selection* restoredSelection=0, Selection* customSelection=0);

	void itemSelection_ApplyParagraphStyle(const ParagraphStyle & newstyle, Selection* customSelection=0);
	void itemSelection_SetParagraphStyle(const ParagraphStyle & newstyle, Selection* customSelection=0);
	void itemSelection_ApplyCharStyle(const CharStyle & newstyle, Selection* customSelection=0);
	void itemSelection_SetCharStyle(const CharStyle & newstyle, Selection* customSelection=0);
	void itemSelection_EraseParagraphStyle(Selection* customSelection=0);
	void itemSelection_EraseCharStyle(Selection* customSelection=0);

	void itemSelection_SetNamedParagraphStyle(const QString & name, Selection* customSelection=0);
	void itemSelection_SetNamedCharStyle(const QString & name, Selection* customSelection=0);
	void itemSelection_SetNamedLineStyle(const QString & name, Selection* customSelection=0);

	void itemSelection_SetLineWidth(double w);
	void itemSelection_SetLineArt(Qt::PenStyle w);
	void itemSelection_SetLineJoin(Qt::PenJoinStyle w);
	void itemSelection_SetLineEnd(Qt::PenCapStyle w);
	void itemSelection_SetAlignment(int w, Selection* customSelection=0);
	void itemSelection_SetLineSpacing(double w, Selection* customSelection=0);
	void itemSelection_SetLineSpacingMode(int w, Selection* customSelection=0);
	//void ChLocalXY(double x, double y);
	//void ChLocalSc(double x, double y);
	void itemSelection_SetFont(QString fon, Selection* customSelection=0);
	void itemSelection_SetFillColor(QString farbe, Selection* customSelection=0);
	void itemSelection_SetFillShade(int sha, Selection* customSelection=0);
	void itemSelection_SetStrokeColor(QString farbe, Selection* customSelection=0);
	void itemSelection_SetStrokeShade(int sha, Selection* customSelection=0);
	void itemSelection_SetScaleV(int, Selection* customSelection=0);
	void itemSelection_SetScaleH(int, Selection* customSelection=0);
	void itemSelection_SetBaselineOffset(int, Selection* customSelection=0);
	void itemSelection_SetOutlineWidth(int, Selection* customSelection=0);
	void itemSelection_SetShadowOffsets(int shx, int shy, Selection* customSelection=0);
	void itemSelection_SetUnderline(int pos, int wid, Selection* customSelection=0);
	void itemSelection_SetStrikethru(int pos, int wid, Selection* customSelection=0);
	void itemSelection_SetEffects(int s, Selection* customSelection=0);
	void itemSelection_SetOpticalMargins(int i, Selection* customSelection=0);
	void itemSelection_SetColorProfile(const QString& profileName, Selection* customSelection=0);
	void itemSelection_SetRenderIntent(int intentIndex, Selection* customSelection=0);
	
//	void chAbStyle(PageItem *currItem, int s);

	void itemSelection_SetTracking(int us, Selection* customSelection=0);
	void itemSelection_SetFontSize(int size, Selection* customSelection=0);
public slots:
	/*!
	 * Change display quality of all images in document.
	 * @author OssiLehtinen
	 */
	void allItems_ChangePreviewResolution(int id);

	void itemSelection_ToggleLock();
	void itemSelection_ToggleSizeLock();
	void itemSelection_ToggleImageShown();
	void itemSelection_TogglePrintEnabled();
	void itemSelection_ChangePreviewResolution(int id);
	void itemSelection_ClearItem(Selection* customSelection=0);
	//! Delete the items in the current selection. When force is true, we do not warn the user and make SE happy too. Force is used from @sa Page::restorePageItemCreation
	void itemSelection_DeleteItem(Selection* customSelection=0, bool forceDeletion=false);
	void itemSelection_SetItemFillTransparency(double t);
	void itemSelection_SetItemLineTransparency(double t);
	void itemSelection_SetItemFillBlend(int t);
	void itemSelection_SetItemLineBlend(int t);
	void itemSelection_SetLineGradient(VGradient& newGradient, Selection* customSelection=0);
	void itemSelection_SetFillGradient(VGradient& newGradient, Selection* customSelection=0);
	void itemSelection_SetOverprint(bool overprint, Selection* customSelection=0);
	void itemSelection_ApplyImageEffects(ScImageEffectList& newEffectList, Selection* customSelection=0);
	void itemSelection_FlipH();
	void itemSelection_FlipV();
	void itemSelection_DoHyphenate();
	void itemSelection_DoDeHyphenate();
	void itemSelection_SendToLayer(int layerNumber);
	void itemSelection_SetImageOffset(double x, double y, Selection* customSelection=0);
	void itemSelection_SetImageScale(double x, double y, Selection* customSelection=0);
	void itemSelection_SetImageScaleAndOffset(double ox, double oy, double sx, double sy, Selection* customSelection=0);
	void itemSelection_AlignLeftOut(AlignTo currAlignTo, double guidePosition);
	void itemSelection_AlignRightOut(AlignTo currAlignTo, double guidePosition);
	void itemSelection_AlignBottomIn(AlignTo currAlignTo, double guidePosition);
	void itemSelection_AlignRightIn(AlignTo currAlignTo, double guidePosition);
	void itemSelection_AlignBottomOut(AlignTo currAlignTo, double guidePosition);
	void itemSelection_AlignCenterHor(AlignTo currAlignTo, double guidePosition);
	void itemSelection_AlignLeftIn(AlignTo currAlignTo, double guidePosition);
	void itemSelection_AlignCenterVer(AlignTo currAlignTo, double guidePosition);
	void itemSelection_AlignTopOut(AlignTo currAlignTo, double guidePosition);
	void itemSelection_AlignTopIn(AlignTo currAlignTo, double guidePosition);
	void itemSelection_DistributeDistH(bool usingDistance=false, double distance=0.0);
	void itemSelection_DistributeAcrossPage(bool useMargins=false);
	void itemSelection_DistributeRight();
	void itemSelection_DistributeBottom();
	void itemSelection_DistributeCenterH();
	void itemSelection_DistributeDistV(bool usingDistance=false, double distance=0.0);
	void itemSelection_DistributeDownPage(bool useMargins=false);
	void itemSelection_DistributeLeft();
	void itemSelection_DistributeCenterV();
	void itemSelection_DistributeTop();
	void itemSelection_MultipleDuplicate(ItemMultipleDuplicateData&);
	void itemSelection_UniteItems(Selection* customSelection=0);
	void itemSelection_SplitItems(Selection* customSelection=0);
	/*! Adjust an image frame's size to fit the size of the image in it. */
	void itemSelection_AdjustFrametoImageSize(Selection* customSelection=0);
	/*! Adjust an image size to fit the size of the frame. */
	void itemSelection_AdjustImagetoFrameSize(Selection* customSelection=0);
	/*! startArrowID or endArrowID of -1 mean not applying a selection at this point.*/
	void itemSelection_ApplyArrowHead(int startArrowID=-1, int endArrowID=-1, Selection* customSelection=0);

	void itemSelection_SetItemPen(QString farbe);
	void itemSelection_SetItemPenShade(int sha);
	void itemSelection_SetItemBrush(QString farbe);
	void itemSelection_SetItemBrushShade(int sha);
	void itemSelection_SetItemGradFill(int typ);
	void itemSelection_SetItemPatternFill(QString pattern);
	void itemSelection_SetItemPatternProps(double scaleX, double scaleY, double offsetX, double offsetY, double rotation);
//@} // End of item selection group

/*! @name Various functions
 */ //@{

	/*!
	 * Save function.
	 */
	bool save(const QString& fileName, QString* savedFile = NULL);

	/*!
	 * Create the default master pages based on the layout selected by the user, ie, Normal, Normal Left, etc.
	 */
	void createDefaultMasterPages();
	/*!
	 * Create the requested pages in a new document.
	 * Run after ScribusDoc.createDefaultMasterPages()
	 * @param pageCount number of page to create
	 */
	void createNewDocPages(int pageCount);

	/*!
	 * Update the fill and line QColors for all items in the doc.
	 */
	void updateAllItemQColors();

	/*!
	 * Sets up the ScText defaults from the document.
	 */
	void setScTextDefaultsFromDoc(ScText *);

// Restore

	/*!
	 * Method used when an undo/redo is requested.
	 * @param state State describing the action that is wanted to be undone/redone
	 * @param isUndo If true undo is wanted else if false redo.
	 * @author Riku Leino
	 */
	void restore(UndoState* state, bool isUndo);
	/*!
	 * Undo function for applying a master page.
	 */
	void restoreMasterPageApplying(SimpleState *state, bool isUndo);
	/*!
	 * Undo function for copy a page.
	 */
	void restorePageCopy(SimpleState *state, bool isUndo);

// Loading images

	/*!
	 * Load images into an image frame, moved from the view.
	 * @param fn image file name
	 * @param ItNr page item number
	 * @param reload
	 * @param showMsg
	 * @return Return false on failure
	 */
	bool LoadPict(QString fn, int ItNr, bool reload = false, bool showMsg = false);
	/*!
	 * Load images into an image frame.
	 * @param fn image file name
	 * @param pageItem page item 
	 * @param reload 
	 * @param showMsg
	 * @return Return false on failure
	 */
	bool loadPict(QString fn, PageItem *pageItem, bool reload = false, bool showMsg = false);
	/*!
	 * Handle image with color profiles.
	 * @param Pr profile
	 * @param PrCMYK cmyk profile
	 * @param dia optional progress widget
	 */
	void RecalcPictures(ProfilesL *Pr, ProfilesL *PrCMYK, QProgressBar *dia = 0);
public slots:
	/*! Update all the picture in the current selection. */
	void updatePic();
	/*! Update the specified picture. */
	void updatePict(QString name);
	/*! Update all picture in the specified directory. */
	void updatePictDir(QString name);
	/*! Remove a picture from document. */
	void removePict(QString name);
public:
	/*!
	 * Find the minX,MinY and maxX,maxY for the canvas required for the doc.
	 * @param minPoint
	 * @param maxPoint
	 */
	void canvasMinMax(FPoint& minPoint, FPoint& maxPoint);
	
	/*!
	 * Find page index where the point exists.
	 * In masterPage mode return the current master page index if the point exists on the current master page,
	 * In normal mode return the first page index where this point exists.
	 * 
	 * @param x X coord of the point
	 * @param y Y coord of the point
	 * @return page index or -1
	 */
	int OnPage(double x, double  y);
	/*!
	 * Find page index where the item exists.
	 * In masterPageMode return the current master page index if the item exists on the current master page.
	 * In mormal mode return the page index where this item exists.
	 *
	 * @param item item we looking for
	 * @return page index or -1
	 */
	int OnPage(PageItem *item);

	void GroupOnPage(PageItem *currItem);
	//void reformPages(double& maxX, double& maxY, bool moveObjects = true);
	void reformPages(bool moveObjects = true);

	void setRedrawBounding(PageItem *currItem);
	void adjustCanvas(FPoint minPos, FPoint maxPos, bool absolute = false);
	void recalcPicturesRes(bool applyNewRes = false);
	void connectDocSignals();

// Named Ressources

	void getNamedResources(ResourceCollection& lists) const;
	void replaceNamedResources(ResourceCollection& newNames);	


	QMap<QString, double>& constants() { return m_constants; }

// Grid and Guides

	/*! \brief Apply grid to a QPoint, from ScribusView. */
	QPoint ApplyGrid(const QPoint& in);
	/*! \brief Apply grid to an FPoint, from ScribusView. */
	FPoint ApplyGridF(const FPoint& in);

	//! \brief Get the closest guide to the given point.
	void getClosestGuides(double xin, double yin, double *xout, double *yout, int *GxM, int *GyM);
	//! \brief Snap an item to the guides.
	void SnapToGuides(PageItem *currItem);
	bool ApplyGuides(double *x, double *y);

	/*! \brief Does this doc have any TOC setups and potentially a TOC to generate. */
	bool hasTOCSetup() { return !docToCSetups.empty(); }

// Group

	void moveGroup(double x, double y, bool fromMP = false, Selection* customSelection = 0);
	void rotateGroup(double angle, FPoint RCenter);
	void scaleGroup(double scx, double scy, bool scaleText=true, Selection* customSelection = 0);

	/*!
	 * Return the guarded object associated with the document.
	 */
	const ScGuardedPtr<ScribusDoc>& guardedPtr() const;

	UpdateManager* updateManager() { return &m_updateManager; }
	MassObservable<PageItem*> * itemsChanged() { return &m_itemsChanged; }
	MassObservable<Page*>     * pagesChanged() { return &m_pagesChanged; }
	MassObservable<QRectF>    * regionsChanged() { return &m_regionsChanged; }
	void invalidateRegion(QRectF region);

protected:
	void addSymbols();	
//@} // End of various group
	
signals:
	//Lets make our doc talk to our GUI rather than confusing all our normal stuff
	/*!
	 * Let the document tell whatever is listening that it has changed.
	 */
	void docChanged();
	void updateContents();
	void updateContents(const QRect &r);
	void refreshItem(PageItem *);
	void canvasAdjusted(double width, double height, double dX, double dY);
	void firstSelectedItemType(int);
	void setApplicationMode(int);
	/*!
	 * A signal for when the outline palette needs to rebuild itself.
	 * Emit when:
	 * - An item is created or deleted
	 * - An item changes page
	 * - An page is created or deleted
	 * - Some items are grouped or a group is ungrouped
	 * This also applies to Master Pages
	 */
	void signalRebuildOutLinePalette();
	//! Temporary signal for SizeItem
	void widthAndHeight(double, double);

public:
	QList<Page*>* Pages;			/*!< Pointer on a list of pages. See masterPageMode() */
	QList<Page*> MasterPages;	 	/*!< List of Master Pages. */
	QList<Page*> DocPages;			/*!< List of Document Pages. */

	QList<PageItem*>* Items;		/*!< Pointer on a list of items. See masterPageMode() */
	QList<PageItem*> MasterItems;		/*!< List of items that belongs to Master Pages. */
	QList<PageItem*> DocItems;		/*!< List of items that belongs to Document Pages. */
	QList<PageItem*> FrameItems;		/*!< List of items that belongs to Frames. */

	double PageSp;				/*!< Number of Columns for automaticTextFrames. */
	double PageSpa;				/*!< Distance between Columns for automaticTextFrames. */
	PageItem *LastAuto;			/*!< Last AutomaticTextFrame element. */
	PageItem *FirstAuto;			/*!< First AutomaticTextFrame element. */

	bool GuideLock;				/*!< Is the guides must be locked ? See LockGuides() */

	MarginStruct bleeds; 			/*!< Default page's bleeds. */
//ivro: are those necessary anymore ?
// 	double BleedTop;
// 	double BleedLeft;
// 	double BleedRight;
// 	double BleedBottom;
	MarginStruct scratch;
//ivro: are those necessary anymore ?
// 	double ScratchLeft;
// 	double ScratchRight;
// 	double ScratchTop;
// 	double ScratchBottom;
	double pageWidth;			/*!< Default page's width.  */
	double pageHeight;			/*!< Default page's height. */
//ivro: use the scribusstruct PageOrientation enum ?
	int PageOri;				/*!< Default page's orientation. 0 = Portrait, 1 = Landscape. */
	QString m_pageSize;			/*!< Default page's size. */
	MarginStruct pageMargins;		/*!< Default page's margins. */
//ivro: what is this for ?
	int marginPreset;

	double GapHorizontal;		/*!< Horizontal gap between page on canvas. */
	double GapVertical;		/*!< Vertical gap between page on canvas. */

	FPoint minCanvasCoordinate;	/*!< Minimun points of document. */
	FPoint maxCanvasCoordinate;	/*!< Maximun point of document. */

	QMap<QString,int> MasterNames;		/*!< Mapping Master Page Name to Master Page numbers. See rebuildMasterNames() */

	QList<PageSet> pageSets;	/*!< List of page layout scribus support. Use ::currentPageLayout to select the one this document uses. */
//ivro: is name DocumentLayout not better ?
	int currentPageLayout;		/*!< Current Page's layout. Index of page layout in ::pageSets */

	/*! Some internal align tools. */
//ivro: is this cannot be moved elsewhere ?
	typedef enum {
		alignFirst,
		alignLast,
		alignPage,
		alignMargins,
		alignGuide,
		alignSelection
	} AlignTo;

	ParagraphStyle currentStyle;		/*!< The current paragraph style. */

	QString DocName;			/*!< Document's name. */

	bool AutoSave;				/*!< Document's auto saving mode. */
	int AutoSaveTime;			/*!< Auto save interval. Number of milliseconds between auto save. */
	QTimer * const autoSaveTimer;		/*!< Auto save timer. */


	bool is12doc; //public for now, it will be removed later
	int NrItems;
	int First;
	int Last;
	int viewCount;
	int viewID;
	bool SnapGuides;
	double rulerXoffset;
	double rulerYoffset;
	Selection* const m_Selection;
	/* Number of Pages */
	// int pageCount; Disabled CR no longer required

	int FirstPnum;				/*!< Erste Seitennummer im Dokument. */
	bool useRaster;				/*!< Flag fuer Rasterbenutzung. */
	ColorList PageColors;			/*!< Im Dokument benutzte Farben. */
	DocumentInformation documentInfo;	/*!< InfoStrings for the document. */
	int appMode;
	int SubMode;
	double *ShapeValues;
	int ValCount;
	QMap<QString,int> UsedFonts;
	SCFonts * const AllFonts;
	QList<AlignObjs> AObjects;
	QColor papColor;
	int CurrentSel;
	NodeEditContext nodeEdit;
	ApplicationPrefs& prefsData;
	typoPrefs typographicSettings;
	guidesPrefs guidesSettings;
	toolPrefs toolSettings;
	QMap<QString, checkerPrefs> checkerProfiles;
	QString curCheckProfile;
	bool DragP;
	bool leaveDrag;
	PageItem *DraggedElem;
	PageItem *ElemToLink;
	QList<uint> DragElements;
	ScLayers Layers;
	bool marginColored;
	int GroupCounter;
	CMSData CMSSettings;
	cmsHPROFILE DocInputImageRGBProf;
	cmsHPROFILE DocInputImageCMYKProf;
	cmsHPROFILE DocInputRGBProf;
	cmsHPROFILE DocInputCMYKProf;
	cmsHPROFILE DocOutputProf;
	cmsHPROFILE DocPrinterProf;
	cmsHTRANSFORM stdTransRGBMon;
	cmsHTRANSFORM stdTransCMYKMon;
	cmsHTRANSFORM stdProof;
	cmsHTRANSFORM stdTransImg;
	cmsHTRANSFORM stdProofImg;
	cmsHTRANSFORM stdProofImgCMYK;
	cmsHTRANSFORM stdTransCMYK;
	cmsHTRANSFORM stdProofCMYK;
	cmsHTRANSFORM stdTransRGB;
	cmsHTRANSFORM stdProofGC;
	cmsHTRANSFORM stdProofCMYKGC;
	bool BlackPoint;
	bool SoftProofing;
	bool Gamut;
	int  IntentColors;
	int  IntentImages;
	bool HasCMS;
	QMap<QString,QString> JavaScripts;
	int TotalItems;
	int MinWordLen;
	int HyCount;
	QString Language;
	bool Automatic;
	bool AutoCheck;
	PDFOptions PDF_Options;
	PrintOptions Print_Options;
	bool RePos;
	struct BookMa {
		QString Title;
		QString Text;
		QString Aktion;
		PageItem *PageObject;
		int Parent;
		int ItemNr;
		int First;
		int Last;
		int Prev;
		int Next;
	};
	QList<BookMa> BookMarks;
	bool OldBM;
	bool hasName;
	int RotMode;
	QMap<QString,multiLine> MLineStyles;
	QList<ArrowDesc> arrowStyles;
	QMap<QString, ScPattern> docPatterns;
	QWidget* WinHan;
	bool DoDrawing;
	struct OpenNodesList
	{
		int type;
		Page *page;
		PageItem *item;
	};
	QList<OpenNodesList> OpenNodes;
	QTimer *CurTimer;
	QMap<int, errorCodes> docLayerErrors;
	QMap<int, errorCodes> docItemErrors;
	QMap<int, errorCodes> masterItemErrors;
	ObjAttrVector docItemAttributes;	/*!< Attributes to be applied to frames. */
	ToCSetupVector docToCSetups;
	DocumentSectionMap sections;
	FPointArray symReturn;
	FPointArray symNewLine;
	FPointArray symTab;
	FPointArray symNonBreak;
	FPointArray symNewCol;
	FPointArray symNewFrame;
	Hyphenator * docHyphenator;
protected:
	bool loading;				/*!< Is the document loading ? See isLoading() and setLoading(). */
	bool modified;				/*!< Is the document modified ? See isModified() and setModified(). */

	bool m_hasGUI;		 		/*!< Is document associated with a GUI ? See hasGUI() and setGUI(). */
	ScribusMainWindow* m_ScMW; 		/*!< Main window associated with the document. See scMW() and setGUI(). */
	ScribusView* m_View;			/*!< View associated with the document. See view() and setGUI(). */

	bool m_masterPageMode;			/*!< Is the document in master page mode ? See masterPageMode() and setMasterPageMode(). */

	bool automaticTextFrames;		/*!< Is the document using automaticTextFrames ? See usesAutomaticTextFrames() and setUsesAutomagicTextFrames(). */

	int docUnitIndex;			/*!< Document's unit index. See setUnitIndex() and unitIndex(). */
	double docUnitRatio;			/*!< Document's unit ratio. See unitRatio(). */

	UndoManager * const undoManager;
	int ActiveLayer;
	QMap<QString, double> m_constants;
	ScGuardedObject<ScribusDoc> m_guardedObject;
private:
	Page* m_currentPage;			/*!< Current page. See setCurrentPage() and currentPage(). */

	StyleSet<ParagraphStyle> docParagraphStyles;	/*!< Paragraph StyleSet. */
	StyleSet<CharStyle> docCharStyles;		/*!< Character StyleSet. */

//ivro: don't know what it is
	UndoTransaction* m_itemCreationTransaction;
	UndoTransaction* m_alignTransaction;

	UpdateManager m_updateManager;
	MassObservable<PageItem*> m_itemsChanged;
	MassObservable<Page*> m_pagesChanged;
	MassObservable<QRectF> m_regionsChanged;
	DocUpdater* m_docUpdater;
};

Q_DECLARE_METATYPE(ScribusDoc*);

#endif
scribusdoc.h (55,998 bytes)   

cbradney

2009-02-21 20:52

administrator   ~0021182

Sure, we would love such contributions. We use doxygen to parse the files into http://docs.scribus.net/devel/, so the format existing in some files is ok.

ivro

2009-02-21 21:35

reporter   ~0021183

Are you ok with the change in scribus.h ?
Do you what a diff ?

ivro

2009-02-21 21:44

reporter   ~0021184

It's Do you want a diff !

avox

2009-02-21 22:51

administrator   ~0021185

What do you mean with "vertical layout"? As in Japanese or traditional Chinese writing?

ivro

2009-02-22 06:23

reporter   ~0021187

No, I mean vertical document. A top and a bottom pages document, like left and right.

######### #########
# # # #
# page 1 # # page 3 #
######### #########
# # # #
# page 2 # # ... #
#########

2009-02-22 06:49

 

page.h (5,881 bytes)   
/*
For general Scribus (>=1.3.2) copyright and licensing information please refer
to the COPYING file provided with the program. Following this notice may exist
a copyright and/or license notice that predates the release of Scribus 1.3.2
for which a new license (GPL+exception) is in place.
*/
/*!*************************************************************************
                          page.h  -  description
                             -------------------
    begin                : Sat Apr 7 2001
    copyright            : (C) 2001 by Franz Schmid
    email                : Franz.Schmid@altmuehlnet.de
 ***************************************************************************/

/*!*************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/

#ifndef PAGE_H
#define PAGE_H

#include <utility>

#include <QList>

#include "scribusapi.h"
#include "undostate.h"
#include "scribusstructs.h"
#include "guidemanagercore.h"

class PageItem;
class QString;
class UndoManager;
class UndoState;
class ScribusDoc;


/*!
  *@author Franz Schmid
  */
class SCRIBUS_API Page : public UndoObject, public SingleObservable<Page>
{
public:
	/*!
	 * Create a new Page.
	 * @param xOffset page's X offset
	 * @param yOffset page's Y offset
	 * @param width page's width
	 * @param height page's height
	 */
	Page(const double xOffset, const double yOffset, const double width, const double height);
	~Page();

	/*! Get the page's X offset. */
	double xOffset() const { return m_xOffset; }
	/*! Get the page's Y offset. */
	double yOffset() const { return m_yOffset; }
	/*! Get the page's width. */
	double width() const { return m_width; }
	/*! Get the page's height. */
	double height() const { return m_height; }
	/*! Get the initial page's width. */
	double initialWidth() const { return m_initialWidth; }
	/*! Get the initial page's height. */
	double initialHeight() const { return m_initialHeight; }

	/*! Set the page's X offset. */
	void setXOffset(const double);
	/*! Set the page's Y offset. */
	void setYOffset(const double);
	/*! Set the page's width. */
	void setWidth(const double);
	/*! Set the page's height. */
	void setHeight(const double);
	/*! Set the initial page's width. */
	void setInitialWidth(const double);
	/*! Set the initial page's height. */
	void setInitialHeight(const double);
	
//ivro: create functions to set margins and initial margins ?
// 	void setMargins(MarginsStruct& margins);
// 	void setInitialMargins(MarginStruct& margins);

	/*! Get the scribus document this page belongs to. */
	ScribusDoc* doc() const { return m_Doc; }
	/*! Set the scribus document this page belongs to. */
	void setDocument(ScribusDoc*);

	/*! Get the page's number. */
	int pageNr() const { return m_pageNr; }
	/*! Set the page's number. */
	void setPageNr(int);

	/*! Get the page's section number. */
	const QString& pageSectionNumber() const { return m_pageSectionNumber; }
	/*! Set the page's section number. */
	void setPageSectionNumber(const QString&);

	/*! Get the page's name. */
	const QString& pageName() const {return m_PageName;};
	/*! Set the page's name. */
	void setPageName(const QString&);

	/*!
	 * Copy page's sizing properties.
	 * Copy X offset, Y offset, width, height, initial width and initial height from page
	 * And uses pageMargins to set margins and initial margins
	 * @param sourcePage page to copy
	 * @param pageMargins margins to use
	 */
	void copySizingProperties(Page *sourcePage, const MarginStruct& pageMargins);

public:
	MarginStruct Margins;			/*!< Current page's margins. */
	MarginStruct initialMargins;		/*!< Initial page's margins. */
	int LeftPg;				/*!< Page's location in the document. 1 for left page, 0 for right page, 2 for middle page. */
//ivro: rename masterPageName ?
	QString MPageNam;			/*!< Name of the Master page this page uses. */
	QString m_pageSize;			/*!< Page's size name. */
//ivro: use the scribusstruct PageOrientation enum ?
	int PageOri;				/*!< Page's orientation. 0 = Portrait, 1 = Landscape. */

	int marginPreset;

	void restore(UndoState* state, bool isUndo);

	/*! As a bit of a dirty hack, we declare this mutable so it can be altered
	even while the object is `const'. That's normally only for internal
	implementation, but in this case it at least lets us guarantee the rest
	of the object is unchanged in (eg) pdflib. This should be replaced with
	proper access methods later. */
	mutable QList<PageItem*> FromMaster;

	GuideManagerCore guides;		/*!< Guides lists and basic operations. */

protected:
	UndoManager * const undoManager;
	void restorePageItemCreation(ItemState<PageItem*> *state, bool isUndo);
	void restorePageItemDeletion(ItemState<PageItem*> *state, bool isUndo);
	void restorePageItemConversion(ItemState<std::pair<PageItem*, PageItem*> >*state, bool isUndo);
	
	double m_xOffset;			/*!< Page's X offset. */
	double m_yOffset;			/*!< Page's Y offset. */
	double m_width;				/*!< Page's width. */
	double m_height;			/*!< Page's height. */
	double m_initialWidth;			/*!< Initial page's width. */
	double m_initialHeight;			/*!< Initial page's height. */
	int m_pageNr;				/*!< Page's number. */
	QString m_PageName;			/*!< Page's name. */
	ScribusDoc* m_Doc;			/*!< Scribus document this page belongs to. */
	QString m_pageSectionNumber;		/*!< Page's section number. */
};

Q_DECLARE_METATYPE(Page*);

#endif
page.h (5,881 bytes)   

ivro

2009-02-22 06:50

reporter   ~0021188

I add more work, see page.h

pierremarchand

2009-02-22 11:37

reporter   ~0021190

ivro, please upload diffs rather than source files. We need to review your changes and it’s not possible with source files.
TIA

2009-02-22 21:23

 

diff scribusdoc.h (79,432 bytes)   
Index: Scribus/scribus/scribusdoc.h
===================================================================
--- Scribus/scribus/scribusdoc.h	(révision 13182)
+++ Scribus/scribus/scribusdoc.h	(copie de travail)
@@ -4,7 +4,7 @@
 a copyright and/or license notice that predates the release of Scribus 1.3.2
 for which a new license (GPL+exception) is in place.
 */
-/***************************************************************************
+/*!*************************************************************************
                           scribusdoc.h  -  description
                              -------------------
     begin                : Fre Apr  6 21:47:55 CEST 2001
@@ -12,7 +12,7 @@
     email                : Franz.Schmid@altmuehlnet.de
  ***************************************************************************/
 
-/***************************************************************************
+/*!*************************************************************************
  *                                                                         *
  *   This program is free software; you can redistribute it and/or modify  *
  *   it under the terms of the GNU General Public License as published by  *
@@ -107,688 +107,1031 @@
 };
 
 
-/**! \brief the Document Class
-  */
+/*!
+ * @brief The Scribus Document Class
+ *
+ * TODO: Write some introduction
+ */
 class SCRIBUS_API ScribusDoc : public QObject, public UndoObject, public Observable<ScribusDoc>
 {
 	Q_OBJECT
 
 public:
+	// Constructors, destructor
+
+	/*!
+	 *  Create a new scribus document
+	 */
 	ScribusDoc();
+	/*!
+	 * Create a new scribus document
+	 * @param docName name for the new document
+	 * @param unitIndex
+	 * @param pageSize
+	 * @param margins initial margins for the document
+	 * @param pageSetup
+	 */
 	ScribusDoc(const QString& docName, int unitIndex, const PageSize& pagesize, const MarginStruct& margins, const DocPagesSetup& pagesSetup);
 	~ScribusDoc();
+
 	void init();
-	void setup(const int, const int, const int, const int, const int, const QString&, const QString&);
+	void setup(const int unitIndex, const int fp, const int firstLeft, const int orientation, const int firstPageNumber, const QString& defaultPageSize, const QString& documentName);
+
+
+
+
+public:
+
+// Document states
+
+	/*!
+	 * Set the loading state of the document
+	 * See ScribusDoc.isLoading()
+	 */
 	void setLoading(const bool);
+	/*!
+	 * Is the document loading ?
+	 * See ScribusDoc.setLoading()
+	 */
 	bool isLoading() const;
+	/*!
+	 * Set modified state of the document
+	 * If state changed, update the document
+	 * See ScribusDoc.isModified()
+	 */
 	void setModified(const bool);
+	/*!
+	 * Is the document modified ?
+	 * See ScribusDoc.setModified()
+	 */
 	bool isModified() const;
-/** Setzt die Seitenattribute */
-	void setPage(double b, double h, double t, double l, double r, double bo, double sp, double ab, bool atf, int fp);
-	void resetPage(MarginStruct& newMargins, int fp);
+	/*!
+	 * Call whenever the document needs to know it has been changed.
+	 * If the document is the primary document in a main window,
+	 * it will emit the DocChanged signal to enable/disable certain operations.
+	 */
+	void changed();
 
-	/**
-	 * @brief Return the view associated with the document
+// GUI 
+	/*!
+	 * Associate document and GUI.
+	 * See ScribusDoc.hasGUI(), ScribusDoc.scMW() and ScribusDoc.view()
+	 * @param hasgui Is document associated with gui ?
+	 * @param mainWindow scribus main window
+	 * @param view scribus view
 	 */
+	void setGUI(bool hasgui, ScribusMainWindow* mainWindow, ScribusView* view);
+	/*!
+	 * Is the document associated with GUI ?
+	 * See Scribus.setGUI()
+	 */
+	bool hasGUI() const {return m_hasGUI;}
+	/*!
+	  * Get the scribus main window associated with the document.
+	  * See Scribus.setGUI()
+	  * @return the scribus man window
+	  */
+//ivro: rename this function (mainWindow or scribusMainWindow) ?
+	ScribusMainWindow* scMW() const {return m_ScMW;}
+	/*!
+	 * Get the view associated with the document.
+	 * See Scribus.setGUI()
+	 * @return the scribus view
+	 */
 	ScribusView* view() const;
-	ScribusMainWindow* scMW() const {return m_ScMW;}
-	void setGUI(bool hasgui, ScribusMainWindow* mw, ScribusView* view);
 
-	/**
-	 * @brief Return the guarded object associated with the document
+// Automatic Text Frames
+	/*!
+	 * Set if doc uses automatic text frames.
+	 * See ScribusDoc.usesAutomaticTextFrames(), ScribusDoc.PageSp and ScribusDoc.PageSpa
 	 */
-	const ScGuardedPtr<ScribusDoc>& guardedPtr() const;
-	
-	UpdateManager* updateManager() { return &m_updateManager; }
-	MassObservable<PageItem*> * itemsChanged() { return &m_itemsChanged; }
-	MassObservable<Page*>     * pagesChanged() { return &m_pagesChanged; }
-	MassObservable<QRectF>    * regionsChanged() { return &m_regionsChanged; }
-	void invalidateRegion(QRectF region);
-	
-	// Add, delete and move pages
-	
-	Page* addPage(const int pageNumber, const QString& masterPageName=QString::null, const bool addAutoFrame=false);
-	void deletePage(const int);
-	//! @brief Add a master page with this function, do not use addPage
-	Page* addMasterPage(const int, const QString&);
-	void deleteMasterPage(const int);
-	//! @brief Rebuild master name list
-	void rebuildMasterNames(void);
-	//! @brief Replace a master page by default one
+	void setUsesAutomaticTextFrames(const bool);
+	/*!
+	 * Is document using automatic text frames ?
+	 * See ScribusDoc.setUsesAutomaticTextFrames
+	 */
+	bool usesAutomaticTextFrames() const;
+
+// Grid and Guides
+	/*!
+	 * Should guides be locked or not ?
+	 * @param isLocked If true guides on pages cannot be moved if false they
+	 * can be dragged to new positions.
+	 * @author Riku Leino
+	 */
+	void lockGuides(bool isLocked);
+
+// Current Page
+	/*!
+	 * Set new current page.
+	 */
+	void setCurrentPage(Page*);
+	/*!
+	 * Get the current page.
+	 */
+	Page* currentPage();
+	/*!
+	 * Get the current page number.
+	 */
+	int currentPageNumber();
+
+// Unit index and unit ratio
+	/*!
+	 * Set the document's unit index and update the document's unit ratio.
+	 * See ScribusDoc.unitIndex() and ScribusDoc.unitRatio()
+	 */
+	void setUnitIndex(const int);
+	/*!
+	 * Get the document's unit index.
+	 * See ScribusDoc.setUnitIndex()
+	 */
+	int unitIndex() const;
+	/*!
+	 * Get the document's unit ratio.
+	 * See ScribusDoc.setUnitIndex()
+	 */
+	double unitRatio() const;
+// Document's properties
+	/*!
+	 * Sets the name of the document.
+	 * See ScribusDoc.DocName
+	 * @param name Name for the document
+	 * @author Riku Leino
+	 */
+	void setName(const QString& name);
+
+/*! @name Master Page
+ * Master page related functions.
+ *
+ * A master page is a model for page. It is used to use common item on multiple page.
+ * Use applyMasterPage() to associate a master page to a page.
+ * The master page mode (see masterPageMode()) allow to work with master pages and items with the same functions that use for pages and items.
+ */ //@{
+	/*!
+	 * Is the document in master page mode ?
+	 * In master page mode
+	 *      ScribusDoc.Pages = &ScribusDoc.MasterPages
+	 *      ScribusDoc.Items = &ScribusDoc.MasterItems
+	 * In normal mode (ie not in master mode)
+	 *      ScribusDoc.Pages = &ScribusDoc.DocPages
+	 *      ScribusDoc.Items = &ScribusDoc.DocItems
+	 */
+	bool masterPageMode() const { return m_masterPageMode; }
+	/*!
+	 * Set the doc into Master page mode.
+	 */
+// Do we need to return if the move to master page mode was successful?
+	void setMasterPageMode(bool);
+
+	/*!
+	 * Add a master page.
+	 * Use this function to add a master page, do not use addPage
+	 * @param pageNumber index for the master page
+	 * @param pageName name of the master page
+	 * @return added page
+	 */
+	Page* addMasterPage(const int pageNumber, const QString& pageName);
+	/*!
+	 * Delete a master page.
+	 * @param pageNumber index of the master page
+	 */
+	void deleteMasterPage(const int pageNumber);
+	/*!
+	 * Copies a normal page to be a master pages.
+	 * @param pageNumber index of the page to copy
+	 * @param leftPage
+         * @param maxLeftPage
+	 * @param masterPageName name for the master page
+	 * @param copyFromAppliedMaster
+	 */
+	bool copyPageToMasterPage(const int pageNumber, const int leftPage, const int maxLeftPage, const QString& masterPageName, bool copyFromAppliedMaster);
+	/*!
+	 * Replace a master page by default one.
+	 * @param oldMasterPage name of the master page to remplace
+	 */
 	void replaceMasterPage(const QString& oldMasterPage);
-	//! @brief Rename a master page
+	/*!
+	 * Rename a master page.
+	 * @param oldPageName old name of the master page
+	 * @param newPageName new name for the master page
+	 */
 	bool renameMasterPage(const QString& oldPageName, const QString& newPageName);
-	//! @brief Create the default master pages based on the layout selected by the user, ie, Normal, Normal Left, etc.
-	void createDefaultMasterPages();
-	//! @brief Create the requested pages in a new document, run after createDefaultMasterPages()
-	void createNewDocPages(int pageCount);
-	/**
-	 * @brief Add the automatic text frame to the page
-	 * @param pageNumber page number
-	 * @return number of frame
+	/*!
+	 * Apply a master page.
+	 * @param masterPageName name of the master page
+	 * @param pageNumber index of the page
 	 */
-	int addAutomaticTextFrame(const int pageNumber);
-	/**
-	 * Set the left and right margins based on the location of the page
-	 * @param pageIndex 
+	bool applyMasterPage(const QString& masterPageName, const int pageNumber);
+	/*!
+	 * Rebuild master name list.
+	 * Rebuild ScribusDoc.MasterName list from the master page name
 	 */
-	void setLocationBasedPageLRMargins(uint pageIndex);
-	/**
-	 * @brief Move page(s) within the document
+	void rebuildMasterNames(void);
+//@} //End of masterpage group
+
+/*! @name Page
+ * Page related functions.
+ *
+ * A page represents a paper page. See Page::Page
+ */ //@{
+	// Add, delete and move page
+
+	/*!
+	 * Add a page.
+	 * Do not use this to add a master page, use addMasterPage instead
+	 * @param pageNumber index for the page
+	 * @param masterPageName master page to use
+	 * @param addAutoFrame add automatic text frame
+	 * @return addedpage
+	 */
+	Page* addPage(const int pageNumber, const QString& masterPageName=QString::null, const bool addAutoFrame=false);
+	/*!
+	 * Delete a page.
+	 * @param pageNumber index of the page
+	 */
+	void deletePage(const int pageNumber);
+	/*!
+	 * Move page(s) within the document.
 	 * @param from page index
 	 * @param to page index
-	 * @param ziel target to move to (page index)
-	 * @param art Before, After or at the end
+	 * @param ziel page index of the target to move to
+	 * @param art Before (0), After (1) or At the end (2)
 	 */
+//ivro: create typedef for param art (like whereToMove) ?
 	void movePage(const int from, const int to, const int ziel, const int art);
-	
-	/**
-	 * @brief Copy a page (pageNumberToCopy) copyCount times, whereToInsert(before or after) the existingPage or at the end.
-	 * @param pageNumberToCopy 
-	 * @param existingPage 
-	 * @param whereToInsert 
-	 * @param copyCount 
+	/*!
+	 * Copy a page.
+	 * Copy a page (pageNumberToCopy) copyCount times, whereToInsert(before or after) the existingPage or at the end.
+	 * @param pageNumberToCopy index of the page
+	 * @param existingPage where to copy (page index)
+	 * @param whereToInsert Before (0), After (1) or At the end (2)
+	 * @param copyCount number of copy
 	 */
+//ivro: use typedef whereToMove for param whereToInsert ?
 	void copyPage(int pageNumberToCopy, int existingPage, int whereToInsert, int copyCount);
-	
+
+	// Properties of page
+
+	/*!
+	 * Set page properties.
+	 * @param width page width
+	 * @param height page height
+	 * @param marginsTop page margins top
+	 * @param marginsLeft page margins left
+	 * @param marginsRight page margins right
+	 * @param marginsBottom page margins bottom
+	 * @param numberOfColumns number of automaticTextFrames columns
+	 * @param distanceOfColumns distance between automaticTextFrams columns 
+	 * @param automaticTextFrames is automaticTextFrames enabled ?
+	 * @param pageLayout index of the page layout in ScribusDoc.pageSets
+	 */
+	void setPage(double width, double height, double marginsTop, double marginsLeft, double marginsRight, double marginsBottom, double numberOfColums, double distanceOfColumns, bool automatictTextFrames, int pageLayout);
+	/*!
+	 * Reset the page properties.
+	 * @param newMargins margins to apply
+	 * @param pageLayout index of the page layout in Scribus.pageSets
+	 */
+	void resetPage(MarginStruct& newMargins, int pageLayout);
+
+	/*!
+	 * Add the automatic text frame to the page.
+	 * @param pageNumber index of page
+	 * @return number of text frame created, -1 on error
+	 */
+	int addAutomaticTextFrame(const int pageNumber);
+
+	/*!
+	 * Set the page margins. Current code uses current page only, also provide a (currently, TODO) option for this.
+	 * @param initialTop
+	 * @param initialBottom
+	 * @param initialLeft
+	 * @param initialRight
+	 * @param initialHeight
+	 * @param initialWight
+	 * @param height
+	 * @param width
+	 * @param orientation
+	 * @param pageSize
+	 * @param pageNumber if equal to -1, do nothing and return false. Caution default is -1.
+	 * @param pageType see Page.LeftPg, default to 0 (Right page)
+	 */
+//ivro: is this fuction name goods as it does things that not only about margins ?
+	bool changePageMargins(const double initialTop, const double initialBottom, const double initialLeft, const double initialRight, const double initialHeight, const double initialWidth, const double height, const double width, const int orientation, const QString& pageSize, const int pageNumber=-1, const int pageType = 0);
+
+	/*!
+	 * Get page's bleeds.
+	 * @param pageNumber index of the page
+	 * @param bleedData struct to get the bleed
+	 */
+//ivro: is this not better in Page ?
+	void getBleeds(int pageNumber, MarginStruct& bleedData);
+	/*!
+	 * Get page's bleeds.
+	 * @param page page to look at
+	 * @param bleedData struct to get the bleed
+	 */
+	void getBleeds(Page* page, MarginStruct& bleedData);
+
+
+	// Canvas
+
+	/*!
+	 * Get the location of the page on the canvas, ie, left, middle, or right.
+	 * Does not give information about middle left, etc.
+	 * @param pageIndex Index of page to find location for
+	 * @return LeftPage, MiddlePage, RightPage, enum from pagestructs.h
+	 */
+	PageLocation locationOfPage(int pageIndex) const;
+	/*!
+	 * Get the column of the page on the canvas, ie, left, middle, or right.
+	 * @param pageIndex Index of page to find location for
+	 * @return int of 0,1,2,3
+	 */
+	int columnOfPage(int pageIndex) const;
+	/*!
+	 * Return the x offset for a page on the canvas.
+	 * @retval double containing the offset. Returns -1.0 if page not in Pages list (as -ve is not possible).
+	 * Mostly saves bringing in extra includes into files that already have scribusdoc.h
+	 */
+	double getXOffsetForPage(const int);
+	/*!
+	 * Return the y offset for a page on the canvas.
+	 * @retval double coutaining the offset. Returns -1.0 if page not in pages list (as -ve is not possible).
+	 */
+	double getYOffsetForPage(const int);
+
+	/*!
+	 * Set the left and right margins based on the location of the page.
+	 * @param pageIndex index of the page
+	 */
+	void setLocationBasedPageLRMargins(uint pageIndex);
+//@} // End of pages groups
+
+/*! @name Layer
+ * layer related functions.
+ */ //@{
 	// Add, delete and move layers
-	/**
-	 * @brief Add a layer to the current document
+
+	/*!
+	 * Add a layer to the current document.
 	 * @param layerName name of layer
 	 * @param activate the layer active
 	 * @return Number of the layer created
 	 */
 	int addLayer(const QString& layerName=QString::null, const bool activate=false);
-	/**
-	 * @brief Copies a layer from the current document
+	/*!
+	 * Copies a layer from the current document.
 	 * @param layerNumberToCopy source layer
 	 * @param whereToInsert target layer
 	 * @return Success or failure
 	 */
 	void copyLayer(int layerNumberToCopy, int whereToInsert);
-	/**
-	 * @brief Delete a layer from the current document
+	/*!
+	 * Delete a layer from the current document.
 	 * @param layerNumber of layer
 	 * @param deleteItems the items on the layer too?
 	 * @return Success or failure
 	 */
 	bool deleteLayer(const int layerNumber, const bool deleteItems);
-	/**
-	 * @brief Return the number of the current layer
-	 * @return Active layer number
+	/*!
+	 * FIXME: Make protected once scripter function no longer uses this directly
 	 */
-	int activeLayer();
+	void removeLayer(int l, bool dl = false);
 
-	/**
-	 * @brief Return the name of the current layer
-	 * @return Name of the layer
-	 */
-	const QString& activeLayerName();
-	/**
-	 * @brief Set the active layer via the layer number
+	// Active layer
+
+	/*!
+	 * Set the active layer via the layer number.
 	 * @param layerToActivate Number of the layer
 	 * @return Success or failure
 	 */
 	bool setActiveLayer(const int layerToActivate);
-	/**
-	 * @brief Set the active layer via the layer name
+	/*!
+	 * Set the active layer via the layer name.
 	 * @param layerNameToActivate Name of the layer
 	 * @return Success or failure
 	 */
 	bool setActiveLayer(const QString & layerNameToActivate);
-	/**
-	 * @brief Set the layer printable via the layer number
+	/*!
+	 * Return the number of the current layer.
+	 * @return Active layer number
+	 */
+	int activeLayer();
+	/*!
+	 * Return the name of the current layer.
+	 * @return Name of the layer
+	 */
+	const QString& activeLayerName();
+
+	// Layer properties
+
+	/*!
+	 * Return the layer name.
 	 * @param layerNumber Number of the layer
+	 * @return Name of the layer
+	 */
+	QString layerName(const int layerNumber) const;
+	/*!
+	 * Change the name of a layer.
+	 * @param layerNumber number of the layer
+	 * @param newName new name of the layer
+	 * @return Success or failure
+	 */
+	bool changeLayerName(const int layerNumber, const QString& newName);
+	/*!
+	 * Set the layer printable via the layer number.
+	 * @param layerNumber Number of the layer
 	 * @param isPrintable bool true = layer is prantable
 	 * @return Success or failure
 	 */
 	bool setLayerPrintable(const int layerNumber, const bool isPrintable);
-	/**
-	 * @brief Is the layer printable
+	/*!
+	 * Is the layer printable ?
 	 * @param layerNumber Number of the layer
 	 * @return Printable or not
 	 */
-	bool layerPrintable(const int layerNumber);
-	/**
-	 * @brief Set the layer visible via the layer number
+	bool layerPrintable(const int layerNumber);  
+	/*!
+	 * Set the layer visible via the layer number.
 	 * @param layerNumber Number of the layer
 	 * @param isViewable true = layer is visible
 	 * @return Success or failure
 	 */
 	bool setLayerVisible(const int layerNumber, const bool isViewable);
-	/**
-	 * @brief Is the layer visible
+	/*!
+	 * Is the layer visible ?
 	 * @param layerNumber Number of the layer
 	 * @return Visible or not
 	 */
 	bool layerVisible(const int layerNumber);
-	/**
-	 * @brief Set the layer locked via the layer number
+	/*!
+	 * Set the layer locked via the layer number.
 	 * @param layerNumber Number of the layer
 	 * @param isLocked true = layer is locked
 	 * @return Success or failure
 	 */
 	bool setLayerLocked(const int layerNumber, const bool isLocked);
-	/**
-	 * @brief Is the layer locked
+	/*!
+	 * Is the layer locked ?
 	 * @param layerNumber Number of the layer
 	 * @return Locked or not
 	 */
 	bool layerLocked(const int layerNumber);
-	/**
-	 * @brief Set the layer flow via the layer number
+	/*!
+	 * Set the layer flow via the layer number.
 	 * @param layerNumber Number of the layer
 	 * @param flow true = Text flows around objects on this layer
 	 * @return Success or failure
 	 */
 	bool setLayerFlow(const int layerNumber, const bool flow);
-	/**
-	 * @brief does text flow around objects on this layer
+	/*!
+	 * does text flow around objects on this layer ?
 	 * @param layerNumber Number of the layer
 	 * @return flow or not
 	 */
 	bool layerFlow(const int layerNumber);
-	/**
-	 * @brief Set the layer transparency via the layer number
+	/*!
+	 * Set the layer transparency via the layer number.
 	 * @param layerNumber Number of the layer
 	 * @param trans transparency value 0.0 - 1.0
 	 * @return Success or failure
 	 */
 	bool setLayerTransparency(const int layerNumber, double trans);
-	/**
-	 * @brief returns the layer transparency
+	/*!
+	 * returns the layer transparency.
 	 * @param layerNumber Number of the layer
 	 * @return transparency value 0.0 - 1.0
 	 */
 	double layerTransparency(const int layerNumber);
-	/**
-	 * @brief Set the layer layerBlendMode via the layer number
+	/*!
+	 * Set the layer layerBlendMode via the layer number.
 	 * @param layerNumber Number of the layer
 	 * @param blend layerBlendMode
 	 * @return Success or failure
 	 */
 	bool setLayerBlendMode(const int layerNumber, int blend);
-	/**
-	 * @brief returns the layer BlendMode
+	/*!
+	 * Returns the layer BlendMode.
 	 * @param layerNumber Number of the layer
 	 * @return layerBlendMode
 	 */
 	int layerBlendMode(const int layerNumber);
-	/**
-	 * @brief Return the level of the requested layer
+	/*!
+	 * Set the layer outline mode via the layer number.
 	 * @param layerNumber Number of the layer
-	 * @return Level of the layer
+	 * @param outline true = layer is displayed in outlines only
+	 * @return Success or failure
 	 */
-	int layerLevelFromNumber(const int layerNumber);
-	/**
-	 * @brief Set the layer marker color
+	bool setLayerOutline(const int layerNumber, const bool outline);
+	/*!
+	 * Is this layer in outline mode ?
 	 * @param layerNumber Number of the layer
+	 * @return outline or not
+	 */
+	bool layerOutline(const int layerNumber);
+
+	// Layer marker color
+
+	/*!
+	 * Set the layer marker color.
+	 * @param layerNumber Number of the layer
 	 * @param color color of the marker
 	 * @return Success or failure
 	 */
 	bool setLayerMarker(const int layerNumber, QColor color);
-	/**
-	 * @brief returns the layer marker color
+	/*!
+	 * Returns the layer marker color.
 	 * @param layerNumber Number of the layer
 	 * @return marker color
 	 */
 	QColor layerMarker(const int layerNumber);
-	/**
-	 * @brief Set the layer outline mode via the layer number
+
+	// Layer level
+
+	/*!
+	 * Returns the level of the requested layer.
 	 * @param layerNumber Number of the layer
-	 * @param outline true = layer is displayed in outlines only
-	 * @return Success or failure
+	 * @return Level of the layer
 	 */
-	bool setLayerOutline(const int layerNumber, const bool outline);
-	/**
-	 * @brief is this layer in outline mode
-	 * @param layerNumber Number of the layer
-	 * @return outline or not
-	 */
-	bool layerOutline(const int layerNumber);
-	/**
-	 * @brief Return the number of the layer at a certain level
+	int layerLevelFromNumber(const int layerNumber);
+	/*!
+	 * Returns the number of the layer at a certain level.
 	 * @param layerLevel Layer level
 	 * @return Layer number
 	 */
 	int layerNumberFromLevel(const int layerLevel);
-	/**
-	 * @brief Return the layer count
-	 * @return Number of layers in doc
-	 */
-	int layerCount() const;
-	/**
-	 * @brief Lower a layer
+
+	// Lower and Raise Layer
+
+	/*!
+	 * Lowers a layer.
 	 * @param layerNumber Number of the layer
 	 * @return Success or failure
 	 */
 	bool lowerLayer(const int layerNumber);
-	/**
-	 * @brief Lower a layer using the level
+	/*!
+	 * Lowers a layer using the level.
 	 * @param layerLevel Level of the layer
 	 * @return Success or failure
 	 */
 	bool lowerLayerByLevel(const int layerLevel);
-	/**
-	 * @brief Raise a layer
+	/*!
+	 * Raises a layer.
 	 * @param layerNumber Number of the layer
 	 * @return Success or failure
 	 */
 	bool raiseLayer(const int layerNumber);
-	/**
-	 * @brief Raise a layer using the level
+	/*!
+	 * Raises a layer using the level.
 	 * @param layerLevel Level of the layer
 	 * @return Success or failure
 	 */
 	bool raiseLayerByLevel(const int layerLevel);
-	/**
-	 * @brief Return the layer name
-	 * @param layerNumber Number of the layer
-	 * @return Name of the layer
+
+	// Various functions on layer
+
+	/*!
+	 * Returns the layer count.
+	 * @return Number of layers in doc
 	 */
-	QString layerName(const int layerNumber) const;
-	/**
-	 * @brief Change the name of a layer
-	 * @param layerNumber number of the layer
-	 * @param newName new name of the layer
-	 * @return Success or failure
-	 */
-	bool changeLayerName(const int layerNumber, const QString& newName);
-	/**
-	 * @brief Does the layer have items on it?
+	int layerCount() const;
+	/*!
+	 * Does the layer have items on it ?
 	 * @param layerNumber Number of the layer
 	 * @return Layer contains items bool
 	 */
 	bool layerContainsItems(const int layerNumber);
-	/**
-	 * @brief Renumber a layer. Used in particular for reinsertion for undo/redo
+	/*!
+	 * Renumbers a layer. Used in particular for reinsertion for undo/redo.
 	 * @param layerNumber old layer number
 	 * @param newLayerNumber New layer number
 	 * @return Success or failure
 	 */
 	bool renumberLayer(const int layerNumber, const int newLayerNumber);
-	/**
-	 * @brief Return a list of the layers in their order
+	/*!
+	 * Returns a list of the layers in their order.
 	 * @param list QStringList to insert the layer names into
 	 */
 	void orderedLayerList(QStringList* list);
-	//Items
-	bool deleteTaggedItems();
+//@} // End of Layer function
 
+/*! @name Item
+ * Item related functions.
+ */ //@{
+	// Add
+
 	/*!
-		* @brief Builds a qmap of the icc profiles used within the document
+	 * Add an Item to the document.
+	 * A simple function to create an item of a defined type and add it to the document
+	 * Will need extensive rewriting once we have various classes of PageItems, at a guess.
+	 *
+	 * @param itemType type
+	 * @param frameType frame type
+	 * @param x X pos
+	 * @param y Y pos
+	 * @param b width
+	 * @param h height
+	 * @param w ?
+	 * @param fill fill color name
+	 * @param outline outline color name
+	 * @param itemFinalised Used to handle item creation for undo while the user is still dragging.
+	 * @return Number of created item, -1 on failure.
 	 */
-	void getUsedProfiles(ProfilesL& usedProfiles);
-	bool OpenCMSProfiles(ProfilesL InPo, ProfilesL InPoCMYK, ProfilesL MoPo, ProfilesL PrPo);
-	void CloseCMSProfiles();
-	void SetDefaultCMSParams();
-	/**
-	 * @brief Switch Colormanagement on or of
-	 * @param enable bool, if true Colormanagement is switched on, else off
+	int itemAdd(const PageItem::ItemType itemType, const PageItem::ItemFrameType frameType, const double x, const double y, const double b, const double h, const double w, const QString& fill, const QString& outline, const bool itemFinalised);
+	/*!
+	 * Add an Item to the page.
+	 * Item will be fitted to the closest guides/margins of the x/y position.
+	 *
+	 * @param itemType type
+	 * @param itemFramType frame type
+	 * @param x X pos
+	 * @param y Y pos
+	 * @param w ?
+	 * @param fill fill color name
+	 * @param outline outline color name
+	 * @param itemFinalised Used to handle item creation for undo while the user is still dragging
+	 * @return Number of created item, -1 on failure.
 	 */
-	void enableCMS(bool enable);
-	
-	const ParagraphStyle& paragraphStyle(QString name) { return docParagraphStyles.get(name); }
-	const StyleSet<ParagraphStyle>& paragraphStyles()   { return docParagraphStyles; }
-	bool isDefaultStyle( const ParagraphStyle& p ) const { return docParagraphStyles.isDefault(p); }
-	bool isDefaultStyle( const CharStyle& c ) const { return docCharStyles.isDefault(c); }
-// 	bool isDefaultStyle( LineStyle& l ) const { return MLineStyles......; }
-
-	void getNamedResources(ResourceCollection& lists) const;
-	void replaceNamedResources(ResourceCollection& newNames);	
-	
-	void redefineStyles(const StyleSet<ParagraphStyle>& newStyles, bool removeUnused=false);
-	/**
-	 * @brief Remove any reference to old styles and replace with new name. This needs to be
-	 *        called when a style was removed. New name may be "".
-	 * @param newNameForOld a map which maps the name of any style to remove to a new stylename
+	int itemAddArea(const PageItem::ItemType itemType, const PageItem::ItemFrameType frameType, const double x, const double y, const double w, const QString& fill, const QString& outline, const bool itemFinalised);
+	/*!
+	 * Allow the user to create a frame easily with some simple placement and sizing options.
+	 * @param iafData a InsertAFrameData structure with params
+	 * @return int item id? FIXME
 	 */
-	void replaceStyles(const QMap<QString,QString>& newNameForOld);
-	/**
-	 * @brief Insert styles from another document in this document.
-	 *        
-	 * @param fileName The path of the document we want to extract its styles
+	int itemAddUserFrame(InsertAFrameData &iafData);
+	/*!
+	 * Commit item creation when a user has click-drag created an item.
+	 * Only called from ScribusView. Note the undo target is the page, so the undo code remains their for now.
+	 *
+	 * @return If an item was committed and the view must emit its signal, which needs removing from here, TODO.
 	 */
-	void loadStylesFromFile(QString fileName);
-	/**
-	 * @brief Gather styles from another document.
-	 *        
-	 * @param fileName The path of the document we want to extract its styles
-	 * @param tempStyles A pointer to a StyleSet which will be filled by paragraph styles
-	 * @param tempCharStyles A pointer to a StyleSet which will be filled by character styles
-	 * @param tempLineStyles A map which will be filled by line styles
+	bool itemAddCommit(const int itemNumber);
+	/*!
+	 * Finalise item creation, only to be called from itemAdd().
+	 * Simply split off code from itemAdd.
+	 * 
+	 * @param itemType type
+	 * @param frameType frame type
+	 * @param itemNumber item index
 	 */
-	void loadStylesFromFile(QString fileName, StyleSet<ParagraphStyle> *tempStyles,
-	                                          StyleSet<CharStyle> *tempCharStyles,
-	                                          QMap<QString, multiLine> *tempLineStyles);
-
-	const CharStyle& charStyle(QString name) { return docCharStyles.get(name); }
-	const StyleSet<CharStyle>& charStyles()  { return docCharStyles; }
-	void redefineCharStyles(const StyleSet<CharStyle>& newStyles, bool removeUnused=false);
-	/**
-	 * @brief Remove any reference to old styles and replace with new name. This needs to be
-	 *        called when a style was removed. New name may be "".
-	 * @param newNameForOld a map which maps the name of any style to remove to a new stylename
+	void itemAddDetails(const PageItem::ItemType itemType, const PageItem::ItemFrameType frameType, const int itemNumber);
+	/*!
+	 * Item type conversion functions.
+	 * @param currItem item to convert
+	 * @param newType
+	 * @param secondaryItem ?
 	 */
-	void replaceCharStyles(const QMap<QString,QString>& newNameForOld);
-
-	/**
-	 * @brief Should guides be locked or not
-	 * @param isLocked If true guides on pages cannot be moved if false they
-	 * can be dragged to new positions.
-	 * @author Riku Leino
-	 */
-	void lockGuides(bool isLocked);
-	/**
-	 * @brief Method used when an undo/redo is requested.
-	 * @param state State describing the action that is wanted to be undone/redone
-	 * @param isUndo If true undo is wanted else if false redo.
-	 * @author Riku Leino
-	 */
-	void restore(UndoState* state, bool isUndo);
-	/**
-	 * @brief Sets the name of the document
-	 * @param name Name for the document
-	 * @author Riku Leino
-	 */
-	void setName(const QString& name);
+	PageItem* convertItemTo(PageItem *currItem, PageItem::ItemType newType, PageItem* secondaryItem=NULL);
 	/*!
-	 * @brief Returns a stringlist of the item attributes within the document
+	 * Paste an item to the document.
+	 * The bulk of a paste item process runs here for want of a better place, but its a better place
+	 * than the view where it used to be. 
+	 * TODO Once the pageitem restructure is done, this is probably unnecessary but it removes the 
+	 * unnecessary part from the view for now which is overloaded with non ScrollView code.
 	 */
-	QStringList getItemAttributeNames();
+	//TODO: void PasteItem(struct CopyPasteBuffer *Buffer, bool loading, bool drag = false);
 
-	bool AddFont(QString name, int fsize = 10);
+	//itemDelete
+	//itemBlah...
+
+	// move, rotate, resize items
+
 	/*!
-	 * @brief TODO: Reorganise the fonts.. how? Moved from scribus.cpp
-	 * CB: almost the same as getUsedFonts???
+	 * Move item.
+	 * @param newX new X coord
+	 * @param newY new Y coord
+	 * @param item page item to move
+	 * @param fromMP ?
 	 */
-	QMap<QString,int> reorganiseFonts();
+//ivro: standardize param order as PageItem changed each function ?
+//	something like item, args, options ?
+	bool MoveItem(double newX, double newY, PageItem* ite, bool fromMP = false);
 	/*!
-	 * @brief Returns a qmap of the fonts and  their glyphs used within the document
+	 * Rotate Item.
+	 * @param angle angle to rotate
+	 * @param itemNumber index of the item to rotate
 	 */
-	void getUsedFonts(QMap<QString,QMap<uint, FPointArray> > &Really);
-	void checkItemForFonts(PageItem *it, QMap<QString, QMap<uint, FPointArray> > & Really, uint lc);
-
+	void RotateItem(double angle, int itemNumber);
 	/*!
-	 * @brief Replace line style colors
+	 * Rotate Item.
+	 * @param angle angle to rotate
+	 * @param currItem page item to rotate
 	 */
-	void replaceLineStyleColors(const QMap<QString, QString>& colorMap);
+	void RotateItem(double angle, PageItem *currItem);
 	/*!
-	* @brief Builds a qmap of the colours used within the document
-	*/
-	void getUsedColors(ColorList &colorsToUse, bool spot = false);
+	 * Move and Rotate Item.
+	 * @param currItem page item to transform
+	 * @param npv ?
+	 * @param fromMP ?
+	 */
+	void MoveRotated(PageItem *currItem, FPoint npv, bool fromMP = false);
 	/*!
-	* @brief Return if a specific color is used by line styles
-	*/
-	bool lineStylesUseColor(const QString& colorName);
+	 * Resize item.
+	 * @param newX new X coord
+	 * @param newY new Y coord
+	 * @param ite index of page item to resize
+	 * @param fromMp ?
+	 * @param DoUpdateClip ?
+	 * @param redraw ?
+	 */
+	bool SizeItem(double newX, double newY, int ite, bool fromMP = false, bool DoUpdateClip = true, bool redraw = true);
 	/*!
-	* @brief Set the patterns for a document
-	*/
-	bool addPattern(QString &name, ScPattern& pattern);
-	void setPatterns(QMap<QString, ScPattern> &patterns);
+	 * Resize item.
+	 * @param newX new X coord
+	 * @param newY new Y coord
+	 * @param pi page item to resize
+	 * @param fromMp ?
+	 * @param DoUpdateClip ?
+	 * @param redraw ?
+	 */
+	bool SizeItem(double newX, double newY, PageItem *pi, bool fromMP = false, bool DoUpdateClip = true, bool redraw = true);
 	/*!
-	* @brief Builds a QStringList of the patterns used within the document
-	*/
-	QStringList getUsedPatterns();
-	QStringList getUsedPatternsSelection(Selection* customSelection);
-	QStringList getUsedPatternsHelper(QString pattern, QStringList &results);
-	/**
-	 * @brief Set and get the document's unit index
+	 * Size and Move item.
+	 * @param newX new X coord
+	 * @param newY new Y coord
+	 * @param ite index of page item to transform
+	 * @param fromMp ?
+	 * @param constrainRotation ?
 	 */
-	void setUnitIndex(const int);
-	int unitIndex() const;
-	double unitRatio() const;
-	/**
-	 * @brief Apply a master page
-	 */
-	bool applyMasterPage(const QString& pageName, const int pageNumber);
-	/**
-	 * @brief Undo function for applying a master page
-	 */
-	void restoreMasterPageApplying(SimpleState *state, bool isUndo);
-	void restorePageCopy(SimpleState *state, bool isUndo);
-	/**
-	 * @brief Save function
-	 */
-	bool save(const QString& fileName, QString* savedFile = NULL);
-	/**
-	 * @brief Set the page margins. Current code uses current page only, also provide a (currently, TODO) option for this.
-	 */
-	bool changePageMargins(const double initialTop, const double initialBottom, const double initialLeft, const double initialRight, const double initialHeight, const double initialWidth, const double Height, const double width, const int orientation, const QString& pageSize, const int pageNumber=-1, const int pageType = 0);
-	/**
-	 * @brief Recalculate the colors after CMS settings change. Update the items in the doc accordingly.
-	 */
-	 void recalculateColors();
-	/**
-	 * @brief Sets up the ScText defaults from the document
-	 */
-	void setScTextDefaultsFromDoc(ScText *);
-	/**
-	 * @brief Copies a normal page to be a master pages
-	 */
-	bool copyPageToMasterPage(const int, const int, const int, const QString&, bool);
-	/**
-	 * @brief Paste an item to the document.
-	 * The bulk of a paste item process runs here for want of a better place, but its a better place
-	 * than the view where it used to be. 
-	 * TODO Once the pageitem restructure is done, this is probably unnecessary but it removes the 
-	 * unnecessary part from the view for now which is overloaded with non ScrollView code.
-	 */
-	//TODO: void PasteItem(struct CopyPasteBuffer *Buffer, bool loading, bool drag = false);
-	
-	/**
-	 * @brief Add an Item to the document.
-	 * A simple function to create an item of a defined type and add it to the document
-	 * Will need extensive rewriting once we have various classes of PageItems, at a guess.
-	 *
-	 * @param itemFinalised Used to handle item creation for undo while the user is still dragging.
-	 * @return Number of created item, -1 on failure.
-	\param itemType type
-	\param frameType frame type
-	\param x X pos
-	\param y Y pos
-	\param b width
-	\param h height
-	\param w ?
-	\param fill fill color name
-	\param outline outline color name
-	*/
-	int itemAdd(const PageItem::ItemType itemType, const PageItem::ItemFrameType frameType, const double x, const double y, const double b, const double h, const double w, const QString& fill, const QString& outline, const bool itemFinalised);
+	bool MoveSizeItem(FPoint newX, FPoint newY, int ite, bool fromMP = false, bool constrainRotation=false);
+//ivro: don't know what it does
+	void AdjustItemSize(PageItem *currItem);
 
-	/** Add an item to the page based on the x/y position. Item will be fitted to the closest guides/margins */
-	int itemAddArea(const PageItem::ItemType itemType, const PageItem::ItemFrameType frameType, const double x, const double y, const double w, const QString& fill, const QString& outline, const bool itemFinalised);
-	
-	/**
-	 * @brief Allow the user to create a frame easily with some simple placement and sizing options
-	 * @param iafData a InsertAFrameData structure with params
-	 * @return int item id? FIXME
-	 */
-	int itemAddUserFrame(InsertAFrameData &iafData);
+	//void FlipImageH();
+	//void FlipImageV();
+	void MirrorPolyH(PageItem *currItem);
+	void MirrorPolyV(PageItem *currItem);
 
-	/**
-	 * @brief Commit item creation when a user has click-drag created an item
-	 * Only called from ScribusView. Note the undo target is the page, so the undo code remains their for now.
-	 * @return If an item was committed and the view must emit its signal, which needs removing from here, TODO.
+	// Various
+
+	/*!
+	 * Delete the tagged items.
+	 * Currently does nothing
 	 */
-	bool itemAddCommit(const int itemNumber);
-	
-	/**
-	 * @brief Finalise item creation. Simply split off code from itemAdd
-	 * Only to be called from itemAdd()
+	bool deleteTaggedItems();
+	/*!
+	 * Get the item index from a unique ID.
+	 * @param unique ID of item
+	 * @return index of the item
 	 */
-	void itemAddDetails(const PageItem::ItemType itemType, const PageItem::ItemFrameType frameType, const int itemNumber);
-
 	uint getItemNrfromUniqueID(uint unique);
-	//itemDelete
-	//itemBlah...
-	
-	/**
-	 * @brief Run this common frame item update code
+	/*!
+	 * Run this common frame item update code.
 	 */
 	void updateFrameItems();
-	/**
-	 * @brief Renumbers the items into the order they are stored in in the lists.
+	/*!
+	 * Renumbers the items into the order they are stored in in the lists.
 	 * Utility function used in various places, basically handles keeping items numbered in the way
 	 * they are layered. When layer is a property and not a fuction of storage, this should be removed.
 	 * Depends on the Items pointer pointing to the correct item list (doc, master, etc).
 	 * @sa updateFrameItems();
 	 */
 	void renumberItemsInListOrder();
-	/**
-	 * @brief Rebuild item lists taking into account layer order.
+	/*!
+	 * Rebuild item lists taking into account layer order.
 	 * Utility function used in various places, basically handles keeping items numbered in the way
 	 * they are layered. When layer is a property and not a fuction of storage, this should be removed.
 	 * @sa updateFrameItems();
 	 */
 	void rebuildItemLists();
-	/**
-	 * @brief Doc uses automatic text frames?
-	 */
-	bool usesAutomaticTextFrames() const;
-	void setUsesAutomaticTextFrames(const bool);
-	
-	/**
-	 * @brief Load images into an image frame, moved from the view
-	 * @retval Return false on failure
-	 */
-	bool LoadPict(QString fn, int ItNr, bool reload = false, bool showMsg = false);
-	/**
-	 * 
-	 * @param fn 
-	 * @param pageItem 
-	 * @param reload 
-	 * @return 
-	 */
-	bool loadPict(QString fn, PageItem *pageItem, bool reload = false, bool showMsg = false);
-	/**
-	 * \brief Handle image with color profiles
-	 * @param Pr profile
-	   @param PrCMYK cmyk profile
-	   @param dia optional progress widget
-	 */
-	void RecalcPictures(ProfilesL *Pr, ProfilesL *PrCMYK, QProgressBar *dia = 0);
-	/**
-	 * @brief Find the minX,MinY and maxX,maxY for the canvas required for the doc
-	 */
-	void canvasMinMax(FPoint&, FPoint&);
-	
-	int OnPage(double x2, double  y2);
-	int OnPage(PageItem *currItem);
-	void GroupOnPage(PageItem *currItem);
-	//void reformPages(double& maxX, double& maxY, bool moveObjects = true);
-	void reformPages(bool moveObjects = true);
-	
-	/**
-	 * @brief Return the x or y offset for a page on the canvas
-	 * @retval double containing the offset. Returns -1.0 if page not in Pages list (as -ve is not possible).
-	 * Mostly saves bringing in extra includes into files that already have scribusdoc.h
-	 */
-	double getXOffsetForPage(const int);
-	double getYOffsetForPage(const int);
-	void getBleeds(int pageNumber, MarginStruct& bleedData);
-	void getBleeds(Page* page, MarginStruct& bleedData);
-	
-	/**
-	 * @brief Item type conversion functions
-	 */
-	PageItem* convertItemTo(PageItem *currItem, PageItem::ItemType newType, PageItem* secondaryItem=NULL);
-	
-	/**
-	 * @brief The page number of the current page
-	 */
-	int currentPageNumber();
-	
-	/**
-	 * @brief Return true iff the passed name is not used by any existing PageItem
+	/*!
+	 * Find if item is not an already used item.
+	 * Return true if the passed name is not used by any existing PageItem
 	 *        in the same document as this PageItem.
 	 * @author Craig Ringer
 	 ** CB Moved from PageItem
 	 */
+//ivro: is returning true if the passed name exists not better ? (or rename to itemNameDontUses ?)
 	bool itemNameExists(const QString itemName);
-	
-	/**
-	 * @brief Set the doc into Master page mode
-	 * Do we need to return if the move to master page mode was successful?
+	/*!
+	 * Returns a stringlist of the item attributes within the document.
 	 */
-	void setMasterPageMode(bool);
+	QStringList getItemAttributeNames();
 
-	/*** Is the document in master page mode? */
-	bool masterPageMode() const { return m_masterPageMode; }
-	
-	/**
-	 * @brief Add a section to the document sections list
+	/*! Get a list of frames of certain type. */
+	QMap<PageItem*, QString> getDocItemNames(PageItem::ItemType itemType);
+//@} //End Items group
+
+/*! @name Sections
+ * Sections related functions
+ */ //@{
+	// add, delete, use sections
+
+	/*!
+	 * Add a section to the document sections list.
 	 * Set number to -1 to add in the default section if the map is empty
 	 */
 	void addSection(const int number=0, const QString& name=QString::null, const uint fromindex=0, const uint toindex=0, const  DocumentSectionType type=Type_1_2_3, const uint sectionstartindex=0, const bool reversed=false, const bool active=true);
-	/**
-	 * @brief Delete a section from the document sections list
+	/*!
+	 * Delete a section from the document sections list.
 	 */
 	bool deleteSection(const uint);
-	/**
-	 * @brief Gets the page number to be printed based on the section it is in.
+	/*!
+	 * Gets the page number to be printed based on the section it is in.
 	 * Returns QString::null on failure to find the pageIndex
 	 */
 	const QString getSectionPageNumberForPageIndex(const uint) const;
-	/**
-	 * @brief Gets the key of the sections map based on the section the page index is in.
+	/*!
+	 * Gets the key of the sections map based on the section the page index is in.
 	 * Returns -1 on failure to find the pageIndex
 	 */
 	int getSectionKeyForPageIndex(const uint pageIndex) const;
-	/**
+	/*!
 	 *
 	 *
 	 */
 	void updateSectionPageNumbersToPages();
-	/**
+	/*!
 	 * 
 	 * @param otherPageIndex 
 	 * @param location 
 	 * @param count 
 	 */
 	void addPageToSection(const uint otherPageIndex, const uint location, const uint count=1);
-	/**
+	/*!
 	 * 
 	 * @param pageIndex 
 	 */
 	void removePageFromSection(const uint pageIndex);
-	/**
+	/*!
 	 * 
 	 */
 	void setFirstSectionFromFirstPageNumber();
-	/**
-	 * @brief Update the fill and line QColors for all items in the doc
-	 */
-	void updateAllItemQColors();
-	//! @brief Some internal align tools
-	typedef enum {alignFirst, alignLast, alignPage, alignMargins, alignGuide, alignSelection } AlignTo;
+//@} // End of Sections group
+
+/*! @name Align
+ * Align related functions
+ */ //@{
 	void buildAlignItemList(Selection* customSelection=0);
 	bool startAlign();
 	void endAlign();
-	/**
-	 * \brief Insert a color into the documents color list
-	 * @param nam Name of the colour
-	 * @param c Cyan component
-	 * @param m Magenta component
-	 * @param y Yellow component
-	 * @param k Black component
+//@} // End of align functions
+
+/*! @name Color Management
+ * Color Management related functions.
+ */ //@{
+	/*!
+	 * Builds a qmap of the icc profiles used within the document.
 	 */
-	void insertColor(QString nam, double c, double m, double y, double k);
-	
-	QMap<QString, double>& constants() { return m_constants; }
-	/**
-	 * \brief Get the location of the page on the canvas, ie, left, middle, or right
-	 * Does not give information about middle left, etc.
-	 * @param pageIndex Index of page to find location for
-	 * @return LeftPage, MiddlePage, RightPage, enum from pagestructs.h
+	void getUsedProfiles(ProfilesL& usedProfiles);
+	bool OpenCMSProfiles(ProfilesL InPo, ProfilesL InPoCMYK, ProfilesL MoPo, ProfilesL PrPo);
+	void CloseCMSProfiles();
+	void SetDefaultCMSParams();
+	/*!
+	 * Switch Colormanagement on or of.
+	 * @param enable bool, if true Colormanagement is switched on, else off
 	 */
-	PageLocation locationOfPage(int pageIndex) const;
-	/**
-	 * \brief Get the column of the page on the canvas, ie, left, middle, or right
-	 * @param pageIndex Index of page to find location for
-	 * @return int of 0,1,2,3
+	void enableCMS(bool enable);
+	/*!
+	 * Recalculate the colors after CMS settings change. Update the items in the doc accordingly.
 	 */
-	int columnOfPage(int pageIndex) const;
-	
+	void recalculateColors();
+
+	/*!
+	 * Insert a color into the documents color list.
+	 * @param colorList Name of the color list
+	 * @param cyan Cyan component
+	 * @param magenta Magenta component
+	 * @param yellow Yellow component
+	 * @param black Black component
+	 */
+	void insertColor(QString colorList, double cryan, double magenta, double yellow, double black);
+//@} // End of color functions
+
+/*! @name Styles
+ * Style related functions
+ */ //@{
+	// Paragraphe style
+
+	/*!
+	 * Get a paragraph style by its name.
+	 */
+	const ParagraphStyle& paragraphStyle(QString name) { return docParagraphStyles.get(name); }
+	/*!
+	 * Get all the paragraph style.
+	 */
+	const StyleSet<ParagraphStyle>& paragraphStyles()   { return docParagraphStyles; }
+	/*!
+	 * Redefine Paragraphes style.
+	 */
+//ivro: rename rededineParaStyles ?
+	void redefineStyles(const StyleSet<ParagraphStyle>& newStyles, bool removeUnused=false);
+	/*!
+	 * Remove any reference to old styles and replace with new name.
+	 * This needs to be called when a style was removed. New name may be "".
+	 * @param newNameForOld a map which maps the name of any style to remove to a new stylename
+	 */
+//ivro: rename replaceParaStyles ?
+	void replaceStyles(const QMap<QString,QString>& newNameForOld);
+	/*!
+	 * Is the default paragraph style ?
+	 * @param p paragraph style to test
+	 */
+//ivro: is this must be with the one for char style ?
+	bool isDefaultStyle( const ParagraphStyle& p ) const { return docParagraphStyles.isDefault(p); }
+
+	// Character style
+
+	/*!
+	 * Get a character style by name.
+	 * @param name char style name
+	 */
+	const CharStyle& charStyle(QString name) { return docCharStyles.get(name); }
+	/*!
+	 * Get all the Character styles.
+	 */
+	const StyleSet<CharStyle>& charStyles()  { return docCharStyles; }
+	/*!
+	 * Redefine Character styles.
+	 * @param newStyle character styles
+	 * @param removeUnused
+	 */
+	void redefineCharStyles(const StyleSet<CharStyle>& newStyles, bool removeUnused=false);
+	/*!
+	 * Remove any reference to old styles and replace with new name.
+	 * This needs to be called when a style was removed. New name may be "".
+	 * @param newNameForOld a map which maps the name of any style to remove to a new stylename
+	 */
+	void replaceCharStyles(const QMap<QString,QString>& newNameForOld);
+	/*!
+	 * Is the default character style ?
+	 * @param c character style to test
+	 */
+	bool isDefaultStyle( const CharStyle& c ) const { return docCharStyles.isDefault(c); }
+// 	bool isDefaultStyle( LineStyle& l ) const { return MLineStyles......; }
+
+	// Load Style
+
+	/*!
+	 * Insert styles from another document in this document.
+	 * @param fileName The path of the document we want to extract its styles
+	 */
+	void loadStylesFromFile(QString fileName);
+	/*!
+	 * Gather styles from another document.       
+	 * @param fileName The path of the document we want to extract its styles
+	 * @param tempStyles A pointer to a StyleSet which will be filled by paragraph styles
+	 * @param tempCharStyles A pointer to a StyleSet which will be filled by character styles
+	 * @param tempLineStyles A map which will be filled by line styles
+	 */
+	void loadStylesFromFile(QString fileName, StyleSet<ParagraphStyle> *tempStyles,
+	                                          StyleSet<CharStyle> *tempCharStyles,
+	                                          QMap<QString, multiLine> *tempLineStyles);
+//@} // End of style group
+
+/*! @name Font
+ * font related funtions.
+ */ //@{
+	/*!
+	 * Add a font
+	 */
+	bool AddFont(QString name, int fsize = 10);
+	/*!
+	 * TODO: Reorganise the fonts.. how? Moved from scribus.cpp
+	 * CB: almost the same as getUsedFonts???
+	 */
+	QMap<QString,int> reorganiseFonts();
+	/*!
+	 * Returns a qmap of the fonts and  their glyphs used within the document.
+	 */
+	void getUsedFonts(QMap<QString,QMap<uint, FPointArray> > &Really);
+	void checkItemForFonts(PageItem *it, QMap<QString, QMap<uint, FPointArray> > & Really, uint lc);
+
+	/*!
+	 * Replace line style colors.
+	 */
+	void replaceLineStyleColors(const QMap<QString, QString>& colorMap);
+	/*!
+	* Builds a qmap of the colours used within the document.
+	*/
+	void getUsedColors(ColorList &colorsToUse, bool spot = false);
+	/*!
+	* Is this specific color is used by line styles.
+	*/
+	bool lineStylesUseColor(const QString& colorName);
+//@} // End of font functions
+
+/*! @name Pattern
+ * Pattern related functions
+ */ //@{
+	/*!
+	* Set the patterns for a document.
+	*/
+	bool addPattern(QString &name, ScPattern& pattern);
+	void setPatterns(QMap<QString, ScPattern> &patterns);
+	/*!
+	* Builds a QStringList of the patterns used within the document.
+	*/
+	QStringList getUsedPatterns();
+	QStringList getUsedPatternsSelection(Selection* customSelection);
+	QStringList getUsedPatternsHelper(QString pattern, QStringList &results);
+//@} // End of pattern functions
+
+/*! @name Item selection
+ * Item selection related functions.
+ *
+ * Item selection is used to modify items.
+ */ //@{
 	bool sendItemSelectionToBack();
 	bool bringItemSelectionToFront();
 
@@ -837,71 +1180,336 @@
 
 	void itemSelection_SetTracking(int us, Selection* customSelection=0);
 	void itemSelection_SetFontSize(int size, Selection* customSelection=0);
-	//void FlipImageH();
-	//void FlipImageV();
-	void MirrorPolyH(PageItem *currItem);
-	void MirrorPolyV(PageItem *currItem);
+public slots:
+	/*!
+	 * Change display quality of all images in document.
+	 * @author OssiLehtinen
+	 */
+	void allItems_ChangePreviewResolution(int id);
+
+	void itemSelection_ToggleLock();
+	void itemSelection_ToggleSizeLock();
+	void itemSelection_ToggleImageShown();
+	void itemSelection_TogglePrintEnabled();
+	void itemSelection_ChangePreviewResolution(int id);
+	void itemSelection_ClearItem(Selection* customSelection=0);
+	//! Delete the items in the current selection. When force is true, we do not warn the user and make SE happy too. Force is used from @sa Page::restorePageItemCreation
+	void itemSelection_DeleteItem(Selection* customSelection=0, bool forceDeletion=false);
+	void itemSelection_SetItemFillTransparency(double t);
+	void itemSelection_SetItemLineTransparency(double t);
+	void itemSelection_SetItemFillBlend(int t);
+	void itemSelection_SetItemLineBlend(int t);
+	void itemSelection_SetLineGradient(VGradient& newGradient, Selection* customSelection=0);
+	void itemSelection_SetFillGradient(VGradient& newGradient, Selection* customSelection=0);
+	void itemSelection_SetOverprint(bool overprint, Selection* customSelection=0);
+	void itemSelection_ApplyImageEffects(ScImageEffectList& newEffectList, Selection* customSelection=0);
+	void itemSelection_FlipH();
+	void itemSelection_FlipV();
+	void itemSelection_DoHyphenate();
+	void itemSelection_DoDeHyphenate();
+	void itemSelection_SendToLayer(int layerNumber);
+	void itemSelection_SetImageOffset(double x, double y, Selection* customSelection=0);
+	void itemSelection_SetImageScale(double x, double y, Selection* customSelection=0);
+	void itemSelection_SetImageScaleAndOffset(double ox, double oy, double sx, double sy, Selection* customSelection=0);
+	void itemSelection_AlignLeftOut(AlignTo currAlignTo, double guidePosition);
+	void itemSelection_AlignRightOut(AlignTo currAlignTo, double guidePosition);
+	void itemSelection_AlignBottomIn(AlignTo currAlignTo, double guidePosition);
+	void itemSelection_AlignRightIn(AlignTo currAlignTo, double guidePosition);
+	void itemSelection_AlignBottomOut(AlignTo currAlignTo, double guidePosition);
+	void itemSelection_AlignCenterHor(AlignTo currAlignTo, double guidePosition);
+	void itemSelection_AlignLeftIn(AlignTo currAlignTo, double guidePosition);
+	void itemSelection_AlignCenterVer(AlignTo currAlignTo, double guidePosition);
+	void itemSelection_AlignTopOut(AlignTo currAlignTo, double guidePosition);
+	void itemSelection_AlignTopIn(AlignTo currAlignTo, double guidePosition);
+	void itemSelection_DistributeDistH(bool usingDistance=false, double distance=0.0);
+	void itemSelection_DistributeAcrossPage(bool useMargins=false);
+	void itemSelection_DistributeRight();
+	void itemSelection_DistributeBottom();
+	void itemSelection_DistributeCenterH();
+	void itemSelection_DistributeDistV(bool usingDistance=false, double distance=0.0);
+	void itemSelection_DistributeDownPage(bool useMargins=false);
+	void itemSelection_DistributeLeft();
+	void itemSelection_DistributeCenterV();
+	void itemSelection_DistributeTop();
+	void itemSelection_MultipleDuplicate(ItemMultipleDuplicateData&);
+	void itemSelection_UniteItems(Selection* customSelection=0);
+	void itemSelection_SplitItems(Selection* customSelection=0);
+	/*! Adjust an image frame's size to fit the size of the image in it. */
+	void itemSelection_AdjustFrametoImageSize(Selection* customSelection=0);
+	/*! Adjust an image size to fit the size of the frame. */
+	void itemSelection_AdjustImagetoFrameSize(Selection* customSelection=0);
+	/*! startArrowID or endArrowID of -1 mean not applying a selection at this point.*/
+	void itemSelection_ApplyArrowHead(int startArrowID=-1, int endArrowID=-1, Selection* customSelection=0);
+
+	void itemSelection_SetItemPen(QString farbe);
+	void itemSelection_SetItemPenShade(int sha);
+	void itemSelection_SetItemBrush(QString farbe);
+	void itemSelection_SetItemBrushShade(int sha);
+	void itemSelection_SetItemGradFill(int typ);
+	void itemSelection_SetItemPatternFill(QString pattern);
+	void itemSelection_SetItemPatternProps(double scaleX, double scaleY, double offsetX, double offsetY, double rotation);
+//@} // End of item selection group
+
+/*! @name Various functions
+ */ //@{
+
+	/*!
+	 * Save function.
+	 */
+	bool save(const QString& fileName, QString* savedFile = NULL);
+
+	/*!
+	 * Create the default master pages based on the layout selected by the user, ie, Normal, Normal Left, etc.
+	 */
+	void createDefaultMasterPages();
+	/*!
+	 * Create the requested pages in a new document.
+	 * Run after ScribusDoc.createDefaultMasterPages()
+	 * @param pageCount number of page to create
+	 */
+	void createNewDocPages(int pageCount);
+
+	/*!
+	 * Update the fill and line QColors for all items in the doc.
+	 */
+	void updateAllItemQColors();
+
+	/*!
+	 * Sets up the ScText defaults from the document.
+	 */
+	void setScTextDefaultsFromDoc(ScText *);
+
+// Restore
+
+	/*!
+	 * Method used when an undo/redo is requested.
+	 * @param state State describing the action that is wanted to be undone/redone
+	 * @param isUndo If true undo is wanted else if false redo.
+	 * @author Riku Leino
+	 */
+	void restore(UndoState* state, bool isUndo);
+	/*!
+	 * Undo function for applying a master page.
+	 */
+	void restoreMasterPageApplying(SimpleState *state, bool isUndo);
+	/*!
+	 * Undo function for copy a page.
+	 */
+	void restorePageCopy(SimpleState *state, bool isUndo);
+
+// Loading images
+
+	/*!
+	 * Load images into an image frame, moved from the view.
+	 * @param fn image file name
+	 * @param ItNr page item number
+	 * @param reload
+	 * @param showMsg
+	 * @return Return false on failure
+	 */
+	bool LoadPict(QString fn, int ItNr, bool reload = false, bool showMsg = false);
+	/*!
+	 * Load images into an image frame.
+	 * @param fn image file name
+	 * @param pageItem page item 
+	 * @param reload 
+	 * @param showMsg
+	 * @return Return false on failure
+	 */
+	bool loadPict(QString fn, PageItem *pageItem, bool reload = false, bool showMsg = false);
+	/*!
+	 * Handle image with color profiles.
+	 * @param Pr profile
+	 * @param PrCMYK cmyk profile
+	 * @param dia optional progress widget
+	 */
+	void RecalcPictures(ProfilesL *Pr, ProfilesL *PrCMYK, QProgressBar *dia = 0);
+public slots:
+	/*! Update all the picture in the current selection. */
+	void updatePic();
+	/*! Update the specified picture. */
+	void updatePict(QString name);
+	/*! Update all picture in the specified directory. */
+	void updatePictDir(QString name);
+	/*! Remove a picture from document. */
+	void removePict(QString name);
+public:
+	/*!
+	 * Find the minX,MinY and maxX,maxY for the canvas required for the doc.
+	 * @param minPoint
+	 * @param maxPoint
+	 */
+	void canvasMinMax(FPoint& minPoint, FPoint& maxPoint);
 	
+	/*!
+	 * Find page index where the point exists.
+	 * In masterPage mode return the current master page index if the point exists on the current master page,
+	 * In normal mode return the first page index where this point exists.
+	 * 
+	 * @param x X coord of the point
+	 * @param y Y coord of the point
+	 * @return page index or -1
+	 */
+	int OnPage(double x, double  y);
+	/*!
+	 * Find page index where the item exists.
+	 * In masterPageMode return the current master page index if the item exists on the current master page.
+	 * In mormal mode return the page index where this item exists.
+	 *
+	 * @param item item we looking for
+	 * @return page index or -1
+	 */
+	int OnPage(PageItem *item);
+
+	void GroupOnPage(PageItem *currItem);
+	//void reformPages(double& maxX, double& maxY, bool moveObjects = true);
+	void reformPages(bool moveObjects = true);
+
 	void setRedrawBounding(PageItem *currItem);
 	void adjustCanvas(FPoint minPos, FPoint maxPos, bool absolute = false);
 	void recalcPicturesRes(bool applyNewRes = false);
 	void connectDocSignals();
-	void removeLayer(int l, bool dl = false); //FIXME: Make protected once scripter function no longer uses this directly
-	/*! \brief We call changed() whenever the document needs to know it has been changed.
-	 *  If the document is the primary document in a main window, it will signal to enable/disable
-	 * certain operations.
-	 */
-	void changed();
-	/*! \brief Get pointer to the current page
-	\retval Page* current page object */
-	Page* currentPage();
-	/*! \brief Set new current page
-	\param newPage New current page */
-	void setCurrentPage(Page *newPage);
-	bool hasGUI() const {return m_hasGUI;}
-	/*! \brief Apply grid to a QPoint, from ScribusView */
+
+// Named Ressources
+
+	void getNamedResources(ResourceCollection& lists) const;
+	void replaceNamedResources(ResourceCollection& newNames);	
+
+
+	QMap<QString, double>& constants() { return m_constants; }
+
+// Grid and Guides
+
+	/*! \brief Apply grid to a QPoint, from ScribusView. */
 	QPoint ApplyGrid(const QPoint& in);
-	/*! \brief Apply grid to an FPoint, from ScribusView */
+	/*! \brief Apply grid to an FPoint, from ScribusView. */
 	FPoint ApplyGridF(const FPoint& in);
-	/*! \brief Does this doc have any TOC setups and potentially a TOC to generate */
-	bool hasTOCSetup() { return !docToCSetups.empty(); }
-	//! \brief Get the closest guide to the given point
+
+	//! \brief Get the closest guide to the given point.
 	void getClosestGuides(double xin, double yin, double *xout, double *yout, int *GxM, int *GyM);
-	//! \brief Snap an item to the guides
+	//! \brief Snap an item to the guides.
 	void SnapToGuides(PageItem *currItem);
 	bool ApplyGuides(double *x, double *y);
-	bool MoveItem(double newX, double newY, PageItem* ite, bool fromMP = false);
-	void RotateItem(double win, int ite);
-	void RotateItem(double win, PageItem *currItem);
-	void MoveRotated(PageItem *currItem, FPoint npv, bool fromMP = false);
-	bool SizeItem(double newX, double newY, int ite, bool fromMP = false, bool DoUpdateClip = true, bool redraw = true);
-	bool SizeItem(double newX, double newY, PageItem *pi, bool fromMP = false, bool DoUpdateClip = true, bool redraw = true);
-	bool MoveSizeItem(FPoint newX, FPoint newY, int ite, bool fromMP = false, bool constrainRotation=false);
-	void AdjustItemSize(PageItem *currItem);
+
+	/*! \brief Does this doc have any TOC setups and potentially a TOC to generate. */
+	bool hasTOCSetup() { return !docToCSetups.empty(); }
+
+// Group
+
 	void moveGroup(double x, double y, bool fromMP = false, Selection* customSelection = 0);
 	void rotateGroup(double angle, FPoint RCenter);
 	void scaleGroup(double scx, double scy, bool scaleText=true, Selection* customSelection = 0);
-	//! \brief Get a list of frames of certain type
-	QMap<PageItem*, QString> getDocItemNames(PageItem::ItemType itemType);
-	
+
+	/*!
+	 * Return the guarded object associated with the document.
+	 */
+	const ScGuardedPtr<ScribusDoc>& guardedPtr() const;
+
+	UpdateManager* updateManager() { return &m_updateManager; }
+	MassObservable<PageItem*> * itemsChanged() { return &m_itemsChanged; }
+	MassObservable<Page*>     * pagesChanged() { return &m_pagesChanged; }
+	MassObservable<QRectF>    * regionsChanged() { return &m_regionsChanged; }
+	void invalidateRegion(QRectF region);
+
 protected:
-	void addSymbols();
-	bool m_hasGUI;
-	ApplicationPrefs& prefsData;
-	UndoManager * const undoManager;
-	bool loading;
-	bool modified;
-	int ActiveLayer;
-	int docUnitIndex;
-	double docUnitRatio;
-	bool automaticTextFrames; // Flag for automatic Textframes
-	bool m_masterPageMode;
-	QMap<QString, double> m_constants;
-	ScribusMainWindow* m_ScMW;
-	ScribusView* m_View;
-	ScGuardedObject<ScribusDoc> m_guardedObject;
+	void addSymbols();	
+//@} // End of various group
 	
-public: // Public attributes
+signals:
+	//Lets make our doc talk to our GUI rather than confusing all our normal stuff
+	/*!
+	 * Let the document tell whatever is listening that it has changed.
+	 */
+	void docChanged();
+	void updateContents();
+	void updateContents(const QRect &r);
+	void refreshItem(PageItem *);
+	void canvasAdjusted(double width, double height, double dX, double dY);
+	void firstSelectedItemType(int);
+	void setApplicationMode(int);
+	/*!
+	 * A signal for when the outline palette needs to rebuild itself.
+	 * Emit when:
+	 * - An item is created or deleted
+	 * - An item changes page
+	 * - An page is created or deleted
+	 * - Some items are grouped or a group is ungrouped
+	 * This also applies to Master Pages
+	 */
+	void signalRebuildOutLinePalette();
+	//! Temporary signal for SizeItem
+	void widthAndHeight(double, double);
+
+public:
+	QList<Page*>* Pages;			/*!< Pointer on a list of pages. See masterPageMode() */
+	QList<Page*> MasterPages;	 	/*!< List of Master Pages. */
+	QList<Page*> DocPages;			/*!< List of Document Pages. */
+
+	QList<PageItem*>* Items;		/*!< Pointer on a list of items. See masterPageMode() */
+	QList<PageItem*> MasterItems;		/*!< List of items that belongs to Master Pages. */
+	QList<PageItem*> DocItems;		/*!< List of items that belongs to Document Pages. */
+	QList<PageItem*> FrameItems;		/*!< List of items that belongs to Frames. */
+
+	double PageSp;				/*!< Number of Columns for automaticTextFrames. */
+	double PageSpa;				/*!< Distance between Columns for automaticTextFrames. */
+	PageItem *LastAuto;			/*!< Last AutomaticTextFrame element. */
+	PageItem *FirstAuto;			/*!< First AutomaticTextFrame element. */
+
+	bool GuideLock;				/*!< Is the guides must be locked ? See LockGuides() */
+
+	MarginStruct bleeds; 			/*!< Default page's bleeds. */
+//ivro: are those necessary anymore ?
+// 	double BleedTop;
+// 	double BleedLeft;
+// 	double BleedRight;
+// 	double BleedBottom;
+	MarginStruct scratch;
+//ivro: are those necessary anymore ?
+// 	double ScratchLeft;
+// 	double ScratchRight;
+// 	double ScratchTop;
+// 	double ScratchBottom;
+	double pageWidth;			/*!< Default page's width.  */
+	double pageHeight;			/*!< Default page's height. */
+//ivro: use the scribusstruct PageOrientation enum ?
+	int PageOri;				/*!< Default page's orientation. 0 = Portrait, 1 = Landscape. */
+	QString m_pageSize;			/*!< Default page's size. */
+	MarginStruct pageMargins;		/*!< Default page's margins. */
+//ivro: what is this for ?
+	int marginPreset;
+
+	double GapHorizontal;		/*!< Horizontal gap between page on canvas. */
+	double GapVertical;		/*!< Vertical gap between page on canvas. */
+
+	FPoint minCanvasCoordinate;	/*!< Minimun points of document. */
+	FPoint maxCanvasCoordinate;	/*!< Maximun point of document. */
+
+	QMap<QString,int> MasterNames;		/*!< Mapping Master Page Name to Master Page numbers. See rebuildMasterNames() */
+
+	QList<PageSet> pageSets;	/*!< List of page layout scribus support. Use ::currentPageLayout to select the one this document uses. */
+//ivro: is name DocumentLayout not better ?
+	int currentPageLayout;		/*!< Current Page's layout. Index of page layout in ::pageSets */
+
+	/*! Some internal align tools. */
+//ivro: is this cannot be moved elsewhere ?
+	typedef enum {
+		alignFirst,
+		alignLast,
+		alignPage,
+		alignMargins,
+		alignGuide,
+		alignSelection
+	} AlignTo;
+
+	ParagraphStyle currentStyle;		/*!< The current paragraph style. */
+
+	QString DocName;			/*!< Document's name. */
+
+	bool AutoSave;				/*!< Document's auto saving mode. */
+	int AutoSaveTime;			/*!< Auto save interval. Number of milliseconds between auto save. */
+	QTimer * const autoSaveTimer;		/*!< Auto save timer. */
+
+
 	bool is12doc; //public for now, it will be removed later
 	int NrItems;
 	int First;
@@ -909,98 +1517,37 @@
 	int viewCount;
 	int viewID;
 	bool SnapGuides;
-	bool GuideLock;
-	/** \brief Scratch space around Pages */
-	MarginStruct scratch;
-	double GapHorizontal;
-	double GapVertical;
-// 	double ScratchLeft;
-// 	double ScratchRight;
-// 	double ScratchTop;
-// 	double ScratchBottom;
-	/** \brief Minimum and Maximum Points of Document */
-	FPoint minCanvasCoordinate;
-	FPoint maxCanvasCoordinate;
 	double rulerXoffset;
 	double rulerYoffset;
-	/** \brief List of Pages */
-	QList<Page*>* Pages;
-	/** \brief List of Master Pages */
-	QList<Page*> MasterPages;
-	/** \brief List of Document Pages */
-	QList<Page*> DocPages;
-	/** \brief Mapping Master Page Name to Master Page numbers */
-	QMap<QString,int> MasterNames;
-	/** \brief List of Objects */
-	QList<PageItem*>* Items;
-	QList<PageItem*> MasterItems;
-	QList<PageItem*> DocItems;
-	QList<PageItem*> FrameItems;
 	Selection* const m_Selection;
-	/** \brief Pagewidth  */
-	double pageWidth;
-	/** \brief Pageheight */
-	double pageHeight;
 	/* Number of Pages */
 	// int pageCount; Disabled CR no longer required
-	/** \brief Margins */
-	MarginStruct pageMargins;
-	int marginPreset;
-	QList<PageSet> pageSets;
-	MarginStruct bleeds;
-// 	double BleedTop;
-// 	double BleedLeft;
-// 	double BleedRight;
-// 	double BleedBottom;
-	/** \brief Number of Columns */
-	double PageSp;
-	/** \brief Distance of Columns */
-	double PageSpa;
-	/** \brief current Pagelayout */
-	int currentPageLayout;
-	/** \brief Flag fuer Hoch- oder Querformat 0 = Hochformat */
-	int PageOri;
-	QString m_pageSize;
-	/** \brief Erste Seitennummer im Dokument */
-	int FirstPnum;
-	/** \brief Flag fuer Rasterbenutzung */
-	bool useRaster;
-	/** \brief Im Dokument benutzte Farben */
-	ColorList PageColors;
-	/** \brief InfoStrings fuer das aktuelle Dokument */
-	DocumentInformation documentInfo;
+
+	int FirstPnum;				/*!< Erste Seitennummer im Dokument. */
+	bool useRaster;				/*!< Flag fuer Rasterbenutzung. */
+	ColorList PageColors;			/*!< Im Dokument benutzte Farben. */
+	DocumentInformation documentInfo;	/*!< InfoStrings for the document. */
 	int appMode;
 	int SubMode;
 	double *ShapeValues;
 	int ValCount;
-	QString DocName;
 	QMap<QString,int> UsedFonts;
 	SCFonts * const AllFonts;
 	QList<AlignObjs> AObjects;
 	QColor papColor;
 	int CurrentSel;
-	ParagraphStyle currentStyle;
-
 	NodeEditContext nodeEdit;
-
+	ApplicationPrefs& prefsData;
 	typoPrefs typographicSettings;
 	guidesPrefs guidesSettings;
 	toolPrefs toolSettings;
 	QMap<QString, checkerPrefs> checkerProfiles;
 	QString curCheckProfile;
-	/** \brief Letztes Element fuer AutoTextrahmen */
-	PageItem *LastAuto;
-	/** \brief Erstes Element fuer AutoTextrahmen */
-	PageItem *FirstAuto;
 	bool DragP;
 	bool leaveDrag;
 	PageItem *DraggedElem;
 	PageItem *ElemToLink;
 	QList<uint> DragElements;
-private:
-	StyleSet<ParagraphStyle> docParagraphStyles;
-	StyleSet<CharStyle> docCharStyles;
-public:
 	ScLayers Layers;
 	bool marginColored;
 	int GroupCounter;
@@ -1039,24 +1586,21 @@
 	PrintOptions Print_Options;
 	bool RePos;
 	struct BookMa {
-					QString Title;
-					QString Text;
-					QString Aktion;
-					PageItem *PageObject;
-					int Parent;
-					int ItemNr;
-					int First;
-					int Last;
-					int Prev;
-					int Next;
-					};
+		QString Title;
+		QString Text;
+		QString Aktion;
+		PageItem *PageObject;
+		int Parent;
+		int ItemNr;
+		int First;
+		int Last;
+		int Prev;
+		int Next;
+	};
 	QList<BookMa> BookMarks;
 	bool OldBM;
 	bool hasName;
 	int RotMode;
-	bool AutoSave;
-	int AutoSaveTime;
-	QTimer * const autoSaveTimer;
 	QMap<QString,multiLine> MLineStyles;
 	QList<ArrowDesc> arrowStyles;
 	QMap<QString, ScPattern> docPatterns;
@@ -1073,8 +1617,7 @@
 	QMap<int, errorCodes> docLayerErrors;
 	QMap<int, errorCodes> docItemErrors;
 	QMap<int, errorCodes> masterItemErrors;
-	//Attributes to be applied to frames
-	ObjAttrVector docItemAttributes;
+	ObjAttrVector docItemAttributes;	/*!< Attributes to be applied to frames. */
 	ToCSetupVector docToCSetups;
 	DocumentSectionMap sections;
 	FPointArray symReturn;
@@ -1083,121 +1626,41 @@
 	FPointArray symNonBreak;
 	FPointArray symNewCol;
 	FPointArray symNewFrame;
-	
 	Hyphenator * docHyphenator;
+protected:
+	bool loading;				/*!< Is the document loading ? See isLoading() and setLoading(). */
+	bool modified;				/*!< Is the document modified ? See isModified() and setModified(). */
+
+	bool m_hasGUI;		 		/*!< Is document associated with a GUI ? See hasGUI() and setGUI(). */
+	ScribusMainWindow* m_ScMW; 		/*!< Main window associated with the document. See scMW() and setGUI(). */
+	ScribusView* m_View;			/*!< View associated with the document. See view() and setGUI(). */
+
+	bool m_masterPageMode;			/*!< Is the document in master page mode ? See masterPageMode() and setMasterPageMode(). */
+
+	bool automaticTextFrames;		/*!< Is the document using automaticTextFrames ? See usesAutomaticTextFrames() and setUsesAutomagicTextFrames(). */
+
+	int docUnitIndex;			/*!< Document's unit index. See setUnitIndex() and unitIndex(). */
+	double docUnitRatio;			/*!< Document's unit ratio. See unitRatio(). */
+
+	UndoManager * const undoManager;
+	int ActiveLayer;
+	QMap<QString, double> m_constants;
+	ScGuardedObject<ScribusDoc> m_guardedObject;
 private:
+	Page* m_currentPage;			/*!< Current page. See setCurrentPage() and currentPage(). */
+
+	StyleSet<ParagraphStyle> docParagraphStyles;	/*!< Paragraph StyleSet. */
+	StyleSet<CharStyle> docCharStyles;		/*!< Character StyleSet. */
+
+//ivro: don't know what it is
 	UndoTransaction* m_itemCreationTransaction;
 	UndoTransaction* m_alignTransaction;
 
-	Page* m_currentPage;
 	UpdateManager m_updateManager;
 	MassObservable<PageItem*> m_itemsChanged;
 	MassObservable<Page*> m_pagesChanged;
 	MassObservable<QRectF> m_regionsChanged;
 	DocUpdater* m_docUpdater;
-	
-signals:
-	//Lets make our doc talk to our GUI rather than confusing all our normal stuff
-	/**
-	 * @brief Let the document tell whatever is listening that it has changed
-	 */
-	void docChanged();
-	void updateContents();
-	void updateContents(const QRect &r);
-	void refreshItem(PageItem *);
-	void canvasAdjusted(double width, double height, double dX, double dY);
-	void firstSelectedItemType(int);
-	void setApplicationMode(int);
-	/**
-	 * @brief A signal for when the outline palette needs to rebuild itself
-	 * Emit when:
-	 * - An item is created or deleted
-	 * - An item changes page
-	 * - An page is created or deleted
-	 * - Some items are grouped or a group is ungrouped
-	 * This also applies to Master Pages
-	 */
-	void signalRebuildOutLinePalette();
-	//! Temporary signal for SizeItem
-	void widthAndHeight(double, double);
-	
-public slots:
-	void itemSelection_ToggleLock();
-	void itemSelection_ToggleSizeLock();
-	void itemSelection_ToggleImageShown();
-	void itemSelection_TogglePrintEnabled();
-	void itemSelection_ChangePreviewResolution(int id);
-
-	/*! \brief Change display quality of all images in document.
-	\author  OssiLehtinen
-	*/
-	void allItems_ChangePreviewResolution(int id);
-
-	void itemSelection_ClearItem(Selection* customSelection=0);
-	//! Delete the items in the current selection. When force is true, we do not warn the user and make SE happy too. Force is used from @sa Page::restorePageItemCreation
-	void itemSelection_DeleteItem(Selection* customSelection=0, bool forceDeletion=false);
-	void itemSelection_SetItemFillTransparency(double t);
-	void itemSelection_SetItemLineTransparency(double t);
-	void itemSelection_SetItemFillBlend(int t);
-	void itemSelection_SetItemLineBlend(int t);
-	void itemSelection_SetLineGradient(VGradient& newGradient, Selection* customSelection=0);
-	void itemSelection_SetFillGradient(VGradient& newGradient, Selection* customSelection=0);
-	void itemSelection_SetOverprint(bool overprint, Selection* customSelection=0);
-	void itemSelection_ApplyImageEffects(ScImageEffectList& newEffectList, Selection* customSelection=0);
-	void itemSelection_FlipH();
-	void itemSelection_FlipV();
-	void itemSelection_DoHyphenate();
-	void itemSelection_DoDeHyphenate();
-	void itemSelection_SendToLayer(int layerNumber);
-	void itemSelection_SetImageOffset(double x, double y, Selection* customSelection=0);
-	void itemSelection_SetImageScale(double x, double y, Selection* customSelection=0);
-	void itemSelection_SetImageScaleAndOffset(double ox, double oy, double sx, double sy, Selection* customSelection=0);
-	void itemSelection_AlignLeftOut(AlignTo currAlignTo, double guidePosition);
-	void itemSelection_AlignRightOut(AlignTo currAlignTo, double guidePosition);
-	void itemSelection_AlignBottomIn(AlignTo currAlignTo, double guidePosition);
-	void itemSelection_AlignRightIn(AlignTo currAlignTo, double guidePosition);
-	void itemSelection_AlignBottomOut(AlignTo currAlignTo, double guidePosition);
-	void itemSelection_AlignCenterHor(AlignTo currAlignTo, double guidePosition);
-	void itemSelection_AlignLeftIn(AlignTo currAlignTo, double guidePosition);
-	void itemSelection_AlignCenterVer(AlignTo currAlignTo, double guidePosition);
-	void itemSelection_AlignTopOut(AlignTo currAlignTo, double guidePosition);
-	void itemSelection_AlignTopIn(AlignTo currAlignTo, double guidePosition);
-	void itemSelection_DistributeDistH(bool usingDistance=false, double distance=0.0);
-	void itemSelection_DistributeAcrossPage(bool useMargins=false);
-	void itemSelection_DistributeRight();
-	void itemSelection_DistributeBottom();
-	void itemSelection_DistributeCenterH();
-	void itemSelection_DistributeDistV(bool usingDistance=false, double distance=0.0);
-	void itemSelection_DistributeDownPage(bool useMargins=false);
-	void itemSelection_DistributeLeft();
-	void itemSelection_DistributeCenterV();
-	void itemSelection_DistributeTop();
-	void itemSelection_MultipleDuplicate(ItemMultipleDuplicateData&);
-	void itemSelection_UniteItems(Selection* customSelection=0);
-	void itemSelection_SplitItems(Selection* customSelection=0);
-	/**
-	 * Adjust an image frame's size to fit the size of the image in it
-	 */
-	void itemSelection_AdjustFrametoImageSize(Selection* customSelection=0);
-	/**
-	 * Adjust an image size to fit the size of the frame
-	 */
-	void itemSelection_AdjustImagetoFrameSize(Selection* customSelection=0);
-	//! @brief startArrowID or endArrowID of -1 mean not applying a selection at this point.
-	void itemSelection_ApplyArrowHead(int startArrowID=-1, int endArrowID=-1, Selection* customSelection=0);
-
-	void itemSelection_SetItemPen(QString farbe);
-	void itemSelection_SetItemPenShade(int sha);
-	void itemSelection_SetItemBrush(QString farbe);
-	void itemSelection_SetItemBrushShade(int sha);
-	void itemSelection_SetItemGradFill(int typ);
-	void itemSelection_SetItemPatternFill(QString pattern);
-	void itemSelection_SetItemPatternProps(double scaleX, double scaleY, double offsetX, double offsetY, double rotation);
-
-	void updatePic();
-	void updatePict(QString name);
-	void updatePictDir(QString name);
-	void removePict(QString name);
 };
 
 Q_DECLARE_METATYPE(ScribusDoc*);
diff scribusdoc.h (79,432 bytes)   

2009-02-22 21:23

 

diff page.h (5,455 bytes)   
Index: Scribus/scribus/page.h
===================================================================
--- Scribus/scribus/page.h	(révision 13182)
+++ Scribus/scribus/page.h	(copie de travail)
@@ -40,74 +40,116 @@
 class ScribusDoc;
 
 
-/**
+/*!
   *@author Franz Schmid
   */
 class SCRIBUS_API Page : public UndoObject, public SingleObservable<Page>
 {
 public:
-	Page(const double x, const double y, const double b, const double h);
+	/*!
+	 * Create a new Page.
+	 * @param xOffset page's X offset
+	 * @param yOffset page's Y offset
+	 * @param width page's width
+	 * @param height page's height
+	 */
+	Page(const double xOffset, const double yOffset, const double width, const double height);
 	~Page();
+
+	/*! Get the page's X offset. */
 	double xOffset() const { return m_xOffset; }
+	/*! Get the page's Y offset. */
 	double yOffset() const { return m_yOffset; }
+	/*! Get the page's width. */
 	double width() const { return m_width; }
+	/*! Get the page's height. */
 	double height() const { return m_height; }
+	/*! Get the initial page's width. */
 	double initialWidth() const { return m_initialWidth; }
+	/*! Get the initial page's height. */
 	double initialHeight() const { return m_initialHeight; }
+
+	/*! Set the page's X offset. */
 	void setXOffset(const double);
+	/*! Set the page's Y offset. */
 	void setYOffset(const double);
+	/*! Set the page's width. */
 	void setWidth(const double);
+	/*! Set the page's height. */
 	void setHeight(const double);
+	/*! Set the initial page's width. */
 	void setInitialWidth(const double);
+	/*! Set the initial page's height. */
 	void setInitialHeight(const double);
-	void copySizingProperties(Page *sourcePage, const MarginStruct& pageMargins);
-	MarginStruct Margins;
-	MarginStruct initialMargins;
-  /** Nummer der Seite */
-	int LeftPg;
-	//! Name of the master page that this page uses
-	QString MPageNam;
 
-	QString m_pageSize;
-	int PageOri;
-	int marginPreset;
+	/*! Get the scribus document this page belongs to. */
 	ScribusDoc* doc() const { return m_Doc; }
-	void setDocument(ScribusDoc* doc);
+	/*! Set the scribus document this page belongs to. */
+	void setDocument(ScribusDoc*);
+
+	/*! Get the page's number. */
 	int pageNr() const { return m_pageNr; }
-	void setPageNr(int pageNr);
+	/*! Set the page's number. */
+	void setPageNr(int);
+
+	/*! Get the page's section number. */
 	const QString& pageSectionNumber() const { return m_pageSectionNumber; }
+	/*! Set the page's section number. */
 	void setPageSectionNumber(const QString&);
-	//! Return the page's name
+
+	/*! Get the page's name. */
 	const QString& pageName() const {return m_PageName;};
-	void setPageName(const QString& newName);
+	/*! Set the page's name. */
+	void setPageName(const QString&);
+
+	/*!
+	 * Copy page's sizing properties.
+	 * Copy X offset, Y offset, width, height, initial width and initial height from page
+	 * And uses pageMargins to set margins and initial margins
+	 * @param sourcePage page to copy
+	 * @param pageMargins margins to use
+	 */
+	void copySizingProperties(Page *sourcePage, const MarginStruct& pageMargins);
+
+public:
+	MarginStruct Margins;			/*!< Current page's margins. */
+	MarginStruct initialMargins;		/*!< Initial page's margins. */
+	int LeftPg;				/*!< Page's location in the document. 1 for left page, 0 for right page, 2 for middle page. */
+//ivro: rename masterPageName ?
+	QString MPageNam;			/*!< Name of the Master page this page uses. */
+	QString m_pageSize;			/*!< Page's size name. */
+//ivro: use the scribusstruct PageOrientation enum ?
+	int PageOri;				/*!< Page's orientation. 0 = Portrait, 1 = Landscape. */
+
+	int marginPreset;
+
 	void restore(UndoState* state, bool isUndo);
 
-	/*! \brief As a bit of a dirty hack, we declare this mutable so it can be altered
+	/*! As a bit of a dirty hack, we declare this mutable so it can be altered
 	even while the object is `const'. That's normally only for internal
 	implementation, but in this case it at least lets us guarantee the rest
 	of the object is unchanged in (eg) pdflib. This should be replaced with
 	proper access methods later. */
 	mutable QList<PageItem*> FromMaster;
-	//! \brief Guides lists and basic operations
-	GuideManagerCore guides;
 
+	GuideManagerCore guides;		/*!< Guides lists and basic operations. */
+
 protected:
 	UndoManager * const undoManager;
 	void restorePageItemCreation(ItemState<PageItem*> *state, bool isUndo);
 	void restorePageItemDeletion(ItemState<PageItem*> *state, bool isUndo);
 	void restorePageItemConversion(ItemState<std::pair<PageItem*, PageItem*> >*state, bool isUndo);
 	
-	double m_xOffset;
-	double m_yOffset;
-	double m_width;
-	double m_height;
-	double m_initialWidth;
-	double m_initialHeight;
-	int m_pageNr;
-	//! Name of this page, currently only allowed to be used by a master page
-	QString m_PageName;
-	ScribusDoc* m_Doc;	
-	QString m_pageSectionNumber;
+	double m_xOffset;			/*!< Page's X offset. */
+	double m_yOffset;			/*!< Page's Y offset. */
+	double m_width;				/*!< Page's width. */
+	double m_height;			/*!< Page's height. */
+	double m_initialWidth;			/*!< Initial page's width. */
+	double m_initialHeight;			/*!< Initial page's height. */
+	int m_pageNr;				/*!< Page's number. */
+	QString m_PageName;			/*!< Page's name. */
+	ScribusDoc* m_Doc;			/*!< Scribus document this page belongs to. */
+	QString m_pageSectionNumber;		/*!< Page's section number. */
 };
 
 Q_DECLARE_METATYPE(Page*);
diff page.h (5,455 bytes)   

ivro

2009-02-22 21:24

reporter   ~0021193

Add them.

cbradney

2009-02-22 21:51

administrator   ~0021194

I'm not clear on the syntax change and how that will affect the doxygen output on docs.scribus.net/devel

ivro

2009-02-22 22:19

reporter   ~0021195

All the old syntax behave the same. When you explicitly use @brief the behaviour is the same.
The thing that change is when you write a comment without the tag, the first phrase (until the first point) is used as brief. I find it more readable but I can revert things.

cbradney

2009-02-22 22:31

administrator   ~0021196

The new syntax can stay if it will still work

christoph_s

2009-03-15 01:47

administrator   ~0021311

Ivro: It would be great if you could complete your work (at least partially) once 1.3.5 is released, i.e. in 1.3.6svn. Thank you very much for your efforts!

cbradney

2009-03-15 21:50

administrator   ~0021324

ivro, we can include this in 135svn if we have updated files to match current svn ( i mean for easy patching, rather than more completeness)

ivro

2009-03-27 10:20

reporter   ~0021416

Cool

How can I send it to you ?

My works are on a git repository, set up with full copy of the scribus svn history.
It's available at http://github.com/ivro/scribus/, looks at branch docs.

I can rebase my works on top of any svn revision as you like.

2009-03-27 15:07

 

2009-03-27 15:44

 

patches-docs-from-ivro-based-on-r13556.diff (84,689 bytes)   
diff --git a/Scribus/scribus/page.h b/Scribus/scribus/page.h
index 743cbc7..f62886b 100644
--- a/Scribus/scribus/page.h
+++ b/Scribus/scribus/page.h
@@ -40,55 +40,137 @@ class UndoState;
 class ScribusDoc;
 
 
-/**
-  *@author Franz Schmid
-  */
+/*!
+ * \author Franz Schmid
+ */
 class SCRIBUS_API Page : public UndoObject, public SingleObservable<Page>
 {
 public:
+	/*!
+	 * \brief Create a new page.
+	 *
+	 * \param x page's X offset
+	 * \param y page's Y offset
+	 * \param b page's widht
+	 * \param h page's height
+	 */
 	Page(const double x, const double y, const double b, const double h);
+	/*!
+	 * \brief Destroy a page.
+	 */
 	~Page();
+
+	/*!
+	 * \brief Get the page's X offset.
+	 */
 	double xOffset() const { return m_xOffset; }
+	/*!
+	 * \brief Get the page's Y offset.
+	 */
 	double yOffset() const { return m_yOffset; }
+	/*!
+	 * \brief Get the page's width.
+	 */
 	double width() const { return m_width; }
+	/*!
+	 * \brief Get the page's height.
+	 */
 	double height() const { return m_height; }
+	/*!
+	 * \brief Get the initial page's width.
+	 */
 	double initialWidth() const { return m_initialWidth; }
+	/*!
+	 * \brief Get the initial page's height.
+	 */
 	double initialHeight() const { return m_initialHeight; }
+	/*!
+	 * \brief Set the page's X offset.
+	 */
 	void setXOffset(const double);
+	/*!
+	 * \brief Set the page's Y offset.
+	 */
 	void setYOffset(const double);
+	/*!
+	 * \brief Set the page's width.
+	 */
 	void setWidth(const double);
+	/*!
+	 * \brief Set the page's height.
+	 */
 	void setHeight(const double);
+	/*!
+	 * \brief Set the initial page's width.
+	 */
 	void setInitialWidth(const double);
+	/*!
+	 * \brief Set the initial page's height.
+	 */
 	void setInitialHeight(const double);
+	/*!
+	 * \brief Copy the size property from page.
+	 *
+	 * For know doesn't take care of layout.
+	 * \param page page to copy the properties
+	 * \param pageMargins margins to apply
+	 */
 	void copySizingProperties(Page *sourcePage, const MarginStruct& pageMargins);
-	MarginStruct Margins;
-	MarginStruct initialMargins;
-  /** Nummer der Seite */
+	MarginStruct Margins;		/*!< \brief Page's margins. */
+	MarginStruct initialMargins;	/*!< \brief Initial page's margins. */
+	/*! \brief Nummer der Seite */
 	int LeftPg;
-	//! Name of the master page that this page uses
-	QString MPageNam;
+	QString MPageNam;		/*!< \brief Name of the used master page. */
 
 	QString m_pageSize;
-	int PageOri;
+	int PageOri;			/*!< \brief Page's orientation. \details O => Portrait, 1 => Landscape. */
 	int marginPreset;
+	/*!
+	 * \brief Get the document this page belongs to.
+	 */
 	ScribusDoc* doc() const { return m_Doc; }
+	/*!
+	 * \brief Set the document this page belongs to.
+	 */
 	void setDocument(ScribusDoc* doc);
+	/*!
+	 * \brief Get the page's number.
+	 */
 	int pageNr() const { return m_pageNr; }
+	/*!
+	 * \brief Set the page's number.
+	 */
 	void setPageNr(int pageNr);
 	const QString& pageSectionNumber() const { return m_pageSectionNumber; }
 	void setPageSectionNumber(const QString&);
-	//! Return the page's name
+	/*!
+	 * \brief Return the page's name.
+	 */
 	const QString& pageName() const {return m_PageName;};
+	/*!
+	 * \brief Set the page's name.
+	 *
+	 * Currently only allowed for master page.
+	 */
 	void setPageName(const QString& newName);
+	/*!
+	 * \brief Used for undo/redo actions.
+	 */
 	void restore(UndoState* state, bool isUndo);
 
-	/*! \brief As a bit of a dirty hack, we declare this mutable so it can be altered
-	even while the object is `const'. That's normally only for internal
-	implementation, but in this case it at least lets us guarantee the rest
-	of the object is unchanged in (eg) pdflib. This should be replaced with
-	proper access methods later. */
+	/*!
+	 * \brief The page item we get from master page.
+	 *
+	 * As a bit of a dirty hack, we declare this mutable so it can be altered
+	 * even while the object is `const'. That's normally only for internal
+	 * implementation, but in this case it at least lets us guarantee the rest
+	 * of the object is unchanged in (eg) pdflib. This should be replaced with
+	 * proper access methods later.
+	 */
 	mutable QList<PageItem*> FromMaster;
-	//! \brief Guides lists and basic operations
+	/*!
+	 * \brief Guides lists and basic operations.
+	 */
 	GuideManagerCore guides;
 
 protected:
@@ -97,16 +179,15 @@ protected:
 	void restorePageItemDeletion(ItemState<PageItem*> *state, bool isUndo);
 	void restorePageItemConversion(ItemState<std::pair<PageItem*, PageItem*> >*state, bool isUndo);
 	
-	double m_xOffset;
-	double m_yOffset;
-	double m_width;
-	double m_height;
-	double m_initialWidth;
-	double m_initialHeight;
-	int m_pageNr;
-	//! Name of this page, currently only allowed to be used by a master page
-	QString m_PageName;
-	ScribusDoc* m_Doc;	
+	double m_xOffset;		/*!< \brief Page's X Offset. */
+	double m_yOffset;		/*!< \brief Page's Y Offset. */
+	double m_width;			/*!< \brief Page's width. */
+	double m_height;		/*!< \brief Page's height. */
+	double m_initialWidth;		/*!< \brief Initial page's width. */
+	double m_initialHeight;		/*!< \brief Initial page's height. */
+	int m_pageNr;			/*!< \brief Page's number. */
+	QString m_PageName;		/*!< \brief Page's name. \details Currently only allowed to be used by a master page. */
+	ScribusDoc* m_Doc;		/*!< \brief The document this page belongs to. */
 	QString m_pageSectionNumber;
 };
 
diff --git a/Scribus/scribus/scribusdoc.h b/Scribus/scribus/scribusdoc.h
index 7336ceb..d34643e 100644
--- a/Scribus/scribus/scribusdoc.h
+++ b/Scribus/scribus/scribusdoc.h
@@ -107,693 +107,1126 @@ struct SCRIBUS_API NodeEditContext : public MassObservable<QPointF>
 };
 
 
-/**! \brief the Document Class
+/*! \brief the Document Class
   */
 class SCRIBUS_API ScribusDoc : public QObject, public UndoObject, public Observable<ScribusDoc>
 {
 	Q_OBJECT
 
 public:
+	/*! \brief Some internal align tools. */
+//ivro: is this cannot be moved elsewhere ?
+	typedef enum {
+		alignFirst,
+		alignLast,
+		alignPage,
+		alignMargins,
+		alignGuide,
+		alignSelection
+	} AlignTo;
+
 	ScribusDoc();
 	ScribusDoc(const QString& docName, int unitIndex, const PageSize& pagesize, const MarginStruct& margins, const DocPagesSetup& pagesSetup);
 	~ScribusDoc();
 	void init();
 	void setup(const int, const int, const int, const int, const int, const QString&, const QString&);
+
+// States
+	/*!
+	 * \brief Set the loading state of the document
+	 *
+	 * See ScribusDoc.isLoading()
+	 */
 	void setLoading(const bool);
+	/*!
+	 * \brief Is the document loading ?
+	 *
+	 * See ScribusDoc.setLoading()
+	 */
 	bool isLoading() const;
+	/*!
+	 * \brief Set modified state of the document.
+	 *
+	 * If state changed, update the document
+	 * See ScribusDoc.isModified()
+	 */
 	void setModified(const bool);
+	/*!
+	 * \brief Is the document modified ?
+	 *
+	 * See ScribusDoc.setModified()
+	 */
 	bool isModified() const;
-/** Setzt die Seitenattribute */
-	void setPage(double b, double h, double t, double l, double r, double bo, double sp, double ab, bool atf, int fp);
-	void resetPage(MarginStruct& newMargins, int fp);
 
-	/**
-	 * @brief Return the view associated with the document
+// GUI
+	/*!
+	 * \brief Associate document and GUI.
+	 *
+	 * See ScribusDoc.hasGUI(), ScribusDoc.scMW() and ScribusDoc.view()
+	 * \param hasgui Is document associated with gui ?
+	 * \param mainWindow scribus main window
+	 * \param view scribus view
 	 */
-	ScribusView* view() const;
+	void setGUI(bool hasgui, ScribusMainWindow* mainWindow, ScribusView* view);
+	/*!
+	 * \brief Is the document associated with GUI ?
+	 *
+	 * See Scribus.setGUI()
+	 */
+	bool hasGUI() const {return m_hasGUI;}
+	/*!
+	 * \brief Get the scribus main window associated with the document.
+	 *
+	 * See Scribus.setGUI()
+	 * \return the scribus man window
+	 */
+//ivro: rename this function (mainWindow or scribusMainWindow) ?
 	ScribusMainWindow* scMW() const {return m_ScMW;}
-	void setGUI(bool hasgui, ScribusMainWindow* mw, ScribusView* view);
+	/*!
+	 * \brief Get the view associated with the document.
+	 *
+	 * See Scribus.setGUI()
+	 * \return the scribus view
+	 */
+	ScribusView* view() const;
 
-	/**
-	 * @brief Return the guarded object associated with the document
+// Automatic Text Frames
+	/*!
+	 * \brief Set if doc uses automatic text frames.
+	 *
+	 * See ScribusDoc.usesAutomaticTextFrames(), ScribusDoc.PageSp and ScribusDoc.PageSpa
+	 */
+	void setUsesAutomaticTextFrames(const bool);
+	/*!
+	 * \brief Is document using automatic text frames ?
+	 *
+	 * See ScribusDoc.setUsesAutomaticTextFrames
+	 */
+	bool usesAutomaticTextFrames() const;
+
+// Grid and Guides
+	/*!
+	 * \brief Should guides be locked or not ?
+	 *
+	 * \param isLocked If true guides on pages cannot be moved if false they
+	 * can be dragged to new positions.
+	 * \author Riku Leino
+	 */
+	void lockGuides(bool isLocked);
+
+// Current Page
+	/*!
+	 * \brief Set new current page.
+	 *
+	 */
+	void setCurrentPage(Page*);
+	/*!
+	 * \brief Get the current page.
+	 */
+	Page* currentPage();
+	/*!
+	 * \brief Get the current page number.
+	 */
+	int currentPageNumber();
+
+// Unit index and unit ratio
+	/*!
+	 * \brief Set the document's unit index and update the document's unit ratio.
+	 *
+	 * See ScribusDoc.unitIndex() and ScribusDoc.unitRatio()
+	 */
+	void setUnitIndex(const int);
+	/*!
+	 * \brief Get the document's unit index.
+	 *
+	 * See ScribusDoc.setUnitIndex()
+	 */
+	int unitIndex() const;
+	/*!
+	 * \brief Get the document's unit ratio.
+	 *
+	 * See ScribusDoc.setUnitIndex()
+	 */
+	double unitRatio() const;
+
+// Document's properties
+	/*!
+	 * \brief Sets the name of the document.
+	 *
+	 * \param name Name for the document
+	 * \author Riku Leino
+	 */
+	void setName(const QString& name);
+
+/*! \name Master Page
+ * \brief Master page related functions.
+ *
+ * A master page is a model for page. Items on master pages will be repeated on each page with the master page.
+ * Use applyMasterPage() to associate a master page to a page and copyPageToMasterPage() to make a master page from a page.
+ *
+ * The master page mode allow to work with master pages and items with the same functions you use for pages and items.
+ * See masterPageMode() and setMasterPageMode().
+ */ //@{
+	/*!
+	 * \brief Is the document in master page mode ?
+	 *
+	 * In master page mode
+	 *      ScribusDoc.Pages = &ScribusDoc.MasterPages
+	 *      ScribusDoc.Items = &ScribusDoc.MasterItems
+	 * In normal mode (ie not in master mode)
+	 *      ScribusDoc.Pages = &ScribusDoc.DocPages
+	 *      ScribusDoc.Items = &ScribusDoc.DocItems
+	 */
+	bool masterPageMode() const { return m_masterPageMode; }
+	/*!
+	 * \brief Set the doc into Master page mode.
+	 */
+// Do we need to return if the move to master page mode was successful?
+	void setMasterPageMode(bool);
+
+	/*!
+	 * \brief Add a master page.
+	 *
+	 * Use this function to add a master page, do not use addPage
+	 * \param pageNumber index for the master page
+	 * \param pageName name of the master page
+	 * \return added page
+	 */
+	Page* addMasterPage(const int pageNumber, const QString& pageName);
+	/*!
+	 * \brief Delete a master page.
+	 *
+	 * \param pageNumber index of the master page
+	 */
+	void deleteMasterPage(const int pageNumber);
+	/*!
+	 * \brief Replace a master page by default one.
+	 *
+	 * \param oldMasterPage name of the master page to remplace
 	 */
-	const ScGuardedPtr<ScribusDoc>& guardedPtr() const;
-	
-	UpdateManager* updateManager() { return &m_updateManager; }
-	MassObservable<PageItem*> * itemsChanged() { return &m_itemsChanged; }
-	MassObservable<Page*>     * pagesChanged() { return &m_pagesChanged; }
-	MassObservable<QRectF>    * regionsChanged() { return &m_regionsChanged; }
-	void invalidateRegion(QRectF region);
-	
-	// Add, delete and move pages
-	
-	Page* addPage(const int pageNumber, const QString& masterPageName=QString::null, const bool addAutoFrame=false);
-	void deletePage(const int);
-	//! @brief Add a master page with this function, do not use addPage
-	Page* addMasterPage(const int, const QString&);
-	void deleteMasterPage(const int);
-	//! @brief Rebuild master name list
-	void rebuildMasterNames(void);
-	//! @brief Replace a master page by default one
 	void replaceMasterPage(const QString& oldMasterPage);
-	//! @brief Rename a master page
+	/*!
+	 * \brief Rename a master page.
+	 *
+	 * \param oldPageName old name of the master page
+	 * \param newPageName new name for the master page
+	 */
 	bool renameMasterPage(const QString& oldPageName, const QString& newPageName);
-	//! @brief Create the default master pages based on the layout selected by the user, ie, Normal, Normal Left, etc.
-	void createDefaultMasterPages();
-	//! @brief Create the requested pages in a new document, run after createDefaultMasterPages()
-	void createNewDocPages(int pageCount);
-	/**
-	 * @brief Add the automatic text frame to the page
-	 * @param pageNumber page number
-	 * @return number of frame
+	/*!
+	 * \brief Rebuild master name list.
+	 *
+	 * Rebuild ScribusDoc.MasterName list from the master page name
 	 */
-	int addAutomaticTextFrame(const int pageNumber);
-	/**
-	 * Set the left and right margins based on the location of the page
-	 * @param pageIndex 
+	void rebuildMasterNames(void);
+//@} // End of master page group
+
+/*! \name Page
+ * \brief Page related functions.
+ *
+ * A page represents a paper page. See Page::Page
+ */ //@{
+	// Add, delete and move page
+
+	/*!
+	 * \brief Add a page.
+	 *
+	 * Do not use this to add a master page, use addMasterPage instead
+	 * \param pageNumber index for the page
+	 * \param masterPageName master page to use
+	 * \param addAutoFrame add automatic text frame
+	 * \return addedpage
 	 */
-	void setLocationBasedPageLRMargins(uint pageIndex);
-	/**
-	 * @brief Move page(s) within the document
-	 * @param from page index
-	 * @param to page index
-	 * @param ziel target to move to (page index)
-	 * @param art Before, After or at the end
+	Page* addPage(const int pageNumber, const QString& masterPageName=QString::null, const bool addAutoFrame=false);
+	/*!
+	 * \brief Delete a page.
+	 *
+	 * \param pageNumber index of the page
 	 */
+	void deletePage(const int pageNumber);
+	/*!
+	 * \brief Move page(s) within the document.
+	 *
+	 * \param from page index
+	 * \param to page index
+	 * \param ziel page index of the target to move to
+	 * \param art Before (0), After (1) or At the end (2)
+	 */
+//ivro: create typedef for param art (like whereToMove) ?
 	void movePage(const int from, const int to, const int ziel, const int art);
-	
-	/**
-	 * @brief Copy a page (pageNumberToCopy) copyCount times, whereToInsert(before or after) the existingPage or at the end.
-	 * @param pageNumberToCopy 
-	 * @param existingPage 
-	 * @param whereToInsert 
-	 * @param copyCount 
+	/*!
+	 * \brief Copy a page.
+	 *
+	 * Copy a page (pageNumberToCopy) copyCount times, whereToInsert(before or after) the existingPage or at the end.
+	 * \param pageNumberToCopy index of the page
+	 * \param existingPage where to copy (page index)
+	 * \param whereToInsert Before (0), After (1) or At the end (2)
+	 * \param copyCount number of copy
 	 */
+//ivro: use typedef whereToMove for param whereToInsert ?
 	void copyPage(int pageNumberToCopy, int existingPage, int whereToInsert, int copyCount);
-	
+
+	// Properties of page
+
+	/*!
+	 * \brief Set page properties.
+	 *
+	 * \param width page width
+	 * \param height page height
+	 * \param marginsTop page margins top
+	 * \param marginsLeft page margins left
+	 * \param marginsRight page margins right
+	 * \param marginsBottom page margins bottom
+	 * \param numberOfColumns number of automaticTextFrames columns
+	 * \param distanceOfColumns distance between automaticTextFrams columns
+	 * \param automaticTextFrames is automaticTextFrames enabled ?
+	 * \param pageLayout index of the page layout in ScribusDoc.pageSets
+	 */
+	void setPage(double width, double height, double marginsTop, double marginsLeft, double marginsRight, double marginsBottom, double numberOfColums, double distanceOfColumns, bool automatictTextFrames, int pageLayout);
+	/*!
+	 * \brief Reset the page properties.
+	 *
+	 * \param newMargins margins to apply
+	 * \param pageLayout index of the page layout in Scribus.pageSets
+	 */
+	void resetPage(MarginStruct& newMargins, int pageLayout);
+	/*!
+	 * \brief Apply a master page.
+	 *
+	 * \param masterPageName name of the master page
+	 * \param pageNumber index of the page
+	 */
+	bool applyMasterPage(const QString& masterPageName, const int pageNumber);
+	/*!
+	 * \brief Copies a normal page to be a master pages.
+	 *
+	 * \param pageNumber index of the page to copy
+	 * \param leftPage
+         * \param maxLeftPage
+	 * \param masterPageName name for the master page
+	 * \param copyFromAppliedMaster
+	 */
+	bool copyPageToMasterPage(const int pageNumber, const int leftPage, const int maxLeftPage, const QString& masterPageName, bool copyFromAppliedMaster);
+
+	/*!
+	 * \brief Add the automatic text frame to the page.
+	 *
+	 * \param pageNumber index of page
+	 * \return number of text frame created, -1 on error
+	 */
+	int addAutomaticTextFrame(const int pageNumber);
+
+	/*!
+	 * \brief Set the page margins.
+	 *
+	 * Current code uses current page only, also provide a (currently, TODO) option for this.
+	 * \param initialTop
+	 * \param initialBottom
+	 * \param initialLeft
+	 * \param initialRight
+	 * \param initialHeight
+	 * \param initialWight
+	 * \param height
+	 * \param width
+	 * \param orientation
+	 * \param pageSize
+	 * \param pageNumber if equal to -1, do nothing and return false. Caution default is -1.
+	 * \param pageType see Page.LeftPg, default to 0 (Right page)
+	 */
+//ivro: is this fuction name goods as it does things that not only about margins ?
+	bool changePageMargins(const double initialTop, const double initialBottom, const double initialLeft, const double initialRight, const double initialHeight, const double initialWidth, const double height, const double width, const int orientation, const QString& pageSize, const int pageNumber=-1, const int pageType = 0);
+
+	/*!
+	 * \brief Get page's bleeds.
+	 *
+	 * \param pageNumber index of the page
+	 * \param bleedData struct to get the bleed
+	 */
+//ivro: is this not better in Page ?
+	void getBleeds(int pageNumber, MarginStruct& bleedData);
+	/*!
+	 * \brief Get page's bleeds.
+	 *
+	 * \param page page to look at
+	 * \param bleedData struct to get the bleed
+	 */
+	void getBleeds(Page* page, MarginStruct& bleedData);
+
+
+	// Canvas
+
+	/*!
+	 * \brief Get the location of the page on the canvas, ie, left, middle, or right.
+	 *
+	 * Does not give information about middle left, etc.
+	 * \param pageIndex Index of page to find location for
+	 * \return LeftPage, MiddlePage, RightPage, enum from pagestructs.h
+	 */
+	PageLocation locationOfPage(int pageIndex) const;
+	/*!
+	 * \brief Get the column of the page on the canvas, ie, left, middle, or right.
+	 *
+	 * \param pageIndex Index of page to find location for
+	 * \return int of 0,1,2,3
+	 */
+	int columnOfPage(int pageIndex) const;
+	/*!
+	 * \brief Return the x offset for a page on the canvas.
+	 *
+	 * @retval double containing the offset. Returns -1.0 if page not in Pages list (as -ve is not possible).
+	 * Mostly saves bringing in extra includes into files that already have scribusdoc.h
+	 */
+	double getXOffsetForPage(const int);
+	/*!
+	 * \brief Return the y offset for a page on the canvas.
+	 *
+	 * @retval double coutaining the offset. Returns -1.0 if page not in pages list (as -ve is not possible).
+	 */
+	double getYOffsetForPage(const int);
+
+	/*!
+	 * \brief Set the left and right margins based on the location of the page.
+	 *
+	 * \param pageIndex index of the page
+	 */
+	void setLocationBasedPageLRMargins(uint pageIndex);
+//@} // End of Page group
+
+/*! \name Layer
+ * \brief Layer related functions.
+ */ //@{
 	// Add, delete and move layers
-	/**
-	 * @brief Add a layer to the current document
-	 * @param layerName name of layer
-	 * @param activate the layer active
-	 * @return Number of the layer created
+
+	/*!
+	 * \brief Add a layer to the current document.
+	 *
+	 * \param layerName name of layer
+	 * \param activate the layer active
+	 * \return Number of the layer created
 	 */
 	int addLayer(const QString& layerName=QString::null, const bool activate=false);
-	/**
-	 * @brief Copies a layer from the current document
-	 * @param layerNumberToCopy source layer
-	 * @param whereToInsert target layer
-	 * @return Success or failure
+	/*!
+	 * \brief Copies a layer from the current document.
+	 *
+	 * \param layerNumberToCopy source layer
+	 * \param whereToInsert target layer
+	 * \return Success or failure
 	 */
 	void copyLayer(int layerNumberToCopy, int whereToInsert);
-	/**
-	 * @brief Delete a layer from the current document
-	 * @param layerNumber of layer
-	 * @param deleteItems the items on the layer too?
-	 * @return Success or failure
+	/*!
+	 * \brief Delete a layer from the current document.
+	 *
+	 * \param layerNumber of layer
+	 * \param deleteItems the items on the layer too?
+	 * \return Success or failure
 	 */
 	bool deleteLayer(const int layerNumber, const bool deleteItems);
-	/**
-	 * @brief Return the number of the current layer
-	 * @return Active layer number
+	/*!
+	 * FIXME: Make protected once scripter function no longer uses this directly
 	 */
-	int activeLayer();
+	void removeLayer(int l, bool dl = false);
 
-	/**
-	 * @brief Return the name of the current layer
-	 * @return Name of the layer
-	 */
-	const QString& activeLayerName();
-	/**
-	 * @brief Set the active layer via the layer number
-	 * @param layerToActivate Number of the layer
-	 * @return Success or failure
+	// Active layer
+
+	/*!
+	 * \brief Set the active layer via the layer number.
+	 *
+	 * \param layerToActivate Number of the layer
+	 * \return Success or failure
 	 */
 	bool setActiveLayer(const int layerToActivate);
-	/**
-	 * @brief Set the active layer via the layer name
-	 * @param layerNameToActivate Name of the layer
-	 * @return Success or failure
+	/*!
+	 * \brief Set the active layer via the layer name.
+	 *
+	 * \param layerNameToActivate Name of the layer
+	 * \return Success or failure
 	 */
 	bool setActiveLayer(const QString & layerNameToActivate);
-	/**
-	 * @brief Set the layer printable via the layer number
-	 * @param layerNumber Number of the layer
-	 * @param isPrintable bool true = layer is prantable
-	 * @return Success or failure
+	/*!
+	 * \brief Return the number of the current layer.
+	 *
+	 * \return Active layer number
+	 */
+	int activeLayer();
+	/*!
+	 * \brief Return the name of the current layer.
+	 *
+	 * \return Name of the layer
+	 */
+	const QString& activeLayerName();
+
+	// Layer properties
+
+	/*!
+	 * \brief Return the layer name.
+	 *
+	 * \param layerNumber Number of the layer
+	 * \return Name of the layer
+	 */
+	QString layerName(const int layerNumber) const;
+	/*!
+	 * \brief Change the name of a layer.
+	 *
+	 * \param layerNumber number of the layer
+	 * \param newName new name of the layer
+	 * \return Success or failure
+	 */
+	bool changeLayerName(const int layerNumber, const QString& newName);
+	/*!
+	 * \brief Set the layer printable via the layer number.
+	 *
+	 * \param layerNumber Number of the layer
+	 * \param isPrintable bool true = layer is prantable
+	 * \return Success or failure
 	 */
 	bool setLayerPrintable(const int layerNumber, const bool isPrintable);
-	/**
-	 * @brief Is the layer printable
-	 * @param layerNumber Number of the layer
-	 * @return Printable or not
+	/*!
+	 * \brief Is the layer printable ?
+	 *
+	 * \param layerNumber Number of the layer
+	 * \return Printable or not
 	 */
 	bool layerPrintable(const int layerNumber);
-	/**
-	 * @brief Set the layer visible via the layer number
-	 * @param layerNumber Number of the layer
-	 * @param isViewable true = layer is visible
-	 * @return Success or failure
+	/*!
+	 * \brief Set the layer visible via the layer number.
+	 *
+	 * \param layerNumber Number of the layer
+	 * \param isViewable true = layer is visible
+	 * \return Success or failure
 	 */
 	bool setLayerVisible(const int layerNumber, const bool isViewable);
-	/**
-	 * @brief Is the layer visible
-	 * @param layerNumber Number of the layer
-	 * @return Visible or not
+	/*!
+	 * \brief Is the layer visible ?
+	 *
+	 * \param layerNumber Number of the layer
+	 * \return Visible or not
 	 */
 	bool layerVisible(const int layerNumber);
-	/**
-	 * @brief Set the layer locked via the layer number
-	 * @param layerNumber Number of the layer
-	 * @param isLocked true = layer is locked
-	 * @return Success or failure
+	/*!
+	 * \brief Set the layer locked via the layer number.
+	 *
+	 * \param layerNumber Number of the layer
+	 * \param isLocked true = layer is locked
+	 * \return Success or failure
 	 */
 	bool setLayerLocked(const int layerNumber, const bool isLocked);
-	/**
-	 * @brief Is the layer locked
-	 * @param layerNumber Number of the layer
-	 * @return Locked or not
+	/*!
+	 * \brief Is the layer locked ?
+	 *
+	 * \param layerNumber Number of the layer
+	 * \return Locked or not
 	 */
 	bool layerLocked(const int layerNumber);
-	/**
-	 * @brief Set the layer flow via the layer number
-	 * @param layerNumber Number of the layer
-	 * @param flow true = Text flows around objects on this layer
-	 * @return Success or failure
+	/*!
+	 * \brief Set the layer flow via the layer number.
+	 *
+	 * \param layerNumber Number of the layer
+	 * \param flow true = Text flows around objects on this layer
+	 * \return Success or failure
 	 */
 	bool setLayerFlow(const int layerNumber, const bool flow);
-	/**
-	 * @brief does text flow around objects on this layer
-	 * @param layerNumber Number of the layer
-	 * @return flow or not
+	/*!
+	 * \brief Does text flow around objects on this layer ?
+	 *
+	 * \param layerNumber Number of the layer
+	 * \return flow or not
 	 */
 	bool layerFlow(const int layerNumber);
-	/**
-	 * @brief Set the layer transparency via the layer number
-	 * @param layerNumber Number of the layer
-	 * @param trans transparency value 0.0 - 1.0
-	 * @return Success or failure
+	/*!
+	 * \brief Set the layer transparency via the layer number.
+	 *
+	 * \param layerNumber Number of the layer
+	 * \param trans transparency value 0.0 - 1.0
+	 * \return Success or failure
 	 */
 	bool setLayerTransparency(const int layerNumber, double trans);
-	/**
-	 * @brief returns the layer transparency
-	 * @param layerNumber Number of the layer
-	 * @return transparency value 0.0 - 1.0
+	/*!
+	 * \brief Returns the layer transparency.
+	 *
+	 * \param layerNumber Number of the layer
+	 * \return transparency value 0.0 - 1.0
 	 */
 	double layerTransparency(const int layerNumber);
-	/**
-	 * @brief Set the layer layerBlendMode via the layer number
-	 * @param layerNumber Number of the layer
-	 * @param blend layerBlendMode
-	 * @return Success or failure
+	/*!
+	 * \brief Set the layer layerBlendMode via the layer number.
+	 *
+	 * \param layerNumber Number of the layer
+	 * \param blend layerBlendMode
+	 * \return Success or failure
 	 */
 	bool setLayerBlendMode(const int layerNumber, int blend);
-	/**
-	 * @brief returns the layer BlendMode
-	 * @param layerNumber Number of the layer
-	 * @return layerBlendMode
+	/*!
+	 * \brief Returns the layer BlendMode.
+	 *
+	 * \param layerNumber Number of the layer
+	 * \return layerBlendMode
 	 */
 	int layerBlendMode(const int layerNumber);
-	/**
-	 * @brief Return the level of the requested layer
-	 * @param layerNumber Number of the layer
-	 * @return Level of the layer
+	/*!
+	 * \brief Set the layer outline mode via the layer number.
+	 *
+	 * \param layerNumber Number of the layer
+	 * \param outline true = layer is displayed in outlines only
+	 * \return Success or failure
 	 */
-	int layerLevelFromNumber(const int layerNumber);
-	/**
-	 * @brief Set the layer marker color
-	 * @param layerNumber Number of the layer
-	 * @param color color of the marker
-	 * @return Success or failure
+	bool setLayerOutline(const int layerNumber, const bool outline);
+	/*!
+	 * \brief Is this layer in outline mode ?
+	 *
+	 * \param layerNumber Number of the layer
+	 * \return outline or not
+	 */
+	bool layerOutline(const int layerNumber);
+
+	// Layer marker color
+
+	/*!
+	 * \brief Set the layer marker color.
+	 *
+	 * \param layerNumber Number of the layer
+	 * \param color color of the marker
+	 * \return Success or failure
 	 */
 	bool setLayerMarker(const int layerNumber, QColor color);
-	/**
-	 * @brief returns the layer marker color
-	 * @param layerNumber Number of the layer
-	 * @return marker color
+	/*!
+	 * \brief Returns the layer marker color.
+	 *
+	 * \param layerNumber Number of the layer
+	 * \return marker color
 	 */
 	QColor layerMarker(const int layerNumber);
-	/**
-	 * @brief Set the layer outline mode via the layer number
-	 * @param layerNumber Number of the layer
-	 * @param outline true = layer is displayed in outlines only
-	 * @return Success or failure
-	 */
-	bool setLayerOutline(const int layerNumber, const bool outline);
-	/**
-	 * @brief is this layer in outline mode
-	 * @param layerNumber Number of the layer
-	 * @return outline or not
+
+	// Layer level
+
+	/*!
+	 * \brief Returns the level of the requested layer.
+	 *
+	 * \param layerNumber Number of the layer
+	 * \return Level of the layer
 	 */
-	bool layerOutline(const int layerNumber);
-	/**
-	 * @brief Return the number of the layer at a certain level
-	 * @param layerLevel Layer level
-	 * @return Layer number
+	int layerLevelFromNumber(const int layerNumber);
+	/*!
+	 * \brief Returns the number of the layer at a certain level.
+	 *
+	 * \param layerLevel Layer level
+	 * \return Layer number
 	 */
 	int layerNumberFromLevel(const int layerLevel);
-	/**
-	 * @brief Return the layer count
-	 * @return Number of layers in doc
-	 */
-	int layerCount() const;
-	/**
-	 * @brief Lower a layer
-	 * @param layerNumber Number of the layer
-	 * @return Success or failure
+
+	// Lower and Raise Layer
+
+	/*!
+	 * \brief Lowers a layer.
+	 *
+	 * \param layerNumber Number of the layer
+	 * \return Success or failure
 	 */
 	bool lowerLayer(const int layerNumber);
-	/**
-	 * @brief Lower a layer using the level
-	 * @param layerLevel Level of the layer
-	 * @return Success or failure
+	/*!
+	 * \brief Lowers a layer using the level.
+	 *
+	 * \param layerLevel Level of the layer
+	 * \return Success or failure
 	 */
 	bool lowerLayerByLevel(const int layerLevel);
-	/**
-	 * @brief Raise a layer
-	 * @param layerNumber Number of the layer
-	 * @return Success or failure
+	/*!
+	 * \brief Raises a layer.
+	 *
+	 * \param layerNumber Number of the layer
+	 * \return Success or failure
 	 */
 	bool raiseLayer(const int layerNumber);
-	/**
-	 * @brief Raise a layer using the level
-	 * @param layerLevel Level of the layer
-	 * @return Success or failure
+	/*!
+	 * \brief Raises a layer using the level.
+	 *
+	 * \param layerLevel Level of the layer
+	 * \return Success or failure
 	 */
 	bool raiseLayerByLevel(const int layerLevel);
-	/**
-	 * @brief Return the layer name
-	 * @param layerNumber Number of the layer
-	 * @return Name of the layer
-	 */
-	QString layerName(const int layerNumber) const;
-	/**
-	 * @brief Change the name of a layer
-	 * @param layerNumber number of the layer
-	 * @param newName new name of the layer
-	 * @return Success or failure
+
+	// Various functions on layer
+
+	/*!
+	 * \brief Returns the layer count.
+	 *
+	 * \return Number of layers in doc
 	 */
-	bool changeLayerName(const int layerNumber, const QString& newName);
-	/**
-	 * @brief Does the layer have items on it?
-	 * @param layerNumber Number of the layer
-	 * @return Layer contains items bool
+	int layerCount() const;
+	/*!
+	 * \brief Does the layer have items on it ?
+	 *
+	 * \param layerNumber Number of the layer
+	 * \return Layer contains items bool
 	 */
 	bool layerContainsItems(const int layerNumber);
-	/**
-	 * @brief Renumber a layer. Used in particular for reinsertion for undo/redo
-	 * @param layerNumber old layer number
-	 * @param newLayerNumber New layer number
-	 * @return Success or failure
+	/*!
+	 * \brief Renumbers a layer.
+	 *
+	 * Used in particular for reinsertion for undo/redo.
+	 * \param layerNumber old layer number
+	 * \param newLayerNumber New layer number
+	 * \return Success or failure
 	 */
 	bool renumberLayer(const int layerNumber, const int newLayerNumber);
-	/**
-	 * @brief Return a list of the layers in their order
-	 * @param list QStringList to insert the layer names into
-	 */
-	void orderedLayerList(QStringList* list);
-	//Items
-	bool deleteTaggedItems();
-
 	/*!
-		* @brief Builds a qmap of the icc profiles used within the document
-	 */
-	void getUsedProfiles(ProfilesL& usedProfiles);
-	bool OpenCMSProfiles(ProfilesL InPo, ProfilesL InPoCMYK, ProfilesL MoPo, ProfilesL PrPo);
-	void CloseCMSProfiles();
-	void SetDefaultCMSParams();
-	/**
-	 * @brief Switch Colormanagement on or of
-	 * @param enable bool, if true Colormanagement is switched on, else off
+	 * \brief Returns a list of the layers in their order.
+	 *
+	 * \param list QStringList to insert the layer names into
 	 */
-	void enableCMS(bool enable);
-	
-	const ParagraphStyle& paragraphStyle(QString name) { return docParagraphStyles.get(name); }
-	const StyleSet<ParagraphStyle>& paragraphStyles()   { return docParagraphStyles; }
-	bool isDefaultStyle( const ParagraphStyle& p ) const { return docParagraphStyles.isDefault(p); }
-	bool isDefaultStyle( const CharStyle& c ) const { return docCharStyles.isDefault(c); }
-// 	bool isDefaultStyle( LineStyle& l ) const { return MLineStyles......; }
+	void orderedLayerList(QStringList* list);
+//@} // End of Layer function
 
-	void getNamedResources(ResourceCollection& lists) const;
-	void replaceNamedResources(ResourceCollection& newNames);	
-	
-	void redefineStyles(const StyleSet<ParagraphStyle>& newStyles, bool removeUnused=false);
-	/**
-	 * @brief Remove any reference to old styles and replace with new name. This needs to be
-	 *        called when a style was removed. New name may be "".
-	 * @param newNameForOld a map which maps the name of any style to remove to a new stylename
-	 */
-	void replaceStyles(const QMap<QString,QString>& newNameForOld);
-	/**
-	 * @brief Insert styles from another document in this document.
-	 *        
-	 * @param fileName The path of the document we want to extract its styles
-	 */
-	void loadStylesFromFile(QString fileName);
-	/**
-	 * @brief Gather styles from another document.
-	 *        
-	 * @param fileName The path of the document we want to extract its styles
-	 * @param tempStyles A pointer to a StyleSet which will be filled by paragraph styles
-	 * @param tempCharStyles A pointer to a StyleSet which will be filled by character styles
-	 * @param tempLineStyles A map which will be filled by line styles
-	 */
-	void loadStylesFromFile(QString fileName, StyleSet<ParagraphStyle> *tempStyles,
-	                                          StyleSet<CharStyle> *tempCharStyles,
-	                                          QMap<QString, multiLine> *tempLineStyles);
+/*! \name Item
+ * \brief Item related functions.
+ */ //@{
+	// Add
 
-	const CharStyle& charStyle(QString name) { return docCharStyles.get(name); }
-	const StyleSet<CharStyle>& charStyles()  { return docCharStyles; }
-	void redefineCharStyles(const StyleSet<CharStyle>& newStyles, bool removeUnused=false);
-	/**
-	 * @brief Remove any reference to old styles and replace with new name. This needs to be
-	 *        called when a style was removed. New name may be "".
-	 * @param newNameForOld a map which maps the name of any style to remove to a new stylename
+	/*!
+	 * \brief Add an Item to the document.
+	 *
+	 * A simple function to create an item of a defined type and add it to the document
+	 * Will need extensive rewriting once we have various classes of PageItems, at a guess.
+	 *
+	 * \param itemType type
+	 * \param frameType frame type
+	 * \param x X pos
+	 * \param y Y pos
+	 * \param b width
+	 * \param h height
+	 * \param w ?
+	 * \param fill fill color name
+	 * \param outline outline color name
+	 * \param itemFinalised Used to handle item creation for undo while the user is still dragging.
+	 * \return Number of created item, -1 on failure.
 	 */
-	void replaceCharStyles(const QMap<QString,QString>& newNameForOld);
-
-	/**
-	 * @brief Should guides be locked or not
-	 * @param isLocked If true guides on pages cannot be moved if false they
-	 * can be dragged to new positions.
-	 * @author Riku Leino
+	int itemAdd(const PageItem::ItemType itemType, const PageItem::ItemFrameType frameType, const double x, const double y, const double b, const double h, const double w, const QString& fill, const QString& outline, const bool itemFinalised);
+	/*!
+	 * \brief Add an Item to the page.
+	 *
+	 * Item will be fitted to the closest guides/margins of the x/y position.
+	 *
+	 * \param itemType type
+	 * \param itemFramType frame type
+	 * \param x X pos
+	 * \param y Y pos
+	 * \param w ?
+	 * \param fill fill color name
+	 * \param outline outline color name
+	 * \param itemFinalised Used to handle item creation for undo while the user is still dragging
+	 * \return Number of created item, -1 on failure.
 	 */
-	void lockGuides(bool isLocked);
-	/**
-	 * @brief Method used when an undo/redo is requested.
-	 * @param state State describing the action that is wanted to be undone/redone
-	 * @param isUndo If true undo is wanted else if false redo.
-	 * @author Riku Leino
+	int itemAddArea(const PageItem::ItemType itemType, const PageItem::ItemFrameType frameType, const double x, const double y, const double w, const QString& fill, const QString& outline, const bool itemFinalised);
+	/*!
+	 * \brief Allow the user to create a frame easily with some simple placement and sizing options.
+	 *
+	 * \param iafData a InsertAFrameData structure with params
+	 * \return int item id? FIXME
 	 */
-	void restore(UndoState* state, bool isUndo);
-	/**
-	 * @brief Sets the name of the document
-	 * @param name Name for the document
-	 * @author Riku Leino
+	int itemAddUserFrame(InsertAFrameData &iafData);
+	/*!
+	 * \brief Commit item creation when a user has click-drag created an item.
+	 *
+	 * Only called from ScribusView. Note the undo target is the page, so the undo code remains their for now.
+	 *
+	 * \return If an item was committed and the view must emit its signal, which needs removing from here, TODO.
 	 */
-	void setName(const QString& name);
+	bool itemAddCommit(const int itemNumber);
 	/*!
-	 * @brief Returns a stringlist of the item attributes within the document
+	 * \brief Finalise item creation, only to be called from itemAdd().
+	 *
+	 * Simply split off code from itemAdd.
+	 *
+	 * \param itemType type
+	 * \param frameType frame type
+	 * \param itemNumber item index
 	 */
-	QStringList getItemAttributeNames();
-
-	bool AddFont(QString name, int fsize = 10);
+	void itemAddDetails(const PageItem::ItemType itemType, const PageItem::ItemFrameType frameType, const int itemNumber);
 	/*!
-	 * @brief TODO: Reorganise the fonts.. how? Moved from scribus.cpp
-	 * CB: almost the same as getUsedFonts???
+	 * \brief Item type conversion functions.
+	 *
+	 * \param currItem item to convert
+	 * \param newType
+	 * \param secondaryItem ?
 	 */
-	QMap<QString,int> reorganiseFonts();
+	PageItem* convertItemTo(PageItem *currItem, PageItem::ItemType newType, PageItem* secondaryItem=NULL);
 	/*!
-	 * @brief Returns a qmap of the fonts and  their glyphs used within the document
+	 * \brief Paste an item to the document.
+	 *
+	 * The bulk of a paste item process runs here for want of a better place, but its a better place
+	 * than the view where it used to be.
+	 * TODO Once the pageitem restructure is done, this is probably unnecessary but it removes the
+	 * unnecessary part from the view for now which is overloaded with non ScrollView code.
 	 */
-	void getUsedFonts(QMap<QString,QMap<uint, FPointArray> > &Really);
-	void checkItemForFonts(PageItem *it, QMap<QString, QMap<uint, FPointArray> > & Really, uint lc);
+	//TODO: void PasteItem(struct CopyPasteBuffer *Buffer, bool loading, bool drag = false);
+
+	//itemDelete
+	//itemBlah...
+
+	// move, rotate, resize items
 
 	/*!
-	 * @brief Replace line style colors
+	 * \brief Move item.
+	 *
+	 * \param newX new X coord
+	 * \param newY new Y coord
+	 * \param item page item to move
+	 * \param fromMP ?
 	 */
-	void replaceLineStyleColors(const QMap<QString, QString>& colorMap);
-	/*!
-	* @brief Builds a qmap of the colours used within the document
-	*/
-	void getUsedColors(ColorList &colorsToUse, bool spot = false);
-	/*!
-	* @brief Return if a specific color is used by line styles
-	*/
-	bool lineStylesUseColor(const QString& colorName);
-	/*!
-	* @brief Set the patterns for a document
-	*/
-	bool addPattern(QString &name, ScPattern& pattern);
-	void setPatterns(QMap<QString, ScPattern> &patterns);
+//ivro: standardize param order as PageItem changed each function ?
+//	something like item, args, options ?
+	bool MoveItem(double newX, double newY, PageItem* ite, bool fromMP = false);
 	/*!
-	* @brief Builds a QStringList of the patterns used within the document
-	*/
-	QStringList getUsedPatterns();
-	QStringList getUsedPatternsSelection(Selection* customSelection);
-	QStringList getUsedPatternsHelper(QString pattern, QStringList &results);
-	/**
-	 * @brief Set and get the document's unit index
-	 */
-	void setUnitIndex(const int);
-	int unitIndex() const;
-	double unitRatio() const;
-	/**
-	 * @brief Apply a master page
-	 */
-	bool applyMasterPage(const QString& pageName, const int pageNumber);
-	/**
-	 * @brief Undo function for applying a master page
-	 */
-	void restoreMasterPageApplying(SimpleState *state, bool isUndo);
-	void restorePageCopy(SimpleState *state, bool isUndo);
-	/**
-	 * @brief Undo function for grouping/ungrouping
-	 */
-	void restoreGrouping(SimpleState *state, bool isUndo);
-	void restoreUngrouping(SimpleState *state, bool isUndo);
-	/**
-	 * @brief Save function
-	 */
-	bool save(const QString& fileName, QString* savedFile = NULL);
-	/**
-	 * @brief Set the page margins. Current code uses current page only, also provide a (currently, TODO) option for this.
+	 * \brief Rotate Item.
+	 *
+	 * \param angle angle to rotate
+	 * \param itemNumber index of the item to rotate
 	 */
-	bool changePageMargins(const double initialTop, const double initialBottom, const double initialLeft, const double initialRight, const double initialHeight, const double initialWidth, const double Height, const double width, const int orientation, const QString& pageSize, const int pageNumber=-1, const int pageType = 0);
-	/**
-	 * @brief Recalculate the colors after CMS settings change. Update the items in the doc accordingly.
+	void RotateItem(double angle, int itemNumber);
+	/*!
+	 * \brief Rotate Item.
+	 *
+	 * \param angle angle to rotate
+	 * \param currItem page item to rotate
 	 */
-	 void recalculateColors();
-	/**
-	 * @brief Sets up the ScText defaults from the document
+	void RotateItem(double angle, PageItem *currItem);
+	/*!
+	 * \brief Move and Rotate Item.
+	 *
+	 * \param currItem page item to transform
+	 * \param npv ?
+	 * \param fromMP ?
 	 */
-	void setScTextDefaultsFromDoc(ScText *);
-	/**
-	 * @brief Copies a normal page to be a master pages
+	void MoveRotated(PageItem *currItem, FPoint npv, bool fromMP = false);
+	/*!
+	 * \brief Resize item.
+	 *
+	 * \param newX new X coord
+	 * \param newY new Y coord
+	 * \param ite index of page item to resize
+	 * \param fromMp ?
+	 * \param DoUpdateClip ?
+	 * \param redraw ?
 	 */
-	bool copyPageToMasterPage(const int, const int, const int, const QString&, bool);
-	/**
-	 * @brief Paste an item to the document.
-	 * The bulk of a paste item process runs here for want of a better place, but its a better place
-	 * than the view where it used to be. 
-	 * TODO Once the pageitem restructure is done, this is probably unnecessary but it removes the 
-	 * unnecessary part from the view for now which is overloaded with non ScrollView code.
+	bool SizeItem(double newX, double newY, int ite, bool fromMP = false, bool DoUpdateClip = true, bool redraw = true);
+	/*!
+	 * \brief Resize item.
+	 *
+	 * \param newX new X coord
+	 * \param newY new Y coord
+	 * \param pi page item to resize
+	 * \param fromMp ?
+	 * \param DoUpdateClip ?
+	 * \param redraw ?
 	 */
-	//TODO: void PasteItem(struct CopyPasteBuffer *Buffer, bool loading, bool drag = false);
-	
-	/**
-	 * @brief Add an Item to the document.
-	 * A simple function to create an item of a defined type and add it to the document
-	 * Will need extensive rewriting once we have various classes of PageItems, at a guess.
+	bool SizeItem(double newX, double newY, PageItem *pi, bool fromMP = false, bool DoUpdateClip = true, bool redraw = true);
+	/*!
+	 * \brief Size and Move item.
 	 *
-	 * @param itemFinalised Used to handle item creation for undo while the user is still dragging.
-	 * @return Number of created item, -1 on failure.
-	\param itemType type
-	\param frameType frame type
-	\param x X pos
-	\param y Y pos
-	\param b width
-	\param h height
-	\param w ?
-	\param fill fill color name
-	\param outline outline color name
-	*/
-	int itemAdd(const PageItem::ItemType itemType, const PageItem::ItemFrameType frameType, const double x, const double y, const double b, const double h, const double w, const QString& fill, const QString& outline, const bool itemFinalised);
-
-	/** Add an item to the page based on the x/y position. Item will be fitted to the closest guides/margins */
-	int itemAddArea(const PageItem::ItemType itemType, const PageItem::ItemFrameType frameType, const double x, const double y, const double w, const QString& fill, const QString& outline, const bool itemFinalised);
-	
-	/**
-	 * @brief Allow the user to create a frame easily with some simple placement and sizing options
-	 * @param iafData a InsertAFrameData structure with params
-	 * @return int item id? FIXME
+	 * \param newX new X coord
+	 * \param newY new Y coord
+	 * \param ite index of page item to transform
+	 * \param fromMp ?
+	 * \param constrainRotation ?
 	 */
-	int itemAddUserFrame(InsertAFrameData &iafData);
+	bool MoveSizeItem(FPoint newX, FPoint newY, int ite, bool fromMP = false, bool constrainRotation=false);
+//ivro: don't know what it does
+	void AdjustItemSize(PageItem *currItem);
 
-	/**
-	 * @brief Commit item creation when a user has click-drag created an item
-	 * Only called from ScribusView. Note the undo target is the page, so the undo code remains their for now.
-	 * @return If an item was committed and the view must emit its signal, which needs removing from here, TODO.
+	//void FlipImageH();
+	//void FlipImageV();
+	void MirrorPolyH(PageItem *currItem);
+	void MirrorPolyV(PageItem *currItem);
+
+	// Various
+
+	/*!
+	 * \brief Delete the tagged items.
+	 *
+	 * Currently does nothing
 	 */
-	bool itemAddCommit(const int itemNumber);
-	
-	/**
-	 * @brief Finalise item creation. Simply split off code from itemAdd
-	 * Only to be called from itemAdd()
+	bool deleteTaggedItems();
+	/*!
+	 * \brief Get the item index from a unique ID.
+	 *
+	 * \param unique ID of item
+	 * \return index of the item
 	 */
-	void itemAddDetails(const PageItem::ItemType itemType, const PageItem::ItemFrameType frameType, const int itemNumber);
-
 	uint getItemNrfromUniqueID(uint unique);
-	//itemDelete
-	//itemBlah...
-	
-	/**
-	 * @brief Run this common frame item update code
+	/*!
+	 * \brief Run this common frame item update code.
 	 */
 	void updateFrameItems();
-	/**
-	 * @brief Renumbers the items into the order they are stored in in the lists.
+	/*!
+	 * \brief Renumbers the items into the order they are stored in in the lists.
+	 *
 	 * Utility function used in various places, basically handles keeping items numbered in the way
 	 * they are layered. When layer is a property and not a fuction of storage, this should be removed.
 	 * Depends on the Items pointer pointing to the correct item list (doc, master, etc).
 	 * @sa updateFrameItems();
 	 */
 	void renumberItemsInListOrder();
-	/**
-	 * @brief Rebuild item lists taking into account layer order.
+	/*!
+	 * \brief Rebuild item lists taking into account layer order.
+	 *
 	 * Utility function used in various places, basically handles keeping items numbered in the way
 	 * they are layered. When layer is a property and not a fuction of storage, this should be removed.
 	 * @sa updateFrameItems();
 	 */
 	void rebuildItemLists();
-	/**
-	 * @brief Doc uses automatic text frames?
-	 */
-	bool usesAutomaticTextFrames() const;
-	void setUsesAutomaticTextFrames(const bool);
-	
-	/**
-	 * @brief Load images into an image frame, moved from the view
-	 * @retval Return false on failure
-	 */
-	bool LoadPict(QString fn, int ItNr, bool reload = false, bool showMsg = false);
-	/**
-	 * 
-	 * @param fn 
-	 * @param pageItem 
-	 * @param reload 
-	 * @return 
-	 */
-	bool loadPict(QString fn, PageItem *pageItem, bool reload = false, bool showMsg = false);
-	/**
-	 * \brief Handle image with color profiles
-	 * @param Pr profile
-	   @param PrCMYK cmyk profile
-	   @param dia optional progress widget
-	 */
-	void RecalcPictures(ProfilesL *Pr, ProfilesL *PrCMYK, QProgressBar *dia = 0);
-	/**
-	 * @brief Find the minX,MinY and maxX,maxY for the canvas required for the doc
-	 */
-	void canvasMinMax(FPoint&, FPoint&);
-	
-	int OnPage(double x2, double  y2);
-	int OnPage(PageItem *currItem);
-	void GroupOnPage(PageItem *currItem);
-	//void reformPages(double& maxX, double& maxY, bool moveObjects = true);
-	void reformPages(bool moveObjects = true);
-	
-	/**
-	 * @brief Return the x or y offset for a page on the canvas
-	 * @retval double containing the offset. Returns -1.0 if page not in Pages list (as -ve is not possible).
-	 * Mostly saves bringing in extra includes into files that already have scribusdoc.h
-	 */
-	double getXOffsetForPage(const int);
-	double getYOffsetForPage(const int);
-	void getBleeds(int pageNumber, MarginStruct& bleedData);
-	void getBleeds(Page* page, MarginStruct& bleedData);
-	
-	/**
-	 * @brief Item type conversion functions
-	 */
-	PageItem* convertItemTo(PageItem *currItem, PageItem::ItemType newType, PageItem* secondaryItem=NULL);
-	
-	/**
-	 * @brief The page number of the current page
-	 */
-	int currentPageNumber();
-	
-	/**
-	 * @brief Return true iff the passed name is not used by any existing PageItem
+	/*!
+	 * \brief Find if item is not an already used item.
+	 *
+	 * Return true if the passed name is not used by any existing PageItem
 	 *        in the same document as this PageItem.
-	 * @author Craig Ringer
+	 * \author Craig Ringer
 	 ** CB Moved from PageItem
 	 */
+//ivro: is returning true if the passed name exists not better ? (or rename to itemNameDontUses ?)
 	bool itemNameExists(const QString itemName);
-	
-	/**
-	 * @brief Set the doc into Master page mode
-	 * Do we need to return if the move to master page mode was successful?
+	/*!
+	 * \brief Returns a stringlist of the item attributes within the document.
 	 */
-	void setMasterPageMode(bool);
+	QStringList getItemAttributeNames();
 
-	/*** Is the document in master page mode? */
-	bool masterPageMode() const { return m_masterPageMode; }
-	
-	/**
-	 * @brief Add a section to the document sections list
+	/*!
+	 * \brief Get a list of frames of certain type.
+	 */
+	QMap<PageItem*, QString> getDocItemNames(PageItem::ItemType itemType);
+//@} //End Items group
+
+/*! \name Sections
+ * \brief Sections related functions
+ */ //@{
+	// add, delete, use sections
+
+	/*!
+	 * \brief Add a section to the document sections list.
+	 *
 	 * Set number to -1 to add in the default section if the map is empty
 	 */
 	void addSection(const int number=0, const QString& name=QString::null, const uint fromindex=0, const uint toindex=0, const  DocumentSectionType type=Type_1_2_3, const uint sectionstartindex=0, const bool reversed=false, const bool active=true);
-	/**
-	 * @brief Delete a section from the document sections list
+	/*!
+	 * \brief Delete a section from the document sections list.
 	 */
 	bool deleteSection(const uint);
-	/**
-	 * @brief Gets the page number to be printed based on the section it is in.
+	/*!
+	 * \brief Gets the page number to be printed based on the section it is in.
+	 *
 	 * Returns QString::null on failure to find the pageIndex
 	 */
 	const QString getSectionPageNumberForPageIndex(const uint) const;
-	/**
-	 * @brief Gets the key of the sections map based on the section the page index is in.
+	/*!
+	 * \brief Gets the key of the sections map based on the section the page index is in.
+	 *
 	 * Returns -1 on failure to find the pageIndex
 	 */
 	int getSectionKeyForPageIndex(const uint pageIndex) const;
-	/**
+	/*!
 	 *
 	 *
 	 */
 	void updateSectionPageNumbersToPages();
-	/**
-	 * 
-	 * @param otherPageIndex 
-	 * @param location 
-	 * @param count 
+	/*!
+	 *
+	 * \param otherPageIndex
+	 * \param location
+	 * \param count
 	 */
 	void addPageToSection(const uint otherPageIndex, const uint location, const uint count=1);
-	/**
-	 * 
-	 * @param pageIndex 
+	/*!
+	 *
+	 * \param pageIndex
 	 */
 	void removePageFromSection(const uint pageIndex);
-	/**
-	 * 
+	/*!
+	 *
 	 */
 	void setFirstSectionFromFirstPageNumber();
-	/**
-	 * @brief Update the fill and line QColors for all items in the doc
-	 */
-	void updateAllItemQColors();
-	//! @brief Some internal align tools
-	typedef enum {alignFirst, alignLast, alignPage, alignMargins, alignGuide, alignSelection } AlignTo;
+//@} // End of Sections group
+
+/*! \name Align
+ * Align related functions
+ */ //@{
 	void buildAlignItemList(Selection* customSelection=0);
 	bool startAlign();
 	void endAlign();
-	/**
-	 * \brief Insert a color into the documents color list
-	 * @param nam Name of the colour
-	 * @param c Cyan component
-	 * @param m Magenta component
-	 * @param y Yellow component
-	 * @param k Black component
-	 */
-	void insertColor(QString nam, double c, double m, double y, double k);
-	
-	QMap<QString, double>& constants() { return m_constants; }
-	/**
-	 * \brief Get the location of the page on the canvas, ie, left, middle, or right
-	 * Does not give information about middle left, etc.
-	 * @param pageIndex Index of page to find location for
-	 * @return LeftPage, MiddlePage, RightPage, enum from pagestructs.h
+//@} // End of align functions
+
+/*! \name Styles
+ * Style related functions
+ */ //@{
+	// Paragraphe style
+
+	/*!
+	 * \brief Get a paragraph style by its name.
 	 */
-	PageLocation locationOfPage(int pageIndex) const;
-	/**
-	 * \brief Get the column of the page on the canvas, ie, left, middle, or right
-	 * @param pageIndex Index of page to find location for
-	 * @return int of 0,1,2,3
+	const ParagraphStyle& paragraphStyle(QString name) { return docParagraphStyles.get(name); }
+	/*!
+	 * \brief Get all the paragraph style.
 	 */
-	int columnOfPage(int pageIndex) const;
-	
+	const StyleSet<ParagraphStyle>& paragraphStyles()   { return docParagraphStyles; }
+	/*!
+	 * \brief Redefine Paragraphes style.
+	 */
+//ivro: rename rededineParaStyles ?
+	void redefineStyles(const StyleSet<ParagraphStyle>& newStyles, bool removeUnused=false);
+	/*!
+	 * \brief Remove any reference to old styles and replace with new name.
+	 *
+	 * This needs to be called when a style was removed. New name may be "".
+	 * \param newNameForOld a map which maps the name of any style to remove to a new stylename
+	 */
+//ivro: rename replaceParaStyles ?
+	void replaceStyles(const QMap<QString,QString>& newNameForOld);
+	/*!
+	 * \brief Is the default paragraph style ?
+	 *
+	 * \param p paragraph style to test
+	 */
+//ivro: is this must be with the one for char style ?
+	bool isDefaultStyle( const ParagraphStyle& p ) const { return docParagraphStyles.isDefault(p); }
+
+	// Character style
+
+	/*!
+	 * \brief Get a character style by name.
+	 *
+	 * \param name char style name
+	 */
+	const CharStyle& charStyle(QString name) { return docCharStyles.get(name); }
+	/*!
+	 * \brief Get all the Character styles.
+	 */
+	const StyleSet<CharStyle>& charStyles()  { return docCharStyles; }
+	/*!
+	 * \brief Redefine Character styles.
+	 *
+	 * \param newStyle character styles
+	 * \param removeUnused
+	 */
+	void redefineCharStyles(const StyleSet<CharStyle>& newStyles, bool removeUnused=false);
+	/*!
+	 * \brief Remove any reference to old styles and replace with new name.
+	 *
+	 * This needs to be called when a style was removed. New name may be "".
+	 * \param newNameForOld a map which maps the name of any style to remove to a new stylename
+	 */
+	void replaceCharStyles(const QMap<QString,QString>& newNameForOld);
+	/*!
+	 * \brief Is the default character style ?
+	 *
+	 * \param c character style to test
+	 */
+	bool isDefaultStyle( const CharStyle& c ) const { return docCharStyles.isDefault(c); }
+// 	bool isDefaultStyle( LineStyle& l ) const { return MLineStyles......; }
+
+	// Load Style
+
+	/*!
+	 * \brief Insert styles from another document in this document.
+	 *
+	 * \param fileName The path of the document we want to extract its styles
+	 */
+	void loadStylesFromFile(QString fileName);
+	/*!
+	 * \brief Gather styles from another document.
+	 *
+	 * \param fileName The path of the document we want to extract its styles
+	 * \param tempStyles A pointer to a StyleSet which will be filled by paragraph styles
+	 * \param tempCharStyles A pointer to a StyleSet which will be filled by character styles
+	 * \param tempLineStyles A map which will be filled by line styles
+	 */
+	void loadStylesFromFile(QString fileName, StyleSet<ParagraphStyle> *tempStyles,
+	                                          StyleSet<CharStyle> *tempCharStyles,
+	                                          QMap<QString, multiLine> *tempLineStyles);
+//@} // End of style group
+
+/*! \name Color Management
+ * \brief Color Management related functions.
+ */ //@{
+	/*!
+	 * \brief Builds a qmap of the icc profiles used within the document.
+	 */
+	void getUsedProfiles(ProfilesL& usedProfiles);
+	bool OpenCMSProfiles(ProfilesL InPo, ProfilesL InPoCMYK, ProfilesL MoPo, ProfilesL PrPo);
+	void CloseCMSProfiles();
+	void SetDefaultCMSParams();
+	/*!
+	 * \brief Switch Colormanagement on or of.
+	 *
+	 * \param enable bool, if true Colormanagement is switched on, else off
+	 */
+	void enableCMS(bool enable);
+	/*!
+	 * \brief Recalculate the colors after CMS settings change.
+	 *
+	 * Update the items in the doc accordingly.
+	 */
+	void recalculateColors();
+
+	/*!
+	 * \brief Insert a color into the documents color list.
+	 *
+	 * \param colorList Name of the color list
+	 * \param cyan Cyan component
+	 * \param magenta Magenta component
+	 * \param yellow Yellow component
+	 * \param black Black component
+	 */
+	void insertColor(QString colorList, double cryan, double magenta, double yellow, double black);
+	/*!
+	 * \brief Replace line style colors.
+	 */
+	void replaceLineStyleColors(const QMap<QString, QString>& colorMap);
+	/*!
+	* \brief Builds a qmap of the colours used within the document.
+	*/
+	void getUsedColors(ColorList &colorsToUse, bool spot = false);
+	/*!
+	* \brief Is this specific color is used by line styles.
+	*/
+	bool lineStylesUseColor(const QString& colorName);
+//@} // End of color functions
+
+/*! \name Font
+ * \brief Font related funtions.
+ */ //@{
+	/*!
+	 * \brief Add a font.
+	 */
+	bool AddFont(QString name, int fsize = 10);
+	/*!
+	 * TODO: Reorganise the fonts.. how? Moved from scribus.cpp
+	 * CB: almost the same as getUsedFonts???
+	 */
+	QMap<QString,int> reorganiseFonts();
+	/*!
+	 * \brief Returns a qmap of the fonts and  their glyphs used within the document.
+	 */
+	void getUsedFonts(QMap<QString,QMap<uint, FPointArray> > &Really);
+	void checkItemForFonts(PageItem *it, QMap<QString, QMap<uint, FPointArray> > & Really, uint lc);
+//@} // End of font functions
+
+/*! \name Patterns
+ * \brief Pattern related functions.
+ */ //@{
+	/*!
+	* \brief Set the patterns for a document.
+	*/
+	bool addPattern(QString &name, ScPattern& pattern);
+	void setPatterns(QMap<QString, ScPattern> &patterns);
+	/*!
+	* \brief Builds a QStringList of the patterns used within the document.
+	*/
+	QStringList getUsedPatterns();
+	QStringList getUsedPatternsSelection(Selection* customSelection);
+	QStringList getUsedPatternsHelper(QString pattern, QStringList &results);
+//@} // End of patterns functions
+
+/*! \name Item selection
+ * \brief Item selection related functions.
+ *
+ * Item selection is used to modify items.
+ */ //@{
 	bool sendItemSelectionToBack();
 	bool bringItemSelectionToFront();
 
@@ -835,76 +1268,325 @@ public:
 	void itemSelection_SetStrikethru(int pos, int wid, Selection* customSelection=0);
 	void itemSelection_SetEffects(int s, Selection* customSelection=0);
 	void itemSelection_SetOpticalMargins(int i, Selection* customSelection=0);
-	void itemSelection_resetOpticalMargins(Selection* customSelection=0);
 	void itemSelection_SetColorProfile(const QString& profileName, Selection* customSelection=0);
 	void itemSelection_SetRenderIntent(int intentIndex, Selection* customSelection=0);
-	
+
 //	void chAbStyle(PageItem *currItem, int s);
 
 	void itemSelection_SetTracking(int us, Selection* customSelection=0);
 	void itemSelection_SetFontSize(int size, Selection* customSelection=0);
-	//void FlipImageH();
-	//void FlipImageV();
-	void MirrorPolyH(PageItem *currItem);
-	void MirrorPolyV(PageItem *currItem);
-	
+public slots:
+	void itemSelection_ToggleLock();
+	void itemSelection_ToggleSizeLock();
+	void itemSelection_ToggleImageShown();
+	void itemSelection_TogglePrintEnabled();
+	void itemSelection_ChangePreviewResolution(int id);
+	void itemSelection_ClearItem(Selection* customSelection=0);
+	//! Delete the items in the current selection. When force is true, we do not warn the user and make SE happy too. Force is used from @sa Page::restorePageItemCreation
+	void itemSelection_DeleteItem(Selection* customSelection=0, bool forceDeletion=false);
+	void itemSelection_SetItemFillTransparency(double t);
+	void itemSelection_SetItemLineTransparency(double t);
+	void itemSelection_SetItemFillBlend(int t);
+	void itemSelection_SetItemLineBlend(int t);
+	void itemSelection_SetLineGradient(VGradient& newGradient, Selection* customSelection=0);
+	void itemSelection_SetFillGradient(VGradient& newGradient, Selection* customSelection=0);
+	void itemSelection_SetOverprint(bool overprint, Selection* customSelection=0);
+	void itemSelection_ApplyImageEffects(ScImageEffectList& newEffectList, Selection* customSelection=0);
+	void itemSelection_FlipH();
+	void itemSelection_FlipV();
+	void itemSelection_DoHyphenate();
+	void itemSelection_DoDeHyphenate();
+	void itemSelection_SendToLayer(int layerNumber);
+	void itemSelection_SetImageOffset(double x, double y, Selection* customSelection=0);
+	void itemSelection_SetImageScale(double x, double y, Selection* customSelection=0);
+	void itemSelection_SetImageScaleAndOffset(double ox, double oy, double sx, double sy, Selection* customSelection=0);
+	void itemSelection_AlignLeftOut(AlignTo currAlignTo, double guidePosition);
+	void itemSelection_AlignRightOut(AlignTo currAlignTo, double guidePosition);
+	void itemSelection_AlignBottomIn(AlignTo currAlignTo, double guidePosition);
+	void itemSelection_AlignRightIn(AlignTo currAlignTo, double guidePosition);
+	void itemSelection_AlignBottomOut(AlignTo currAlignTo, double guidePosition);
+	void itemSelection_AlignCenterHor(AlignTo currAlignTo, double guidePosition);
+	void itemSelection_AlignLeftIn(AlignTo currAlignTo, double guidePosition);
+	void itemSelection_AlignCenterVer(AlignTo currAlignTo, double guidePosition);
+	void itemSelection_AlignTopOut(AlignTo currAlignTo, double guidePosition);
+	void itemSelection_AlignTopIn(AlignTo currAlignTo, double guidePosition);
+	void itemSelection_DistributeDistH(bool usingDistance=false, double distance=0.0);
+	void itemSelection_DistributeAcrossPage(bool useMargins=false);
+	void itemSelection_DistributeRight();
+	void itemSelection_DistributeBottom();
+	void itemSelection_DistributeCenterH();
+	void itemSelection_DistributeDistV(bool usingDistance=false, double distance=0.0);
+	void itemSelection_DistributeDownPage(bool useMargins=false);
+	void itemSelection_DistributeLeft();
+	void itemSelection_DistributeCenterV();
+	void itemSelection_DistributeTop();
+	void itemSelection_MultipleDuplicate(ItemMultipleDuplicateData&);
+	void itemSelection_UniteItems(Selection* customSelection=0);
+	void itemSelection_SplitItems(Selection* customSelection=0);
+	/*!
+	 * \brief Adjust an image frame's size to fit the size of the image in it.
+	 */
+	void itemSelection_AdjustFrametoImageSize(Selection* customSelection=0);
+	/*!
+	 * \brief Adjust an image size to fit the size of the frame.
+	 */
+	void itemSelection_AdjustImagetoFrameSize(Selection* customSelection=0);
+	/*!
+	 * \brief startArrowID or endArrowID of -1 mean not applying a selection at this point.
+	 */
+	void itemSelection_ApplyArrowHead(int startArrowID=-1, int endArrowID=-1, Selection* customSelection=0);
+
+	void itemSelection_SetItemPen(QString farbe);
+	void itemSelection_SetItemPenShade(int sha);
+	void itemSelection_SetItemBrush(QString farbe);
+	void itemSelection_SetItemBrushShade(int sha);
+	void itemSelection_SetItemGradFill(int typ);
+	void itemSelection_SetItemPatternFill(QString pattern);
+	void itemSelection_SetItemPatternProps(double scaleX, double scaleY, double offsetX, double offsetY, double rotation);
+//@} // End of item selection group
+
+public:
+
+/*! \name Various functions
+ */ //@{
+
+	/*!
+	 * \brief Save function.
+	 */
+	bool save(const QString& fileName, QString* savedFile = NULL);
+
+	/*!
+	 * \brief Create the default master pages based on the layout selected by the user, ie, Normal, Normal Left, etc.
+	 */
+	void createDefaultMasterPages();
+	/*!
+	 * \brief Create the requested pages in a new document.
+	 *
+	 * Run after ScribusDoc.createDefaultMasterPages()
+	 * \param pageCount number of page to create
+	 */
+	void createNewDocPages(int pageCount);
+
+	/*!
+	 * \brief Update the fill and line QColors for all items in the doc.
+	 */
+	void updateAllItemQColors();
+
+	/*!
+	 * \brief Sets up the ScText defaults from the document.
+	 */
+	void setScTextDefaultsFromDoc(ScText *);
+
+// Restore
+
+	/*!
+	 * \brief Method used when an undo/redo is requested.
+	 *
+	 * \param state State describing the action that is wanted to be undone/redone
+	 * \param isUndo If true undo is wanted else if false redo.
+	 * \author Riku Leino
+	 */
+	void restore(UndoState* state, bool isUndo);
+	/*!
+	 * \brief Undo function for applying a master page.
+	 */
+	void restoreMasterPageApplying(SimpleState *state, bool isUndo);
+	/*!
+	 * \brief Undo function for copy a page.
+	 */
+	void restorePageCopy(SimpleState *state, bool isUndo);
+	/*!
+	 * \brief Undo function for grouping/ungrouping.
+	 */
+	void restoreGrouping(SimpleState *state, bool isUndo);
+	void restoreUngrouping(SimpleState *state, bool isUndo);
+// Loading images
+
+	/*!
+	 * \brief Load images into an image frame, moved from the view.
+	 *
+	 * \param fn image file name
+	 * \param ItNr page item number
+	 * \param reload
+	 * \param showMsg
+	 * \return Return false on failure
+	 */
+	bool LoadPict(QString fn, int ItNr, bool reload = false, bool showMsg = false);
+	/*!
+	 * \brief Load images into an image frame.
+	 *
+	 * \param fn image file name
+	 * \param pageItem page item
+	 * \param reload
+	 * \param showMsg
+	 * \return Return false on failure
+	 */
+	bool loadPict(QString fn, PageItem *pageItem, bool reload = false, bool showMsg = false);
+	/*!
+	 * \brief Handle image with color profiles.
+	 *
+	 * \param Pr profile
+	 * \param PrCMYK cmyk profile
+	 * \param dia optional progress widget
+	 */
+	void RecalcPictures(ProfilesL *Pr, ProfilesL *PrCMYK, QProgressBar *dia = 0);
+public slots:
+	/*!
+	 * \brief Update all the picture in the current selection.
+	 */
+	void updatePic();
+	/*!
+	 * \brief Update the specified picture.
+	 */
+	void updatePict(QString name);
+	/*!
+	 * \brief Update all picture in the specified directory.
+	 */
+	void updatePictDir(QString name);
+	/*!
+	 * \brief Remove a picture from document.
+	 */
+	void removePict(QString name);
+public:
+	/*!
+	 * \brief Find the minX,MinY and maxX,maxY for the canvas required for the doc.
+	 *
+	 * \param minPoint
+	 * \param maxPoint
+	 */
+	void canvasMinMax(FPoint& minPoint, FPoint& maxPoint);
+
+	/*!
+	 * \brief Find page index where the point exists.
+	 *
+	 * In masterPage mode return the current master page index if the point exists on the current master page,
+	 * In normal mode return the first page index where this point exists.
+	 *
+	 * \param x X coord of the point
+	 * \param y Y coord of the point
+	 * \return page index or -1
+	 */
+	int OnPage(double x, double  y);
+	/*!
+	 * \brief Find page index where the item exists.
+	 *
+	 * In masterPageMode return the current master page index if the item exists on the current master page.
+	 * In mormal mode return the page index where this item exists.
+	 *
+	 * \param item item we looking for
+	 * \return page index or -1
+	 */
+	int OnPage(PageItem *item);
+
+	void GroupOnPage(PageItem *currItem);
+	//void reformPages(double& maxX, double& maxY, bool moveObjects = true);
+	void reformPages(bool moveObjects = true);
 	void setRedrawBounding(PageItem *currItem);
 	void adjustCanvas(FPoint minPos, FPoint maxPos, bool absolute = false);
 	void recalcPicturesRes(bool applyNewRes = false);
 	void connectDocSignals();
-	void removeLayer(int l, bool dl = false); //FIXME: Make protected once scripter function no longer uses this directly
-	/*! \brief We call changed() whenever the document needs to know it has been changed.
-	 *  If the document is the primary document in a main window, it will signal to enable/disable
-	 * certain operations.
+
+// Named Ressources
+
+	void getNamedResources(ResourceCollection& lists) const;
+	void replaceNamedResources(ResourceCollection& newNames);
+
+
+	QMap<QString, double>& constants() { return m_constants; }
+
+// Grid and Guides
+
+	/*!
+	 * \brief Apply grid to a QPoint, from ScribusView.
 	 */
-	void changed();
-	/*! \brief Get pointer to the current page
-	\retval Page* current page object */
-	Page* currentPage();
-	/*! \brief Set new current page
-	\param newPage New current page */
-	void setCurrentPage(Page *newPage);
-	bool hasGUI() const {return m_hasGUI;}
-	/*! \brief Apply grid to a QPoint, from ScribusView */
 	QPoint ApplyGrid(const QPoint& in);
-	/*! \brief Apply grid to an FPoint, from ScribusView */
+	/*!
+	 * \brief Apply grid to an FPoint, from ScribusView.
+	 */
 	FPoint ApplyGridF(const FPoint& in);
-	/*! \brief Does this doc have any TOC setups and potentially a TOC to generate */
-	bool hasTOCSetup() { return !docToCSetups.empty(); }
-	//! \brief Get the closest guide to the given point
+
+	/*!
+	 * \brief Get the closest guide to the given point.
+	 */
 	void getClosestGuides(double xin, double yin, double *xout, double *yout, int *GxM, int *GyM);
-	//! \brief Snap an item to the guides
+	/*!
+	 * \brief Snap an item to the guides.
+	 */
 	void SnapToGuides(PageItem *currItem);
 	bool ApplyGuides(double *x, double *y);
-	bool MoveItem(double newX, double newY, PageItem* ite, bool fromMP = false);
-	void RotateItem(double win, int ite);
-	void RotateItem(double win, PageItem *currItem);
-	void MoveRotated(PageItem *currItem, FPoint npv, bool fromMP = false);
-	bool SizeItem(double newX, double newY, int ite, bool fromMP = false, bool DoUpdateClip = true, bool redraw = true);
-	bool SizeItem(double newX, double newY, PageItem *pi, bool fromMP = false, bool DoUpdateClip = true, bool redraw = true);
-	bool MoveSizeItem(FPoint newX, FPoint newY, int ite, bool fromMP = false, bool constrainRotation=false);
-	void AdjustItemSize(PageItem *currItem);
+
+	/*!
+	 * \brief Does this doc have any TOC setups and potentially a TOC to generate.
+	 */
+	bool hasTOCSetup() { return !docToCSetups.empty(); }
+
+// Group
+
 	void moveGroup(double x, double y, bool fromMP = false, Selection* customSelection = 0);
 	void rotateGroup(double angle, FPoint RCenter);
 	void scaleGroup(double scx, double scy, bool scaleText=true, Selection* customSelection = 0);
-	//! \brief Get a list of frames of certain type
-	QMap<PageItem*, QString> getDocItemNames(PageItem::ItemType itemType);
-	
+
+	/*!
+	 * \brief Return the guarded object associated with the document.
+	 */
+	const ScGuardedPtr<ScribusDoc>& guardedPtr() const;
+
+	UpdateManager* updateManager() { return &m_updateManager; }
+	MassObservable<PageItem*> * itemsChanged() { return &m_itemsChanged; }
+	MassObservable<Page*>     * pagesChanged() { return &m_pagesChanged; }
+	MassObservable<QRectF>    * regionsChanged() { return &m_regionsChanged; }
+	void invalidateRegion(QRectF region);
+public:
+	/*!
+	 * \brief We call changed() whenever the document needs to know it has been changed.
+	 *
+	 * If the document is the primary document in a main window, it will signal to enable/disable
+	 * certain operations.
+	 */
+	void changed();
+public slots:
+	/*!
+	 * \brief Change display quality of all images in document.
+	 * \author  OssiLehtinen
+	 */
+	void allItems_ChangePreviewResolution(int id);
 protected:
 	void addSymbols();
-	bool m_hasGUI;
+//@} // End of various group
+
+signals:
+	//Lets make our doc talk to our GUI rather than confusing all our normal stuff
+	/*!
+	 * \brief Let the document tell whatever is listening that it has changed.
+	 */
+	void docChanged();
+	void updateContents();
+	void updateContents(const QRect &r);
+	void refreshItem(PageItem *);
+	void canvasAdjusted(double width, double height, double dX, double dY);
+	void firstSelectedItemType(int);
+	void setApplicationMode(int);
+	/*!
+	 * \brief A signal for when the outline palette needs to rebuild itself.
+	 *
+	 * Emit when:
+	 * - An item is created or deleted
+	 * - An item changes page
+	 * - An page is created or deleted
+	 * - Some items are grouped or a group is ungrouped
+	 * This also applies to Master Pages
+	 */
+	void signalRebuildOutLinePalette();
+	/*!
+	 * \brief Temporary signal for SizeItem.
+	 */
+	void widthAndHeight(double, double);
+
+protected:
 	ApplicationPrefs& prefsData;
 	UndoManager * const undoManager;
-	bool loading;
-	bool modified;
 	int ActiveLayer;
-	int docUnitIndex;
-	double docUnitRatio;
-	bool automaticTextFrames; // Flag for automatic Textframes
-	bool m_masterPageMode;
 	QMap<QString, double> m_constants;
-	ScribusMainWindow* m_ScMW;
-	ScribusView* m_View;
 	ScGuardedObject<ScribusDoc> m_guardedObject;
 	
 public: // Public attributes
@@ -915,71 +1597,60 @@ public: // Public attributes
 	int viewCount;
 	int viewID;
 	bool SnapGuides;
-	bool GuideLock;
-	/** \brief Scratch space around Pages */
+	/*! \brief Scratch space around Pages */
 	MarginStruct scratch;
-	double GapHorizontal;
-	double GapVertical;
+	double GapHorizontal;			/*!< \brief Horizontal gap between page on canvas. */
+	double GapVertical;			/*!< \brief Vertical gap betwwen page on canvas. */
 // 	double ScratchLeft;
 // 	double ScratchRight;
 // 	double ScratchTop;
 // 	double ScratchBottom;
-	/** \brief Minimum and Maximum Points of Document */
-	FPoint minCanvasCoordinate;
-	FPoint maxCanvasCoordinate;
+	FPoint minCanvasCoordinate;		/*!< \brief Minimum point of document. */
+	FPoint maxCanvasCoordinate;		/*!< \brief Maximum point of document. */
 	double rulerXoffset;
 	double rulerYoffset;
-	/** \brief List of Pages */
-	QList<Page*>* Pages;
-	/** \brief List of Master Pages */
-	QList<Page*> MasterPages;
-	/** \brief List of Document Pages */
-	QList<Page*> DocPages;
-	/** \brief Mapping Master Page Name to Master Page numbers */
-	QMap<QString,int> MasterNames;
-	/** \brief List of Objects */
-	QList<PageItem*>* Items;
-	QList<PageItem*> MasterItems;
-	QList<PageItem*> DocItems;
 	QList<PageItem*> FrameItems;
 	Selection* const m_Selection;
-	/** \brief Pagewidth  */
-	double pageWidth;
-	/** \brief Pageheight */
-	double pageHeight;
+	double pageWidth;			/*!< \brief Default page's width. */
+	double pageHeight;			/*!< \brief Default page's height. */
 	/* Number of Pages */
 	// int pageCount; Disabled CR no longer required
-	/** \brief Margins */
-	MarginStruct pageMargins;
+	MarginStruct pageMargins;		/*!< \brief Default page's margins. */
 	int marginPreset;
-	QList<PageSet> pageSets;
-	MarginStruct bleeds;
+//ivro: is this cannot be moved elsewhere
+//	Save only the current pageSets and when we change it, copy the new here.
+	QList<PageSet> pageSets;		/*!< \brief List of page layout supported by Scribus. */
+	int currentPageLayout;			/*!< \brief Index of the currently used page layout. \details See ScribusDoc::pageSets. */
+	MarginStruct bleeds;			/*!< Default page's bleeds. */
 // 	double BleedTop;
 // 	double BleedLeft;
 // 	double BleedRight;
 // 	double BleedBottom;
-	/** \brief Number of Columns */
-	double PageSp;
-	/** \brief Distance of Columns */
-	double PageSpa;
-	/** \brief current Pagelayout */
-	int currentPageLayout;
-	/** \brief Flag fuer Hoch- oder Querformat 0 = Hochformat */
-	int PageOri;
-	QString m_pageSize;
-	/** \brief Erste Seitennummer im Dokument */
+	double PageSp;				/*!< \brief Number of Columns for AutomaticTextFrame. */
+	double PageSpa;				/*!< \brief Distance between columns for AutomaticTextFrame. */
+//ivro: use the scribusstruct PageOrientation enum ?
+	int PageOri;				/*!< \brief Default page's orientation. \details O => Portrait, 1 = Landscape. */
+	QString m_pageSize;			/*!< \brief Default page's format. */
+	/*!
+	 * \brief Erste Seitennummer im Dokument.
+	 */
 	int FirstPnum;
-	/** \brief Flag fuer Rasterbenutzung */
+	/*!
+	 * \brief Flag fuer Rasterbenutzung.
+	 */
 	bool useRaster;
-	/** \brief Im Dokument benutzte Farben */
+	/*!
+	 * \brief Im Dokument benutzte Farben.
+	 */
 	ColorList PageColors;
-	/** \brief InfoStrings fuer das aktuelle Dokument */
+	/*!
+	 * \brief InfoStrings fuer das aktuelle Dokument.
+	 */
 	DocumentInformation documentInfo;
 	int appMode;
 	int SubMode;
 	double *ShapeValues;
 	int ValCount;
-	QString DocName;
 	QMap<QString,int> UsedFonts;
 	SCFonts * const AllFonts;
 	QList<AlignObjs> AObjects;
@@ -994,10 +1665,8 @@ public: // Public attributes
 	toolPrefs toolSettings;
 	QMap<QString, checkerPrefs> checkerProfiles;
 	QString curCheckProfile;
-	/** \brief Letztes Element fuer AutoTextrahmen */
-	PageItem *LastAuto;
-	/** \brief Erstes Element fuer AutoTextrahmen */
-	PageItem *FirstAuto;
+	PageItem *LastAuto;			/*!< \brief The last AutomaticTextFrame element. */
+	PageItem *FirstAuto;			/*!< \brief The first AutomaticTextFrame element. */
 	bool DragP;
 	bool leaveDrag;
 	PageItem *DraggedElem;
@@ -1045,23 +1714,23 @@ public:
 	PrintOptions Print_Options;
 	bool RePos;
 	struct BookMa {
-					QString Title;
-					QString Text;
-					QString Aktion;
-					PageItem *PageObject;
-					int Parent;
-					int ItemNr;
-					int First;
-					int Last;
-					int Prev;
-					int Next;
-					};
+		QString Title;
+		QString Text;
+		QString Aktion;
+		PageItem *PageObject;
+		int Parent;
+		int ItemNr;
+		int First;
+		int Last;
+		int Prev;
+		int Next;
+	};
 	QList<BookMa> BookMarks;
 	bool OldBM;
 	bool hasName;
 	int RotMode;
-	bool AutoSave;
-	int AutoSaveTime;
+	bool AutoSave;				/*!< \brief Is autosaved ? */
+	int AutoSaveTime;			/*!< \brief Time in milliseconds between autosave. */
 	QTimer * const autoSaveTimer;
 	QMap<QString,multiLine> MLineStyles;
 	QList<ArrowDesc> arrowStyles;
@@ -1082,7 +1751,7 @@ public:
 	//Attributes to be applied to frames
 	ObjAttrVector docItemAttributes;
 	ToCSetupVector docToCSetups;
-	DocumentSectionMap sections;
+	DocumentSectionMap sections;		/*!< \brief Map of document's sections */
 	FPointArray symReturn;
 	FPointArray symNewLine;
 	FPointArray symTab;
@@ -1095,50 +1764,14 @@ private:
 	UndoTransaction* m_itemCreationTransaction;
 	UndoTransaction* m_alignTransaction;
 
-	Page* m_currentPage;
 	UpdateManager m_updateManager;
 	MassObservable<PageItem*> m_itemsChanged;
 	MassObservable<Page*> m_pagesChanged;
 	MassObservable<QRectF> m_regionsChanged;
 	DocUpdater* m_docUpdater;
-	
-signals:
-	//Lets make our doc talk to our GUI rather than confusing all our normal stuff
-	/**
-	 * @brief Let the document tell whatever is listening that it has changed
-	 */
-	void docChanged();
-	void updateContents();
-	void updateContents(const QRect &r);
-	void refreshItem(PageItem *);
-	void canvasAdjusted(double width, double height, double dX, double dY);
-	void firstSelectedItemType(int);
-	void setApplicationMode(int);
-	/**
-	 * @brief A signal for when the outline palette needs to rebuild itself
-	 * Emit when:
-	 * - An item is created or deleted
-	 * - An item changes page
-	 * - An page is created or deleted
-	 * - Some items are grouped or a group is ungrouped
-	 * This also applies to Master Pages
-	 */
-	void signalRebuildOutLinePalette();
-	//! Temporary signal for SizeItem
-	void widthAndHeight(double, double);
-	
-public slots:
-	void itemSelection_ToggleLock();
-	void itemSelection_ToggleSizeLock();
-	void itemSelection_ToggleImageShown();
-	void itemSelection_TogglePrintEnabled();
-	void itemSelection_ChangePreviewResolution(int id);
-
-	/*! \brief Change display quality of all images in document.
-	\author  OssiLehtinen
-	*/
-	void allItems_ChangePreviewResolution(int id);
 
+<<<<<<< HEAD:Scribus/scribus/scribusdoc.h
+<<<<<<< HEAD:Scribus/scribus/scribusdoc.h
 	void itemSelection_ClearItem(Selection* customSelection=0);
 	//! Delete the items in the current selection. When force is true, we do not warn the user and make SE happy too. Force is used from @sa Page::restorePageItemCreation
 	void itemSelection_DeleteItem(Selection* customSelection=0, bool forceDeletion=false);
@@ -1203,10 +1836,44 @@ public slots:
 	void undoRedoBegin();
 	void undoRedoDone();
 
+=======
+>>>>>>> Documents ScribusDoc itemSelection related:Scribus/scribus/scribusdoc.h
 	void updatePic();
 	void updatePict(QString name);
 	void updatePictDir(QString name);
 	void removePict(QString name);
+
+=======
+>>>>>>> Groups and documents ScribusDoc various related:Scribus/scribus/scribusdoc.h
+public:
+	QList<Page*>* Pages;			/*!< \brief Pointer on a list of pages. \details See masterPageMode() */
+	QList<Page*> MasterPages;	 	/*!< \brief List of Master Pages. */
+	QList<Page*> DocPages;			/*!< \brief List of Document Pages. */
+
+	QList<PageItem*>* Items;		/*!< \brief Pointer on a list of items. \details See masterPageMode() */
+	QList<PageItem*> MasterItems;		/*!< \brief List of items that belongs to Master Pages. */
+	QList<PageItem*> DocItems;		/*!< \brief List of items that belongs to Document Pages. */
+
+	QMap<QString,int> MasterNames;		/*!< \brief Mapping Master Page Name to Master Page numbers. \details See rebuildMasterNames() */
+	bool GuideLock;				/*!< \brief Is the guides must be locked ? See LockGuides() */
+
+	QString DocName;			/*!< \brief Document's name. */
+protected:
+	bool loading;				/*!< \brief Is the document loading ? \details See isLoading() and setLoading(). */
+	bool modified;				/*!< \brief Is the document modified ? \details See isModified() and setModified(). */
+
+	bool m_hasGUI;		 		/*!< \brief Is document associated with a GUI ? \details See hasGUI() and setGUI(). */
+	ScribusMainWindow* m_ScMW;		/*!< \brief Main window associated with the document. \details See scMW() and setGUI(). */
+	ScribusView* m_View;			/*!< \brief View associated with the document. \details See view() and setGUI(). */
+
+	bool automaticTextFrames;		/*!< \brief Is the document using automaticTextFrames ? \details See usesAutomaticTextFrames() and setUsesAutomagicTextFrames(). */
+
+	int docUnitIndex;			/*!< \brief Document's unit index. \details See setUnitIndex() and unitIndex(). */
+	double docUnitRatio;			/*!< \brief Document's unit ratio. \details See unitRatio(). */
+
+	bool m_masterPageMode;			/*!< \brief Is the document in master page mode ? \details See masterPageMode() and setMasterPageMode(). */
+private:
+	Page* m_currentPage;			/*!< \brief Current page. \details See setCurrentPage() and currentPage(). */
 };
 
 Q_DECLARE_METATYPE(ScribusDoc*);

ivro

2009-03-27 15:53

reporter   ~0021420

Last edited: 2009-03-27 16:16

Add diff between r13356 and docs branch

I haven't find a way to create collection of diff in git,
so I sent a full diff on my works.

If you know a way to create diff for each commit in git, you're welcome !

2009-03-27 20:06

 

2009-03-27 20:16

 

ivro

2009-03-27 20:21

reporter   ~0021424

I find it!


The file docs-patches-based-on-r13356.tar.gz contains documentations patches based on top of revision 13356.

The file remove-git-patch-header-and-footer.sed-script is a sed script to use git format-patch to generate patch series.

cbradney

2009-03-27 20:53

administrator   ~0021425

something is wrong with the scribusdoc.h files.. I now have duplicated selection based functions.. any chance u can just make one big patch file?

ivro

2009-03-27 23:23

reporter   ~0021427

This file patches-docs-from-ivro-based-on-r13556.diff is one

cbradney

2009-03-27 23:47

administrator   ~0021428

Last edited: 2009-03-27 23:47

Something isnt quite right in the file:

- */
- void allItems_ChangePreviewResolution(int id);
 
+<<<<<<< HEAD:Scribus/scribus/scribusdoc.h
+<<<<<<< HEAD:Scribus/scribus/scribusdoc.h
     void itemSelection_ClearItem(Selection* customSelection=0);
     //! Delete the items in the current selection. When force is true, we do not warn the user and make SE happy too. Force is used from @sa Page::restorePageItemCreation
     void itemSelection_DeleteItem(Selection* customSelection=0, bool forceDeletion=false);
@@ -1203,10 +1836,44 @@ public slots:
     void undoRedoBegin();
     void undoRedoDone();
 
+=======
+>>>>>>> Documents ScribusDoc itemSelection related:Scribus/scribus/scribusdoc.h
     void updatePic();
     void updatePict(QString name);
     void updatePictDir(QString name);
     void removePict(QString name);
+
+=======
+>>>>>>> Groups and documents ScribusDoc various related:Scribus/scribus/scribusdoc.h

2009-03-28 01:16

 

docs-patches-part1.patch (57,761 bytes)   
diff --git a/Scribus/devel-doc/Doxyfile b/Scribus/devel-doc/Doxyfile
index e238da4..474e952 100644
--- a/Scribus/devel-doc/Doxyfile
+++ b/Scribus/devel-doc/Doxyfile
@@ -144,7 +144,7 @@ JAVADOC_AUTOBRIEF      = NO
 # will behave just like regular Qt-style comments (thus requiring 
 # an explicit \brief command for a brief description.)
 
-QT_AUTOBRIEF           = NO
+QT_AUTOBRIEF           = YES
 
 # The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen 
 # treat a multi-line C++ special comment block (i.e. a block of //! or /// 
diff --git a/Scribus/scribus/scribusdoc.h b/Scribus/scribus/scribusdoc.h
index 7336ceb..12ffa5f 100644
--- a/Scribus/scribus/scribusdoc.h
+++ b/Scribus/scribus/scribusdoc.h
@@ -119,340 +119,898 @@ public:
 	~ScribusDoc();
 	void init();
 	void setup(const int, const int, const int, const int, const int, const QString&, const QString&);
+
+// States
+	/*!
+	 * Set the loading state of the document
+	 * See ScribusDoc.isLoading()
+	 */
 	void setLoading(const bool);
+	/*!
+	 * Is the document loading ?
+	 * See ScribusDoc.setLoading()
+	 */
 	bool isLoading() const;
+	/*!
+	 * Set modified state of the document
+	 * If state changed, update the document
+	 * See ScribusDoc.isModified()
+	 */
 	void setModified(const bool);
+	/*!
+	 * Is the document modified ?
+	 * See ScribusDoc.setModified()
+	 */
 	bool isModified() const;
-/** Setzt die Seitenattribute */
-	void setPage(double b, double h, double t, double l, double r, double bo, double sp, double ab, bool atf, int fp);
-	void resetPage(MarginStruct& newMargins, int fp);
 
-	/**
-	 * @brief Return the view associated with the document
+// GUI
+	/*!
+	 * Associate document and GUI.
+	 * See ScribusDoc.hasGUI(), ScribusDoc.scMW() and ScribusDoc.view()
+	 * @param hasgui Is document associated with gui ?
+	 * @param mainWindow scribus main window
+	 * @param view scribus view
 	 */
-	ScribusView* view() const;
+	void setGUI(bool hasgui, ScribusMainWindow* mainWindow, ScribusView* view);
+	/*!
+	 * Is the document associated with GUI ?
+	 * See Scribus.setGUI()
+	 */
+	bool hasGUI() const {return m_hasGUI;}
+	/*!
+	  * Get the scribus main window associated with the document.
+	  * See Scribus.setGUI()
+	  * @return the scribus man window
+	  */
+//ivro: rename this function (mainWindow or scribusMainWindow) ?
 	ScribusMainWindow* scMW() const {return m_ScMW;}
-	void setGUI(bool hasgui, ScribusMainWindow* mw, ScribusView* view);
+	/*!
+	 * Get the view associated with the document.
+	 * See Scribus.setGUI()
+	 * @return the scribus view
+	 */
+	ScribusView* view() const;
 
-	/**
-	 * @brief Return the guarded object associated with the document
+// Automatic Text Frames
+	/*!
+	 * Set if doc uses automatic text frames.
+	 * See ScribusDoc.usesAutomaticTextFrames(), ScribusDoc.PageSp and ScribusDoc.PageSpa
+	 */
+	void setUsesAutomaticTextFrames(const bool);
+	/*!
+	 * Is document using automatic text frames ?
+	 * See ScribusDoc.setUsesAutomaticTextFrames
+	 */
+	bool usesAutomaticTextFrames() const;
+
+// Grid and Guides
+	/*!
+	 * Should guides be locked or not ?
+	 * @param isLocked If true guides on pages cannot be moved if false they
+	 * can be dragged to new positions.
+	 * @author Riku Leino
+	 */
+	void lockGuides(bool isLocked);
+
+// Current Page
+	/*!
+	 * Set new current page.
+	 */
+	void setCurrentPage(Page*);
+	/*!
+	 * Get the current page.
+	 */
+	Page* currentPage();
+	/*!
+	 * Get the current page number.
+	 */
+	int currentPageNumber();
+
+// Unit index and unit ratio
+	/*!
+	 * Set the document's unit index and update the document's unit ratio.
+	 * See ScribusDoc.unitIndex() and ScribusDoc.unitRatio()
+	 */
+	void setUnitIndex(const int);
+	/*!
+	 * Get the document's unit index.
+	 * See ScribusDoc.setUnitIndex()
+	 */
+	int unitIndex() const;
+	/*!
+	 * Get the document's unit ratio.
+	 * See ScribusDoc.setUnitIndex()
+	 */
+	double unitRatio() const;
+
+// Document's properties
+	/*!
+	 * Sets the name of the document.
+	 * @param name Name for the document
+	 * @author Riku Leino
+	 */
+	void setName(const QString& name);
+
+/*! @name Master Page
+ * Master page related functions.
+ *
+ * A master page is a model for page. Items on master pages will be repeated on each page with the master page.
+ * Use applyMasterPage() to associate a master page to a page and copyPageToMasterPage() to make a master page from a page.
+ *
+ * The master page mode allow to work with master pages and items with the same functions you use for pages and items.
+ * See masterPageMode() and setMasterPageMode().
+ */ //@{
+	/*!
+	 * Is the document in master page mode ?
+	 * In master page mode
+	 *      ScribusDoc.Pages = &ScribusDoc.MasterPages
+	 *      ScribusDoc.Items = &ScribusDoc.MasterItems
+	 * In normal mode (ie not in master mode)
+	 *      ScribusDoc.Pages = &ScribusDoc.DocPages
+	 *      ScribusDoc.Items = &ScribusDoc.DocItems
+	 */
+	bool masterPageMode() const { return m_masterPageMode; }
+	/*!
+	 * Set the doc into Master page mode.
+	 */
+// Do we need to return if the move to master page mode was successful?
+	void setMasterPageMode(bool);
+
+	/*!
+	 * Add a master page.
+	 * Use this function to add a master page, do not use addPage
+	 * @param pageNumber index for the master page
+	 * @param pageName name of the master page
+	 * @return added page
+	 */
+	Page* addMasterPage(const int pageNumber, const QString& pageName);
+	/*!
+	 * Delete a master page.
+	 * @param pageNumber index of the master page
+	 */
+	void deleteMasterPage(const int pageNumber);
+	/*!
+	 * Replace a master page by default one.
+	 * @param oldMasterPage name of the master page to remplace
 	 */
-	const ScGuardedPtr<ScribusDoc>& guardedPtr() const;
-	
-	UpdateManager* updateManager() { return &m_updateManager; }
-	MassObservable<PageItem*> * itemsChanged() { return &m_itemsChanged; }
-	MassObservable<Page*>     * pagesChanged() { return &m_pagesChanged; }
-	MassObservable<QRectF>    * regionsChanged() { return &m_regionsChanged; }
-	void invalidateRegion(QRectF region);
-	
-	// Add, delete and move pages
-	
-	Page* addPage(const int pageNumber, const QString& masterPageName=QString::null, const bool addAutoFrame=false);
-	void deletePage(const int);
-	//! @brief Add a master page with this function, do not use addPage
-	Page* addMasterPage(const int, const QString&);
-	void deleteMasterPage(const int);
-	//! @brief Rebuild master name list
-	void rebuildMasterNames(void);
-	//! @brief Replace a master page by default one
 	void replaceMasterPage(const QString& oldMasterPage);
-	//! @brief Rename a master page
+	/*!
+	 * Rename a master page.
+	 * @param oldPageName old name of the master page
+	 * @param newPageName new name for the master page
+	 */
 	bool renameMasterPage(const QString& oldPageName, const QString& newPageName);
-	//! @brief Create the default master pages based on the layout selected by the user, ie, Normal, Normal Left, etc.
-	void createDefaultMasterPages();
-	//! @brief Create the requested pages in a new document, run after createDefaultMasterPages()
-	void createNewDocPages(int pageCount);
-	/**
-	 * @brief Add the automatic text frame to the page
-	 * @param pageNumber page number
-	 * @return number of frame
+	/*!
+	 * Rebuild master name list.
+	 * Rebuild ScribusDoc.MasterName list from the master page name
 	 */
-	int addAutomaticTextFrame(const int pageNumber);
-	/**
-	 * Set the left and right margins based on the location of the page
-	 * @param pageIndex 
+	void rebuildMasterNames(void);
+//@} // End of master page group
+
+/*! @name Page
+ * Page related functions.
+ *
+ * A page represents a paper page. See Page::Page
+ */ //@{
+	// Add, delete and move page
+
+	/*!
+	 * Add a page.
+	 * Do not use this to add a master page, use addMasterPage instead
+	 * @param pageNumber index for the page
+	 * @param masterPageName master page to use
+	 * @param addAutoFrame add automatic text frame
+	 * @return addedpage
 	 */
-	void setLocationBasedPageLRMargins(uint pageIndex);
-	/**
-	 * @brief Move page(s) within the document
+	Page* addPage(const int pageNumber, const QString& masterPageName=QString::null, const bool addAutoFrame=false);
+	/*!
+	 * Delete a page.
+	 * @param pageNumber index of the page
+	 */
+	void deletePage(const int pageNumber);
+	/*!
+	 * Move page(s) within the document.
 	 * @param from page index
 	 * @param to page index
-	 * @param ziel target to move to (page index)
-	 * @param art Before, After or at the end
+	 * @param ziel page index of the target to move to
+	 * @param art Before (0), After (1) or At the end (2)
 	 */
+//ivro: create typedef for param art (like whereToMove) ?
 	void movePage(const int from, const int to, const int ziel, const int art);
-	
-	/**
-	 * @brief Copy a page (pageNumberToCopy) copyCount times, whereToInsert(before or after) the existingPage or at the end.
-	 * @param pageNumberToCopy 
-	 * @param existingPage 
-	 * @param whereToInsert 
-	 * @param copyCount 
-	 */
+	/*!
+	 * Copy a page.
+	 * Copy a page (pageNumberToCopy) copyCount times, whereToInsert(before or after) the existingPage or at the end.
+	 * @param pageNumberToCopy index of the page
+	 * @param existingPage where to copy (page index)
+	 * @param whereToInsert Before (0), After (1) or At the end (2)
+	 * @param copyCount number of copy
+	 */
+//ivro: use typedef whereToMove for param whereToInsert ?
 	void copyPage(int pageNumberToCopy, int existingPage, int whereToInsert, int copyCount);
-	
+
+	// Properties of page
+
+	/*!
+	 * Set page properties.
+	 * @param width page width
+	 * @param height page height
+	 * @param marginsTop page margins top
+	 * @param marginsLeft page margins left
+	 * @param marginsRight page margins right
+	 * @param marginsBottom page margins bottom
+	 * @param numberOfColumns number of automaticTextFrames columns
+	 * @param distanceOfColumns distance between automaticTextFrams columns
+	 * @param automaticTextFrames is automaticTextFrames enabled ?
+	 * @param pageLayout index of the page layout in ScribusDoc.pageSets
+	 */
+	void setPage(double width, double height, double marginsTop, double marginsLeft, double marginsRight, double marginsBottom, double numberOfColums, double distanceOfColumns, bool automatictTextFrames, int pageLayout);
+	/*!
+	 * Reset the page properties.
+	 * @param newMargins margins to apply
+	 * @param pageLayout index of the page layout in Scribus.pageSets
+	 */
+	void resetPage(MarginStruct& newMargins, int pageLayout);
+	/*!
+	 * Apply a master page.
+	 * @param masterPageName name of the master page
+	 * @param pageNumber index of the page
+	 */
+	bool applyMasterPage(const QString& masterPageName, const int pageNumber);
+	/*!
+	 * Copies a normal page to be a master pages.
+	 * @param pageNumber index of the page to copy
+	 * @param leftPage
+         * @param maxLeftPage
+	 * @param masterPageName name for the master page
+	 * @param copyFromAppliedMaster
+	 */
+	bool copyPageToMasterPage(const int pageNumber, const int leftPage, const int maxLeftPage, const QString& masterPageName, bool copyFromAppliedMaster);
+
+	/*!
+	 * Add the automatic text frame to the page.
+	 * @param pageNumber index of page
+	 * @return number of text frame created, -1 on error
+	 */
+	int addAutomaticTextFrame(const int pageNumber);
+
+	/*!
+	 * Set the page margins. Current code uses current page only, also provide a (currently, TODO) option for this.
+	 * @param initialTop
+	 * @param initialBottom
+	 * @param initialLeft
+	 * @param initialRight
+	 * @param initialHeight
+	 * @param initialWight
+	 * @param height
+	 * @param width
+	 * @param orientation
+	 * @param pageSize
+	 * @param pageNumber if equal to -1, do nothing and return false. Caution default is -1.
+	 * @param pageType see Page.LeftPg, default to 0 (Right page)
+	 */
+//ivro: is this fuction name goods as it does things that not only about margins ?
+	bool changePageMargins(const double initialTop, const double initialBottom, const double initialLeft, const double initialRight, const double initialHeight, const double initialWidth, const double height, const double width, const int orientation, const QString& pageSize, const int pageNumber=-1, const int pageType = 0);
+
+	/*!
+	 * Get page's bleeds.
+	 * @param pageNumber index of the page
+	 * @param bleedData struct to get the bleed
+	 */
+//ivro: is this not better in Page ?
+	void getBleeds(int pageNumber, MarginStruct& bleedData);
+	/*!
+	 * Get page's bleeds.
+	 * @param page page to look at
+	 * @param bleedData struct to get the bleed
+	 */
+	void getBleeds(Page* page, MarginStruct& bleedData);
+
+
+	// Canvas
+
+	/*!
+	 * Get the location of the page on the canvas, ie, left, middle, or right.
+	 * Does not give information about middle left, etc.
+	 * @param pageIndex Index of page to find location for
+	 * @return LeftPage, MiddlePage, RightPage, enum from pagestructs.h
+	 */
+	PageLocation locationOfPage(int pageIndex) const;
+	/*!
+	 * Get the column of the page on the canvas, ie, left, middle, or right.
+	 * @param pageIndex Index of page to find location for
+	 * @return int of 0,1,2,3
+	 */
+	int columnOfPage(int pageIndex) const;
+	/*!
+	 * Return the x offset for a page on the canvas.
+	 * @retval double containing the offset. Returns -1.0 if page not in Pages list (as -ve is not possible).
+	 * Mostly saves bringing in extra includes into files that already have scribusdoc.h
+	 */
+	double getXOffsetForPage(const int);
+	/*!
+	 * Return the y offset for a page on the canvas.
+	 * @retval double coutaining the offset. Returns -1.0 if page not in pages list (as -ve is not possible).
+	 */
+	double getYOffsetForPage(const int);
+
+	/*!
+	 * Set the left and right margins based on the location of the page.
+	 * @param pageIndex index of the page
+	 */
+	void setLocationBasedPageLRMargins(uint pageIndex);
+//@} // End of Page group
+
+/*! @name Layer
+ * layer related functions.
+ */ //@{
 	// Add, delete and move layers
-	/**
-	 * @brief Add a layer to the current document
+
+	/*!
+	 * Add a layer to the current document.
 	 * @param layerName name of layer
 	 * @param activate the layer active
 	 * @return Number of the layer created
 	 */
 	int addLayer(const QString& layerName=QString::null, const bool activate=false);
-	/**
-	 * @brief Copies a layer from the current document
+	/*!
+	 * Copies a layer from the current document.
 	 * @param layerNumberToCopy source layer
 	 * @param whereToInsert target layer
 	 * @return Success or failure
 	 */
 	void copyLayer(int layerNumberToCopy, int whereToInsert);
-	/**
-	 * @brief Delete a layer from the current document
+	/*!
+	 * Delete a layer from the current document.
 	 * @param layerNumber of layer
 	 * @param deleteItems the items on the layer too?
 	 * @return Success or failure
 	 */
 	bool deleteLayer(const int layerNumber, const bool deleteItems);
-	/**
-	 * @brief Return the number of the current layer
-	 * @return Active layer number
+	/*!
+	 * FIXME: Make protected once scripter function no longer uses this directly
 	 */
-	int activeLayer();
+	void removeLayer(int l, bool dl = false);
 
-	/**
-	 * @brief Return the name of the current layer
-	 * @return Name of the layer
-	 */
-	const QString& activeLayerName();
-	/**
-	 * @brief Set the active layer via the layer number
+	// Active layer
+
+	/*!
+	 * Set the active layer via the layer number.
 	 * @param layerToActivate Number of the layer
 	 * @return Success or failure
 	 */
 	bool setActiveLayer(const int layerToActivate);
-	/**
-	 * @brief Set the active layer via the layer name
+	/*!
+	 * Set the active layer via the layer name.
 	 * @param layerNameToActivate Name of the layer
 	 * @return Success or failure
 	 */
 	bool setActiveLayer(const QString & layerNameToActivate);
-	/**
-	 * @brief Set the layer printable via the layer number
+	/*!
+	 * Return the number of the current layer.
+	 * @return Active layer number
+	 */
+	int activeLayer();
+	/*!
+	 * Return the name of the current layer.
+	 * @return Name of the layer
+	 */
+	const QString& activeLayerName();
+
+	// Layer properties
+
+	/*!
+	 * Return the layer name.
+	 * @param layerNumber Number of the layer
+	 * @return Name of the layer
+	 */
+	QString layerName(const int layerNumber) const;
+	/*!
+	 * Change the name of a layer.
+	 * @param layerNumber number of the layer
+	 * @param newName new name of the layer
+	 * @return Success or failure
+	 */
+	bool changeLayerName(const int layerNumber, const QString& newName);
+	/*!
+	 * Set the layer printable via the layer number.
 	 * @param layerNumber Number of the layer
 	 * @param isPrintable bool true = layer is prantable
 	 * @return Success or failure
 	 */
 	bool setLayerPrintable(const int layerNumber, const bool isPrintable);
-	/**
-	 * @brief Is the layer printable
+	/*!
+	 * Is the layer printable ?
 	 * @param layerNumber Number of the layer
 	 * @return Printable or not
 	 */
 	bool layerPrintable(const int layerNumber);
-	/**
-	 * @brief Set the layer visible via the layer number
+	/*!
+	 * Set the layer visible via the layer number.
 	 * @param layerNumber Number of the layer
 	 * @param isViewable true = layer is visible
 	 * @return Success or failure
 	 */
 	bool setLayerVisible(const int layerNumber, const bool isViewable);
-	/**
-	 * @brief Is the layer visible
+	/*!
+	 * Is the layer visible ?
 	 * @param layerNumber Number of the layer
 	 * @return Visible or not
 	 */
 	bool layerVisible(const int layerNumber);
-	/**
-	 * @brief Set the layer locked via the layer number
+	/*!
+	 * Set the layer locked via the layer number.
 	 * @param layerNumber Number of the layer
 	 * @param isLocked true = layer is locked
 	 * @return Success or failure
 	 */
 	bool setLayerLocked(const int layerNumber, const bool isLocked);
-	/**
-	 * @brief Is the layer locked
+	/*!
+	 * Is the layer locked ?
 	 * @param layerNumber Number of the layer
 	 * @return Locked or not
 	 */
 	bool layerLocked(const int layerNumber);
-	/**
-	 * @brief Set the layer flow via the layer number
+	/*!
+	 * Set the layer flow via the layer number.
 	 * @param layerNumber Number of the layer
 	 * @param flow true = Text flows around objects on this layer
 	 * @return Success or failure
 	 */
 	bool setLayerFlow(const int layerNumber, const bool flow);
-	/**
-	 * @brief does text flow around objects on this layer
+	/*!
+	 * does text flow around objects on this layer ?
 	 * @param layerNumber Number of the layer
 	 * @return flow or not
 	 */
 	bool layerFlow(const int layerNumber);
-	/**
-	 * @brief Set the layer transparency via the layer number
+	/*!
+	 * Set the layer transparency via the layer number.
 	 * @param layerNumber Number of the layer
 	 * @param trans transparency value 0.0 - 1.0
 	 * @return Success or failure
 	 */
 	bool setLayerTransparency(const int layerNumber, double trans);
-	/**
-	 * @brief returns the layer transparency
+	/*!
+	 * returns the layer transparency.
 	 * @param layerNumber Number of the layer
 	 * @return transparency value 0.0 - 1.0
 	 */
 	double layerTransparency(const int layerNumber);
-	/**
-	 * @brief Set the layer layerBlendMode via the layer number
+	/*!
+	 * Set the layer layerBlendMode via the layer number.
 	 * @param layerNumber Number of the layer
 	 * @param blend layerBlendMode
 	 * @return Success or failure
 	 */
 	bool setLayerBlendMode(const int layerNumber, int blend);
-	/**
-	 * @brief returns the layer BlendMode
+	/*!
+	 * Returns the layer BlendMode.
 	 * @param layerNumber Number of the layer
 	 * @return layerBlendMode
 	 */
 	int layerBlendMode(const int layerNumber);
-	/**
-	 * @brief Return the level of the requested layer
+	/*!
+	 * Set the layer outline mode via the layer number.
 	 * @param layerNumber Number of the layer
-	 * @return Level of the layer
+	 * @param outline true = layer is displayed in outlines only
+	 * @return Success or failure
 	 */
-	int layerLevelFromNumber(const int layerNumber);
-	/**
-	 * @brief Set the layer marker color
+	bool setLayerOutline(const int layerNumber, const bool outline);
+	/*!
+	 * Is this layer in outline mode ?
+	 * @param layerNumber Number of the layer
+	 * @return outline or not
+	 */
+	bool layerOutline(const int layerNumber);
+
+	// Layer marker color
+
+	/*!
+	 * Set the layer marker color.
 	 * @param layerNumber Number of the layer
 	 * @param color color of the marker
 	 * @return Success or failure
 	 */
 	bool setLayerMarker(const int layerNumber, QColor color);
-	/**
-	 * @brief returns the layer marker color
+	/*!
+	 * Returns the layer marker color.
 	 * @param layerNumber Number of the layer
 	 * @return marker color
 	 */
 	QColor layerMarker(const int layerNumber);
-	/**
-	 * @brief Set the layer outline mode via the layer number
-	 * @param layerNumber Number of the layer
-	 * @param outline true = layer is displayed in outlines only
-	 * @return Success or failure
-	 */
-	bool setLayerOutline(const int layerNumber, const bool outline);
-	/**
-	 * @brief is this layer in outline mode
+
+	// Layer level
+
+	/*!
+	 * Returns the level of the requested layer.
 	 * @param layerNumber Number of the layer
-	 * @return outline or not
+	 * @return Level of the layer
 	 */
-	bool layerOutline(const int layerNumber);
-	/**
-	 * @brief Return the number of the layer at a certain level
+	int layerLevelFromNumber(const int layerNumber);
+	/*!
+	 * Returns the number of the layer at a certain level.
 	 * @param layerLevel Layer level
 	 * @return Layer number
 	 */
 	int layerNumberFromLevel(const int layerLevel);
-	/**
-	 * @brief Return the layer count
-	 * @return Number of layers in doc
-	 */
-	int layerCount() const;
-	/**
-	 * @brief Lower a layer
+
+	// Lower and Raise Layer
+
+	/*!
+	 * Lowers a layer.
 	 * @param layerNumber Number of the layer
 	 * @return Success or failure
 	 */
 	bool lowerLayer(const int layerNumber);
-	/**
-	 * @brief Lower a layer using the level
+	/*!
+	 * Lowers a layer using the level.
 	 * @param layerLevel Level of the layer
 	 * @return Success or failure
 	 */
 	bool lowerLayerByLevel(const int layerLevel);
-	/**
-	 * @brief Raise a layer
+	/*!
+	 * Raises a layer.
 	 * @param layerNumber Number of the layer
 	 * @return Success or failure
 	 */
 	bool raiseLayer(const int layerNumber);
-	/**
-	 * @brief Raise a layer using the level
+	/*!
+	 * Raises a layer using the level.
 	 * @param layerLevel Level of the layer
 	 * @return Success or failure
 	 */
 	bool raiseLayerByLevel(const int layerLevel);
-	/**
-	 * @brief Return the layer name
-	 * @param layerNumber Number of the layer
-	 * @return Name of the layer
-	 */
-	QString layerName(const int layerNumber) const;
-	/**
-	 * @brief Change the name of a layer
-	 * @param layerNumber number of the layer
-	 * @param newName new name of the layer
-	 * @return Success or failure
+
+	// Various functions on layer
+
+	/*!
+	 * Returns the layer count.
+	 * @return Number of layers in doc
 	 */
-	bool changeLayerName(const int layerNumber, const QString& newName);
-	/**
-	 * @brief Does the layer have items on it?
+	int layerCount() const;
+	/*!
+	 * Does the layer have items on it ?
 	 * @param layerNumber Number of the layer
 	 * @return Layer contains items bool
 	 */
 	bool layerContainsItems(const int layerNumber);
-	/**
-	 * @brief Renumber a layer. Used in particular for reinsertion for undo/redo
+	/*!
+	 * Renumbers a layer. Used in particular for reinsertion for undo/redo.
 	 * @param layerNumber old layer number
 	 * @param newLayerNumber New layer number
 	 * @return Success or failure
 	 */
 	bool renumberLayer(const int layerNumber, const int newLayerNumber);
-	/**
-	 * @brief Return a list of the layers in their order
+	/*!
+	 * Returns a list of the layers in their order.
 	 * @param list QStringList to insert the layer names into
 	 */
 	void orderedLayerList(QStringList* list);
-	//Items
+//@} // End of Layer function
+
+/*! @name Item
+ * Item related functions.
+ */ //@{
+	// Add
+
+	/*!
+	 * Add an Item to the document.
+	 * A simple function to create an item of a defined type and add it to the document
+	 * Will need extensive rewriting once we have various classes of PageItems, at a guess.
+	 *
+	 * @param itemType type
+	 * @param frameType frame type
+	 * @param x X pos
+	 * @param y Y pos
+	 * @param b width
+	 * @param h height
+	 * @param w ?
+	 * @param fill fill color name
+	 * @param outline outline color name
+	 * @param itemFinalised Used to handle item creation for undo while the user is still dragging.
+	 * @return Number of created item, -1 on failure.
+	 */
+	int itemAdd(const PageItem::ItemType itemType, const PageItem::ItemFrameType frameType, const double x, const double y, const double b, const double h, const double w, const QString& fill, const QString& outline, const bool itemFinalised);
+	/*!
+	 * Add an Item to the page.
+	 * Item will be fitted to the closest guides/margins of the x/y position.
+	 *
+	 * @param itemType type
+	 * @param itemFramType frame type
+	 * @param x X pos
+	 * @param y Y pos
+	 * @param w ?
+	 * @param fill fill color name
+	 * @param outline outline color name
+	 * @param itemFinalised Used to handle item creation for undo while the user is still dragging
+	 * @return Number of created item, -1 on failure.
+	 */
+	int itemAddArea(const PageItem::ItemType itemType, const PageItem::ItemFrameType frameType, const double x, const double y, const double w, const QString& fill, const QString& outline, const bool itemFinalised);
+	/*!
+	 * Allow the user to create a frame easily with some simple placement and sizing options.
+	 * @param iafData a InsertAFrameData structure with params
+	 * @return int item id? FIXME
+	 */
+	int itemAddUserFrame(InsertAFrameData &iafData);
+	/*!
+	 * Commit item creation when a user has click-drag created an item.
+	 * Only called from ScribusView. Note the undo target is the page, so the undo code remains their for now.
+	 *
+	 * @return If an item was committed and the view must emit its signal, which needs removing from here, TODO.
+	 */
+	bool itemAddCommit(const int itemNumber);
+	/*!
+	 * Finalise item creation, only to be called from itemAdd().
+	 * Simply split off code from itemAdd.
+	 *
+	 * @param itemType type
+	 * @param frameType frame type
+	 * @param itemNumber item index
+	 */
+	void itemAddDetails(const PageItem::ItemType itemType, const PageItem::ItemFrameType frameType, const int itemNumber);
+	/*!
+	 * Item type conversion functions.
+	 * @param currItem item to convert
+	 * @param newType
+	 * @param secondaryItem ?
+	 */
+	PageItem* convertItemTo(PageItem *currItem, PageItem::ItemType newType, PageItem* secondaryItem=NULL);
+	/*!
+	 * Paste an item to the document.
+	 * The bulk of a paste item process runs here for want of a better place, but its a better place
+	 * than the view where it used to be.
+	 * TODO Once the pageitem restructure is done, this is probably unnecessary but it removes the
+	 * unnecessary part from the view for now which is overloaded with non ScrollView code.
+	 */
+	//TODO: void PasteItem(struct CopyPasteBuffer *Buffer, bool loading, bool drag = false);
+
+	//itemDelete
+	//itemBlah...
+
+	// move, rotate, resize items
+
+	/*!
+	 * Move item.
+	 * @param newX new X coord
+	 * @param newY new Y coord
+	 * @param item page item to move
+	 * @param fromMP ?
+	 */
+//ivro: standardize param order as PageItem changed each function ?
+//	something like item, args, options ?
+	bool MoveItem(double newX, double newY, PageItem* ite, bool fromMP = false);
+	/*!
+	 * Rotate Item.
+	 * @param angle angle to rotate
+	 * @param itemNumber index of the item to rotate
+	 */
+	void RotateItem(double angle, int itemNumber);
+	/*!
+	 * Rotate Item.
+	 * @param angle angle to rotate
+	 * @param currItem page item to rotate
+	 */
+	void RotateItem(double angle, PageItem *currItem);
+	/*!
+	 * Move and Rotate Item.
+	 * @param currItem page item to transform
+	 * @param npv ?
+	 * @param fromMP ?
+	 */
+	void MoveRotated(PageItem *currItem, FPoint npv, bool fromMP = false);
+	/*!
+	 * Resize item.
+	 * @param newX new X coord
+	 * @param newY new Y coord
+	 * @param ite index of page item to resize
+	 * @param fromMp ?
+	 * @param DoUpdateClip ?
+	 * @param redraw ?
+	 */
+	bool SizeItem(double newX, double newY, int ite, bool fromMP = false, bool DoUpdateClip = true, bool redraw = true);
+	/*!
+	 * Resize item.
+	 * @param newX new X coord
+	 * @param newY new Y coord
+	 * @param pi page item to resize
+	 * @param fromMp ?
+	 * @param DoUpdateClip ?
+	 * @param redraw ?
+	 */
+	bool SizeItem(double newX, double newY, PageItem *pi, bool fromMP = false, bool DoUpdateClip = true, bool redraw = true);
+	/*!
+	 * Size and Move item.
+	 * @param newX new X coord
+	 * @param newY new Y coord
+	 * @param ite index of page item to transform
+	 * @param fromMp ?
+	 * @param constrainRotation ?
+	 */
+	bool MoveSizeItem(FPoint newX, FPoint newY, int ite, bool fromMP = false, bool constrainRotation=false);
+//ivro: don't know what it does
+	void AdjustItemSize(PageItem *currItem);
+
+	//void FlipImageH();
+	//void FlipImageV();
+	void MirrorPolyH(PageItem *currItem);
+	void MirrorPolyV(PageItem *currItem);
+
+	// Various
+
+	/*!
+	 * Delete the tagged items.
+	 * Currently does nothing
+	 */
 	bool deleteTaggedItems();
+	/*!
+	 * Get the item index from a unique ID.
+	 * @param unique ID of item
+	 * @return index of the item
+	 */
+	uint getItemNrfromUniqueID(uint unique);
+	/*!
+	 * Run this common frame item update code.
+	 */
+	void updateFrameItems();
+	/*!
+	 * Renumbers the items into the order they are stored in in the lists.
+	 * Utility function used in various places, basically handles keeping items numbered in the way
+	 * they are layered. When layer is a property and not a fuction of storage, this should be removed.
+	 * Depends on the Items pointer pointing to the correct item list (doc, master, etc).
+	 * @sa updateFrameItems();
+	 */
+	void renumberItemsInListOrder();
+	/*!
+	 * Rebuild item lists taking into account layer order.
+	 * Utility function used in various places, basically handles keeping items numbered in the way
+	 * they are layered. When layer is a property and not a fuction of storage, this should be removed.
+	 * @sa updateFrameItems();
+	 */
+	void rebuildItemLists();
+	/*!
+	 * Find if item is not an already used item.
+	 * Return true if the passed name is not used by any existing PageItem
+	 *        in the same document as this PageItem.
+	 * @author Craig Ringer
+	 ** CB Moved from PageItem
+	 */
+//ivro: is returning true if the passed name exists not better ? (or rename to itemNameDontUses ?)
+	bool itemNameExists(const QString itemName);
+	/*!
+	 * Returns a stringlist of the item attributes within the document.
+	 */
+	QStringList getItemAttributeNames();
+
+	/*! Get a list of frames of certain type. */
+	QMap<PageItem*, QString> getDocItemNames(PageItem::ItemType itemType);
+//@} //End Items group
+
+/*! @name Sections
+ * Sections related functions
+ */ //@{
+	// add, delete, use sections
 
 	/*!
-		* @brief Builds a qmap of the icc profiles used within the document
+	 * Add a section to the document sections list.
+	 * Set number to -1 to add in the default section if the map is empty
 	 */
-	void getUsedProfiles(ProfilesL& usedProfiles);
-	bool OpenCMSProfiles(ProfilesL InPo, ProfilesL InPoCMYK, ProfilesL MoPo, ProfilesL PrPo);
-	void CloseCMSProfiles();
-	void SetDefaultCMSParams();
-	/**
-	 * @brief Switch Colormanagement on or of
-	 * @param enable bool, if true Colormanagement is switched on, else off
+	void addSection(const int number=0, const QString& name=QString::null, const uint fromindex=0, const uint toindex=0, const  DocumentSectionType type=Type_1_2_3, const uint sectionstartindex=0, const bool reversed=false, const bool active=true);
+	/*!
+	 * Delete a section from the document sections list.
+	 */
+	bool deleteSection(const uint);
+	/*!
+	 * Gets the page number to be printed based on the section it is in.
+	 * Returns QString::null on failure to find the pageIndex
+	 */
+	const QString getSectionPageNumberForPageIndex(const uint) const;
+	/*!
+	 * Gets the key of the sections map based on the section the page index is in.
+	 * Returns -1 on failure to find the pageIndex
+	 */
+	int getSectionKeyForPageIndex(const uint pageIndex) const;
+	/*!
+	 *
+	 *
+	 */
+	void updateSectionPageNumbersToPages();
+	/*!
+	 *
+	 * @param otherPageIndex
+	 * @param location
+	 * @param count
+	 */
+	void addPageToSection(const uint otherPageIndex, const uint location, const uint count=1);
+	/*!
+	 *
+	 * @param pageIndex
+	 */
+	void removePageFromSection(const uint pageIndex);
+	/*!
+	 *
+	 */
+	void setFirstSectionFromFirstPageNumber();
+//@} // End of Sections group
+
+/*! @name Align
+ * Align related functions
+ */ //@{
+	void buildAlignItemList(Selection* customSelection=0);
+	bool startAlign();
+	void endAlign();
+//@} // End of align functions
+
+/*! @name Styles
+ * Style related functions
+ */ //@{
+	// Paragraphe style
+
+	/*!
+	 * Get a paragraph style by its name.
 	 */
-	void enableCMS(bool enable);
-	
 	const ParagraphStyle& paragraphStyle(QString name) { return docParagraphStyles.get(name); }
+	/*!
+	 * Get all the paragraph style.
+	 */
 	const StyleSet<ParagraphStyle>& paragraphStyles()   { return docParagraphStyles; }
-	bool isDefaultStyle( const ParagraphStyle& p ) const { return docParagraphStyles.isDefault(p); }
-	bool isDefaultStyle( const CharStyle& c ) const { return docCharStyles.isDefault(c); }
-// 	bool isDefaultStyle( LineStyle& l ) const { return MLineStyles......; }
-
-	void getNamedResources(ResourceCollection& lists) const;
-	void replaceNamedResources(ResourceCollection& newNames);	
-	
+	/*!
+	 * Redefine Paragraphes style.
+	 */
+//ivro: rename rededineParaStyles ?
 	void redefineStyles(const StyleSet<ParagraphStyle>& newStyles, bool removeUnused=false);
-	/**
-	 * @brief Remove any reference to old styles and replace with new name. This needs to be
-	 *        called when a style was removed. New name may be "".
+	/*!
+	 * Remove any reference to old styles and replace with new name.
+	 * This needs to be called when a style was removed. New name may be "".
 	 * @param newNameForOld a map which maps the name of any style to remove to a new stylename
 	 */
+//ivro: rename replaceParaStyles ?
 	void replaceStyles(const QMap<QString,QString>& newNameForOld);
-	/**
-	 * @brief Insert styles from another document in this document.
-	 *        
+	/*!
+	 * Is the default paragraph style ?
+	 * @param p paragraph style to test
+	 */
+//ivro: is this must be with the one for char style ?
+	bool isDefaultStyle( const ParagraphStyle& p ) const { return docParagraphStyles.isDefault(p); }
+
+	// Character style
+
+	/*!
+	 * Get a character style by name.
+	 * @param name char style name
+	 */
+	const CharStyle& charStyle(QString name) { return docCharStyles.get(name); }
+	/*!
+	 * Get all the Character styles.
+	 */
+	const StyleSet<CharStyle>& charStyles()  { return docCharStyles; }
+	/*!
+	 * Redefine Character styles.
+	 * @param newStyle character styles
+	 * @param removeUnused
+	 */
+	void redefineCharStyles(const StyleSet<CharStyle>& newStyles, bool removeUnused=false);
+	/*!
+	 * Remove any reference to old styles and replace with new name.
+	 * This needs to be called when a style was removed. New name may be "".
+	 * @param newNameForOld a map which maps the name of any style to remove to a new stylename
+	 */
+	void replaceCharStyles(const QMap<QString,QString>& newNameForOld);
+	/*!
+	 * Is the default character style ?
+	 * @param c character style to test
+	 */
+	bool isDefaultStyle( const CharStyle& c ) const { return docCharStyles.isDefault(c); }
+// 	bool isDefaultStyle( LineStyle& l ) const { return MLineStyles......; }
+
+	// Load Style
+
+	/*!
+	 * Insert styles from another document in this document.
 	 * @param fileName The path of the document we want to extract its styles
 	 */
 	void loadStylesFromFile(QString fileName);
-	/**
-	 * @brief Gather styles from another document.
-	 *        
+	/*!
+	 * Gather styles from another document.
 	 * @param fileName The path of the document we want to extract its styles
 	 * @param tempStyles A pointer to a StyleSet which will be filled by paragraph styles
 	 * @param tempCharStyles A pointer to a StyleSet which will be filled by character styles
@@ -461,87 +1019,116 @@ public:
 	void loadStylesFromFile(QString fileName, StyleSet<ParagraphStyle> *tempStyles,
 	                                          StyleSet<CharStyle> *tempCharStyles,
 	                                          QMap<QString, multiLine> *tempLineStyles);
+//@} // End of style group
 
-	const CharStyle& charStyle(QString name) { return docCharStyles.get(name); }
-	const StyleSet<CharStyle>& charStyles()  { return docCharStyles; }
-	void redefineCharStyles(const StyleSet<CharStyle>& newStyles, bool removeUnused=false);
-	/**
-	 * @brief Remove any reference to old styles and replace with new name. This needs to be
-	 *        called when a style was removed. New name may be "".
-	 * @param newNameForOld a map which maps the name of any style to remove to a new stylename
-	 */
-	void replaceCharStyles(const QMap<QString,QString>& newNameForOld);
-
-	/**
-	 * @brief Should guides be locked or not
-	 * @param isLocked If true guides on pages cannot be moved if false they
-	 * can be dragged to new positions.
-	 * @author Riku Leino
-	 */
-	void lockGuides(bool isLocked);
-	/**
-	 * @brief Method used when an undo/redo is requested.
-	 * @param state State describing the action that is wanted to be undone/redone
-	 * @param isUndo If true undo is wanted else if false redo.
-	 * @author Riku Leino
-	 */
-	void restore(UndoState* state, bool isUndo);
-	/**
-	 * @brief Sets the name of the document
-	 * @param name Name for the document
-	 * @author Riku Leino
-	 */
-	void setName(const QString& name);
+/*! @name Color Management
+ * Color Management related functions.
+ */ //@{
 	/*!
-	 * @brief Returns a stringlist of the item attributes within the document
+	 * Builds a qmap of the icc profiles used within the document.
 	 */
-	QStringList getItemAttributeNames();
-
-	bool AddFont(QString name, int fsize = 10);
+	void getUsedProfiles(ProfilesL& usedProfiles);
+	bool OpenCMSProfiles(ProfilesL InPo, ProfilesL InPoCMYK, ProfilesL MoPo, ProfilesL PrPo);
+	void CloseCMSProfiles();
+	void SetDefaultCMSParams();
 	/*!
-	 * @brief TODO: Reorganise the fonts.. how? Moved from scribus.cpp
-	 * CB: almost the same as getUsedFonts???
+	 * Switch Colormanagement on or of.
+	 * @param enable bool, if true Colormanagement is switched on, else off
 	 */
-	QMap<QString,int> reorganiseFonts();
+	void enableCMS(bool enable);
 	/*!
-	 * @brief Returns a qmap of the fonts and  their glyphs used within the document
+	 * Recalculate the colors after CMS settings change. Update the items in the doc accordingly.
 	 */
-	void getUsedFonts(QMap<QString,QMap<uint, FPointArray> > &Really);
-	void checkItemForFonts(PageItem *it, QMap<QString, QMap<uint, FPointArray> > & Really, uint lc);
+	void recalculateColors();
 
 	/*!
-	 * @brief Replace line style colors
+	 * Insert a color into the documents color list.
+	 * @param colorList Name of the color list
+	 * @param cyan Cyan component
+	 * @param magenta Magenta component
+	 * @param yellow Yellow component
+	 * @param black Black component
+	 */
+	void insertColor(QString colorList, double cryan, double magenta, double yellow, double black);
+	/*!
+	 * Replace line style colors.
 	 */
 	void replaceLineStyleColors(const QMap<QString, QString>& colorMap);
 	/*!
-	* @brief Builds a qmap of the colours used within the document
+	* Builds a qmap of the colours used within the document.
 	*/
 	void getUsedColors(ColorList &colorsToUse, bool spot = false);
 	/*!
-	* @brief Return if a specific color is used by line styles
+	* Is this specific color is used by line styles.
 	*/
 	bool lineStylesUseColor(const QString& colorName);
+//@} // End of color functions
+
+/*! @name Font
+ * font related funtions.
+ */ //@{
 	/*!
-	* @brief Set the patterns for a document
+	 * Add a font
+	 */
+	bool AddFont(QString name, int fsize = 10);
+	/*!
+	 * TODO: Reorganise the fonts.. how? Moved from scribus.cpp
+	 * CB: almost the same as getUsedFonts???
+	 */
+	QMap<QString,int> reorganiseFonts();
+	/*!
+	 * Returns a qmap of the fonts and  their glyphs used within the document.
+	 */
+	void getUsedFonts(QMap<QString,QMap<uint, FPointArray> > &Really);
+	void checkItemForFonts(PageItem *it, QMap<QString, QMap<uint, FPointArray> > & Really, uint lc);
+//@} // End of font functions
+
+/*! @name Patterns
+ * Pattern related functions
+ */ //@{
+	/*!
+	* Set the patterns for a document.
 	*/
 	bool addPattern(QString &name, ScPattern& pattern);
 	void setPatterns(QMap<QString, ScPattern> &patterns);
 	/*!
-	* @brief Builds a QStringList of the patterns used within the document
+	* Builds a QStringList of the patterns used within the document.
 	*/
 	QStringList getUsedPatterns();
 	QStringList getUsedPatternsSelection(Selection* customSelection);
 	QStringList getUsedPatternsHelper(QString pattern, QStringList &results);
+//@} // End of patterns functions
+
 	/**
-	 * @brief Set and get the document's unit index
+	 * @brief Return the guarded object associated with the document
 	 */
-	void setUnitIndex(const int);
-	int unitIndex() const;
-	double unitRatio() const;
+	const ScGuardedPtr<ScribusDoc>& guardedPtr() const;
+
+	UpdateManager* updateManager() { return &m_updateManager; }
+	MassObservable<PageItem*> * itemsChanged() { return &m_itemsChanged; }
+	MassObservable<Page*>     * pagesChanged() { return &m_pagesChanged; }
+	MassObservable<QRectF>    * regionsChanged() { return &m_regionsChanged; }
+	void invalidateRegion(QRectF region);
+
+	// Add, delete and move pages
+
+	//! @brief Create the default master pages based on the layout selected by the user, ie, Normal, Normal Left, etc.
+	void createDefaultMasterPages();
+	//! @brief Create the requested pages in a new document, run after createDefaultMasterPages()
+	void createNewDocPages(int pageCount);
+
+
+	void getNamedResources(ResourceCollection& lists) const;
+	void replaceNamedResources(ResourceCollection& newNames);
+
 	/**
-	 * @brief Apply a master page
+	 * @brief Method used when an undo/redo is requested.
+	 * @param state State describing the action that is wanted to be undone/redone
+	 * @param isUndo If true undo is wanted else if false redo.
+	 * @author Riku Leino
 	 */
-	bool applyMasterPage(const QString& pageName, const int pageNumber);
+	void restore(UndoState* state, bool isUndo);
+
 	/**
 	 * @brief Undo function for applying a master page
 	 */
@@ -557,100 +1144,9 @@ public:
 	 */
 	bool save(const QString& fileName, QString* savedFile = NULL);
 	/**
-	 * @brief Set the page margins. Current code uses current page only, also provide a (currently, TODO) option for this.
-	 */
-	bool changePageMargins(const double initialTop, const double initialBottom, const double initialLeft, const double initialRight, const double initialHeight, const double initialWidth, const double Height, const double width, const int orientation, const QString& pageSize, const int pageNumber=-1, const int pageType = 0);
-	/**
-	 * @brief Recalculate the colors after CMS settings change. Update the items in the doc accordingly.
-	 */
-	 void recalculateColors();
-	/**
 	 * @brief Sets up the ScText defaults from the document
 	 */
 	void setScTextDefaultsFromDoc(ScText *);
-	/**
-	 * @brief Copies a normal page to be a master pages
-	 */
-	bool copyPageToMasterPage(const int, const int, const int, const QString&, bool);
-	/**
-	 * @brief Paste an item to the document.
-	 * The bulk of a paste item process runs here for want of a better place, but its a better place
-	 * than the view where it used to be. 
-	 * TODO Once the pageitem restructure is done, this is probably unnecessary but it removes the 
-	 * unnecessary part from the view for now which is overloaded with non ScrollView code.
-	 */
-	//TODO: void PasteItem(struct CopyPasteBuffer *Buffer, bool loading, bool drag = false);
-	
-	/**
-	 * @brief Add an Item to the document.
-	 * A simple function to create an item of a defined type and add it to the document
-	 * Will need extensive rewriting once we have various classes of PageItems, at a guess.
-	 *
-	 * @param itemFinalised Used to handle item creation for undo while the user is still dragging.
-	 * @return Number of created item, -1 on failure.
-	\param itemType type
-	\param frameType frame type
-	\param x X pos
-	\param y Y pos
-	\param b width
-	\param h height
-	\param w ?
-	\param fill fill color name
-	\param outline outline color name
-	*/
-	int itemAdd(const PageItem::ItemType itemType, const PageItem::ItemFrameType frameType, const double x, const double y, const double b, const double h, const double w, const QString& fill, const QString& outline, const bool itemFinalised);
-
-	/** Add an item to the page based on the x/y position. Item will be fitted to the closest guides/margins */
-	int itemAddArea(const PageItem::ItemType itemType, const PageItem::ItemFrameType frameType, const double x, const double y, const double w, const QString& fill, const QString& outline, const bool itemFinalised);
-	
-	/**
-	 * @brief Allow the user to create a frame easily with some simple placement and sizing options
-	 * @param iafData a InsertAFrameData structure with params
-	 * @return int item id? FIXME
-	 */
-	int itemAddUserFrame(InsertAFrameData &iafData);
-
-	/**
-	 * @brief Commit item creation when a user has click-drag created an item
-	 * Only called from ScribusView. Note the undo target is the page, so the undo code remains their for now.
-	 * @return If an item was committed and the view must emit its signal, which needs removing from here, TODO.
-	 */
-	bool itemAddCommit(const int itemNumber);
-	
-	/**
-	 * @brief Finalise item creation. Simply split off code from itemAdd
-	 * Only to be called from itemAdd()
-	 */
-	void itemAddDetails(const PageItem::ItemType itemType, const PageItem::ItemFrameType frameType, const int itemNumber);
-
-	uint getItemNrfromUniqueID(uint unique);
-	//itemDelete
-	//itemBlah...
-	
-	/**
-	 * @brief Run this common frame item update code
-	 */
-	void updateFrameItems();
-	/**
-	 * @brief Renumbers the items into the order they are stored in in the lists.
-	 * Utility function used in various places, basically handles keeping items numbered in the way
-	 * they are layered. When layer is a property and not a fuction of storage, this should be removed.
-	 * Depends on the Items pointer pointing to the correct item list (doc, master, etc).
-	 * @sa updateFrameItems();
-	 */
-	void renumberItemsInListOrder();
-	/**
-	 * @brief Rebuild item lists taking into account layer order.
-	 * Utility function used in various places, basically handles keeping items numbered in the way
-	 * they are layered. When layer is a property and not a fuction of storage, this should be removed.
-	 * @sa updateFrameItems();
-	 */
-	void rebuildItemLists();
-	/**
-	 * @brief Doc uses automatic text frames?
-	 */
-	bool usesAutomaticTextFrames() const;
-	void setUsesAutomaticTextFrames(const bool);
 	
 	/**
 	 * @brief Load images into an image frame, moved from the view
@@ -684,115 +1180,13 @@ public:
 	void reformPages(bool moveObjects = true);
 	
 	/**
-	 * @brief Return the x or y offset for a page on the canvas
-	 * @retval double containing the offset. Returns -1.0 if page not in Pages list (as -ve is not possible).
-	 * Mostly saves bringing in extra includes into files that already have scribusdoc.h
-	 */
-	double getXOffsetForPage(const int);
-	double getYOffsetForPage(const int);
-	void getBleeds(int pageNumber, MarginStruct& bleedData);
-	void getBleeds(Page* page, MarginStruct& bleedData);
-	
-	/**
-	 * @brief Item type conversion functions
-	 */
-	PageItem* convertItemTo(PageItem *currItem, PageItem::ItemType newType, PageItem* secondaryItem=NULL);
-	
-	/**
-	 * @brief The page number of the current page
-	 */
-	int currentPageNumber();
-	
-	/**
-	 * @brief Return true iff the passed name is not used by any existing PageItem
-	 *        in the same document as this PageItem.
-	 * @author Craig Ringer
-	 ** CB Moved from PageItem
-	 */
-	bool itemNameExists(const QString itemName);
-	
-	/**
-	 * @brief Set the doc into Master page mode
-	 * Do we need to return if the move to master page mode was successful?
-	 */
-	void setMasterPageMode(bool);
-
-	/*** Is the document in master page mode? */
-	bool masterPageMode() const { return m_masterPageMode; }
-	
-	/**
-	 * @brief Add a section to the document sections list
-	 * Set number to -1 to add in the default section if the map is empty
-	 */
-	void addSection(const int number=0, const QString& name=QString::null, const uint fromindex=0, const uint toindex=0, const  DocumentSectionType type=Type_1_2_3, const uint sectionstartindex=0, const bool reversed=false, const bool active=true);
-	/**
-	 * @brief Delete a section from the document sections list
-	 */
-	bool deleteSection(const uint);
-	/**
-	 * @brief Gets the page number to be printed based on the section it is in.
-	 * Returns QString::null on failure to find the pageIndex
-	 */
-	const QString getSectionPageNumberForPageIndex(const uint) const;
-	/**
-	 * @brief Gets the key of the sections map based on the section the page index is in.
-	 * Returns -1 on failure to find the pageIndex
-	 */
-	int getSectionKeyForPageIndex(const uint pageIndex) const;
-	/**
-	 *
-	 *
-	 */
-	void updateSectionPageNumbersToPages();
-	/**
-	 * 
-	 * @param otherPageIndex 
-	 * @param location 
-	 * @param count 
-	 */
-	void addPageToSection(const uint otherPageIndex, const uint location, const uint count=1);
-	/**
-	 * 
-	 * @param pageIndex 
-	 */
-	void removePageFromSection(const uint pageIndex);
-	/**
-	 * 
-	 */
-	void setFirstSectionFromFirstPageNumber();
-	/**
 	 * @brief Update the fill and line QColors for all items in the doc
 	 */
 	void updateAllItemQColors();
 	//! @brief Some internal align tools
 	typedef enum {alignFirst, alignLast, alignPage, alignMargins, alignGuide, alignSelection } AlignTo;
-	void buildAlignItemList(Selection* customSelection=0);
-	bool startAlign();
-	void endAlign();
-	/**
-	 * \brief Insert a color into the documents color list
-	 * @param nam Name of the colour
-	 * @param c Cyan component
-	 * @param m Magenta component
-	 * @param y Yellow component
-	 * @param k Black component
-	 */
-	void insertColor(QString nam, double c, double m, double y, double k);
 	
 	QMap<QString, double>& constants() { return m_constants; }
-	/**
-	 * \brief Get the location of the page on the canvas, ie, left, middle, or right
-	 * Does not give information about middle left, etc.
-	 * @param pageIndex Index of page to find location for
-	 * @return LeftPage, MiddlePage, RightPage, enum from pagestructs.h
-	 */
-	PageLocation locationOfPage(int pageIndex) const;
-	/**
-	 * \brief Get the column of the page on the canvas, ie, left, middle, or right
-	 * @param pageIndex Index of page to find location for
-	 * @return int of 0,1,2,3
-	 */
-	int columnOfPage(int pageIndex) const;
 	
 	bool sendItemSelectionToBack();
 	bool bringItemSelectionToFront();
@@ -843,28 +1237,18 @@ public:
 
 	void itemSelection_SetTracking(int us, Selection* customSelection=0);
 	void itemSelection_SetFontSize(int size, Selection* customSelection=0);
-	//void FlipImageH();
-	//void FlipImageV();
-	void MirrorPolyH(PageItem *currItem);
-	void MirrorPolyV(PageItem *currItem);
+
+
 	
 	void setRedrawBounding(PageItem *currItem);
 	void adjustCanvas(FPoint minPos, FPoint maxPos, bool absolute = false);
 	void recalcPicturesRes(bool applyNewRes = false);
 	void connectDocSignals();
-	void removeLayer(int l, bool dl = false); //FIXME: Make protected once scripter function no longer uses this directly
 	/*! \brief We call changed() whenever the document needs to know it has been changed.
 	 *  If the document is the primary document in a main window, it will signal to enable/disable
 	 * certain operations.
 	 */
 	void changed();
-	/*! \brief Get pointer to the current page
-	\retval Page* current page object */
-	Page* currentPage();
-	/*! \brief Set new current page
-	\param newPage New current page */
-	void setCurrentPage(Page *newPage);
-	bool hasGUI() const {return m_hasGUI;}
 	/*! \brief Apply grid to a QPoint, from ScribusView */
 	QPoint ApplyGrid(const QPoint& in);
 	/*! \brief Apply grid to an FPoint, from ScribusView */
@@ -876,35 +1260,16 @@ public:
 	//! \brief Snap an item to the guides
 	void SnapToGuides(PageItem *currItem);
 	bool ApplyGuides(double *x, double *y);
-	bool MoveItem(double newX, double newY, PageItem* ite, bool fromMP = false);
-	void RotateItem(double win, int ite);
-	void RotateItem(double win, PageItem *currItem);
-	void MoveRotated(PageItem *currItem, FPoint npv, bool fromMP = false);
-	bool SizeItem(double newX, double newY, int ite, bool fromMP = false, bool DoUpdateClip = true, bool redraw = true);
-	bool SizeItem(double newX, double newY, PageItem *pi, bool fromMP = false, bool DoUpdateClip = true, bool redraw = true);
-	bool MoveSizeItem(FPoint newX, FPoint newY, int ite, bool fromMP = false, bool constrainRotation=false);
-	void AdjustItemSize(PageItem *currItem);
 	void moveGroup(double x, double y, bool fromMP = false, Selection* customSelection = 0);
 	void rotateGroup(double angle, FPoint RCenter);
 	void scaleGroup(double scx, double scy, bool scaleText=true, Selection* customSelection = 0);
-	//! \brief Get a list of frames of certain type
-	QMap<PageItem*, QString> getDocItemNames(PageItem::ItemType itemType);
 	
 protected:
 	void addSymbols();
-	bool m_hasGUI;
 	ApplicationPrefs& prefsData;
 	UndoManager * const undoManager;
-	bool loading;
-	bool modified;
 	int ActiveLayer;
-	int docUnitIndex;
-	double docUnitRatio;
-	bool automaticTextFrames; // Flag for automatic Textframes
-	bool m_masterPageMode;
 	QMap<QString, double> m_constants;
-	ScribusMainWindow* m_ScMW;
-	ScribusView* m_View;
 	ScGuardedObject<ScribusDoc> m_guardedObject;
 	
 public: // Public attributes
@@ -915,7 +1280,6 @@ public: // Public attributes
 	int viewCount;
 	int viewID;
 	bool SnapGuides;
-	bool GuideLock;
 	/** \brief Scratch space around Pages */
 	MarginStruct scratch;
 	double GapHorizontal;
@@ -929,18 +1293,7 @@ public: // Public attributes
 	FPoint maxCanvasCoordinate;
 	double rulerXoffset;
 	double rulerYoffset;
-	/** \brief List of Pages */
-	QList<Page*>* Pages;
-	/** \brief List of Master Pages */
-	QList<Page*> MasterPages;
 	/** \brief List of Document Pages */
-	QList<Page*> DocPages;
-	/** \brief Mapping Master Page Name to Master Page numbers */
-	QMap<QString,int> MasterNames;
-	/** \brief List of Objects */
-	QList<PageItem*>* Items;
-	QList<PageItem*> MasterItems;
-	QList<PageItem*> DocItems;
 	QList<PageItem*> FrameItems;
 	Selection* const m_Selection;
 	/** \brief Pagewidth  */
@@ -979,7 +1332,6 @@ public: // Public attributes
 	int SubMode;
 	double *ShapeValues;
 	int ValCount;
-	QString DocName;
 	QMap<QString,int> UsedFonts;
 	SCFonts * const AllFonts;
 	QList<AlignObjs> AObjects;
@@ -1082,7 +1434,7 @@ public:
 	//Attributes to be applied to frames
 	ObjAttrVector docItemAttributes;
 	ToCSetupVector docToCSetups;
-	DocumentSectionMap sections;
+	DocumentSectionMap sections;		/*< Map of document's sections */
 	FPointArray symReturn;
 	FPointArray symNewLine;
 	FPointArray symTab;
@@ -1095,7 +1447,6 @@ private:
 	UndoTransaction* m_itemCreationTransaction;
 	UndoTransaction* m_alignTransaction;
 
-	Page* m_currentPage;
 	UpdateManager m_updateManager;
 	MassObservable<PageItem*> m_itemsChanged;
 	MassObservable<Page*> m_pagesChanged;
@@ -1207,6 +1558,36 @@ public slots:
 	void updatePict(QString name);
 	void updatePictDir(QString name);
 	void removePict(QString name);
+
+public:
+	QList<Page*>* Pages;			/*!< Pointer on a list of pages. See masterPageMode() */
+	QList<Page*> MasterPages;	 	/*!< List of Master Pages. */
+	QList<Page*> DocPages;			/*!< List of Document Pages. */
+
+	QList<PageItem*>* Items;		/*!< Pointer on a list of items. See masterPageMode() */
+	QList<PageItem*> MasterItems;		/*!< List of items that belongs to Master Pages. */
+	QList<PageItem*> DocItems;		/*!< List of items that belongs to Document Pages. */
+
+	QMap<QString,int> MasterNames;		/*!< Mapping Master Page Name to Master Page numbers. See rebuildMasterNames() */
+	bool GuideLock;				/*!< Is the guides must be locked ? See LockGuides() */
+
+	QString DocName;			/*!< Document's name. */
+protected:
+	bool loading;				/*!< Is the document loading ? See isLoading() and setLoading(). */
+	bool modified;				/*!< Is the document modified ? See isModified() and setModified(). */
+
+	bool m_hasGUI;		 		/*!< Is document associated with a GUI ? See hasGUI() and setGUI(). */
+	ScribusMainWindow* m_ScMW;		/*!< Main window associated with the document. See scMW() and setGUI(). */
+	ScribusView* m_View;			/*!< View associated with the document. See view() and setGUI(). */
+
+	bool automaticTextFrames;		/*!< Is the document using automaticTextFrames ? See usesAutomaticTextFrames() and setUsesAutomagicTextFrames(). */
+
+	int docUnitIndex;			/*!< Document's unit index. See setUnitIndex() and unitIndex(). */
+	double docUnitRatio;			/*!< Document's unit ratio. See unitRatio(). */
+
+	bool m_masterPageMode;			/*!< Is the document in master page mode ? See masterPageMode() and setMasterPageMode(). */
+private:
+	Page* m_currentPage;			/*!< Current page. See setCurrentPage() and currentPage(). */
 };
 
 Q_DECLARE_METATYPE(ScribusDoc*);
docs-patches-part1.patch (57,761 bytes)   

ivro

2009-03-28 01:17

reporter   ~0021429

docs-patches-part1.patch -> the valid part of patches

2009-03-28 07:56

 

docs-patches-based-on-r13358.patch (87,912 bytes)   
diff --git a/Scribus/scribus/page.h b/Scribus/scribus/page.h
index 743cbc7..f62886b 100644
--- a/Scribus/scribus/page.h
+++ b/Scribus/scribus/page.h
@@ -40,55 +40,137 @@ class UndoState;
 class ScribusDoc;
 
 
-/**
-  *@author Franz Schmid
-  */
+/*!
+ * \author Franz Schmid
+ */
 class SCRIBUS_API Page : public UndoObject, public SingleObservable<Page>
 {
 public:
+	/*!
+	 * \brief Create a new page.
+	 *
+	 * \param x page's X offset
+	 * \param y page's Y offset
+	 * \param b page's widht
+	 * \param h page's height
+	 */
 	Page(const double x, const double y, const double b, const double h);
+	/*!
+	 * \brief Destroy a page.
+	 */
 	~Page();
+
+	/*!
+	 * \brief Get the page's X offset.
+	 */
 	double xOffset() const { return m_xOffset; }
+	/*!
+	 * \brief Get the page's Y offset.
+	 */
 	double yOffset() const { return m_yOffset; }
+	/*!
+	 * \brief Get the page's width.
+	 */
 	double width() const { return m_width; }
+	/*!
+	 * \brief Get the page's height.
+	 */
 	double height() const { return m_height; }
+	/*!
+	 * \brief Get the initial page's width.
+	 */
 	double initialWidth() const { return m_initialWidth; }
+	/*!
+	 * \brief Get the initial page's height.
+	 */
 	double initialHeight() const { return m_initialHeight; }
+	/*!
+	 * \brief Set the page's X offset.
+	 */
 	void setXOffset(const double);
+	/*!
+	 * \brief Set the page's Y offset.
+	 */
 	void setYOffset(const double);
+	/*!
+	 * \brief Set the page's width.
+	 */
 	void setWidth(const double);
+	/*!
+	 * \brief Set the page's height.
+	 */
 	void setHeight(const double);
+	/*!
+	 * \brief Set the initial page's width.
+	 */
 	void setInitialWidth(const double);
+	/*!
+	 * \brief Set the initial page's height.
+	 */
 	void setInitialHeight(const double);
+	/*!
+	 * \brief Copy the size property from page.
+	 *
+	 * For know doesn't take care of layout.
+	 * \param page page to copy the properties
+	 * \param pageMargins margins to apply
+	 */
 	void copySizingProperties(Page *sourcePage, const MarginStruct& pageMargins);
-	MarginStruct Margins;
-	MarginStruct initialMargins;
-  /** Nummer der Seite */
+	MarginStruct Margins;		/*!< \brief Page's margins. */
+	MarginStruct initialMargins;	/*!< \brief Initial page's margins. */
+	/*! \brief Nummer der Seite */
 	int LeftPg;
-	//! Name of the master page that this page uses
-	QString MPageNam;
+	QString MPageNam;		/*!< \brief Name of the used master page. */
 
 	QString m_pageSize;
-	int PageOri;
+	int PageOri;			/*!< \brief Page's orientation. \details O => Portrait, 1 => Landscape. */
 	int marginPreset;
+	/*!
+	 * \brief Get the document this page belongs to.
+	 */
 	ScribusDoc* doc() const { return m_Doc; }
+	/*!
+	 * \brief Set the document this page belongs to.
+	 */
 	void setDocument(ScribusDoc* doc);
+	/*!
+	 * \brief Get the page's number.
+	 */
 	int pageNr() const { return m_pageNr; }
+	/*!
+	 * \brief Set the page's number.
+	 */
 	void setPageNr(int pageNr);
 	const QString& pageSectionNumber() const { return m_pageSectionNumber; }
 	void setPageSectionNumber(const QString&);
-	//! Return the page's name
+	/*!
+	 * \brief Return the page's name.
+	 */
 	const QString& pageName() const {return m_PageName;};
+	/*!
+	 * \brief Set the page's name.
+	 *
+	 * Currently only allowed for master page.
+	 */
 	void setPageName(const QString& newName);
+	/*!
+	 * \brief Used for undo/redo actions.
+	 */
 	void restore(UndoState* state, bool isUndo);
 
-	/*! \brief As a bit of a dirty hack, we declare this mutable so it can be altered
-	even while the object is `const'. That's normally only for internal
-	implementation, but in this case it at least lets us guarantee the rest
-	of the object is unchanged in (eg) pdflib. This should be replaced with
-	proper access methods later. */
+	/*!
+	 * \brief The page item we get from master page.
+	 *
+	 * As a bit of a dirty hack, we declare this mutable so it can be altered
+	 * even while the object is `const'. That's normally only for internal
+	 * implementation, but in this case it at least lets us guarantee the rest
+	 * of the object is unchanged in (eg) pdflib. This should be replaced with
+	 * proper access methods later.
+	 */
 	mutable QList<PageItem*> FromMaster;
-	//! \brief Guides lists and basic operations
+	/*!
+	 * \brief Guides lists and basic operations.
+	 */
 	GuideManagerCore guides;
 
 protected:
@@ -97,16 +179,15 @@ protected:
 	void restorePageItemDeletion(ItemState<PageItem*> *state, bool isUndo);
 	void restorePageItemConversion(ItemState<std::pair<PageItem*, PageItem*> >*state, bool isUndo);
 	
-	double m_xOffset;
-	double m_yOffset;
-	double m_width;
-	double m_height;
-	double m_initialWidth;
-	double m_initialHeight;
-	int m_pageNr;
-	//! Name of this page, currently only allowed to be used by a master page
-	QString m_PageName;
-	ScribusDoc* m_Doc;	
+	double m_xOffset;		/*!< \brief Page's X Offset. */
+	double m_yOffset;		/*!< \brief Page's Y Offset. */
+	double m_width;			/*!< \brief Page's width. */
+	double m_height;		/*!< \brief Page's height. */
+	double m_initialWidth;		/*!< \brief Initial page's width. */
+	double m_initialHeight;		/*!< \brief Initial page's height. */
+	int m_pageNr;			/*!< \brief Page's number. */
+	QString m_PageName;		/*!< \brief Page's name. \details Currently only allowed to be used by a master page. */
+	ScribusDoc* m_Doc;		/*!< \brief The document this page belongs to. */
 	QString m_pageSectionNumber;
 };
 
diff --git a/Scribus/scribus/scribusdoc.h b/Scribus/scribus/scribusdoc.h
index 7336ceb..429400f 100644
--- a/Scribus/scribus/scribusdoc.h
+++ b/Scribus/scribus/scribusdoc.h
@@ -107,693 +107,1126 @@ struct SCRIBUS_API NodeEditContext : public MassObservable<QPointF>
 };
 
 
-/**! \brief the Document Class
+/*! \brief the Document Class
   */
 class SCRIBUS_API ScribusDoc : public QObject, public UndoObject, public Observable<ScribusDoc>
 {
 	Q_OBJECT
 
 public:
+	/*! \brief Some internal align tools. */
+//ivro: is this cannot be moved elsewhere ?
+	typedef enum {
+		alignFirst,
+		alignLast,
+		alignPage,
+		alignMargins,
+		alignGuide,
+		alignSelection
+	} AlignTo;
+
 	ScribusDoc();
 	ScribusDoc(const QString& docName, int unitIndex, const PageSize& pagesize, const MarginStruct& margins, const DocPagesSetup& pagesSetup);
 	~ScribusDoc();
 	void init();
 	void setup(const int, const int, const int, const int, const int, const QString&, const QString&);
+
+// States
+	/*!
+	 * \brief Set the loading state of the document
+	 *
+	 * See ScribusDoc.isLoading()
+	 */
 	void setLoading(const bool);
+	/*!
+	 * \brief Is the document loading ?
+	 *
+	 * See ScribusDoc.setLoading()
+	 */
 	bool isLoading() const;
+	/*!
+	 * \brief Set modified state of the document.
+	 *
+	 * If state changed, update the document
+	 * See ScribusDoc.isModified()
+	 */
 	void setModified(const bool);
+	/*!
+	 * \brief Is the document modified ?
+	 *
+	 * See ScribusDoc.setModified()
+	 */
 	bool isModified() const;
-/** Setzt die Seitenattribute */
-	void setPage(double b, double h, double t, double l, double r, double bo, double sp, double ab, bool atf, int fp);
-	void resetPage(MarginStruct& newMargins, int fp);
 
-	/**
-	 * @brief Return the view associated with the document
+// GUI
+	/*!
+	 * \brief Associate document and GUI.
+	 *
+	 * See ScribusDoc.hasGUI(), ScribusDoc.scMW() and ScribusDoc.view()
+	 * \param hasgui Is document associated with gui ?
+	 * \param mainWindow scribus main window
+	 * \param view scribus view
 	 */
-	ScribusView* view() const;
+	void setGUI(bool hasgui, ScribusMainWindow* mainWindow, ScribusView* view);
+	/*!
+	 * \brief Is the document associated with GUI ?
+	 *
+	 * See Scribus.setGUI()
+	 */
+	bool hasGUI() const {return m_hasGUI;}
+	/*!
+	 * \brief Get the scribus main window associated with the document.
+	 *
+	 * See Scribus.setGUI()
+	 * \return the scribus man window
+	 */
+//ivro: rename this function (mainWindow or scribusMainWindow) ?
 	ScribusMainWindow* scMW() const {return m_ScMW;}
-	void setGUI(bool hasgui, ScribusMainWindow* mw, ScribusView* view);
+	/*!
+	 * \brief Get the view associated with the document.
+	 *
+	 * See Scribus.setGUI()
+	 * \return the scribus view
+	 */
+	ScribusView* view() const;
+
+// Automatic Text Frames
+	/*!
+	 * \brief Set if doc uses automatic text frames.
+	 *
+	 * See ScribusDoc.usesAutomaticTextFrames(), ScribusDoc.PageSp and ScribusDoc.PageSpa
+	 */
+	void setUsesAutomaticTextFrames(const bool);
+	/*!
+	 * \brief Is document using automatic text frames ?
+	 *
+	 * See ScribusDoc.setUsesAutomaticTextFrames
+	 */
+	bool usesAutomaticTextFrames() const;
 
-	/**
-	 * @brief Return the guarded object associated with the document
+// Grid and Guides
+	/*!
+	 * \brief Should guides be locked or not ?
+	 *
+	 * \param isLocked If true guides on pages cannot be moved if false they
+	 * can be dragged to new positions.
+	 * \author Riku Leino
+	 */
+	void lockGuides(bool isLocked);
+
+// Current Page
+	/*!
+	 * \brief Set new current page.
+	 *
+	 */
+	void setCurrentPage(Page*);
+	/*!
+	 * \brief Get the current page.
+	 */
+	Page* currentPage();
+	/*!
+	 * \brief Get the current page number.
+	 */
+	int currentPageNumber();
+
+// Unit index and unit ratio
+	/*!
+	 * \brief Set the document's unit index and update the document's unit ratio.
+	 *
+	 * See ScribusDoc.unitIndex() and ScribusDoc.unitRatio()
+	 */
+	void setUnitIndex(const int);
+	/*!
+	 * \brief Get the document's unit index.
+	 *
+	 * See ScribusDoc.setUnitIndex()
+	 */
+	int unitIndex() const;
+	/*!
+	 * \brief Get the document's unit ratio.
+	 *
+	 * See ScribusDoc.setUnitIndex()
+	 */
+	double unitRatio() const;
+
+// Document's properties
+	/*!
+	 * \brief Sets the name of the document.
+	 *
+	 * \param name Name for the document
+	 * \author Riku Leino
+	 */
+	void setName(const QString& name);
+
+/*! \name Master Page
+ * \brief Master page related functions.
+ *
+ * A master page is a model for page. Items on master pages will be repeated on each page with the master page.
+ * Use applyMasterPage() to associate a master page to a page and copyPageToMasterPage() to make a master page from a page.
+ *
+ * The master page mode allow to work with master pages and items with the same functions you use for pages and items.
+ * See masterPageMode() and setMasterPageMode().
+ */ //@{
+	/*!
+	 * \brief Is the document in master page mode ?
+	 *
+	 * In master page mode
+	 *      ScribusDoc.Pages = &ScribusDoc.MasterPages
+	 *      ScribusDoc.Items = &ScribusDoc.MasterItems
+	 * In normal mode (ie not in master mode)
+	 *      ScribusDoc.Pages = &ScribusDoc.DocPages
+	 *      ScribusDoc.Items = &ScribusDoc.DocItems
+	 */
+	bool masterPageMode() const { return m_masterPageMode; }
+	/*!
+	 * \brief Set the doc into Master page mode.
+	 */
+// Do we need to return if the move to master page mode was successful?
+	void setMasterPageMode(bool);
+
+	/*!
+	 * \brief Add a master page.
+	 *
+	 * Use this function to add a master page, do not use addPage
+	 * \param pageNumber index for the master page
+	 * \param pageName name of the master page
+	 * \return added page
+	 */
+	Page* addMasterPage(const int pageNumber, const QString& pageName);
+	/*!
+	 * \brief Delete a master page.
+	 *
+	 * \param pageNumber index of the master page
+	 */
+	void deleteMasterPage(const int pageNumber);
+	/*!
+	 * \brief Replace a master page by default one.
+	 *
+	 * \param oldMasterPage name of the master page to remplace
 	 */
-	const ScGuardedPtr<ScribusDoc>& guardedPtr() const;
-	
-	UpdateManager* updateManager() { return &m_updateManager; }
-	MassObservable<PageItem*> * itemsChanged() { return &m_itemsChanged; }
-	MassObservable<Page*>     * pagesChanged() { return &m_pagesChanged; }
-	MassObservable<QRectF>    * regionsChanged() { return &m_regionsChanged; }
-	void invalidateRegion(QRectF region);
-	
-	// Add, delete and move pages
-	
-	Page* addPage(const int pageNumber, const QString& masterPageName=QString::null, const bool addAutoFrame=false);
-	void deletePage(const int);
-	//! @brief Add a master page with this function, do not use addPage
-	Page* addMasterPage(const int, const QString&);
-	void deleteMasterPage(const int);
-	//! @brief Rebuild master name list
-	void rebuildMasterNames(void);
-	//! @brief Replace a master page by default one
 	void replaceMasterPage(const QString& oldMasterPage);
-	//! @brief Rename a master page
+	/*!
+	 * \brief Rename a master page.
+	 *
+	 * \param oldPageName old name of the master page
+	 * \param newPageName new name for the master page
+	 */
 	bool renameMasterPage(const QString& oldPageName, const QString& newPageName);
-	//! @brief Create the default master pages based on the layout selected by the user, ie, Normal, Normal Left, etc.
-	void createDefaultMasterPages();
-	//! @brief Create the requested pages in a new document, run after createDefaultMasterPages()
-	void createNewDocPages(int pageCount);
-	/**
-	 * @brief Add the automatic text frame to the page
-	 * @param pageNumber page number
-	 * @return number of frame
+	/*!
+	 * \brief Rebuild master name list.
+	 *
+	 * Rebuild ScribusDoc.MasterName list from the master page name
 	 */
-	int addAutomaticTextFrame(const int pageNumber);
-	/**
-	 * Set the left and right margins based on the location of the page
-	 * @param pageIndex 
+	void rebuildMasterNames(void);
+//@} // End of master page group
+
+/*! \name Page
+ * \brief Page related functions.
+ *
+ * A page represents a paper page. See Page::Page
+ */ //@{
+	// Add, delete and move page
+
+	/*!
+	 * \brief Add a page.
+	 *
+	 * Do not use this to add a master page, use addMasterPage instead
+	 * \param pageNumber index for the page
+	 * \param masterPageName master page to use
+	 * \param addAutoFrame add automatic text frame
+	 * \return addedpage
 	 */
-	void setLocationBasedPageLRMargins(uint pageIndex);
-	/**
-	 * @brief Move page(s) within the document
-	 * @param from page index
-	 * @param to page index
-	 * @param ziel target to move to (page index)
-	 * @param art Before, After or at the end
+	Page* addPage(const int pageNumber, const QString& masterPageName=QString::null, const bool addAutoFrame=false);
+	/*!
+	 * \brief Delete a page.
+	 *
+	 * \param pageNumber index of the page
 	 */
+	void deletePage(const int pageNumber);
+	/*!
+	 * \brief Move page(s) within the document.
+	 *
+	 * \param from page index
+	 * \param to page index
+	 * \param ziel page index of the target to move to
+	 * \param art Before (0), After (1) or At the end (2)
+	 */
+//ivro: create typedef for param art (like whereToMove) ?
 	void movePage(const int from, const int to, const int ziel, const int art);
-	
-	/**
-	 * @brief Copy a page (pageNumberToCopy) copyCount times, whereToInsert(before or after) the existingPage or at the end.
-	 * @param pageNumberToCopy 
-	 * @param existingPage 
-	 * @param whereToInsert 
-	 * @param copyCount 
+	/*!
+	 * \brief Copy a page.
+	 *
+	 * Copy a page (pageNumberToCopy) copyCount times, whereToInsert(before or after) the existingPage or at the end.
+	 * \param pageNumberToCopy index of the page
+	 * \param existingPage where to copy (page index)
+	 * \param whereToInsert Before (0), After (1) or At the end (2)
+	 * \param copyCount number of copy
 	 */
+//ivro: use typedef whereToMove for param whereToInsert ?
 	void copyPage(int pageNumberToCopy, int existingPage, int whereToInsert, int copyCount);
-	
+
+	// Properties of page
+
+	/*!
+	 * \brief Set page properties.
+	 *
+	 * \param width page width
+	 * \param height page height
+	 * \param marginsTop page margins top
+	 * \param marginsLeft page margins left
+	 * \param marginsRight page margins right
+	 * \param marginsBottom page margins bottom
+	 * \param numberOfColumns number of automaticTextFrames columns
+	 * \param distanceOfColumns distance between automaticTextFrams columns
+	 * \param automaticTextFrames is automaticTextFrames enabled ?
+	 * \param pageLayout index of the page layout in ScribusDoc.pageSets
+	 */
+	void setPage(double width, double height, double marginsTop, double marginsLeft, double marginsRight, double marginsBottom, double numberOfColums, double distanceOfColumns, bool automatictTextFrames, int pageLayout);
+	/*!
+	 * \brief Reset the page properties.
+	 *
+	 * \param newMargins margins to apply
+	 * \param pageLayout index of the page layout in Scribus.pageSets
+	 */
+	void resetPage(MarginStruct& newMargins, int pageLayout);
+	/*!
+	 * \brief Apply a master page.
+	 *
+	 * \param masterPageName name of the master page
+	 * \param pageNumber index of the page
+	 */
+	bool applyMasterPage(const QString& masterPageName, const int pageNumber);
+	/*!
+	 * \brief Copies a normal page to be a master pages.
+	 *
+	 * \param pageNumber index of the page to copy
+	 * \param leftPage
+         * \param maxLeftPage
+	 * \param masterPageName name for the master page
+	 * \param copyFromAppliedMaster
+	 */
+	bool copyPageToMasterPage(const int pageNumber, const int leftPage, const int maxLeftPage, const QString& masterPageName, bool copyFromAppliedMaster);
+
+	/*!
+	 * \brief Add the automatic text frame to the page.
+	 *
+	 * \param pageNumber index of page
+	 * \return number of text frame created, -1 on error
+	 */
+	int addAutomaticTextFrame(const int pageNumber);
+
+	/*!
+	 * \brief Set the page margins.
+	 *
+	 * Current code uses current page only, also provide a (currently, TODO) option for this.
+	 * \param initialTop
+	 * \param initialBottom
+	 * \param initialLeft
+	 * \param initialRight
+	 * \param initialHeight
+	 * \param initialWight
+	 * \param height
+	 * \param width
+	 * \param orientation
+	 * \param pageSize
+	 * \param pageNumber if equal to -1, do nothing and return false. Caution default is -1.
+	 * \param pageType see Page.LeftPg, default to 0 (Right page)
+	 */
+//ivro: is this fuction name goods as it does things that not only about margins ?
+	bool changePageMargins(const double initialTop, const double initialBottom, const double initialLeft, const double initialRight, const double initialHeight, const double initialWidth, const double height, const double width, const int orientation, const QString& pageSize, const int pageNumber=-1, const int pageType = 0);
+
+	/*!
+	 * \brief Get page's bleeds.
+	 *
+	 * \param pageNumber index of the page
+	 * \param bleedData struct to get the bleed
+	 */
+//ivro: is this not better in Page ?
+	void getBleeds(int pageNumber, MarginStruct& bleedData);
+	/*!
+	 * \brief Get page's bleeds.
+	 *
+	 * \param page page to look at
+	 * \param bleedData struct to get the bleed
+	 */
+	void getBleeds(Page* page, MarginStruct& bleedData);
+
+
+	// Canvas
+
+	/*!
+	 * \brief Get the location of the page on the canvas, ie, left, middle, or right.
+	 *
+	 * Does not give information about middle left, etc.
+	 * \param pageIndex Index of page to find location for
+	 * \return LeftPage, MiddlePage, RightPage, enum from pagestructs.h
+	 */
+	PageLocation locationOfPage(int pageIndex) const;
+	/*!
+	 * \brief Get the column of the page on the canvas, ie, left, middle, or right.
+	 *
+	 * \param pageIndex Index of page to find location for
+	 * \return int of 0,1,2,3
+	 */
+	int columnOfPage(int pageIndex) const;
+	/*!
+	 * \brief Return the x offset for a page on the canvas.
+	 *
+	 * @retval double containing the offset. Returns -1.0 if page not in Pages list (as -ve is not possible).
+	 * Mostly saves bringing in extra includes into files that already have scribusdoc.h
+	 */
+	double getXOffsetForPage(const int);
+	/*!
+	 * \brief Return the y offset for a page on the canvas.
+	 *
+	 * @retval double coutaining the offset. Returns -1.0 if page not in pages list (as -ve is not possible).
+	 */
+	double getYOffsetForPage(const int);
+
+	/*!
+	 * \brief Set the left and right margins based on the location of the page.
+	 *
+	 * \param pageIndex index of the page
+	 */
+	void setLocationBasedPageLRMargins(uint pageIndex);
+//@} // End of Page group
+
+/*! \name Layer
+ * \brief Layer related functions.
+ */ //@{
 	// Add, delete and move layers
-	/**
-	 * @brief Add a layer to the current document
-	 * @param layerName name of layer
-	 * @param activate the layer active
-	 * @return Number of the layer created
+
+	/*!
+	 * \brief Add a layer to the current document.
+	 *
+	 * \param layerName name of layer
+	 * \param activate the layer active
+	 * \return Number of the layer created
 	 */
 	int addLayer(const QString& layerName=QString::null, const bool activate=false);
-	/**
-	 * @brief Copies a layer from the current document
-	 * @param layerNumberToCopy source layer
-	 * @param whereToInsert target layer
-	 * @return Success or failure
+	/*!
+	 * \brief Copies a layer from the current document.
+	 *
+	 * \param layerNumberToCopy source layer
+	 * \param whereToInsert target layer
+	 * \return Success or failure
 	 */
 	void copyLayer(int layerNumberToCopy, int whereToInsert);
-	/**
-	 * @brief Delete a layer from the current document
-	 * @param layerNumber of layer
-	 * @param deleteItems the items on the layer too?
-	 * @return Success or failure
+	/*!
+	 * \brief Delete a layer from the current document.
+	 *
+	 * \param layerNumber of layer
+	 * \param deleteItems the items on the layer too?
+	 * \return Success or failure
 	 */
 	bool deleteLayer(const int layerNumber, const bool deleteItems);
-	/**
-	 * @brief Return the number of the current layer
-	 * @return Active layer number
+	/*!
+	 * FIXME: Make protected once scripter function no longer uses this directly
 	 */
-	int activeLayer();
+	void removeLayer(int l, bool dl = false);
 
-	/**
-	 * @brief Return the name of the current layer
-	 * @return Name of the layer
-	 */
-	const QString& activeLayerName();
-	/**
-	 * @brief Set the active layer via the layer number
-	 * @param layerToActivate Number of the layer
-	 * @return Success or failure
+	// Active layer
+
+	/*!
+	 * \brief Set the active layer via the layer number.
+	 *
+	 * \param layerToActivate Number of the layer
+	 * \return Success or failure
 	 */
 	bool setActiveLayer(const int layerToActivate);
-	/**
-	 * @brief Set the active layer via the layer name
-	 * @param layerNameToActivate Name of the layer
-	 * @return Success or failure
+	/*!
+	 * \brief Set the active layer via the layer name.
+	 *
+	 * \param layerNameToActivate Name of the layer
+	 * \return Success or failure
 	 */
 	bool setActiveLayer(const QString & layerNameToActivate);
-	/**
-	 * @brief Set the layer printable via the layer number
-	 * @param layerNumber Number of the layer
-	 * @param isPrintable bool true = layer is prantable
-	 * @return Success or failure
+	/*!
+	 * \brief Return the number of the current layer.
+	 *
+	 * \return Active layer number
+	 */
+	int activeLayer();
+	/*!
+	 * \brief Return the name of the current layer.
+	 *
+	 * \return Name of the layer
+	 */
+	const QString& activeLayerName();
+
+	// Layer properties
+
+	/*!
+	 * \brief Return the layer name.
+	 *
+	 * \param layerNumber Number of the layer
+	 * \return Name of the layer
+	 */
+	QString layerName(const int layerNumber) const;
+	/*!
+	 * \brief Change the name of a layer.
+	 *
+	 * \param layerNumber number of the layer
+	 * \param newName new name of the layer
+	 * \return Success or failure
+	 */
+	bool changeLayerName(const int layerNumber, const QString& newName);
+	/*!
+	 * \brief Set the layer printable via the layer number.
+	 *
+	 * \param layerNumber Number of the layer
+	 * \param isPrintable bool true = layer is prantable
+	 * \return Success or failure
 	 */
 	bool setLayerPrintable(const int layerNumber, const bool isPrintable);
-	/**
-	 * @brief Is the layer printable
-	 * @param layerNumber Number of the layer
-	 * @return Printable or not
+	/*!
+	 * \brief Is the layer printable ?
+	 *
+	 * \param layerNumber Number of the layer
+	 * \return Printable or not
 	 */
 	bool layerPrintable(const int layerNumber);
-	/**
-	 * @brief Set the layer visible via the layer number
-	 * @param layerNumber Number of the layer
-	 * @param isViewable true = layer is visible
-	 * @return Success or failure
+	/*!
+	 * \brief Set the layer visible via the layer number.
+	 *
+	 * \param layerNumber Number of the layer
+	 * \param isViewable true = layer is visible
+	 * \return Success or failure
 	 */
 	bool setLayerVisible(const int layerNumber, const bool isViewable);
-	/**
-	 * @brief Is the layer visible
-	 * @param layerNumber Number of the layer
-	 * @return Visible or not
+	/*!
+	 * \brief Is the layer visible ?
+	 *
+	 * \param layerNumber Number of the layer
+	 * \return Visible or not
 	 */
 	bool layerVisible(const int layerNumber);
-	/**
-	 * @brief Set the layer locked via the layer number
-	 * @param layerNumber Number of the layer
-	 * @param isLocked true = layer is locked
-	 * @return Success or failure
+	/*!
+	 * \brief Set the layer locked via the layer number.
+	 *
+	 * \param layerNumber Number of the layer
+	 * \param isLocked true = layer is locked
+	 * \return Success or failure
 	 */
 	bool setLayerLocked(const int layerNumber, const bool isLocked);
-	/**
-	 * @brief Is the layer locked
-	 * @param layerNumber Number of the layer
-	 * @return Locked or not
+	/*!
+	 * \brief Is the layer locked ?
+	 *
+	 * \param layerNumber Number of the layer
+	 * \return Locked or not
 	 */
 	bool layerLocked(const int layerNumber);
-	/**
-	 * @brief Set the layer flow via the layer number
-	 * @param layerNumber Number of the layer
-	 * @param flow true = Text flows around objects on this layer
-	 * @return Success or failure
+	/*!
+	 * \brief Set the layer flow via the layer number.
+	 *
+	 * \param layerNumber Number of the layer
+	 * \param flow true = Text flows around objects on this layer
+	 * \return Success or failure
 	 */
 	bool setLayerFlow(const int layerNumber, const bool flow);
-	/**
-	 * @brief does text flow around objects on this layer
-	 * @param layerNumber Number of the layer
-	 * @return flow or not
+	/*!
+	 * \brief Does text flow around objects on this layer ?
+	 *
+	 * \param layerNumber Number of the layer
+	 * \return flow or not
 	 */
 	bool layerFlow(const int layerNumber);
-	/**
-	 * @brief Set the layer transparency via the layer number
-	 * @param layerNumber Number of the layer
-	 * @param trans transparency value 0.0 - 1.0
-	 * @return Success or failure
+	/*!
+	 * \brief Set the layer transparency via the layer number.
+	 *
+	 * \param layerNumber Number of the layer
+	 * \param trans transparency value 0.0 - 1.0
+	 * \return Success or failure
 	 */
 	bool setLayerTransparency(const int layerNumber, double trans);
-	/**
-	 * @brief returns the layer transparency
-	 * @param layerNumber Number of the layer
-	 * @return transparency value 0.0 - 1.0
+	/*!
+	 * \brief Returns the layer transparency.
+	 *
+	 * \param layerNumber Number of the layer
+	 * \return transparency value 0.0 - 1.0
 	 */
 	double layerTransparency(const int layerNumber);
-	/**
-	 * @brief Set the layer layerBlendMode via the layer number
-	 * @param layerNumber Number of the layer
-	 * @param blend layerBlendMode
-	 * @return Success or failure
+	/*!
+	 * \brief Set the layer layerBlendMode via the layer number.
+	 *
+	 * \param layerNumber Number of the layer
+	 * \param blend layerBlendMode
+	 * \return Success or failure
 	 */
 	bool setLayerBlendMode(const int layerNumber, int blend);
-	/**
-	 * @brief returns the layer BlendMode
-	 * @param layerNumber Number of the layer
-	 * @return layerBlendMode
+	/*!
+	 * \brief Returns the layer BlendMode.
+	 *
+	 * \param layerNumber Number of the layer
+	 * \return layerBlendMode
 	 */
 	int layerBlendMode(const int layerNumber);
-	/**
-	 * @brief Return the level of the requested layer
-	 * @param layerNumber Number of the layer
-	 * @return Level of the layer
+	/*!
+	 * \brief Set the layer outline mode via the layer number.
+	 *
+	 * \param layerNumber Number of the layer
+	 * \param outline true = layer is displayed in outlines only
+	 * \return Success or failure
 	 */
-	int layerLevelFromNumber(const int layerNumber);
-	/**
-	 * @brief Set the layer marker color
-	 * @param layerNumber Number of the layer
-	 * @param color color of the marker
-	 * @return Success or failure
+	bool setLayerOutline(const int layerNumber, const bool outline);
+	/*!
+	 * \brief Is this layer in outline mode ?
+	 *
+	 * \param layerNumber Number of the layer
+	 * \return outline or not
+	 */
+	bool layerOutline(const int layerNumber);
+
+	// Layer marker color
+
+	/*!
+	 * \brief Set the layer marker color.
+	 *
+	 * \param layerNumber Number of the layer
+	 * \param color color of the marker
+	 * \return Success or failure
 	 */
 	bool setLayerMarker(const int layerNumber, QColor color);
-	/**
-	 * @brief returns the layer marker color
-	 * @param layerNumber Number of the layer
-	 * @return marker color
+	/*!
+	 * \brief Returns the layer marker color.
+	 *
+	 * \param layerNumber Number of the layer
+	 * \return marker color
 	 */
 	QColor layerMarker(const int layerNumber);
-	/**
-	 * @brief Set the layer outline mode via the layer number
-	 * @param layerNumber Number of the layer
-	 * @param outline true = layer is displayed in outlines only
-	 * @return Success or failure
-	 */
-	bool setLayerOutline(const int layerNumber, const bool outline);
-	/**
-	 * @brief is this layer in outline mode
-	 * @param layerNumber Number of the layer
-	 * @return outline or not
+
+	// Layer level
+
+	/*!
+	 * \brief Returns the level of the requested layer.
+	 *
+	 * \param layerNumber Number of the layer
+	 * \return Level of the layer
 	 */
-	bool layerOutline(const int layerNumber);
-	/**
-	 * @brief Return the number of the layer at a certain level
-	 * @param layerLevel Layer level
-	 * @return Layer number
+	int layerLevelFromNumber(const int layerNumber);
+	/*!
+	 * \brief Returns the number of the layer at a certain level.
+	 *
+	 * \param layerLevel Layer level
+	 * \return Layer number
 	 */
 	int layerNumberFromLevel(const int layerLevel);
-	/**
-	 * @brief Return the layer count
-	 * @return Number of layers in doc
-	 */
-	int layerCount() const;
-	/**
-	 * @brief Lower a layer
-	 * @param layerNumber Number of the layer
-	 * @return Success or failure
+
+	// Lower and Raise Layer
+
+	/*!
+	 * \brief Lowers a layer.
+	 *
+	 * \param layerNumber Number of the layer
+	 * \return Success or failure
 	 */
 	bool lowerLayer(const int layerNumber);
-	/**
-	 * @brief Lower a layer using the level
-	 * @param layerLevel Level of the layer
-	 * @return Success or failure
+	/*!
+	 * \brief Lowers a layer using the level.
+	 *
+	 * \param layerLevel Level of the layer
+	 * \return Success or failure
 	 */
 	bool lowerLayerByLevel(const int layerLevel);
-	/**
-	 * @brief Raise a layer
-	 * @param layerNumber Number of the layer
-	 * @return Success or failure
+	/*!
+	 * \brief Raises a layer.
+	 *
+	 * \param layerNumber Number of the layer
+	 * \return Success or failure
 	 */
 	bool raiseLayer(const int layerNumber);
-	/**
-	 * @brief Raise a layer using the level
-	 * @param layerLevel Level of the layer
-	 * @return Success or failure
+	/*!
+	 * \brief Raises a layer using the level.
+	 *
+	 * \param layerLevel Level of the layer
+	 * \return Success or failure
 	 */
 	bool raiseLayerByLevel(const int layerLevel);
-	/**
-	 * @brief Return the layer name
-	 * @param layerNumber Number of the layer
-	 * @return Name of the layer
-	 */
-	QString layerName(const int layerNumber) const;
-	/**
-	 * @brief Change the name of a layer
-	 * @param layerNumber number of the layer
-	 * @param newName new name of the layer
-	 * @return Success or failure
+
+	// Various functions on layer
+
+	/*!
+	 * \brief Returns the layer count.
+	 *
+	 * \return Number of layers in doc
 	 */
-	bool changeLayerName(const int layerNumber, const QString& newName);
-	/**
-	 * @brief Does the layer have items on it?
-	 * @param layerNumber Number of the layer
-	 * @return Layer contains items bool
+	int layerCount() const;
+	/*!
+	 * \brief Does the layer have items on it ?
+	 *
+	 * \param layerNumber Number of the layer
+	 * \return Layer contains items bool
 	 */
 	bool layerContainsItems(const int layerNumber);
-	/**
-	 * @brief Renumber a layer. Used in particular for reinsertion for undo/redo
-	 * @param layerNumber old layer number
-	 * @param newLayerNumber New layer number
-	 * @return Success or failure
+	/*!
+	 * \brief Renumbers a layer.
+	 *
+	 * Used in particular for reinsertion for undo/redo.
+	 * \param layerNumber old layer number
+	 * \param newLayerNumber New layer number
+	 * \return Success or failure
 	 */
 	bool renumberLayer(const int layerNumber, const int newLayerNumber);
-	/**
-	 * @brief Return a list of the layers in their order
-	 * @param list QStringList to insert the layer names into
-	 */
-	void orderedLayerList(QStringList* list);
-	//Items
-	bool deleteTaggedItems();
-
 	/*!
-		* @brief Builds a qmap of the icc profiles used within the document
-	 */
-	void getUsedProfiles(ProfilesL& usedProfiles);
-	bool OpenCMSProfiles(ProfilesL InPo, ProfilesL InPoCMYK, ProfilesL MoPo, ProfilesL PrPo);
-	void CloseCMSProfiles();
-	void SetDefaultCMSParams();
-	/**
-	 * @brief Switch Colormanagement on or of
-	 * @param enable bool, if true Colormanagement is switched on, else off
+	 * \brief Returns a list of the layers in their order.
+	 *
+	 * \param list QStringList to insert the layer names into
 	 */
-	void enableCMS(bool enable);
-	
-	const ParagraphStyle& paragraphStyle(QString name) { return docParagraphStyles.get(name); }
-	const StyleSet<ParagraphStyle>& paragraphStyles()   { return docParagraphStyles; }
-	bool isDefaultStyle( const ParagraphStyle& p ) const { return docParagraphStyles.isDefault(p); }
-	bool isDefaultStyle( const CharStyle& c ) const { return docCharStyles.isDefault(c); }
-// 	bool isDefaultStyle( LineStyle& l ) const { return MLineStyles......; }
+	void orderedLayerList(QStringList* list);
+//@} // End of Layer function
 
-	void getNamedResources(ResourceCollection& lists) const;
-	void replaceNamedResources(ResourceCollection& newNames);	
-	
-	void redefineStyles(const StyleSet<ParagraphStyle>& newStyles, bool removeUnused=false);
-	/**
-	 * @brief Remove any reference to old styles and replace with new name. This needs to be
-	 *        called when a style was removed. New name may be "".
-	 * @param newNameForOld a map which maps the name of any style to remove to a new stylename
-	 */
-	void replaceStyles(const QMap<QString,QString>& newNameForOld);
-	/**
-	 * @brief Insert styles from another document in this document.
-	 *        
-	 * @param fileName The path of the document we want to extract its styles
-	 */
-	void loadStylesFromFile(QString fileName);
-	/**
-	 * @brief Gather styles from another document.
-	 *        
-	 * @param fileName The path of the document we want to extract its styles
-	 * @param tempStyles A pointer to a StyleSet which will be filled by paragraph styles
-	 * @param tempCharStyles A pointer to a StyleSet which will be filled by character styles
-	 * @param tempLineStyles A map which will be filled by line styles
-	 */
-	void loadStylesFromFile(QString fileName, StyleSet<ParagraphStyle> *tempStyles,
-	                                          StyleSet<CharStyle> *tempCharStyles,
-	                                          QMap<QString, multiLine> *tempLineStyles);
+/*! \name Item
+ * \brief Item related functions.
+ */ //@{
+	// Add
 
-	const CharStyle& charStyle(QString name) { return docCharStyles.get(name); }
-	const StyleSet<CharStyle>& charStyles()  { return docCharStyles; }
-	void redefineCharStyles(const StyleSet<CharStyle>& newStyles, bool removeUnused=false);
-	/**
-	 * @brief Remove any reference to old styles and replace with new name. This needs to be
-	 *        called when a style was removed. New name may be "".
-	 * @param newNameForOld a map which maps the name of any style to remove to a new stylename
+	/*!
+	 * \brief Add an Item to the document.
+	 *
+	 * A simple function to create an item of a defined type and add it to the document
+	 * Will need extensive rewriting once we have various classes of PageItems, at a guess.
+	 *
+	 * \param itemType type
+	 * \param frameType frame type
+	 * \param x X pos
+	 * \param y Y pos
+	 * \param b width
+	 * \param h height
+	 * \param w ?
+	 * \param fill fill color name
+	 * \param outline outline color name
+	 * \param itemFinalised Used to handle item creation for undo while the user is still dragging.
+	 * \return Number of created item, -1 on failure.
 	 */
-	void replaceCharStyles(const QMap<QString,QString>& newNameForOld);
-
-	/**
-	 * @brief Should guides be locked or not
-	 * @param isLocked If true guides on pages cannot be moved if false they
-	 * can be dragged to new positions.
-	 * @author Riku Leino
+	int itemAdd(const PageItem::ItemType itemType, const PageItem::ItemFrameType frameType, const double x, const double y, const double b, const double h, const double w, const QString& fill, const QString& outline, const bool itemFinalised);
+	/*!
+	 * \brief Add an Item to the page.
+	 *
+	 * Item will be fitted to the closest guides/margins of the x/y position.
+	 *
+	 * \param itemType type
+	 * \param itemFramType frame type
+	 * \param x X pos
+	 * \param y Y pos
+	 * \param w ?
+	 * \param fill fill color name
+	 * \param outline outline color name
+	 * \param itemFinalised Used to handle item creation for undo while the user is still dragging
+	 * \return Number of created item, -1 on failure.
 	 */
-	void lockGuides(bool isLocked);
-	/**
-	 * @brief Method used when an undo/redo is requested.
-	 * @param state State describing the action that is wanted to be undone/redone
-	 * @param isUndo If true undo is wanted else if false redo.
-	 * @author Riku Leino
+	int itemAddArea(const PageItem::ItemType itemType, const PageItem::ItemFrameType frameType, const double x, const double y, const double w, const QString& fill, const QString& outline, const bool itemFinalised);
+	/*!
+	 * \brief Allow the user to create a frame easily with some simple placement and sizing options.
+	 *
+	 * \param iafData a InsertAFrameData structure with params
+	 * \return int item id? FIXME
 	 */
-	void restore(UndoState* state, bool isUndo);
-	/**
-	 * @brief Sets the name of the document
-	 * @param name Name for the document
-	 * @author Riku Leino
+	int itemAddUserFrame(InsertAFrameData &iafData);
+	/*!
+	 * \brief Commit item creation when a user has click-drag created an item.
+	 *
+	 * Only called from ScribusView. Note the undo target is the page, so the undo code remains their for now.
+	 *
+	 * \return If an item was committed and the view must emit its signal, which needs removing from here, TODO.
 	 */
-	void setName(const QString& name);
+	bool itemAddCommit(const int itemNumber);
 	/*!
-	 * @brief Returns a stringlist of the item attributes within the document
+	 * \brief Finalise item creation, only to be called from itemAdd().
+	 *
+	 * Simply split off code from itemAdd.
+	 *
+	 * \param itemType type
+	 * \param frameType frame type
+	 * \param itemNumber item index
 	 */
-	QStringList getItemAttributeNames();
-
-	bool AddFont(QString name, int fsize = 10);
+	void itemAddDetails(const PageItem::ItemType itemType, const PageItem::ItemFrameType frameType, const int itemNumber);
 	/*!
-	 * @brief TODO: Reorganise the fonts.. how? Moved from scribus.cpp
-	 * CB: almost the same as getUsedFonts???
+	 * \brief Item type conversion functions.
+	 *
+	 * \param currItem item to convert
+	 * \param newType
+	 * \param secondaryItem ?
 	 */
-	QMap<QString,int> reorganiseFonts();
+	PageItem* convertItemTo(PageItem *currItem, PageItem::ItemType newType, PageItem* secondaryItem=NULL);
 	/*!
-	 * @brief Returns a qmap of the fonts and  their glyphs used within the document
+	 * \brief Paste an item to the document.
+	 *
+	 * The bulk of a paste item process runs here for want of a better place, but its a better place
+	 * than the view where it used to be.
+	 * TODO Once the pageitem restructure is done, this is probably unnecessary but it removes the
+	 * unnecessary part from the view for now which is overloaded with non ScrollView code.
 	 */
-	void getUsedFonts(QMap<QString,QMap<uint, FPointArray> > &Really);
-	void checkItemForFonts(PageItem *it, QMap<QString, QMap<uint, FPointArray> > & Really, uint lc);
+	//TODO: void PasteItem(struct CopyPasteBuffer *Buffer, bool loading, bool drag = false);
+
+	//itemDelete
+	//itemBlah...
+
+	// move, rotate, resize items
 
 	/*!
-	 * @brief Replace line style colors
+	 * \brief Move item.
+	 *
+	 * \param newX new X coord
+	 * \param newY new Y coord
+	 * \param item page item to move
+	 * \param fromMP ?
 	 */
-	void replaceLineStyleColors(const QMap<QString, QString>& colorMap);
-	/*!
-	* @brief Builds a qmap of the colours used within the document
-	*/
-	void getUsedColors(ColorList &colorsToUse, bool spot = false);
-	/*!
-	* @brief Return if a specific color is used by line styles
-	*/
-	bool lineStylesUseColor(const QString& colorName);
-	/*!
-	* @brief Set the patterns for a document
-	*/
-	bool addPattern(QString &name, ScPattern& pattern);
-	void setPatterns(QMap<QString, ScPattern> &patterns);
+//ivro: standardize param order as PageItem changed each function ?
+//	something like item, args, options ?
+	bool MoveItem(double newX, double newY, PageItem* ite, bool fromMP = false);
 	/*!
-	* @brief Builds a QStringList of the patterns used within the document
-	*/
-	QStringList getUsedPatterns();
-	QStringList getUsedPatternsSelection(Selection* customSelection);
-	QStringList getUsedPatternsHelper(QString pattern, QStringList &results);
-	/**
-	 * @brief Set and get the document's unit index
-	 */
-	void setUnitIndex(const int);
-	int unitIndex() const;
-	double unitRatio() const;
-	/**
-	 * @brief Apply a master page
-	 */
-	bool applyMasterPage(const QString& pageName, const int pageNumber);
-	/**
-	 * @brief Undo function for applying a master page
-	 */
-	void restoreMasterPageApplying(SimpleState *state, bool isUndo);
-	void restorePageCopy(SimpleState *state, bool isUndo);
-	/**
-	 * @brief Undo function for grouping/ungrouping
-	 */
-	void restoreGrouping(SimpleState *state, bool isUndo);
-	void restoreUngrouping(SimpleState *state, bool isUndo);
-	/**
-	 * @brief Save function
-	 */
-	bool save(const QString& fileName, QString* savedFile = NULL);
-	/**
-	 * @brief Set the page margins. Current code uses current page only, also provide a (currently, TODO) option for this.
+	 * \brief Rotate Item.
+	 *
+	 * \param angle angle to rotate
+	 * \param itemNumber index of the item to rotate
 	 */
-	bool changePageMargins(const double initialTop, const double initialBottom, const double initialLeft, const double initialRight, const double initialHeight, const double initialWidth, const double Height, const double width, const int orientation, const QString& pageSize, const int pageNumber=-1, const int pageType = 0);
-	/**
-	 * @brief Recalculate the colors after CMS settings change. Update the items in the doc accordingly.
+	void RotateItem(double angle, int itemNumber);
+	/*!
+	 * \brief Rotate Item.
+	 *
+	 * \param angle angle to rotate
+	 * \param currItem page item to rotate
 	 */
-	 void recalculateColors();
-	/**
-	 * @brief Sets up the ScText defaults from the document
+	void RotateItem(double angle, PageItem *currItem);
+	/*!
+	 * \brief Move and Rotate Item.
+	 *
+	 * \param currItem page item to transform
+	 * \param npv ?
+	 * \param fromMP ?
 	 */
-	void setScTextDefaultsFromDoc(ScText *);
-	/**
-	 * @brief Copies a normal page to be a master pages
+	void MoveRotated(PageItem *currItem, FPoint npv, bool fromMP = false);
+	/*!
+	 * \brief Resize item.
+	 *
+	 * \param newX new X coord
+	 * \param newY new Y coord
+	 * \param ite index of page item to resize
+	 * \param fromMp ?
+	 * \param DoUpdateClip ?
+	 * \param redraw ?
 	 */
-	bool copyPageToMasterPage(const int, const int, const int, const QString&, bool);
-	/**
-	 * @brief Paste an item to the document.
-	 * The bulk of a paste item process runs here for want of a better place, but its a better place
-	 * than the view where it used to be. 
-	 * TODO Once the pageitem restructure is done, this is probably unnecessary but it removes the 
-	 * unnecessary part from the view for now which is overloaded with non ScrollView code.
+	bool SizeItem(double newX, double newY, int ite, bool fromMP = false, bool DoUpdateClip = true, bool redraw = true);
+	/*!
+	 * \brief Resize item.
+	 *
+	 * \param newX new X coord
+	 * \param newY new Y coord
+	 * \param pi page item to resize
+	 * \param fromMp ?
+	 * \param DoUpdateClip ?
+	 * \param redraw ?
 	 */
-	//TODO: void PasteItem(struct CopyPasteBuffer *Buffer, bool loading, bool drag = false);
-	
-	/**
-	 * @brief Add an Item to the document.
-	 * A simple function to create an item of a defined type and add it to the document
-	 * Will need extensive rewriting once we have various classes of PageItems, at a guess.
+	bool SizeItem(double newX, double newY, PageItem *pi, bool fromMP = false, bool DoUpdateClip = true, bool redraw = true);
+	/*!
+	 * \brief Size and Move item.
 	 *
-	 * @param itemFinalised Used to handle item creation for undo while the user is still dragging.
-	 * @return Number of created item, -1 on failure.
-	\param itemType type
-	\param frameType frame type
-	\param x X pos
-	\param y Y pos
-	\param b width
-	\param h height
-	\param w ?
-	\param fill fill color name
-	\param outline outline color name
-	*/
-	int itemAdd(const PageItem::ItemType itemType, const PageItem::ItemFrameType frameType, const double x, const double y, const double b, const double h, const double w, const QString& fill, const QString& outline, const bool itemFinalised);
-
-	/** Add an item to the page based on the x/y position. Item will be fitted to the closest guides/margins */
-	int itemAddArea(const PageItem::ItemType itemType, const PageItem::ItemFrameType frameType, const double x, const double y, const double w, const QString& fill, const QString& outline, const bool itemFinalised);
-	
-	/**
-	 * @brief Allow the user to create a frame easily with some simple placement and sizing options
-	 * @param iafData a InsertAFrameData structure with params
-	 * @return int item id? FIXME
+	 * \param newX new X coord
+	 * \param newY new Y coord
+	 * \param ite index of page item to transform
+	 * \param fromMp ?
+	 * \param constrainRotation ?
 	 */
-	int itemAddUserFrame(InsertAFrameData &iafData);
+	bool MoveSizeItem(FPoint newX, FPoint newY, int ite, bool fromMP = false, bool constrainRotation=false);
+//ivro: don't know what it does
+	void AdjustItemSize(PageItem *currItem);
 
-	/**
-	 * @brief Commit item creation when a user has click-drag created an item
-	 * Only called from ScribusView. Note the undo target is the page, so the undo code remains their for now.
-	 * @return If an item was committed and the view must emit its signal, which needs removing from here, TODO.
+	//void FlipImageH();
+	//void FlipImageV();
+	void MirrorPolyH(PageItem *currItem);
+	void MirrorPolyV(PageItem *currItem);
+
+	// Various
+
+	/*!
+	 * \brief Delete the tagged items.
+	 *
+	 * Currently does nothing
 	 */
-	bool itemAddCommit(const int itemNumber);
-	
-	/**
-	 * @brief Finalise item creation. Simply split off code from itemAdd
-	 * Only to be called from itemAdd()
+	bool deleteTaggedItems();
+	/*!
+	 * \brief Get the item index from a unique ID.
+	 *
+	 * \param unique ID of item
+	 * \return index of the item
 	 */
-	void itemAddDetails(const PageItem::ItemType itemType, const PageItem::ItemFrameType frameType, const int itemNumber);
-
 	uint getItemNrfromUniqueID(uint unique);
-	//itemDelete
-	//itemBlah...
-	
-	/**
-	 * @brief Run this common frame item update code
+	/*!
+	 * \brief Run this common frame item update code.
 	 */
 	void updateFrameItems();
-	/**
-	 * @brief Renumbers the items into the order they are stored in in the lists.
+	/*!
+	 * \brief Renumbers the items into the order they are stored in in the lists.
+	 *
 	 * Utility function used in various places, basically handles keeping items numbered in the way
 	 * they are layered. When layer is a property and not a fuction of storage, this should be removed.
 	 * Depends on the Items pointer pointing to the correct item list (doc, master, etc).
 	 * @sa updateFrameItems();
 	 */
 	void renumberItemsInListOrder();
-	/**
-	 * @brief Rebuild item lists taking into account layer order.
+	/*!
+	 * \brief Rebuild item lists taking into account layer order.
+	 *
 	 * Utility function used in various places, basically handles keeping items numbered in the way
 	 * they are layered. When layer is a property and not a fuction of storage, this should be removed.
 	 * @sa updateFrameItems();
 	 */
 	void rebuildItemLists();
-	/**
-	 * @brief Doc uses automatic text frames?
-	 */
-	bool usesAutomaticTextFrames() const;
-	void setUsesAutomaticTextFrames(const bool);
-	
-	/**
-	 * @brief Load images into an image frame, moved from the view
-	 * @retval Return false on failure
-	 */
-	bool LoadPict(QString fn, int ItNr, bool reload = false, bool showMsg = false);
-	/**
-	 * 
-	 * @param fn 
-	 * @param pageItem 
-	 * @param reload 
-	 * @return 
-	 */
-	bool loadPict(QString fn, PageItem *pageItem, bool reload = false, bool showMsg = false);
-	/**
-	 * \brief Handle image with color profiles
-	 * @param Pr profile
-	   @param PrCMYK cmyk profile
-	   @param dia optional progress widget
-	 */
-	void RecalcPictures(ProfilesL *Pr, ProfilesL *PrCMYK, QProgressBar *dia = 0);
-	/**
-	 * @brief Find the minX,MinY and maxX,maxY for the canvas required for the doc
-	 */
-	void canvasMinMax(FPoint&, FPoint&);
-	
-	int OnPage(double x2, double  y2);
-	int OnPage(PageItem *currItem);
-	void GroupOnPage(PageItem *currItem);
-	//void reformPages(double& maxX, double& maxY, bool moveObjects = true);
-	void reformPages(bool moveObjects = true);
-	
-	/**
-	 * @brief Return the x or y offset for a page on the canvas
-	 * @retval double containing the offset. Returns -1.0 if page not in Pages list (as -ve is not possible).
-	 * Mostly saves bringing in extra includes into files that already have scribusdoc.h
-	 */
-	double getXOffsetForPage(const int);
-	double getYOffsetForPage(const int);
-	void getBleeds(int pageNumber, MarginStruct& bleedData);
-	void getBleeds(Page* page, MarginStruct& bleedData);
-	
-	/**
-	 * @brief Item type conversion functions
-	 */
-	PageItem* convertItemTo(PageItem *currItem, PageItem::ItemType newType, PageItem* secondaryItem=NULL);
-	
-	/**
-	 * @brief The page number of the current page
-	 */
-	int currentPageNumber();
-	
-	/**
-	 * @brief Return true iff the passed name is not used by any existing PageItem
+	/*!
+	 * \brief Find if item is not an already used item.
+	 *
+	 * Return true if the passed name is not used by any existing PageItem
 	 *        in the same document as this PageItem.
-	 * @author Craig Ringer
+	 * \author Craig Ringer
 	 ** CB Moved from PageItem
 	 */
+//ivro: is returning true if the passed name exists not better ? (or rename to itemNameDontUses ?)
 	bool itemNameExists(const QString itemName);
-	
-	/**
-	 * @brief Set the doc into Master page mode
-	 * Do we need to return if the move to master page mode was successful?
+	/*!
+	 * \brief Returns a stringlist of the item attributes within the document.
 	 */
-	void setMasterPageMode(bool);
+	QStringList getItemAttributeNames();
 
-	/*** Is the document in master page mode? */
-	bool masterPageMode() const { return m_masterPageMode; }
-	
-	/**
-	 * @brief Add a section to the document sections list
+	/*!
+	 * \brief Get a list of frames of certain type.
+	 */
+	QMap<PageItem*, QString> getDocItemNames(PageItem::ItemType itemType);
+//@} //End Items group
+
+/*! \name Sections
+ * \brief Sections related functions
+ */ //@{
+	// add, delete, use sections
+
+	/*!
+	 * \brief Add a section to the document sections list.
+	 *
 	 * Set number to -1 to add in the default section if the map is empty
 	 */
 	void addSection(const int number=0, const QString& name=QString::null, const uint fromindex=0, const uint toindex=0, const  DocumentSectionType type=Type_1_2_3, const uint sectionstartindex=0, const bool reversed=false, const bool active=true);
-	/**
-	 * @brief Delete a section from the document sections list
+	/*!
+	 * \brief Delete a section from the document sections list.
 	 */
 	bool deleteSection(const uint);
-	/**
-	 * @brief Gets the page number to be printed based on the section it is in.
+	/*!
+	 * \brief Gets the page number to be printed based on the section it is in.
+	 *
 	 * Returns QString::null on failure to find the pageIndex
 	 */
 	const QString getSectionPageNumberForPageIndex(const uint) const;
-	/**
-	 * @brief Gets the key of the sections map based on the section the page index is in.
+	/*!
+	 * \brief Gets the key of the sections map based on the section the page index is in.
+	 *
 	 * Returns -1 on failure to find the pageIndex
 	 */
 	int getSectionKeyForPageIndex(const uint pageIndex) const;
-	/**
+	/*!
 	 *
 	 *
 	 */
 	void updateSectionPageNumbersToPages();
-	/**
-	 * 
-	 * @param otherPageIndex 
-	 * @param location 
-	 * @param count 
+	/*!
+	 *
+	 * \param otherPageIndex
+	 * \param location
+	 * \param count
 	 */
 	void addPageToSection(const uint otherPageIndex, const uint location, const uint count=1);
-	/**
-	 * 
-	 * @param pageIndex 
+	/*!
+	 *
+	 * \param pageIndex
 	 */
 	void removePageFromSection(const uint pageIndex);
-	/**
-	 * 
+	/*!
+	 *
 	 */
 	void setFirstSectionFromFirstPageNumber();
-	/**
-	 * @brief Update the fill and line QColors for all items in the doc
-	 */
-	void updateAllItemQColors();
-	//! @brief Some internal align tools
-	typedef enum {alignFirst, alignLast, alignPage, alignMargins, alignGuide, alignSelection } AlignTo;
+//@} // End of Sections group
+
+/*! \name Align
+ * Align related functions
+ */ //@{
 	void buildAlignItemList(Selection* customSelection=0);
 	bool startAlign();
 	void endAlign();
-	/**
-	 * \brief Insert a color into the documents color list
-	 * @param nam Name of the colour
-	 * @param c Cyan component
-	 * @param m Magenta component
-	 * @param y Yellow component
-	 * @param k Black component
-	 */
-	void insertColor(QString nam, double c, double m, double y, double k);
-	
-	QMap<QString, double>& constants() { return m_constants; }
-	/**
-	 * \brief Get the location of the page on the canvas, ie, left, middle, or right
-	 * Does not give information about middle left, etc.
-	 * @param pageIndex Index of page to find location for
-	 * @return LeftPage, MiddlePage, RightPage, enum from pagestructs.h
+//@} // End of align functions
+
+/*! \name Styles
+ * Style related functions
+ */ //@{
+	// Paragraphe style
+
+	/*!
+	 * \brief Get a paragraph style by its name.
 	 */
-	PageLocation locationOfPage(int pageIndex) const;
-	/**
-	 * \brief Get the column of the page on the canvas, ie, left, middle, or right
-	 * @param pageIndex Index of page to find location for
-	 * @return int of 0,1,2,3
+	const ParagraphStyle& paragraphStyle(QString name) { return docParagraphStyles.get(name); }
+	/*!
+	 * \brief Get all the paragraph style.
 	 */
-	int columnOfPage(int pageIndex) const;
-	
+	const StyleSet<ParagraphStyle>& paragraphStyles()   { return docParagraphStyles; }
+	/*!
+	 * \brief Redefine Paragraphes style.
+	 */
+//ivro: rename rededineParaStyles ?
+	void redefineStyles(const StyleSet<ParagraphStyle>& newStyles, bool removeUnused=false);
+	/*!
+	 * \brief Remove any reference to old styles and replace with new name.
+	 *
+	 * This needs to be called when a style was removed. New name may be "".
+	 * \param newNameForOld a map which maps the name of any style to remove to a new stylename
+	 */
+//ivro: rename replaceParaStyles ?
+	void replaceStyles(const QMap<QString,QString>& newNameForOld);
+	/*!
+	 * \brief Is the default paragraph style ?
+	 *
+	 * \param p paragraph style to test
+	 */
+//ivro: is this must be with the one for char style ?
+	bool isDefaultStyle( const ParagraphStyle& p ) const { return docParagraphStyles.isDefault(p); }
+
+	// Character style
+
+	/*!
+	 * \brief Get a character style by name.
+	 *
+	 * \param name char style name
+	 */
+	const CharStyle& charStyle(QString name) { return docCharStyles.get(name); }
+	/*!
+	 * \brief Get all the Character styles.
+	 */
+	const StyleSet<CharStyle>& charStyles()  { return docCharStyles; }
+	/*!
+	 * \brief Redefine Character styles.
+	 *
+	 * \param newStyle character styles
+	 * \param removeUnused
+	 */
+	void redefineCharStyles(const StyleSet<CharStyle>& newStyles, bool removeUnused=false);
+	/*!
+	 * \brief Remove any reference to old styles and replace with new name.
+	 *
+	 * This needs to be called when a style was removed. New name may be "".
+	 * \param newNameForOld a map which maps the name of any style to remove to a new stylename
+	 */
+	void replaceCharStyles(const QMap<QString,QString>& newNameForOld);
+	/*!
+	 * \brief Is the default character style ?
+	 *
+	 * \param c character style to test
+	 */
+	bool isDefaultStyle( const CharStyle& c ) const { return docCharStyles.isDefault(c); }
+// 	bool isDefaultStyle( LineStyle& l ) const { return MLineStyles......; }
+
+	// Load Style
+
+	/*!
+	 * \brief Insert styles from another document in this document.
+	 *
+	 * \param fileName The path of the document we want to extract its styles
+	 */
+	void loadStylesFromFile(QString fileName);
+	/*!
+	 * \brief Gather styles from another document.
+	 *
+	 * \param fileName The path of the document we want to extract its styles
+	 * \param tempStyles A pointer to a StyleSet which will be filled by paragraph styles
+	 * \param tempCharStyles A pointer to a StyleSet which will be filled by character styles
+	 * \param tempLineStyles A map which will be filled by line styles
+	 */
+	void loadStylesFromFile(QString fileName, StyleSet<ParagraphStyle> *tempStyles,
+	                                          StyleSet<CharStyle> *tempCharStyles,
+	                                          QMap<QString, multiLine> *tempLineStyles);
+//@} // End of style group
+
+/*! \name Color Management
+ * \brief Color Management related functions.
+ */ //@{
+	/*!
+	 * \brief Builds a qmap of the icc profiles used within the document.
+	 */
+	void getUsedProfiles(ProfilesL& usedProfiles);
+	bool OpenCMSProfiles(ProfilesL InPo, ProfilesL InPoCMYK, ProfilesL MoPo, ProfilesL PrPo);
+	void CloseCMSProfiles();
+	void SetDefaultCMSParams();
+	/*!
+	 * \brief Switch Colormanagement on or of.
+	 *
+	 * \param enable bool, if true Colormanagement is switched on, else off
+	 */
+	void enableCMS(bool enable);
+	/*!
+	 * \brief Recalculate the colors after CMS settings change.
+	 *
+	 * Update the items in the doc accordingly.
+	 */
+	void recalculateColors();
+
+	/*!
+	 * \brief Insert a color into the documents color list.
+	 *
+	 * \param colorList Name of the color list
+	 * \param cyan Cyan component
+	 * \param magenta Magenta component
+	 * \param yellow Yellow component
+	 * \param black Black component
+	 */
+	void insertColor(QString colorList, double cryan, double magenta, double yellow, double black);
+	/*!
+	 * \brief Replace line style colors.
+	 */
+	void replaceLineStyleColors(const QMap<QString, QString>& colorMap);
+	/*!
+	* \brief Builds a qmap of the colours used within the document.
+	*/
+	void getUsedColors(ColorList &colorsToUse, bool spot = false);
+	/*!
+	* \brief Is this specific color is used by line styles.
+	*/
+	bool lineStylesUseColor(const QString& colorName);
+//@} // End of color functions
+
+/*! \name Font
+ * \brief Font related funtions.
+ */ //@{
+	/*!
+	 * \brief Add a font.
+	 */
+	bool AddFont(QString name, int fsize = 10);
+	/*!
+	 * TODO: Reorganise the fonts.. how? Moved from scribus.cpp
+	 * CB: almost the same as getUsedFonts???
+	 */
+	QMap<QString,int> reorganiseFonts();
+	/*!
+	 * \brief Returns a qmap of the fonts and  their glyphs used within the document.
+	 */
+	void getUsedFonts(QMap<QString,QMap<uint, FPointArray> > &Really);
+	void checkItemForFonts(PageItem *it, QMap<QString, QMap<uint, FPointArray> > & Really, uint lc);
+//@} // End of font functions
+
+/*! \name Patterns
+ * \brief Pattern related functions.
+ */ //@{
+	/*!
+	* \brief Set the patterns for a document.
+	*/
+	bool addPattern(QString &name, ScPattern& pattern);
+	void setPatterns(QMap<QString, ScPattern> &patterns);
+	/*!
+	* \brief Builds a QStringList of the patterns used within the document.
+	*/
+	QStringList getUsedPatterns();
+	QStringList getUsedPatternsSelection(Selection* customSelection);
+	QStringList getUsedPatternsHelper(QString pattern, QStringList &results);
+//@} // End of patterns functions
+
+/*! \name Item selection
+ * \brief Item selection related functions.
+ *
+ * Item selection is used to modify items.
+ */ //@{
 	bool sendItemSelectionToBack();
 	bool bringItemSelectionToFront();
 
@@ -835,76 +1268,329 @@ public:
 	void itemSelection_SetStrikethru(int pos, int wid, Selection* customSelection=0);
 	void itemSelection_SetEffects(int s, Selection* customSelection=0);
 	void itemSelection_SetOpticalMargins(int i, Selection* customSelection=0);
-	void itemSelection_resetOpticalMargins(Selection* customSelection=0);
 	void itemSelection_SetColorProfile(const QString& profileName, Selection* customSelection=0);
 	void itemSelection_SetRenderIntent(int intentIndex, Selection* customSelection=0);
-	
+
 //	void chAbStyle(PageItem *currItem, int s);
 
 	void itemSelection_SetTracking(int us, Selection* customSelection=0);
 	void itemSelection_SetFontSize(int size, Selection* customSelection=0);
-	//void FlipImageH();
-	//void FlipImageV();
-	void MirrorPolyH(PageItem *currItem);
-	void MirrorPolyV(PageItem *currItem);
-	
+public slots:
+	void itemSelection_ToggleLock();
+	void itemSelection_ToggleSizeLock();
+	void itemSelection_ToggleImageShown();
+	void itemSelection_TogglePrintEnabled();
+	void itemSelection_ChangePreviewResolution(int id);
+	void itemSelection_ClearItem(Selection* customSelection=0);
+	//! Delete the items in the current selection. When force is true, we do not warn the user and make SE happy too. Force is used from @sa Page::restorePageItemCreation
+	void itemSelection_DeleteItem(Selection* customSelection=0, bool forceDeletion=false);
+	void itemSelection_SetItemFillTransparency(double t);
+	void itemSelection_SetItemLineTransparency(double t);
+	void itemSelection_SetItemFillBlend(int t);
+	void itemSelection_SetItemLineBlend(int t);
+	void itemSelection_SetLineGradient(VGradient& newGradient, Selection* customSelection=0);
+	void itemSelection_SetFillGradient(VGradient& newGradient, Selection* customSelection=0);
+	void itemSelection_SetOverprint(bool overprint, Selection* customSelection=0);
+	void itemSelection_ApplyImageEffects(ScImageEffectList& newEffectList, Selection* customSelection=0);
+	void itemSelection_FlipH();
+	void itemSelection_FlipV();
+	void itemSelection_DoHyphenate();
+	void itemSelection_DoDeHyphenate();
+	void itemSelection_SendToLayer(int layerNumber);
+	void itemSelection_SetImageOffset(double x, double y, Selection* customSelection=0);
+	void itemSelection_SetImageScale(double x, double y, Selection* customSelection=0);
+	void itemSelection_SetImageScaleAndOffset(double ox, double oy, double sx, double sy, Selection* customSelection=0);
+	void itemSelection_AlignLeftOut(AlignTo currAlignTo, double guidePosition);
+	void itemSelection_AlignRightOut(AlignTo currAlignTo, double guidePosition);
+	void itemSelection_AlignBottomIn(AlignTo currAlignTo, double guidePosition);
+	void itemSelection_AlignRightIn(AlignTo currAlignTo, double guidePosition);
+	void itemSelection_AlignBottomOut(AlignTo currAlignTo, double guidePosition);
+	void itemSelection_AlignCenterHor(AlignTo currAlignTo, double guidePosition);
+	void itemSelection_AlignLeftIn(AlignTo currAlignTo, double guidePosition);
+	void itemSelection_AlignCenterVer(AlignTo currAlignTo, double guidePosition);
+	void itemSelection_AlignTopOut(AlignTo currAlignTo, double guidePosition);
+	void itemSelection_AlignTopIn(AlignTo currAlignTo, double guidePosition);
+	void itemSelection_DistributeDistH(bool usingDistance=false, double distance=0.0);
+	void itemSelection_DistributeAcrossPage(bool useMargins=false);
+	void itemSelection_DistributeRight();
+	void itemSelection_DistributeBottom();
+	void itemSelection_DistributeCenterH();
+	void itemSelection_DistributeDistV(bool usingDistance=false, double distance=0.0);
+	void itemSelection_DistributeDownPage(bool useMargins=false);
+	void itemSelection_DistributeLeft();
+	void itemSelection_DistributeCenterV();
+	void itemSelection_DistributeTop();
+	void itemSelection_MultipleDuplicate(ItemMultipleDuplicateData&);
+	void itemSelection_UniteItems(Selection* customSelection=0);
+	void itemSelection_SplitItems(Selection* customSelection=0);
+	/*!
+	 * \brief Adjust an image frame's size to fit the size of the image in it.
+	 */
+	void itemSelection_AdjustFrametoImageSize(Selection* customSelection=0);
+	/*!
+	 * \brief Adjust an image size to fit the size of the frame.
+	 */
+	void itemSelection_AdjustImagetoFrameSize(Selection* customSelection=0);
+	/*!
+	 * \brief startArrowID or endArrowID of -1 mean not applying a selection at this point.
+	 */
+	void itemSelection_ApplyArrowHead(int startArrowID=-1, int endArrowID=-1, Selection* customSelection=0);
+
+	void itemSelection_SetItemPen(QString farbe);
+	void itemSelection_SetItemPenShade(int sha);
+	void itemSelection_SetItemBrush(QString farbe);
+	void itemSelection_SetItemBrushShade(int sha);
+	void itemSelection_SetItemGradFill(int typ);
+	void itemSelection_SetItemPatternFill(QString pattern);
+	void itemSelection_SetItemPatternProps(double scaleX, double scaleY, double offsetX, double offsetY, double rotation);
+//@} // End of item selection group
+
+public:
+
+/*! \name Various functions
+ */ //@{
+
+	/*!
+	 * \brief Save function.
+	 */
+	bool save(const QString& fileName, QString* savedFile = NULL);
+
+	/*!
+	 * \brief Create the default master pages based on the layout selected by the user, ie, Normal, Normal Left, etc.
+	 */
+	void createDefaultMasterPages();
+	/*!
+	 * \brief Create the requested pages in a new document.
+	 *
+	 * Run after ScribusDoc.createDefaultMasterPages()
+	 * \param pageCount number of page to create
+	 */
+	void createNewDocPages(int pageCount);
+
+	/*!
+	 * \brief Update the fill and line QColors for all items in the doc.
+	 */
+	void updateAllItemQColors();
+
+	/*!
+	 * \brief Sets up the ScText defaults from the document.
+	 */
+	void setScTextDefaultsFromDoc(ScText *);
+
+// Restore
+
+	/*!
+	 * \brief Method used when an undo/redo is requested.
+	 *
+	 * \param state State describing the action that is wanted to be undone/redone
+	 * \param isUndo If true undo is wanted else if false redo.
+	 * \author Riku Leino
+	 */
+	void restore(UndoState* state, bool isUndo);
+	/*!
+	 * \brief Undo function for applying a master page.
+	 */
+	void restoreMasterPageApplying(SimpleState *state, bool isUndo);
+	/*!
+	 * \brief Undo function for copy a page.
+	 */
+	void restorePageCopy(SimpleState *state, bool isUndo);
+	/*!
+	 * \brief Undo function for grouping/ungrouping.
+	 */
+	void restoreGrouping(SimpleState *state, bool isUndo);
+	void restoreUngrouping(SimpleState *state, bool isUndo);
+// Loading images
+
+	/*!
+	 * \brief Load images into an image frame, moved from the view.
+	 *
+	 * \param fn image file name
+	 * \param ItNr page item number
+	 * \param reload
+	 * \param showMsg
+	 * \return Return false on failure
+	 */
+	bool LoadPict(QString fn, int ItNr, bool reload = false, bool showMsg = false);
+	/*!
+	 * \brief Load images into an image frame.
+	 *
+	 * \param fn image file name
+	 * \param pageItem page item
+	 * \param reload
+	 * \param showMsg
+	 * \return Return false on failure
+	 */
+	bool loadPict(QString fn, PageItem *pageItem, bool reload = false, bool showMsg = false);
+	/*!
+	 * \brief Handle image with color profiles.
+	 *
+	 * \param Pr profile
+	 * \param PrCMYK cmyk profile
+	 * \param dia optional progress widget
+	 */
+	void RecalcPictures(ProfilesL *Pr, ProfilesL *PrCMYK, QProgressBar *dia = 0);
+public slots:
+	/*!
+	 * \brief Update all the picture in the current selection.
+	 */
+	void updatePic();
+	/*!
+	 * \brief Update the specified picture.
+	 */
+	void updatePict(QString name);
+	/*!
+	 * \brief Update all picture in the specified directory.
+	 */
+	void updatePictDir(QString name);
+	/*!
+	 * \brief Remove a picture from document.
+	 */
+	void removePict(QString name);
+public:
+	/*!
+	 * \brief Find the minX,MinY and maxX,maxY for the canvas required for the doc.
+	 *
+	 * \param minPoint
+	 * \param maxPoint
+	 */
+	void canvasMinMax(FPoint& minPoint, FPoint& maxPoint);
+
+	/*!
+	 * \brief Find page index where the point exists.
+	 *
+	 * In masterPage mode return the current master page index if the point exists on the current master page,
+	 * In normal mode return the first page index where this point exists.
+	 *
+	 * \param x X coord of the point
+	 * \param y Y coord of the point
+	 * \return page index or -1
+	 */
+	int OnPage(double x, double  y);
+	/*!
+	 * \brief Find page index where the item exists.
+	 *
+	 * In masterPageMode return the current master page index if the item exists on the current master page.
+	 * In mormal mode return the page index where this item exists.
+	 *
+	 * \param item item we looking for
+	 * \return page index or -1
+	 */
+	int OnPage(PageItem *item);
+
+	void GroupOnPage(PageItem *currItem);
+	//void reformPages(double& maxX, double& maxY, bool moveObjects = true);
+	void reformPages(bool moveObjects = true);
 	void setRedrawBounding(PageItem *currItem);
 	void adjustCanvas(FPoint minPos, FPoint maxPos, bool absolute = false);
 	void recalcPicturesRes(bool applyNewRes = false);
 	void connectDocSignals();
-	void removeLayer(int l, bool dl = false); //FIXME: Make protected once scripter function no longer uses this directly
-	/*! \brief We call changed() whenever the document needs to know it has been changed.
-	 *  If the document is the primary document in a main window, it will signal to enable/disable
-	 * certain operations.
+
+// Named Ressources
+
+	void getNamedResources(ResourceCollection& lists) const;
+	void replaceNamedResources(ResourceCollection& newNames);
+
+
+	QMap<QString, double>& constants() { return m_constants; }
+
+// Grid and Guides
+
+	/*!
+	 * \brief Apply grid to a QPoint, from ScribusView.
 	 */
-	void changed();
-	/*! \brief Get pointer to the current page
-	\retval Page* current page object */
-	Page* currentPage();
-	/*! \brief Set new current page
-	\param newPage New current page */
-	void setCurrentPage(Page *newPage);
-	bool hasGUI() const {return m_hasGUI;}
-	/*! \brief Apply grid to a QPoint, from ScribusView */
 	QPoint ApplyGrid(const QPoint& in);
-	/*! \brief Apply grid to an FPoint, from ScribusView */
+	/*!
+	 * \brief Apply grid to an FPoint, from ScribusView.
+	 */
 	FPoint ApplyGridF(const FPoint& in);
-	/*! \brief Does this doc have any TOC setups and potentially a TOC to generate */
-	bool hasTOCSetup() { return !docToCSetups.empty(); }
-	//! \brief Get the closest guide to the given point
+
+	/*!
+	 * \brief Get the closest guide to the given point.
+	 */
 	void getClosestGuides(double xin, double yin, double *xout, double *yout, int *GxM, int *GyM);
-	//! \brief Snap an item to the guides
+	/*!
+	 * \brief Snap an item to the guides.
+	 */
 	void SnapToGuides(PageItem *currItem);
 	bool ApplyGuides(double *x, double *y);
-	bool MoveItem(double newX, double newY, PageItem* ite, bool fromMP = false);
-	void RotateItem(double win, int ite);
-	void RotateItem(double win, PageItem *currItem);
-	void MoveRotated(PageItem *currItem, FPoint npv, bool fromMP = false);
-	bool SizeItem(double newX, double newY, int ite, bool fromMP = false, bool DoUpdateClip = true, bool redraw = true);
-	bool SizeItem(double newX, double newY, PageItem *pi, bool fromMP = false, bool DoUpdateClip = true, bool redraw = true);
-	bool MoveSizeItem(FPoint newX, FPoint newY, int ite, bool fromMP = false, bool constrainRotation=false);
-	void AdjustItemSize(PageItem *currItem);
+
+	/*!
+	 * \brief Does this doc have any TOC setups and potentially a TOC to generate.
+	 */
+	bool hasTOCSetup() { return !docToCSetups.empty(); }
+
+// Group
+
 	void moveGroup(double x, double y, bool fromMP = false, Selection* customSelection = 0);
 	void rotateGroup(double angle, FPoint RCenter);
 	void scaleGroup(double scx, double scy, bool scaleText=true, Selection* customSelection = 0);
-	//! \brief Get a list of frames of certain type
-	QMap<PageItem*, QString> getDocItemNames(PageItem::ItemType itemType);
-	
+
+	/*!
+	 * \brief Return the guarded object associated with the document.
+	 */
+	const ScGuardedPtr<ScribusDoc>& guardedPtr() const;
+
+	UpdateManager* updateManager() { return &m_updateManager; }
+	MassObservable<PageItem*> * itemsChanged() { return &m_itemsChanged; }
+	MassObservable<Page*>     * pagesChanged() { return &m_pagesChanged; }
+	MassObservable<QRectF>    * regionsChanged() { return &m_regionsChanged; }
+	void invalidateRegion(QRectF region);
+
+	void undoRedoBegin();
+	void undoRedoDone();
+
+public:
+	/*!
+	 * \brief We call changed() whenever the document needs to know it has been changed.
+	 *
+	 * If the document is the primary document in a main window, it will signal to enable/disable
+	 * certain operations.
+	 */
+	void changed();
+public slots:
+	/*!
+	 * \brief Change display quality of all images in document.
+	 * \author  OssiLehtinen
+	 */
+	void allItems_ChangePreviewResolution(int id);
 protected:
 	void addSymbols();
-	bool m_hasGUI;
+//@} // End of various group
+
+signals:
+	//Lets make our doc talk to our GUI rather than confusing all our normal stuff
+	/*!
+	 * \brief Let the document tell whatever is listening that it has changed.
+	 */
+	void docChanged();
+	void updateContents();
+	void updateContents(const QRect &r);
+	void refreshItem(PageItem *);
+	void canvasAdjusted(double width, double height, double dX, double dY);
+	void firstSelectedItemType(int);
+	void setApplicationMode(int);
+	/*!
+	 * \brief A signal for when the outline palette needs to rebuild itself.
+	 *
+	 * Emit when:
+	 * - An item is created or deleted
+	 * - An item changes page
+	 * - An page is created or deleted
+	 * - Some items are grouped or a group is ungrouped
+	 * This also applies to Master Pages
+	 */
+	void signalRebuildOutLinePalette();
+	/*!
+	 * \brief Temporary signal for SizeItem.
+	 */
+	void widthAndHeight(double, double);
+
+protected:
 	ApplicationPrefs& prefsData;
 	UndoManager * const undoManager;
-	bool loading;
-	bool modified;
 	int ActiveLayer;
-	int docUnitIndex;
-	double docUnitRatio;
-	bool automaticTextFrames; // Flag for automatic Textframes
-	bool m_masterPageMode;
 	QMap<QString, double> m_constants;
-	ScribusMainWindow* m_ScMW;
-	ScribusView* m_View;
 	ScGuardedObject<ScribusDoc> m_guardedObject;
 	
 public: // Public attributes
@@ -915,71 +1601,60 @@ public: // Public attributes
 	int viewCount;
 	int viewID;
 	bool SnapGuides;
-	bool GuideLock;
-	/** \brief Scratch space around Pages */
+	/*! \brief Scratch space around Pages */
 	MarginStruct scratch;
-	double GapHorizontal;
-	double GapVertical;
+	double GapHorizontal;			/*!< \brief Horizontal gap between page on canvas. */
+	double GapVertical;			/*!< \brief Vertical gap betwwen page on canvas. */
 // 	double ScratchLeft;
 // 	double ScratchRight;
 // 	double ScratchTop;
 // 	double ScratchBottom;
-	/** \brief Minimum and Maximum Points of Document */
-	FPoint minCanvasCoordinate;
-	FPoint maxCanvasCoordinate;
+	FPoint minCanvasCoordinate;		/*!< \brief Minimum point of document. */
+	FPoint maxCanvasCoordinate;		/*!< \brief Maximum point of document. */
 	double rulerXoffset;
 	double rulerYoffset;
-	/** \brief List of Pages */
-	QList<Page*>* Pages;
-	/** \brief List of Master Pages */
-	QList<Page*> MasterPages;
-	/** \brief List of Document Pages */
-	QList<Page*> DocPages;
-	/** \brief Mapping Master Page Name to Master Page numbers */
-	QMap<QString,int> MasterNames;
-	/** \brief List of Objects */
-	QList<PageItem*>* Items;
-	QList<PageItem*> MasterItems;
-	QList<PageItem*> DocItems;
 	QList<PageItem*> FrameItems;
 	Selection* const m_Selection;
-	/** \brief Pagewidth  */
-	double pageWidth;
-	/** \brief Pageheight */
-	double pageHeight;
+	double pageWidth;			/*!< \brief Default page's width. */
+	double pageHeight;			/*!< \brief Default page's height. */
 	/* Number of Pages */
 	// int pageCount; Disabled CR no longer required
-	/** \brief Margins */
-	MarginStruct pageMargins;
+	MarginStruct pageMargins;		/*!< \brief Default page's margins. */
 	int marginPreset;
-	QList<PageSet> pageSets;
-	MarginStruct bleeds;
+//ivro: is this cannot be moved elsewhere
+//	Save only the current pageSets and when we change it, copy the new here.
+	QList<PageSet> pageSets;		/*!< \brief List of page layout supported by Scribus. */
+	int currentPageLayout;			/*!< \brief Index of the currently used page layout. \details See ScribusDoc::pageSets. */
+	MarginStruct bleeds;			/*!< Default page's bleeds. */
 // 	double BleedTop;
 // 	double BleedLeft;
 // 	double BleedRight;
 // 	double BleedBottom;
-	/** \brief Number of Columns */
-	double PageSp;
-	/** \brief Distance of Columns */
-	double PageSpa;
-	/** \brief current Pagelayout */
-	int currentPageLayout;
-	/** \brief Flag fuer Hoch- oder Querformat 0 = Hochformat */
-	int PageOri;
-	QString m_pageSize;
-	/** \brief Erste Seitennummer im Dokument */
+	double PageSp;				/*!< \brief Number of Columns for AutomaticTextFrame. */
+	double PageSpa;				/*!< \brief Distance between columns for AutomaticTextFrame. */
+//ivro: use the scribusstruct PageOrientation enum ?
+	int PageOri;				/*!< \brief Default page's orientation. \details O => Portrait, 1 = Landscape. */
+	QString m_pageSize;			/*!< \brief Default page's format. */
+	/*!
+	 * \brief Erste Seitennummer im Dokument.
+	 */
 	int FirstPnum;
-	/** \brief Flag fuer Rasterbenutzung */
+	/*!
+	 * \brief Flag fuer Rasterbenutzung.
+	 */
 	bool useRaster;
-	/** \brief Im Dokument benutzte Farben */
+	/*!
+	 * \brief Im Dokument benutzte Farben.
+	 */
 	ColorList PageColors;
-	/** \brief InfoStrings fuer das aktuelle Dokument */
+	/*!
+	 * \brief InfoStrings fuer das aktuelle Dokument.
+	 */
 	DocumentInformation documentInfo;
 	int appMode;
 	int SubMode;
 	double *ShapeValues;
 	int ValCount;
-	QString DocName;
 	QMap<QString,int> UsedFonts;
 	SCFonts * const AllFonts;
 	QList<AlignObjs> AObjects;
@@ -994,10 +1669,8 @@ public: // Public attributes
 	toolPrefs toolSettings;
 	QMap<QString, checkerPrefs> checkerProfiles;
 	QString curCheckProfile;
-	/** \brief Letztes Element fuer AutoTextrahmen */
-	PageItem *LastAuto;
-	/** \brief Erstes Element fuer AutoTextrahmen */
-	PageItem *FirstAuto;
+	PageItem *LastAuto;			/*!< \brief The last AutomaticTextFrame element. */
+	PageItem *FirstAuto;			/*!< \brief The first AutomaticTextFrame element. */
 	bool DragP;
 	bool leaveDrag;
 	PageItem *DraggedElem;
@@ -1045,23 +1718,23 @@ public:
 	PrintOptions Print_Options;
 	bool RePos;
 	struct BookMa {
-					QString Title;
-					QString Text;
-					QString Aktion;
-					PageItem *PageObject;
-					int Parent;
-					int ItemNr;
-					int First;
-					int Last;
-					int Prev;
-					int Next;
-					};
+		QString Title;
+		QString Text;
+		QString Aktion;
+		PageItem *PageObject;
+		int Parent;
+		int ItemNr;
+		int First;
+		int Last;
+		int Prev;
+		int Next;
+	};
 	QList<BookMa> BookMarks;
 	bool OldBM;
 	bool hasName;
 	int RotMode;
-	bool AutoSave;
-	int AutoSaveTime;
+	bool AutoSave;				/*!< \brief Is autosaved ? */
+	int AutoSaveTime;			/*!< \brief Time in milliseconds between autosave. */
 	QTimer * const autoSaveTimer;
 	QMap<QString,multiLine> MLineStyles;
 	QList<ArrowDesc> arrowStyles;
@@ -1082,7 +1755,7 @@ public:
 	//Attributes to be applied to frames
 	ObjAttrVector docItemAttributes;
 	ToCSetupVector docToCSetups;
-	DocumentSectionMap sections;
+	DocumentSectionMap sections;		/*!< \brief Map of document's sections */
 	FPointArray symReturn;
 	FPointArray symNewLine;
 	FPointArray symTab;
@@ -1095,118 +1768,41 @@ private:
 	UndoTransaction* m_itemCreationTransaction;
 	UndoTransaction* m_alignTransaction;
 
-	Page* m_currentPage;
 	UpdateManager m_updateManager;
 	MassObservable<PageItem*> m_itemsChanged;
 	MassObservable<Page*> m_pagesChanged;
 	MassObservable<QRectF> m_regionsChanged;
 	DocUpdater* m_docUpdater;
-	
-signals:
-	//Lets make our doc talk to our GUI rather than confusing all our normal stuff
-	/**
-	 * @brief Let the document tell whatever is listening that it has changed
-	 */
-	void docChanged();
-	void updateContents();
-	void updateContents(const QRect &r);
-	void refreshItem(PageItem *);
-	void canvasAdjusted(double width, double height, double dX, double dY);
-	void firstSelectedItemType(int);
-	void setApplicationMode(int);
-	/**
-	 * @brief A signal for when the outline palette needs to rebuild itself
-	 * Emit when:
-	 * - An item is created or deleted
-	 * - An item changes page
-	 * - An page is created or deleted
-	 * - Some items are grouped or a group is ungrouped
-	 * This also applies to Master Pages
-	 */
-	void signalRebuildOutLinePalette();
-	//! Temporary signal for SizeItem
-	void widthAndHeight(double, double);
-	
-public slots:
-	void itemSelection_ToggleLock();
-	void itemSelection_ToggleSizeLock();
-	void itemSelection_ToggleImageShown();
-	void itemSelection_TogglePrintEnabled();
-	void itemSelection_ChangePreviewResolution(int id);
 
-	/*! \brief Change display quality of all images in document.
-	\author  OssiLehtinen
-	*/
-	void allItems_ChangePreviewResolution(int id);
+public:
+	QList<Page*>* Pages;			/*!< \brief Pointer on a list of pages. \details See masterPageMode() */
+	QList<Page*> MasterPages;	 	/*!< \brief List of Master Pages. */
+	QList<Page*> DocPages;			/*!< \brief List of Document Pages. */
 
-	void itemSelection_ClearItem(Selection* customSelection=0);
-	//! Delete the items in the current selection. When force is true, we do not warn the user and make SE happy too. Force is used from @sa Page::restorePageItemCreation
-	void itemSelection_DeleteItem(Selection* customSelection=0, bool forceDeletion=false);
-	void itemSelection_SetItemFillTransparency(double t);
-	void itemSelection_SetItemLineTransparency(double t);
-	void itemSelection_SetItemFillBlend(int t);
-	void itemSelection_SetItemLineBlend(int t);
-	void itemSelection_SetLineGradient(VGradient& newGradient, Selection* customSelection=0);
-	void itemSelection_SetFillGradient(VGradient& newGradient, Selection* customSelection=0);
-	void itemSelection_SetOverprint(bool overprint, Selection* customSelection=0);
-	void itemSelection_ApplyImageEffects(ScImageEffectList& newEffectList, Selection* customSelection=0);
-	void itemSelection_FlipH();
-	void itemSelection_FlipV();
-	void itemSelection_DoHyphenate();
-	void itemSelection_DoDeHyphenate();
-	void itemSelection_SendToLayer(int layerNumber);
-	void itemSelection_SetImageOffset(double x, double y, Selection* customSelection=0);
-	void itemSelection_SetImageScale(double x, double y, Selection* customSelection=0);
-	void itemSelection_SetImageScaleAndOffset(double ox, double oy, double sx, double sy, Selection* customSelection=0);
-	void itemSelection_AlignLeftOut(AlignTo currAlignTo, double guidePosition);
-	void itemSelection_AlignRightOut(AlignTo currAlignTo, double guidePosition);
-	void itemSelection_AlignBottomIn(AlignTo currAlignTo, double guidePosition);
-	void itemSelection_AlignRightIn(AlignTo currAlignTo, double guidePosition);
-	void itemSelection_AlignBottomOut(AlignTo currAlignTo, double guidePosition);
-	void itemSelection_AlignCenterHor(AlignTo currAlignTo, double guidePosition);
-	void itemSelection_AlignLeftIn(AlignTo currAlignTo, double guidePosition);
-	void itemSelection_AlignCenterVer(AlignTo currAlignTo, double guidePosition);
-	void itemSelection_AlignTopOut(AlignTo currAlignTo, double guidePosition);
-	void itemSelection_AlignTopIn(AlignTo currAlignTo, double guidePosition);
-	void itemSelection_DistributeDistH(bool usingDistance=false, double distance=0.0);
-	void itemSelection_DistributeAcrossPage(bool useMargins=false);
-	void itemSelection_DistributeRight();
-	void itemSelection_DistributeBottom();
-	void itemSelection_DistributeCenterH();
-	void itemSelection_DistributeDistV(bool usingDistance=false, double distance=0.0);
-	void itemSelection_DistributeDownPage(bool useMargins=false);
-	void itemSelection_DistributeLeft();
-	void itemSelection_DistributeCenterV();
-	void itemSelection_DistributeTop();
-	void itemSelection_MultipleDuplicate(ItemMultipleDuplicateData&);
-	void itemSelection_UniteItems(Selection* customSelection=0);
-	void itemSelection_SplitItems(Selection* customSelection=0);
-	/**
-	 * Adjust an image frame's size to fit the size of the image in it
-	 */
-	void itemSelection_AdjustFrametoImageSize(Selection* customSelection=0);
-	/**
-	 * Adjust an image size to fit the size of the frame
-	 */
-	void itemSelection_AdjustImagetoFrameSize(Selection* customSelection=0);
-	//! @brief startArrowID or endArrowID of -1 mean not applying a selection at this point.
-	void itemSelection_ApplyArrowHead(int startArrowID=-1, int endArrowID=-1, Selection* customSelection=0);
+	QList<PageItem*>* Items;		/*!< \brief Pointer on a list of items. \details See masterPageMode() */
+	QList<PageItem*> MasterItems;		/*!< \brief List of items that belongs to Master Pages. */
+	QList<PageItem*> DocItems;		/*!< \brief List of items that belongs to Document Pages. */
 
-	void itemSelection_SetItemPen(QString farbe);
-	void itemSelection_SetItemPenShade(int sha);
-	void itemSelection_SetItemBrush(QString farbe);
-	void itemSelection_SetItemBrushShade(int sha);
-	void itemSelection_SetItemGradFill(int typ);
-	void itemSelection_SetItemPatternFill(QString pattern);
-	void itemSelection_SetItemPatternProps(double scaleX, double scaleY, double offsetX, double offsetY, double rotation);
+	QMap<QString,int> MasterNames;		/*!< \brief Mapping Master Page Name to Master Page numbers. \details See rebuildMasterNames() */
+	bool GuideLock;				/*!< \brief Is the guides must be locked ? See LockGuides() */
 
-	void undoRedoBegin();
-	void undoRedoDone();
+	QString DocName;			/*!< \brief Document's name. */
+protected:
+	bool loading;				/*!< \brief Is the document loading ? \details See isLoading() and setLoading(). */
+	bool modified;				/*!< \brief Is the document modified ? \details See isModified() and setModified(). */
 
-	void updatePic();
-	void updatePict(QString name);
-	void updatePictDir(QString name);
-	void removePict(QString name);
+	bool m_hasGUI;		 		/*!< \brief Is document associated with a GUI ? \details See hasGUI() and setGUI(). */
+	ScribusMainWindow* m_ScMW;		/*!< \brief Main window associated with the document. \details See scMW() and setGUI(). */
+	ScribusView* m_View;			/*!< \brief View associated with the document. \details See view() and setGUI(). */
+
+	bool automaticTextFrames;		/*!< \brief Is the document using automaticTextFrames ? \details See usesAutomaticTextFrames() and setUsesAutomagicTextFrames(). */
+
+	int docUnitIndex;			/*!< \brief Document's unit index. \details See setUnitIndex() and unitIndex(). */
+	double docUnitRatio;			/*!< \brief Document's unit ratio. \details See unitRatio(). */
+
+	bool m_masterPageMode;			/*!< \brief Is the document in master page mode ? \details See masterPageMode() and setMasterPageMode(). */
+private:
+	Page* m_currentPage;			/*!< \brief Current page. \details See setCurrentPage() and currentPage(). */
 };
 
 Q_DECLARE_METATYPE(ScribusDoc*);

ivro

2009-03-28 07:57

reporter   ~0021430

docs-patches-based-on-r13358.patch is the corrected patch

2009-03-28 08:10

 

units-docs-patches-based-on-r13358.patch (17,551 bytes)   
diff --git a/Scribus/scribus/units.cpp b/Scribus/scribus/units.cpp
index 4817eee..5c8f40a 100644
--- a/Scribus/scribus/units.cpp
+++ b/Scribus/scribus/units.cpp
@@ -24,24 +24,35 @@ for which a new license (GPL+exception) is in place.
 #include "units.h"
 
 /*!
- * @brief Returns the ratio to points for the selected unit of measure. Ratios are for: PT, MM, IN, P, CM, C. DEG and PCT return 1.0 as they will never convert
+ * \brief Get ratio from unit to points.
+ *
+ * \param unit see #ScUnit for valid unit
+ * \return 0 if unvalid unit,
+ *         1 if for %Points, %Degrees and %Percent unit,
+ *         ratio for other unit
  */
-double unitGetRatioFromIndex(const int index)
+double unitGetRatioFromIndex(const int unit)
 {
 	//PT, MM, IN, P, CM, C (Cicero)
 	//NOTE: Calling functions that divide by this value will crash on divide by 0. They shouldnt be getting
-	// a zero value if they are accessing here with a correct index.
-	if (index<UNITMIN || index>UNITMAX)
+	// a zero value if they are accessing here with a correct unit.
+	if (unit<UNITMIN || unit>UNITMAX)
 		return 0;
 	//                  PT,        MM,       IN,   P,             CM,               C,   °,   %
 	double ratio[] = { 1.0, 25.4/72.0, 1.0/72.0, 1.0,      2.54/72.0, 25.4/72.0/4.512, 1.0, 1.0 };
 // 	double ratio[] = { 1.0, 25.4/72.0, 1.0/72.0, 1.0/12.0, 2.54/72.0, 25.4/72.0/4.512, 1.0, 1.0 };
-	return ratio[index];
+	return ratio[unit];
 }
 
-int SCRIBUS_API unitGetBaseFromIndex(const int index)
+/*!
+ * \brief Get unit base.
+ *
+ * \param unit see #ScUnit for valid unit
+ * \return unit base
+ */
+int SCRIBUS_API unitGetBaseFromIndex(const int unit)
 {
-	if (index==SC_P)
+	if (unit==SC_P)
 		return 12;
 	return 10;
 }
@@ -89,7 +100,10 @@ double unitValueFromString(const QString& value)
 }
 
 /*!
- * @brief Strip the text from a value and return the Unit index for the value
+ * \brief Get unit from string.
+ *
+ * \param value string to consider
+ * \return unit, see #ScUnit for valid unit
  */
 scUnit unitIndexFromString(const QString& value)
 {
@@ -133,73 +147,95 @@ scUnit unitIndexFromString(const QString& value)
 }
 
 /*!
- * @brief Returns the suffix used in GUI widgets
+ * \brief Get GUI suffix for unit.
+ *
+ * GUI suffix have a whitespace prepended.
+ * See unitGetStrFromIndex() for general suffix.
+ * \param unit see #ScUnit for valid unit
+ * \return a translated GUI suffix
  */
-const QString unitGetSuffixFromIndex(const int index)
+const QString unitGetSuffixFromIndex(const int unit)
 {
-	if (index==SC_P)
+	if (unit==SC_P)
 	{
 		return "";
 	}
-	return QString(" %1").arg(unitGetStrFromIndex(index));
+	return QString(" %1").arg(unitGetStrFromIndex(unit));
 }
 
 /*!
- * @brief Returns a general suffix for each of the units
+ * \brief Get general suffix for unit.
+ *
+ * See unitGetSuffixFromIndex() for GUI suffix.
+ * \param unit see #ScUnit for valid unit
+ * \return a translated general suffix
  */
-const QString unitGetStrFromIndex(const int index)
+const QString unitGetStrFromIndex(const int unit)
 {
-	if (index<UNITMIN || index>UNITMAX) 
+	if (unit<UNITMIN || unit>UNITMAX) 
 		return "";
 	QString suffix[] = {
-						QObject::tr("pt"), 
-						QObject::tr("mm"), 
-						QObject::tr("in"), 
-						QObject::tr("p"), 
-						QObject::tr("cm"), 
-						QObject::tr("c"),
-						QObject::tr("\xB0", "degrees, unicode 0xB0"), //degree
-						QObject::tr("%")
-						};
-	return suffix[index];
+		QObject::tr("pt"), 
+		QObject::tr("mm"), 
+		QObject::tr("in"), 
+		QObject::tr("p"), 
+		QObject::tr("cm"), 
+		QObject::tr("c"),
+		QObject::tr("\xB0", "degrees, unicode 0xB0"), //degree
+		QObject::tr("%")
+	};
+	return suffix[unit];
 }
 
 /*!
- * @brief Returns a general untranslated suffix for each of the units
+ * \brief Get unstanslated general suffix for unit
+ *
+ * See unitGetStrFromIndex() for translated one.
+ * \param unit see #ScUnit for valid unit
+ * \return an unstranslated general suffix
  */
-const QString unitGetUntranslatedStrFromIndex(const int index)
+const QString unitGetUntranslatedStrFromIndex(const int unit)
 {
-	if (index<UNITMIN || index>UNITMAX) 
+	if (unit<UNITMIN || unit>UNITMAX) 
 		return "";
 	QString suffix[] = { "pt", "mm", "in", "p", "cm", "c", "\xB0", "%" };
-	return suffix[index];
+	return suffix[unit];
 }
 /*!
- * @brief Returns the decimals for the units
+ * \brief Get decimals for unit.
+ *
+ * \param unit see #ScUnit for valid unit
+ * \return decimals
  */
-int unitGetDecimalsFromIndex(const int index)
+int unitGetDecimalsFromIndex(const int unit)
 {
-	if (index<UNITMIN || index>UNITMAX) 
+	if (unit<UNITMIN || unit>UNITMAX) 
 		return 0;
 	//                      PT,   MM,    IN,   P,    CM,     C,   °,   %
 	int decimalPoints[] = {100, 1000, 10000, 100, 10000, 10000, 100, 100};
-	return decimalPoints[index];
+	return decimalPoints[unit];
 }
 
 /*!
- * @brief Returns the precision for the units
+ * \brief Get precision for unit.
+ *
+ * \param unit see #ScUnit for valid unit
+ * \return number of decimal digit
  */
-int unitGetPrecisionFromIndex(const int index)
+int unitGetPrecisionFromIndex(const int unit)
 {
-	if (index<UNITMIN || index>UNITMAX) 
+	if (unit<UNITMIN || unit>UNITMAX) 
 		return 0;
 	//                PT,MM,IN, P,CM, C, °, %
 	int precision[] = {2, 3, 4, 2, 4, 4, 2, 2};
-	return precision[index];
+	return precision[unit];
 }
 
 /*!
- * @brief Returns a QStringList of the units for use in QComboBoxes etc
+ * \brief Get a list of length units (to use in GUI)
+ *
+ * See unitValidForDocUnit() for length units.
+ * \return an QStringList of length units
  */
 const QStringList unitGetTextUnitList()
 {
@@ -217,7 +253,9 @@ const QStringList unitGetTextUnitList()
 }
 
 /*!
- * @brief Returns the maximum index of the units we have now
+ * Get the maximum index allowed for unit.
+ *
+ * See #ScUnit for valid unit.
  */
 int unitGetMaxIndex()
 {
@@ -225,7 +263,10 @@ int unitGetMaxIndex()
 }
 
 /*!
- * @brief Returns the pts value from the mm value supplied
+ * \brief Converts %Millimeters to %Points.
+ *
+ * \param mm value in %Millimeters
+ * \return value in %Points
  */
 double mm2pts(double mm)
 {
@@ -233,7 +274,10 @@ double mm2pts(double mm)
 }
 
 /*!
- * @brief Returns the pts value from the in value supplied
+ * \brief Converts %Inches to %Points.
+ * 
+ * \param in value in %Inches
+ * \return value in %Points
  */
 double in2pts(double in)
 {
@@ -241,7 +285,10 @@ double in2pts(double in)
 }
 
 /*!
- * @brief Returns the pts value from the pica value supplied
+ * \brief Converts %Picas to %Points
+ *
+ * \param p value in %Picas
+ * \return value in %Points
  */
 double p2pts(double p)
 {
@@ -249,7 +296,10 @@ double p2pts(double p)
 }
 
 /*!
- * @brief Returns the pts value from the cm value supplied
+ * \brief Converts %Centimeters to %Points
+ *
+ * \param cm value in %Centimetes
+ * \return value in %Points
  */
 double cm2pts(double cm)
 {
@@ -257,7 +307,10 @@ double cm2pts(double cm)
 }
 
 /*!
- * @brief Returns the pts value from the cm value supplied
+ * \brief Converts %Cicero to %Points
+ *
+ * \param c value in %Cicero
+ * \return value in %Points
  */
 double c2pts(double c)
 {
@@ -265,7 +318,10 @@ double c2pts(double c)
 }
 
 /*!
- * @brief Returns the mm value from the pt value supplied
+ * \brief Converts %Points to %Millimeters
+ *
+ * \param pts value in %Points
+ * \return value in %Millimeters
  */
 double pts2mm(double pts)
 {
@@ -273,7 +329,10 @@ double pts2mm(double pts)
 }
 
 /*!
- * @brief Returns the in value from the pt value supplied
+ * \brief Converts %Points to %Inches.
+ *
+ * \param pts value in %Points
+ * \return value in %Inches
  */
 double pts2in(double pts)
 {
@@ -281,7 +340,10 @@ double pts2in(double pts)
 }
 
 /*!
- * @brief Returns the pica value from the pt value supplied
+ * \brief Converts %Points to %Picas.
+ *
+ * \param pts value in %Points
+ * \return value in %Picas
  */
 double pts2p(double pts)
 {
@@ -289,7 +351,10 @@ double pts2p(double pts)
 }
 
 /*!
- * @brief Returns the cm value from the pt value supplied
+ * \brief Converts %Points to %Centimeters
+ *
+ * \param pts value in %Points
+ * \return value in %Centimeters
  */
 double pts2cm(double pts)
 {
@@ -297,7 +362,10 @@ double pts2cm(double pts)
 }
 
 /*!
- * @brief Returns the c value from the pt value supplied
+ * \brief Converts %Points to %Cicero
+ *
+ * \param pts value in %Points
+ * \return value in %Cicero
  */
 double pts2c(double pts)
 {
@@ -305,103 +373,152 @@ double pts2c(double pts)
 }
 
 /*!
- * @brief Returns the value from the pt value supplied based on unit index
+ * \brief Converts %Points to specified unit
+ * 
+ * \param pts value in %Points
+ * \param unit see #ScUnit for valid unit
+ * \return value in specified unit
  */
-double pts2value(double unitValue, int unit)
+double pts2value(double pts, int unit)
 {
 	double ret = 0.0;
 	switch (unit)
 	{
-		case 0:
-		case 3:
-		case 6:
-		case 7:
-			ret = unitValue; //dont multiply by 1
+		case SC_POINTS:
+		case SC_PICAS:
+		case SC_DEGREES:
+		case SC_PERCENT:
+			ret = pts; //dont multiply by 1
 			break;
 		default:
-			ret = unitValue * unitGetRatioFromIndex(unit);
+			ret = pts * unitGetRatioFromIndex(unit);
 			break;
 	}
 	return ret;
 }
 
 /*!
- * @brief Returns the pt value from the value supplied based on unit index
+ * \brief Converts specified value in %Points
+ *
+ * \param value value in unit
+ * \param unit see #ScUnit for valid unit
+ * \return value in %Points
  */
-double value2pts(double unitValue, int unit)
+double value2pts(double value, int unit)
 {
 	double ret = 0.0;
 	switch (unit)
 	{
-		case 0:
-		case 3:
-		case 6:
-		case 7:
-			ret = unitValue; // dont divide by 1
+		case SC_POINTS:
+		case SC_PICAS:
+		case SC_DEGREES:
+		case SC_PERCENT:
+			ret = value; // dont divide by 1
 			break;
-		default:
-			ret = unitValue / unitGetRatioFromIndex(unit);
+		default: // others
+			ret = value / unitGetRatioFromIndex(unit);
 			break;
 	}
 	return ret;
 }
 
 /*!
- * @brief Returns the secondary unit value from the value supplied based on primary unit
+ * \brief Converts unit to unit
+ *
+ * \param value value in fromUnit unit
+ * \param fromUnit value unit, see #ScUnit for valid unit
+ * \param toUnit return unit, see #ScUnit for valid unit
+ * \return value in toUnit unit
  */
-double value2value(double unitValue, int primaryUnit, int secondaryUnit)
+double value2value(double value, int fromUnit, int toUnit)
 {
-	if (primaryUnit==secondaryUnit)
-		return unitValue;
+	if (fromUnit==toUnit)
+		return value;
 		
 	double pts = 0.0, ret = 0.0;
 	//Can make this not convert to points at a later stage, for now, the function exists and works.
-	pts= primaryUnit==0 ? unitValue : unitValue / unitGetRatioFromIndex(primaryUnit);
-	ret= secondaryUnit==0 ? pts : pts * unitGetRatioFromIndex(secondaryUnit);
+	pts= fromUnit==0 ? value : value / unitGetRatioFromIndex(fromUnit);
+	ret= toUnit==0 ? pts : pts * unitGetRatioFromIndex(toUnit);
 	return ret;
 }
 
-QString value2String(double unitValue, int unitIndex, bool round2Precision, bool appendSuffix)
+/*!
+ * \brief Get a string of value converted in unit.
+ *
+ * \param pts value in %Points
+ * \param unit see #ScUnit for valid unit
+ * \param round has I have to round the converted value to unit precision, see unitGetPrecisionFromIndex() ?
+ * \param suffix has I have to append suffix ?
+ */
+QString value2String(double pts, int unit, bool round, bool suffix)
 {
+//ivro: Is toString not better as number see Qt documentation ?
 	QString s;
-	if (round2Precision)
-		s=QString::number(pts2value(unitValue, unitIndex), 'f', unitGetPrecisionFromIndex(unitIndex));
+	if (round)
+		s=QString::number(pts2value(pts, unit), 'f', unitGetPrecisionFromIndex(unit));
 	else
-		s=QString::number(pts2value(unitValue, unitIndex));
-	if (appendSuffix)
-		s += unitGetStrFromIndex(unitIndex);
+		s=QString::number(pts2value(pts, unit));
+	if (suffix)
+		s += unitGetStrFromIndex(unit);
 	return s;
 }
 
 /*!
- * @brief Sets up iteration value 1 for vruler, hruler and tabruler
+ * \brief Get iteration value 1 for vruler, hruler and tabruler.
+ *
+ * \param unit see #ScUnit for valid unit
+ * \return iteration value
+ *
+ * \todo Documents use cases
  */
-double unitRulerGetIter1FromIndex(const int index)
+double unitRulerGetIter1FromIndex(const int unit)
 {
-	if (!unitValidForDocUnit(index)) 
+	if (!unitValidForDocUnit(unit)) 
 		return 0;
 	//                 PT,         MM,   IN,    P,        CM,               C     °,    %
 	double iter[] = {10.0, 720.0/25.4, 18.0, 12.0, 72.0/25.4, 72.0/25.4*4.512, 10.0, 10.0};
-	return iter[index];
+	return iter[unit];
 }
 
 /*!
- * @brief Sets up iteration value 2 for vruler, hruler and tabruler
+ * \brief Get iteration value 2 for vruler, hruler, tabruler
+ *
+ * \param unit see #ScUnit for valid unit
+ * \return iteration value
+ *
+ * \todo Documents use cases
  */
-double unitRulerGetIter2FromIndex(const int index)
+double unitRulerGetIter2FromIndex(const int unit)
 {
-	if (!unitValidForDocUnit(index))
+	if (!unitValidForDocUnit(unit))
 		return 0;
 	//                  PT,          MM,   IN,     P,         CM,                C,     °,     %
 	double iter[] = {100.0, 7200.0/25.4, 72.0, 120.0, 720.0/25.4, 720.0/25.4*4.512, 100.0, 100.0};
-	return iter[index];
+	return iter[unit];
 }
 
-bool unitValidForDocUnit(const int index)
+/*!
+ * \brief Is unit can be used as length unit ?
+ *
+ * Valid length unit are
+ * - %Points,
+ * - %Millimeters,
+ * - %Inches,
+ * - %Picas,
+ * - %Centimeters,
+ * - %Cicero.
+ * Invalid unit are
+ * - %Degress,
+ * - %Percent.
+ *
+ * \param unit see #ScUnit for valid unit
+ * \return true if length unit, false otherwise
+ */
+bool unitValidForDocUnit(const int unit)
 {
-	if (index<UNITMIN || index>UNITMAX)
+	if (unit<UNITMIN || unit>UNITMAX)
 		return false;
-	if (index==6 || index==7)
+	if (unit==6 || unit==7)
 		return false;
 	return true;
 }
diff --git a/Scribus/scribus/units.h b/Scribus/scribus/units.h
index 9ed5f4b..1d15951 100644
--- a/Scribus/scribus/units.h
+++ b/Scribus/scribus/units.h
@@ -29,32 +29,36 @@ for which a new license (GPL+exception) is in place.
 #define UNITMIN 0
 #define UNITMAX 7
 
+/*!
+ * \brief Enumeration of valid unit in Scribus.
+ */
 enum scUnit {
-	SC_POINTS      = 0,
-	SC_PT          = 0,
-	SC_MILLIMETERS = 1,
-	SC_MM          = 1,
-	SC_INCHES      = 2,
-	SC_IN          = 2,
-	SC_PICAS       = 3,
-	SC_P           = 3,
-	SC_CENTIMETERS = 4,
-	SC_CM          = 4,
-	SC_CICERO      = 5,
-	SC_C           = 5,
-	SC_DEGREES     = 6,
-	SC_DEG         = 6,
-	SC_PERCENT     = 7,
-	SC_PCT         = 7
+	SC_POINTS      = 0, /*!< %Points */
+	SC_MILLIMETERS = 1, /*!< %Millimeters */
+	SC_INCHES      = 2, /*!< %Inches */
+	SC_PICAS       = 3, /*!< %Picas */
+	SC_CENTIMETERS = 4, /*!< %Centimeters */
+	SC_CICERO      = 5, /*!< %Cicero */
+	SC_DEGREES     = 6, /*!< %Degrees */
+	SC_PERCENT     = 7, /*!< %Pervent */
+
+	SC_PT          = 0, /*!< %Points abbrev */
+	SC_MM          = 1, /*!< %Millimeters abbrev */
+	SC_IN          = 2, /*!< %Inches abbrev */
+	SC_P           = 3, /*!< %Picas abbrev */
+	SC_CM          = 4, /*!< %Centimeters abbrev */
+	SC_C           = 5, /*!< %Cicero abbrev */
+	SC_DEG         = 6, /*!< %Degrees abbrev */
+	SC_PCT         = 7  /*!< %Percent abbrev */
 };
 
-double SCRIBUS_API unitGetRatioFromIndex(const int index);
-int SCRIBUS_API unitGetBaseFromIndex(const int index);
-const QString SCRIBUS_API unitGetStrFromIndex(const int index);
-const QString SCRIBUS_API unitGetUntranslatedStrFromIndex(const int index);
-const QString SCRIBUS_API unitGetSuffixFromIndex(const int index);
-int SCRIBUS_API unitGetDecimalsFromIndex(const int index);
-int SCRIBUS_API unitGetPrecisionFromIndex(const int index);
+double SCRIBUS_API unitGetRatioFromIndex(const int unit);
+int SCRIBUS_API unitGetBaseFromIndex(const int unit);
+const QString SCRIBUS_API unitGetStrFromIndex(const int unit);
+const QString SCRIBUS_API unitGetUntranslatedStrFromIndex(const int unit);
+const QString SCRIBUS_API unitGetSuffixFromIndex(const int unit);
+int SCRIBUS_API unitGetDecimalsFromIndex(const int unit);
+int SCRIBUS_API unitGetPrecisionFromIndex(const int unit);
 double SCRIBUS_API unitValueFromString(const QString& value);
 scUnit SCRIBUS_API unitIndexFromString(const QString& value);
 const QStringList SCRIBUS_API unitGetTextUnitList();
@@ -69,14 +73,14 @@ double SCRIBUS_API pts2in(double pts);
 double SCRIBUS_API pts2p(double pts);
 double SCRIBUS_API pts2cm(double pts);
 double SCRIBUS_API pts2c(double pts);
-double SCRIBUS_API pts2value(double Val, int unit);
-double SCRIBUS_API value2pts(double unitValue, int unit);
-double SCRIBUS_API value2value(double unitValue, int primaryUnit, int secondaryUnit);
-QString SCRIBUS_API value2String(double unitValue, int unitIndex, bool round2Precision, bool appendSuffix);
+double SCRIBUS_API pts2value(double value, int unit);
+double SCRIBUS_API value2pts(double value, int unit);
+double SCRIBUS_API value2value(double value, int fromUnit, int toUnit);
+QString SCRIBUS_API value2String(double value, int unit, bool round, bool suffix);
 //Ruler specific functions
-double SCRIBUS_API unitRulerGetIter1FromIndex(const int index);
-double SCRIBUS_API unitRulerGetIter2FromIndex(const int index);
-bool SCRIBUS_API unitValidForDocUnit(const int index);
+double SCRIBUS_API unitRulerGetIter1FromIndex(const int unit);
+double SCRIBUS_API unitRulerGetIter2FromIndex(const int unit);
+bool SCRIBUS_API unitValidForDocUnit(const int unit);
 
 #endif // UNITS_H
 

ivro

2009-03-28 08:12

reporter   ~0021431

units-docs-patches-based-on-r13358.patch documents units functions.

It renames the argument index to unit.

Kunda

2014-07-03 14:26

updater   ~0032433

bumping to 1.5.1 (patch is 5 years old and most likely needs re-tweaking)

Kunda

2014-07-23 21:38

updater   ~0032934

ivro, If this email is still active. Please respond give a heads up if you are still interested in helping in your efforts here. Appreciate the work you did.

Kunda

2014-09-18 21:17

updater   ~0033743

Cannot reach OP through email and he hasn't responded to this thread. Is there anything we can salvage from these patches ?

Issue History

Date Modified Username Field Change
2009-02-21 19:06 ivro New Issue
2009-02-21 19:06 ivro File Added: scribusdoc.h
2009-02-21 20:52 cbradney Note Added: 0021182
2009-02-21 21:35 ivro Note Added: 0021183
2009-02-21 21:44 ivro Note Added: 0021184
2009-02-21 22:51 avox Note Added: 0021185
2009-02-22 06:23 ivro Note Added: 0021187
2009-02-22 06:49 ivro File Added: page.h
2009-02-22 06:50 ivro Note Added: 0021188
2009-02-22 11:37 pierremarchand Note Added: 0021190
2009-02-22 21:23 ivro File Added: diff scribusdoc.h
2009-02-22 21:23 ivro File Added: diff page.h
2009-02-22 21:24 ivro Note Added: 0021193
2009-02-22 21:51 cbradney Note Added: 0021194
2009-02-22 22:19 ivro Note Added: 0021195
2009-02-22 22:31 cbradney Note Added: 0021196
2009-03-15 01:45 christoph_s Status new => acknowledged
2009-03-15 01:46 christoph_s Target Version => 1.3.6
2009-03-15 01:47 christoph_s Note Added: 0021311
2009-03-15 21:50 cbradney Note Added: 0021324
2009-03-27 10:20 ivro Note Added: 0021416
2009-03-27 15:07 ivro File Added: docs-patchs-from-ivro-based-on-r13346.tar.gz
2009-03-27 15:44 ivro File Added: patches-docs-from-ivro-based-on-r13556.diff
2009-03-27 15:53 ivro Note Added: 0021420
2009-03-27 16:16 ivro Note Edited: 0021420
2009-03-27 20:06 ivro File Added: docs-patches-based-on-r13356.tar.gz
2009-03-27 20:16 ivro File Added: remove-git-patch-header-and-footer.sed-script
2009-03-27 20:21 ivro Note Added: 0021424
2009-03-27 20:53 cbradney Note Added: 0021425
2009-03-27 23:23 ivro Note Added: 0021427
2009-03-27 23:47 cbradney Note Added: 0021428
2009-03-27 23:47 cbradney Note Edited: 0021428
2009-03-28 01:16 ivro File Added: docs-patches-part1.patch
2009-03-28 01:17 ivro Note Added: 0021429
2009-03-28 07:56 ivro File Added: docs-patches-based-on-r13358.patch
2009-03-28 07:57 ivro Note Added: 0021430
2009-03-28 08:10 ivro File Added: units-docs-patches-based-on-r13358.patch
2009-03-28 08:12 ivro Note Added: 0021431
2014-07-03 14:26 Kunda Note Added: 0032433
2014-07-03 14:26 Kunda Target Version 1.5.0 => 1.5.1
2014-07-23 21:38 Kunda Note Added: 0032934
2014-07-23 21:38 Kunda Summary Some souce documentation => [PATCH] Some source documentation patches
2014-09-18 21:17 Kunda Note Added: 0033743
2014-10-24 22:57 Kunda Patch => Yes
2015-11-30 02:43 Kunda Target Version 1.5.1 => 1.5.2
2016-01-23 17:15 cbradney Target Version 1.5.2 => 1.5.4.svn
2018-04-30 13:22 jghali Target Version 1.5.4.svn =>