1 /* -*- Mode: C++; c-default-style: "k&r"; indent-tabs-mode: nil; tab-width: 2; c-basic-offset: 2 -*- */
2 
3 /* libmwaw
4 * Version: MPL 2.0 / LGPLv2+
5 *
6 * The contents of this file are subject to the Mozilla Public License Version
7 * 2.0 (the "License"); you may not use this file except in compliance with
8 * the License or as specified alternatively below. You may obtain a copy of
9 * the License at http://www.mozilla.org/MPL/
10 *
11 * Software distributed under the License is distributed on an "AS IS" basis,
12 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13 * for the specific language governing rights and limitations under the
14 * License.
15 *
16 * Major Contributor(s):
17 * Copyright (C) 2006 Ariya Hidayat (ariya@kde.org)
18 * Copyright (C) 2004 Marc Oude Kotte (marc@solcon.nl)
19 * Copyright (C) 2002 William Lachance (wrlach@gmail.com)
20 * Copyright (C) 2002,2004 Marc Maurer (uwog@uwog.net)
21 * Copyright (C) 2004-2006 Fridrich Strba (fridrich.strba@bluewin.ch)
22 * Copyright (C) 2006, 2007 Andrew Ziem
23 * Copyright (C) 2011, 2012 Alonso Laurent (alonso@loria.fr)
24 *
25 *
26 * All Rights Reserved.
27 *
28 * For minor contributions see the git repository.
29 *
30 * Alternatively, the contents of this file may be used under the terms of
31 * the GNU Lesser General Public License Version 2 or later (the "LGPLv2+"),
32 * in which case the provisions of the LGPLv2+ are applicable
33 * instead of those above.
34 */
35 
36 #include <string.h>
37 
38 #include <librevenge/librevenge.h>
39 #include <libmwaw/libmwaw.hxx>
40 
41 #include "libmwaw_internal.hxx"
42 
43 #include "MWAWDebug.hxx"
44 
45 #include "MWAWSpreadsheetDecoder.hxx"
46 
insertElement(const char * psName)47 void MWAWSpreadsheetDecoder::insertElement(const char *psName)
48 {
49   if (!m_output) return;
50   if (!psName || !*psName) {
51     MWAW_DEBUG_MSG(("MWAWSpreadsheetDecoder::insertElement: called without any name\n"));
52     return;
53   }
54 
55   bool ok=true;
56   switch (psName[0]) {
57   case 'C':
58     if (strcmp(psName,"CloseChart")==0)
59       m_output->closeChart();
60     else if (strcmp(psName,"CloseChartPlotArea")==0)
61       m_output->closeChartPlotArea();
62     else if (strcmp(psName,"CloseChartSerie")==0)
63       m_output->closeChartSerie();
64     else if (strcmp(psName,"CloseChartTextObject")==0)
65       m_output->closeChartTextObject();
66     else if (strcmp(psName,"CloseComment")==0)
67       m_output->closeComment();
68     else if (strcmp(psName,"CloseFooter")==0)
69       m_output->closeFooter();
70     else if (strcmp(psName,"CloseFootnote")==0)
71       m_output->closeFootnote();
72     else if (strcmp(psName,"CloseFrame")==0)
73       m_output->closeFrame();
74     else if (strcmp(psName,"CloseGroup")==0)
75       m_output->closeGroup();
76     else if (strcmp(psName,"CloseHeader")==0)
77       m_output->closeHeader();
78     else if (strcmp(psName,"CloseLink")==0)
79       m_output->closeLink();
80     else if (strcmp(psName,"CloseListElement")==0)
81       m_output->closeListElement();
82     else if (strcmp(psName,"CloseOrderedListLevel")==0)
83       m_output->closeOrderedListLevel();
84     else if (strcmp(psName,"ClosePageSpan")==0)
85       m_output->closePageSpan();
86     else if (strcmp(psName,"CloseParagraph")==0)
87       m_output->closeParagraph();
88     else if (strcmp(psName,"CloseSection")==0)
89       m_output->closeSection();
90     else if (strcmp(psName,"CloseSheet")==0)
91       m_output->closeSheet();
92     else if (strcmp(psName,"CloseSheetCell")==0)
93       m_output->closeSheetCell();
94     else if (strcmp(psName,"CloseSheetRow")==0)
95       m_output->closeSheetRow();
96     else if (strcmp(psName,"CloseSpan")==0)
97       m_output->closeSpan();
98     else if (strcmp(psName,"CloseTableCell")==0)
99       m_output->closeTableCell();
100     else if (strcmp(psName,"CloseTableRow")==0)
101       m_output->closeTableRow();
102     else if (strcmp(psName,"CloseTextBox")==0)
103       m_output->closeTextBox();
104     else if (strcmp(psName,"CloseUnorderedListLevel")==0)
105       m_output->closeUnorderedListLevel();
106     else
107       ok=false;
108     break;
109   case 'E':
110     if (strcmp(psName,"EndDocument")==0)
111       m_output->endDocument();
112     else
113       ok=false;
114     break;
115   case 'I':
116     if (strcmp(psName,"InsertTab")==0)
117       m_output->insertTab();
118     else if (strcmp(psName,"InsertSpace")==0)
119       m_output->insertSpace();
120     else if (strcmp(psName,"InsertLineBreak")==0)
121       m_output->insertLineBreak();
122     else
123       ok=false;
124     break;
125   default:
126     ok=false;
127     break;
128   }
129   if (!ok) {
130     MWAW_DEBUG_MSG(("MWAWSpreadsheetDecoder::insertElement: called with unexpected name %s\n", psName));
131   }
132 }
133 
insertElement(const char * psName,const librevenge::RVNGPropertyList & propList)134 void MWAWSpreadsheetDecoder::insertElement(const char *psName, const librevenge::RVNGPropertyList &propList)
135 {
136   if (!m_output) return;
137   if (!psName || !*psName) {
138     MWAW_DEBUG_MSG(("MWAWSpreadsheetDecoder::insertElement: called without any name\n"));
139     return;
140   }
141 
142   bool ok=true;
143   switch (psName[0]) {
144   case 'D':
145     if (strcmp(psName,"DefineCharacterStyle")==0)
146       m_output->defineCharacterStyle(propList);
147     else if (strcmp(psName,"DefineChartStyle")==0)
148       m_output->defineChartStyle(propList);
149     else if (strcmp(psName,"DefineEmbeddedFont")==0)
150       m_output->defineEmbeddedFont(propList);
151     else if (strcmp(psName,"DefineGraphicStyle")==0)
152       m_output->defineGraphicStyle(propList);
153     else if (strcmp(psName,"DefinePageStyle")==0)
154       m_output->definePageStyle(propList);
155     else if (strcmp(psName,"DefineParagraphStyle")==0)
156       m_output->defineParagraphStyle(propList);
157     else if (strcmp(psName,"DefineSectionStyle")==0)
158       m_output->defineSectionStyle(propList);
159     else if (strcmp(psName,"DefineSheetNumberingStyle")==0)
160       m_output->defineSheetNumberingStyle(propList);
161 
162     else if (strcmp(psName,"DrawConnector")==0)
163       m_output->drawConnector(propList);
164     else if (strcmp(psName,"DrawEllipse")==0)
165       m_output->drawEllipse(propList);
166     else if (strcmp(psName,"DrawPath")==0)
167       m_output->drawPath(propList);
168     else if (strcmp(psName,"DrawPolygon")==0)
169       m_output->drawPolygon(propList);
170     else if (strcmp(psName,"DrawPolyline")==0)
171       m_output->drawPolyline(propList);
172     else if (strcmp(psName,"DrawRectangle")==0)
173       m_output->drawRectangle(propList);
174     else
175       ok=false;
176     break;
177   case 'I':
178     if (strcmp(psName,"InsertBinaryObject")==0)
179       m_output->insertBinaryObject(propList);
180     else if (strcmp(psName,"InsertChartAxis")==0)
181       m_output->insertChartAxis(propList);
182     else if (strcmp(psName,"InsertCoveredTableCell")==0)
183       m_output->insertCoveredTableCell(propList);
184     else if (strcmp(psName,"InsertEquation")==0)
185       m_output->insertEquation(propList);
186     else if (strcmp(psName,"InsertField")==0)
187       m_output->insertField(propList);
188     else
189       ok=false;
190     break;
191   case 'O':
192     if (strcmp(psName,"OpenChart")==0)
193       m_output->openChart(propList);
194     else if (strcmp(psName,"OpenChartPlotArea")==0)
195       m_output->openChartPlotArea(propList);
196     else if (strcmp(psName,"OpenChartSerie")==0)
197       m_output->openChartSerie(propList);
198     else if (strcmp(psName,"OpenChartTextObject")==0)
199       m_output->openChartTextObject(propList);
200     else if (strcmp(psName,"OpenComment")==0)
201       m_output->openComment(propList);
202     else if (strcmp(psName,"OpenFooter")==0)
203       m_output->openFooter(propList);
204     else if (strcmp(psName,"OpenFootnote")==0)
205       m_output->openFootnote(propList);
206     else if (strcmp(psName,"OpenFrame")==0)
207       m_output->openFrame(propList);
208     else if (strcmp(psName,"OpenGroup")==0)
209       m_output->openGroup(propList);
210     else if (strcmp(psName,"OpenHeader")==0)
211       m_output->openHeader(propList);
212     else if (strcmp(psName,"OpenLink")==0)
213       m_output->openLink(propList);
214     else if (strcmp(psName,"OpenListElement")==0)
215       m_output->openListElement(propList);
216     else if (strcmp(psName,"OpenOrderedListLevel")==0)
217       m_output->openOrderedListLevel(propList);
218     else if (strcmp(psName,"OpenPageSpan")==0)
219       m_output->openPageSpan(propList);
220     else if (strcmp(psName,"OpenParagraph")==0)
221       m_output->openParagraph(propList);
222     else if (strcmp(psName,"OpenSheet")==0)
223       m_output->openSheet(propList);
224     else if (strcmp(psName,"OpenSection")==0)
225       m_output->openSection(propList);
226     else if (strcmp(psName,"OpenSheetCell")==0)
227       m_output->openSheetCell(propList);
228     else if (strcmp(psName,"OpenSheetRow")==0)
229       m_output->openSheetRow(propList);
230     else if (strcmp(psName,"OpenSpan")==0)
231       m_output->openSpan(propList);
232     else if (strcmp(psName,"OpenTableCell")==0)
233       m_output->openTableCell(propList);
234     else if (strcmp(psName,"OpenTableRow")==0)
235       m_output->openTableRow(propList);
236     else if (strcmp(psName,"OpenTextBox")==0)
237       m_output->openTextBox(propList);
238     else if (strcmp(psName,"OpenUnorderedListLevel")==0)
239       m_output->openUnorderedListLevel(propList);
240     else
241       ok=false;
242     break;
243   case 'S':
244     if (strcmp(psName,"SetDocumentMetaData")==0)
245       m_output->setDocumentMetaData(propList);
246     else if (strcmp(psName,"StartDocument")==0)
247       m_output->startDocument(propList);
248 
249     else
250       ok=false;
251     break;
252   default:
253     ok=false;
254     break;
255   }
256   if (!ok) {
257     MWAW_DEBUG_MSG(("MWAWSpreadsheetDecoder::insertElement: called with unexpected name %s\n", psName));
258   }
259 }
260 
261 // vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:
262