summaryrefslogtreecommitdiffstats
path: root/part/commands_file.cpp
blob: 1767e883374bf4ddd6490d3527a3d864b363eea0 (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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
/***************************************************************************
                          commands_file  -  description
                             -------------------
    begin                : Wed Nov 26 2003
    copyright           : (C) 2003 by The KXMLEditor Team
    email                : a_charytoniuk@user.sourceforge.net
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   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.                                   *
 *                                                                         *
 ***************************************************************************/
#include "commands_file.h"
#include <tqstring.h>
#include <kurl.h>
#include <tdemessagebox.h>
//////////////////////////////////////////////////////////////////////////////////////////
///////////		Setting Version & Encoding		//////////
//////////////////////////////////////////////////////////////////////////////////////////

KXEVersionEncodingCommand::KXEVersionEncodingCommand(KXEDocument* pDocument, const TQString& oldData, const TQString &newData)
 : KXECommand(pDocument)
{
	m_strOldData = oldData;
	m_strNewData = newData;
}

KXEVersionEncodingCommand::~KXEVersionEncodingCommand()
{
}

void KXEVersionEncodingCommand::execute()
{
	m_pDocument->setSpecProcInstr("xml",m_strNewData);
}

void KXEVersionEncodingCommand::unexecute()
{
	m_pDocument->setSpecProcInstr("xml",m_strOldData);
}

//////////////////////////////////////////////////////////////////////////////////////////
///////////			Attaching stylesheet			//////////
//////////////////////////////////////////////////////////////////////////////////////////

KXEStylesheetAttachCommand::KXEStylesheetAttachCommand(KXEDocument* pDocument,const TQString& prevStylesheet,const TQString& newStylesheet)
 : KXECommand(pDocument)
{
	m_strNewStylesheet = newStylesheet;
	m_strPrevStylesheet = prevStylesheet;
}

KXEStylesheetAttachCommand::~KXEStylesheetAttachCommand()
{
}

void KXEStylesheetAttachCommand::execute()
{
	m_pDocument->detachStylesheet();
	m_pDocument->attachStylesheet(KURL(m_strNewStylesheet));
}

void KXEStylesheetAttachCommand::unexecute()
{
	m_pDocument->detachStylesheet();
	if(!m_strPrevStylesheet.isEmpty())
		m_pDocument->attachStylesheet(KURL(m_strPrevStylesheet));
}

//////////////////////////////////////////////////////////////////////////////////////////
///////////			Detaching Stylesheet		//////////
//////////////////////////////////////////////////////////////////////////////////////////

KXEStylesheetDetachCommand::KXEStylesheetDetachCommand(KXEDocument* pDocument,const TQString& prevStylesheet)
 : KXECommand(pDocument)
{
	m_strPrevStylesheet = prevStylesheet;
}

KXEStylesheetDetachCommand::~KXEStylesheetDetachCommand()
{
}

void KXEStylesheetDetachCommand::execute()
{
	m_pDocument->detachStylesheet();
}

void KXEStylesheetDetachCommand::unexecute()
{
  if (!m_strPrevStylesheet.isEmpty())
		m_pDocument->attachStylesheet(KURL(m_strPrevStylesheet));
}

//////////////////////////////////////////////////////////////////////////////////////////
///////////			Attaching Schema			//////////
//////////////////////////////////////////////////////////////////////////////////////////

KXESchemaAttachCommand::KXESchemaAttachCommand(KXEDocument *pDocument,const TQString& newSchema)
 : KXECommand(pDocument)
{
	m_pDocument = pDocument;
	m_strNewSchema = newSchema;
	m_strPrevSchema = "";
}
KXESchemaAttachCommand::KXESchemaAttachCommand(KXEDocument *pDocument,const TQString& newSchema,const TQString& prevSchema)
 : KXECommand(pDocument)
{
	m_strNewSchema = newSchema;
	m_strPrevSchema = prevSchema;
}

KXESchemaAttachCommand::~KXESchemaAttachCommand()
{
}

void KXESchemaAttachCommand::execute()
{
	m_pDocument->detachSchema();						// old schema is removed
	m_pDocument->attachSchema(KURL(m_strNewSchema));		// new schema is applited
}

void KXESchemaAttachCommand::unexecute()
{
	m_pDocument->detachSchema();						// new schema is removed
	if (!m_strPrevSchema.isEmpty())
		m_pDocument->attachSchema(KURL(m_strPrevSchema));		// old schema is applied
}

//////////////////////////////////////////////////////////////////////////////////////////
///////////			Detaching schema			//////////
//////////////////////////////////////////////////////////////////////////////////////////

KXESchemaDetachCommand::KXESchemaDetachCommand(KXEDocument* pDocument, const TQString& schema)
 : KXECommand(pDocument)
{
		m_schema = schema;
}

KXESchemaDetachCommand::~KXESchemaDetachCommand()
{
}

void KXESchemaDetachCommand::execute()
{
	m_pDocument->detachSchema();
}

void KXESchemaDetachCommand::unexecute()
{
	if (!m_schema.isEmpty())
		m_pDocument->attachSchema(KURL(m_schema));
}