summaryrefslogtreecommitdiffstats
path: root/karbon/karbon_part.h
blob: 34e0e04b1bcc73f99fedff12aa627bf1610b5b20 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
/* This file is part of the KDE project
   Copyright (C) 2001, 2002, 2003 The Karbon Developers

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

   This library is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   Library General Public License for more details.

   You should have received a copy of the GNU Library General Public License
   along with this library; see the file COPYING.LIB.  If not, write to
   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 * Boston, MA 02110-1301, USA.
*/

#ifndef __KARBON_PART_H__
#define __KARBON_PART_H__


#include <tqptrlist.h>

#include <KoDocument.h>
#include <KoUnit.h>
#include "vdocument.h"
#include "koffice_export.h"

class DCOPObject;
class KoRect;
class TQRect;
class VCommand;
class VDocument;
class VCommandHistory;

/**
 * Keeps track of visual per document properties.
 * It manages actions performed on this object in a command history.
 * It loads initial settings and applies them to the document and its views.
 * Finally a dcop interface is set up here.
 */

class KARBONCOMMON_EXPORT KarbonPart : public KoDocument
{
	Q_OBJECT
  TQ_OBJECT
public:
	KarbonPart( TQWidget* parentWidget = 0L, const char* widgetName = 0L,
				TQObject* parent = 0L, const char* name = 0L, bool singleViewMode = false );
	virtual ~KarbonPart();

	virtual void paintContent( TQPainter& painter, const TQRect& rect,
							   bool transparent = false, double zoomX = 1.0, double zoomY = 1.0 );

	/// standard koDocument inherited methods
	virtual bool initDoc(InitDocFlags flags, TQWidget* parentWidget=0);

	/// file-> open calls this method
	virtual bool loadXML( TQIODevice*, const TQDomDocument& document );
	virtual bool loadOasis( const TQDomDocument &doc, KoOasisStyles &styles, const TQDomDocument &settings, KoStore *store );

	/// file-> save and file-> save as call this method
	virtual TQDomDocument saveXML();
	virtual bool saveOasis( KoStore *store, KoXmlWriter *manifestWriter );

	virtual void addShell( KoMainWindow *shell );

	virtual DCOPObject* dcopObject();

	/// insert a new vobject
	void insertObject( VObject* object );

	/// insert a command into the undo/redo-history:
	void addCommand( VCommand* cmd, bool tqrepaint = false );

	// access static document:
	VDocument& document() { return m_doc; }

	// Clear history.
	void clearHistory();

	/// access the command history:
	VCommandHistory* commandHistory()
	{
		return m_commandHistory;
	}

	bool showStatusBar() const
	{
		return m_bShowStatusBar;
	}

	void setShowStatusBar( bool b );
	/// update attached view(s) on the current doc settings
	/// at this time only the status bar is handled
	void reorganizeGUI();

	void setUndoRedoLimit( int undos );

	void initConfig();
	unsigned int maxRecentFiles() const { return m_maxRecentFiles; }

	void setPageLayout( KoPageLayout& tqlayout, KoUnit::Unit _unit );

	bool mergeNativeFormat( const TQString & file );

public slots:
	/// tqrepaint all views attached to this koDocument
	void repaintAllViews( bool tqrepaint = true );
	void repaintAllViews( const KoRect& );
	void slotDocumentRestored();
	void slotCommandExecuted( VCommand * );
	void slotUnitChanged( KoUnit::Unit unit );

protected:
	virtual KoView* createViewInstance( TQWidget* parent, const char* name );
	virtual void removeView( KoView *view );
	void saveOasisSettings( KoXmlWriter &/*settingsWriter*/ );
	void loadOasisSettings( const TQDomDocument&settingsDoc );

private:
	VDocument m_doc;					/// store non-visual doc info
	VCommandHistory* m_commandHistory;	/// maintain a command history for undo/redo

	bool m_bShowStatusBar;				/// enable/disable status bar in attached view(s)
	bool m_merge;
	unsigned int m_maxRecentFiles;				/// max. number of files shown in open recent menu item
	DCOPObject *dcop;
};

#endif