~ubuntu-branches/ubuntu/precise/ipe/precise

« back to all changes in this revision

Viewing changes to src/ipelib/ipeiml.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Steve M. Robbins
  • Date: 2005-02-24 22:09:16 UTC
  • mfrom: (2.1.1 hoary)
  • Revision ID: james.westby@ubuntu.com-20050224220916-9vxiiqjz066r5489
Tags: 6.0pre23-2
debian/control: Ipe should depend on exact version of libipe.
Closes: #296771.

Show diffs side-by-side

added added

removed removed

Lines of Context:
49
49
 
50
50
*/
51
51
 
52
 
IpeImlParser::IpeImlParser(IpeXmlDataSource &source,
 
52
IpeImlParser::IpeImlParser(IpeDataSource &source,
53
53
                           IpeRepository *rep)
54
54
  : IpeXmlParser(source), iRepository(rep)
55
55
{
64
64
  to access PDF data.
65
65
 
66
66
  It is assumed that PDF object \a objNum is a stream.  Its contents
67
 
  is returned as a single (possibly very long) string.
 
67
  (uncompressed!) is returned in a buffer.
68
68
*/
69
 
IpeString IpeImlParser::PdfStream(int /* objNum */)
 
69
IpeBuffer IpeImlParser::PdfStream(int /* objNum */)
70
70
{
71
 
  return IpeString();
 
71
  return IpeBuffer();
72
72
}
73
73
 
74
74
//! Read a complete Ipe document from IML stream.
186
186
  IpeString objNumStr;
187
187
  if (att.Slash() && att.Has("pdfObject", objNumStr)) {
188
188
    int objNum = IpeLex(objNumStr).GetInt();
189
 
    ipeDebug("ParseBitmap: objNum = %d", objNum);
190
 
    IpeBitmap bitmap(att, PdfStream(objNum), true);
 
189
    // ipeDebug("ParseBitmap: objNum = %d", objNum);
 
190
    IpeBitmap bitmap(att, PdfStream(objNum));
191
191
    iBitmaps.push_back(bitmap);
192
192
  } else {
193
193
    IpeString bits;
194
194
    if (!ParsePCDATA("bitmap", bits))
195
195
      return false;
196
 
    IpeBitmap bitmap(att, bits, false);
 
196
    IpeBitmap bitmap(att, bits);
197
197
    iBitmaps.push_back(bitmap);
198
198
  }
199
199
  return true;
219
219
 
220
220
  IpeString str;
221
221
  if (att.Has("gridsize", str))
222
 
    page.SetGridSize(IpeLex(str).GetDouble());
 
222
    page.SetGridSize(IpeLex(str).GetInt());
 
223
  if (att.Has("section", str))
 
224
    page.SetSection(0, str);
 
225
  if (att.Has("subsection", str))
 
226
    page.SetSection(1, str);
 
227
 
 
228
  std::vector<IpeString> hiddenLayers;
223
229
  IpeString tag = ParseToTag();
224
230
  while (tag == "layer") {
225
231
    IpeXmlAttributes att;
226
232
    if (!ParseAttributes(att))
227
233
      return false;
228
234
    IpeLayer layer(att);
 
235
    // OBSOLETE: remove later
 
236
    if (att["visible"] == "no")
 
237
      hiddenLayers.push_back(layer.Name());
229
238
    page.AddLayer(layer);
230
239
    tag = ParseToTag();
231
240
  }
242
251
    page.AddView(view);
243
252
    tag = ParseToTag();
244
253
  }
 
254
 
 
255
  // default view: include all layers
 
256
  if (page.CountViews() == 0) {
 
257
    // need to synthesize a view
 
258
    IpeView view;
 
259
    for (int i = 0; i < page.CountLayers(); ++i) {
 
260
      IpeString name = page.Layer(i).Name();
 
261
      // OBSOLETE: remove later
 
262
      if (std::find(hiddenLayers.begin(), hiddenLayers.end(), name) ==
 
263
          hiddenLayers.end())
 
264
        view.AddLayer(name);
 
265
    }
 
266
    int al = 0;
 
267
    while (al < page.CountLayers() && page.Layer(al).IsLocked())
 
268
      ++al;
 
269
    if (al == page.CountLayers())
 
270
      return false; // no unlocked layer
 
271
    view.SetActive(page.Layer(al).Name());
 
272
    page.AddView(view);
 
273
  }
 
274
 
245
275
  int currentLayer = 0;
246
276
  IpeString layerName;
247
277
  for (;;) {
248
278
    if (tag == "/page") {
249
279
      return true;
250
280
    }
 
281
    // if (tag == "path")
 
282
    // ipeDebug("path at %d", ParsePosition());
251
283
    IpeObject *obj = ParseObject(tag, &page, &currentLayer);
252
284
    if (!obj)
253
285
      return false;
421
453
      if (!att.Slash() && !ParsePCDATA(tag, pcdata))
422
454
        return false;
423
455
      sheet.SetPreamble(pcdata);
 
456
    } else if (tag == "cmap") {
 
457
      if (!ParseAttributes(att) || !att.Slash())
 
458
        return false;
 
459
      sheet.AddCMap(att["font"]);
424
460
    } else if (tag == "color") {
425
461
      if (!ParseAttributes(att) || !att.Slash())
426
462
        return false;