File: OXML_Element_Bookmark.cpp

package info (click to toggle)
abiword 3.0.8%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 64,532 kB
  • sloc: cpp: 477,427; ansic: 16,754; makefile: 5,785; xml: 4,014; yacc: 1,818; lex: 1,104; perl: 812; python: 413; php: 183; sh: 169
file content (103 lines) | stat: -rw-r--r-- 2,367 bytes parent folder | download | duplicates (7)
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
/* -*- mode: C++; tab-width: 4; c-basic-offset: 4; -*- */

/* AbiSource
 * 
 * Copyright (C) 2008 Firat Kiyak <firatkiyak@gmail.com>
 * 
 * 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.
 * 
 * This program 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 General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  
 * 02110-1301 USA.
 */

// Class definition include
#include <OXML_Element_Bookmark.h>

// AbiWord includes
#include <ut_types.h>
#include <ut_string.h>
#include <pd_Document.h>

OXML_Element_Bookmark::OXML_Element_Bookmark(const std::string & id) : 
	OXML_Element(id, BOOK_TAG, BOOKMRK)
{
}

OXML_Element_Bookmark::~OXML_Element_Bookmark()
{

}

void OXML_Element_Bookmark::setType(const std::string & type)
{
	m_type = type;
}

void OXML_Element_Bookmark::setName(const std::string & name)
{
	m_name = name;
}

UT_Error OXML_Element_Bookmark::serialize(IE_Exp_OpenXML* exporter)
{
	UT_Error err = UT_OK;
	const gchar* type;
	const gchar* name;

	err = getAttribute("name", name);
	if(err != UT_OK)
		return UT_OK;

	if(getAttribute("type", type) == UT_OK)
	{
		if(strcmp(type, "start") == 0)
		{
			err = exporter->startBookmark(getId().c_str(), name);
			if(err != UT_OK)
				return err;
		}
		else if(strcmp(type, "end") == 0)
		{
			err = exporter->finishBookmark(getId().c_str());
			if(err != UT_OK)
				return err;
		}
		else
		{
			UT_DEBUGMSG(("FRT: Unknown Bookmark type\n"));
		}
	}
	
	return UT_OK;
}

UT_Error OXML_Element_Bookmark::addToPT(PD_Document* pDocument)
{
	UT_Error err = UT_OK;

	const gchar *field_fmt[5];
	field_fmt[0] = "type";
	field_fmt[1] = m_type.c_str();
	field_fmt[2] = "name";
	field_fmt[3] = m_name.c_str();
	field_fmt[4] = 0;

	if(!pDocument->appendObject(PTO_Bookmark, field_fmt))
		return UT_ERROR;

	err = addChildrenToPT(pDocument);
	if(err != UT_OK)
		return err;

	return UT_OK;
}