File: Presentation.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 (625 lines) | stat: -rwxr-xr-x 20,881 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
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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
/*
 * Presentation
 * Copyright (C) 2007 by Martin Sevior
 *
 * 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.
 */

#define USE_PIXMAP 0

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <sys/types.h>
#include <errno.h>
#include <string>

#include <glib.h>

#include "xap_Module.h"
#include "xap_App.h"
#include "xap_Frame.h"
#include "fv_View.h"
#include "fl_DocLayout.h"
#include "ev_EditMethod.h"
#include "ie_imp.h"
#include "ie_exp.h"
#include "ie_types.h"
#include "ap_Convert.h"
#include "ap_EditMethods.h"
#include "ev_EditBits.h"
#include "Presentation.h"
#include "ap_LoadBindings.h"
#include "ev_NamedVirtualKey.h"
#include "ut_bytebuf.h"
#include "ap_Menu_Id.h"
#include "ev_Menu_Actions.h"
#include "ev_Menu.h"
#include "ev_Menu_Layouts.h"
#include "ev_Menu_Labels.h"
#include "xap_Menu_Layouts.h"
#include "gr_Graphics.h"
#include "gr_DrawArgs.h"
#include "fp_Page.h"
#include "gr_Painter.h"
#if USE_PIXMAP
#include <gdk/gdk.h>
#include "gr_UnixPangoGraphics.h"
#include "gr_UnixPangoPixmapGraphics.h"
#endif

#ifdef ABI_PLUGIN_BUILTIN
#define abi_plugin_register abipgn_presentation_register
#define abi_plugin_unregister abipgn_presentation_unregister
#define abi_plugin_supports_version abipgn_presentation_supports_version
// dll exports break static linking
#define ABI_BUILTIN_FAR_CALL extern "C"
#else
#define ABI_BUILTIN_FAR_CALL ABI_FAR_CALL
ABI_PLUGIN_DECLARE("Presentation")
#endif

#define RES_TO_STATUS(a) ((a) ? 0 : -1)

static bool Presentation_start (AV_View * v, EV_EditMethodCallData * d);
static bool Presentation_end (AV_View * v, EV_EditMethodCallData * d);
static bool Presentation_nextPage (AV_View * v, EV_EditMethodCallData * d);
static bool Presentation_prevPage (AV_View * v, EV_EditMethodCallData * d);
static bool Presentation_context (AV_View * v, EV_EditMethodCallData * d);

Presentation myPresentation;
EV_EditMouseContext PresentationContextID =  EV_EMC_EMBED;
static XAP_Menu_Id presentationID;
static const char * szPresentation = "Presentation";
static const char * szPresentationStatus = "View the document in presentation mode";
static const char * szNextSlide = "Next Slide";
static const char * szPrevSlide = "Previous Slide";
static const char * szEndPresentation = "End Presentation";
static XAP_Menu_Id nextSlideID;
static XAP_Menu_Id prevSlideID;
static XAP_Menu_Id endPresentationID;
//
// Presentation_registerMethod()
// -----------------------
//   Adds Presentation_start, Presentation_end to the EditMethod list
//
static void
Presentation_registerMethod ()
{
	// First we need to get a pointer to the application itself.
	XAP_App *pApp = XAP_App::getApp ();

	// Create an EditMethod that will link our method's name with
	// it's callback function.  This is used to link the name to 
	// the callback.
	EV_EditMethod *myEditMethod = new EV_EditMethod ("Presentation_start",	// name of callback function
							 Presentation_start,	// callback function itself.
							 0,	// no additional data required.
							 ""	// description -- allegedly never used for anything
							 );

	// Now we need to get the EditMethod container for the application.
	// This holds a series of Edit Methods and links names to callbacks.
	EV_EditMethodContainer *pEMC = pApp->getEditMethodContainer ();

	// We have to add our EditMethod to the application's EditMethodList
	// so that the application will know what callback to call when a call

	pEMC->addEditMethod (myEditMethod);

	myEditMethod = new EV_EditMethod ("Presentation_end",	// name of callback function
							 Presentation_end,	// callback function itself.
							 0,	// no additional data required.
							 ""	// description -- allegedly never used for anything
							 );

	pEMC->addEditMethod (myEditMethod);

	myEditMethod = new EV_EditMethod ("Presentation_nextPage",	// name of callback function
							 Presentation_nextPage,	// callback function itself.
							 0,	// no additional data required.
							 ""	// description -- allegedly never used for anything
							 );

	pEMC->addEditMethod (myEditMethod);

	myEditMethod = new EV_EditMethod ("Presentation_prevPage",	// name of callback function
							 Presentation_prevPage,	// callback function itself.
							 0,	// no additional data required.
							 ""	// description -- allegedly never used for anything
							 );

	pEMC->addEditMethod (myEditMethod);

	myEditMethod = new EV_EditMethod ("Presentation_context",	// name of callback function
							 Presentation_context,	// callback function itself.
							 0,	// no additional data required.
							 ""	// description -- allegedly never used for anything
							 );

	pEMC->addEditMethod (myEditMethod);

    // Now we need to grab an ActionSet.  This is going to be used later
    // on in our for loop.  Take a look near the bottom.
    EV_Menu_ActionSet* pActionSet = pApp->getMenuActionSet();

    XAP_Menu_Factory * pFact = pApp->getMenuFactory();

// Put it after 

    presentationID= pFact->addNewMenuAfter("Main",NULL,AP_MENU_ID_VIEW_SHOWPARA,EV_MLF_Normal);
    UT_DEBUGMSG(("presentationID %d \n",presentationID));


    pFact->addNewLabel(NULL,presentationID,szPresentation,szPresentationStatus);

    // Create the Action that will be called.
    EV_Menu_Action* myPresentationAction = new EV_Menu_Action(
	presentationID,          // id that the layout said we could use
	0,                      // no, we don't have a sub menu.
	0,                      // no, we don't raise a dialog.
	0,                      // no, we don't have a checkbox.
	0,                      // no radio buttons for me, thank you
	"Presentation_start",   //  callback function to call.
	NULL,                   // don't know/care what this is for
	NULL                    // don't know/care what this is for
        );

    // Now what we need to do is add this particular action to the ActionSet
    // of the application.  This forms the link between our new ID that we 
    // got for this particular frame with the EditMethod that knows how to 
    // call our callback function.  

    pActionSet->addAction(myPresentationAction);


    //
    // OK Now build a context menu
    //
    PresentationContextID = pFact->createContextMenu("PresentationContext");
    prevSlideID = pFact->addNewMenuBefore("PresentationContext",NULL,0,EV_MLF_Normal,0);
    pFact->addNewLabel(NULL,prevSlideID,szPrevSlide, NULL);
    nextSlideID = pFact->addNewMenuBefore("PresentationContext",NULL,0,EV_MLF_Normal,0);
    pFact->addNewLabel(NULL,nextSlideID,szNextSlide, NULL);
    endPresentationID = pFact->addNewMenuBefore("PresentationContext",NULL,0,EV_MLF_Normal,0);
    pFact->addNewLabel(NULL,endPresentationID,szEndPresentation, NULL);

    myPresentationAction = new EV_Menu_Action(
	prevSlideID,          // id that the layout said we could use
	0,                      // no, we don't have a sub menu.
	0,                      // no, we don't raise a dialog.
	0,                      // no, we don't have a checkbox.
	0,                      // no radio buttons for me, thank you
	"Presentation_prevPage",   //  callback function to call.
	NULL,                   // don't know/care what this is for
	NULL                    // don't know/care what this is for
        );
    pActionSet->addAction(myPresentationAction);
    myPresentationAction = new EV_Menu_Action(
	nextSlideID,          // id that the layout said we could use
	0,                      // no, we don't have a sub menu.
	0,                      // no, we don't raise a dialog.
	0,                      // no, we don't have a checkbox.
	0,                      // no radio buttons for me, thank you
	"Presentation_nextPage",   //  callback function to call.
	NULL,                   // don't know/care what this is for
	NULL                    // don't know/care what this is for
        );
    pActionSet->addAction(myPresentationAction);
    myPresentationAction = new EV_Menu_Action(
	endPresentationID,          // id that the layout said we could use
	0,                      // no, we don't have a sub menu.
	0,                      // no, we don't raise a dialog.
	0,                      // no, we don't have a checkbox.
	0,                      // no radio buttons for me, thank you
	"Presentation_end",   //  callback function to call.
	NULL,                   // don't know/care what this is for
	NULL                    // don't know/care what this is for
        );
    pActionSet->addAction(myPresentationAction);


}

static void
Presentation_RemoveFromMethods ()
{
	// First we need to get a pointer to the application itself.
	XAP_App *pApp = XAP_App::getApp ();

	// remove the edit method
	EV_EditMethodContainer *pEMC = pApp->getEditMethodContainer ();
	EV_EditMethod *pEM = ev_EditMethod_lookup ("Presentation_start");

	pEMC->removeEditMethod (pEM);
	DELETEP (pEM);
	
	pEM = ev_EditMethod_lookup ("Presentation_end");
	pEMC->removeEditMethod (pEM);
	DELETEP (pEM);
	
	pEM = ev_EditMethod_lookup ("Presentation_nextPage");
	pEMC->removeEditMethod (pEM);
	DELETEP (pEM);
	
	pEM = ev_EditMethod_lookup ("Presentation_prevPage");
	pEMC->removeEditMethod (pEM);
	DELETEP (pEM);
	
	pEM = ev_EditMethod_lookup ("Presentation_context");
	pEMC->removeEditMethod (pEM);
	DELETEP (pEM);

	XAP_Menu_Factory * pFact = pApp->getMenuFactory();

	pFact->removeMenuItem("Main",NULL,presentationID);
}

// -----------------------------------------------------------------------
//
//      Abiword Plugin Interface 
//
// -----------------------------------------------------------------------

ABI_BUILTIN_FAR_CALL int
abi_plugin_register (XAP_ModuleInfo * mi)
{
	mi->name = "Presentation";
	mi->desc = "This enables AbiWord to make presentations";
	mi->version = ABI_VERSION_STRING;
	mi->author = "Martin Sevior <msevior@physics.unimelb.edu.au>";
	mi->usage = "Presentaton_start";

	Presentation_registerMethod ();
	return 1;
}

ABI_BUILTIN_FAR_CALL int
abi_plugin_unregister (XAP_ModuleInfo * mi)
{
	mi->name = 0;
	mi->desc = 0;
	mi->version = 0;
	mi->author = 0;
	mi->usage = 0;

	Presentation_RemoveFromMethods ();

	return 1;
}

ABI_BUILTIN_FAR_CALL int
abi_plugin_supports_version (UT_uint32 /*major*/, UT_uint32 /*minor*/, UT_uint32 /*release*/)
{
	return 1;
}

// -----------------------------------------------------------------------
//
//     Presentation_start Invocation Code
//
// -----------------------------------------------------------------------

//
//  Presentation_start
// -------------------
//   This is the function that puts AbiWord into full screen mode and set the 
//   keybindings for a presentation.
//
static bool
Presentation_start (AV_View * v, EV_EditMethodCallData * /*d*/)
{
  myPresentation.start(v);
	
	return true;
}
//
// Presentation_end
// -------------------
// This functions takes AbiWord out of full screen mode and restores the 
// previous keybindings.
//
static bool
Presentation_end (AV_View * /*v*/, EV_EditMethodCallData * /*d*/)
{
  myPresentation.end();
  return true;
}

static bool
Presentation_nextPage (AV_View * /*v*/, EV_EditMethodCallData * /*d*/)
{
  myPresentation.showNextPage();
  return true;
}


static bool
Presentation_prevPage (AV_View * /*v*/, EV_EditMethodCallData * /*d*/)
{
  myPresentation.showPrevPage();
  return true;
}

static bool
Presentation_context (AV_View * v, EV_EditMethodCallData * d)
{
        FV_View * pView = static_cast<FV_View *>(v);
	XAP_Frame * pFrame = static_cast<XAP_Frame *> (pView->getParentData());
	UT_sint32 xPos = d->m_xPos;
	UT_sint32 yPos = d->m_yPos;
	const char * szContextMenuName =  XAP_App::getApp()->getMenuFactory()->FindContextMenu(PresentationContextID);
	UT_DEBUGMSG(("Context Menu Name is........ %s \n",szContextMenuName));
	if (!szContextMenuName)
		return false;
	bool res = pFrame->runModalContextMenu(pView,szContextMenuName,
									   xPos,yPos);
	pFrame->nullUpdate();
	GR_Graphics * pG  = pView->getGraphics();
	if(pG)
	  pG->allCarets()->disable();
	return res;
}


// Hack into seperate strings because C doesn't allow multi-line strings

static UT_String sPresBindings[] = {"name, Presentation\n",
			       "mse,B1,CU,Presentation_nextPage,,,,,,\n",
			       "mse,B1,CL,Presentation_nextPage,,,,,,\n", 
			       "mse,B1,CT,Presentation_nextPage,,,,,,\n", 
			       "mse,B1,CM,Presentation_nextPage,,,,,,\n", 
			       "mse,B1,CR,Presentation_nextPage,,,,,,\n", 
			       "mse,B1,CI,Presentation_nextPage,,,,,,\n", 
			       "mse,B1,CZ,Presentation_nextPage,,,,,,\n", 
			       "mse,B1,CF,Presentation_nextPage,,,,,,\n", 
			       "mse,B1,CH,Presentation_nextPage,,,,,,\n", 
			       "mse,B1,CV,Presentation_nextPage,,,,,,\n", 
			       "mse,B3,CU,Presentation_context,,,,,,\n",
			       "mse,B3,CL,Presentation_context,,,,,,\n", 
			       "mse,B3,CT,Presentation_context,,,,,,\n", 
			       "mse,B3,CM,Presentation_context,,,,,,\n", 
			       "mse,B3,CR,Presentation_context,,,,,,\n", 
			       "mse,B3,CI,Presentation_context,,,,,,\n", 
			       "mse,B3,CZ,Presentation_context,,,,,,\n", 
			       "mse,B3,CF,Presentation_context,,,,,,\n", 
			       "mse,B3,CH,Presentation_context,,,,,,\n", 
			       "mse,B3,CV,Presentation_context,,,,,,\n", 
			       "nvk,ESCAPE,Presentation_end,Presentation_end,Presentation_end,Presentation_end,,,,,\n",
			       "nvk,PAGEUP,Presentation_prevPage,,,,,,\n",
			       "nvk,PAGEDOWN,Presentation_nextPage,,,,,,\n",
			       "nvk,LEFT,Presentation_prevPage,,,,,,\n",
			       "nvk,UP,Presentation_prevPage,,,,,,\n",
			       "nvk,RIGHT,Presentation_nextPage,,,,,,\n",
			       "nvk,DOWN,Presentation_nextPage,,,,,,\n",
			       "nvk,F1,,Presentation_end,Presentation_end,Presentation_end,Presentation_end,,,,,\n",
			       "nvk,F2,,Presentation_end,Presentation_end,Presentation_end,Presentation_end,,,,,\n",
			       "nvk,F3,,Presentation_end,Presentation_end,Presentation_end,Presentation_end,,,,,\n",
			       "nvk,F4,,Presentation_end,Presentation_end,Presentation_end,Presentation_end,,,,,\n"
			       "nvk,F5,,Presentation_end,Presentation_end,Presentation_end,Presentation_end,,,,,\n",
			       ""};

Presentation::Presentation(void):
  m_pApp(NULL),
  m_pView(NULL),
  m_iPage(0),
  m_bDrewNext(false),
  m_bDrewPrev(false)
{
  m_pApp = XAP_App::getApp();
}


Presentation::~Presentation (void)
{

}

bool Presentation::_loadPresentationBindings(AV_View * pView)
{
  EV_EditMethodContainer * pEMC = m_pApp->getEditMethodContainer();
  g_return_val_if_fail (pEMC != 0, FALSE);
  if(m_pApp->getBindingMap("Presentation") != NULL)
  {
      return true;
  }
  // get the path where our app data is located
  XAP_App * pApp = static_cast<XAP_App*>(XAP_App::getApp());
  UT_String data_path( pApp->getAbiSuiteLibDir() );
  data_path += G_DIR_SEPARATOR;
  data_path += "Presentation.xml";

  EV_EditMethod * pLoadB = pEMC->findEditMethodByName ("com.abisource.abiword.loadbindings.fromURI");
  g_return_val_if_fail (pLoadB != 0, false);
  EV_EditMethodCallData calldata(data_path.c_str(),data_path.size());
  calldata.m_xPos = 0;
  calldata.m_yPos = 0;
  return (pLoadB->Fn(pView,&calldata) ? TRUE : FALSE);
}

bool Presentation::start(AV_View * view)
{
  EV_EditMethodContainer * pEMC = m_pApp->getEditMethodContainer();
  g_return_val_if_fail (pEMC != 0, FALSE);
  m_pView = static_cast<FV_View *>(view);
  m_sPrevBindings = m_pApp->getInputMode();
  _loadPresentationBindings(view);
  UT_sint32 i = m_pApp->setInputMode("Presentation");
  if(i < 0 )
    return false;
  // get a handle to the actual EditMethod
  EV_EditMethod * pFullScreen = pEMC->findEditMethodByName ("viewFullScreen");
  g_return_val_if_fail (pFullScreen != 0, false);
  const char * sz ="";
  EV_EditMethodCallData calldata(sz,0);
  calldata.m_xPos = 0;
  calldata.m_yPos = 0;
  m_iPage = 0;
  XAP_Frame * pFrame = static_cast<XAP_Frame*>(m_pView->getParentData());
  m_OldZoomType = pFrame->getZoomType();
  m_iOldZoom = pFrame->getZoomPercentage();

  pFrame->hideMenuScroll(true);
  bool b = false;
  b = (pFullScreen->Fn(view,&calldata) ? TRUE : FALSE);
  GR_Graphics * pG = m_pView->getGraphics();

  //
  // Let all the configure events propagate to their full extent
  //
  for(i= 0; i<20;i++)
    pFrame->nullUpdate();
  pFrame->setZoomType(XAP_Frame::z_PAGEWIDTH);
  i = m_pView-> calculateZoomPercentForPageWidth();
  pFrame->quickZoom(i);
  for(i= 0; i<20;i++)
    pFrame->nullUpdate();

  b= showNextPage();
  if(pG)
    pG->allCarets()->disable();
   return b;
}

bool Presentation::end(void)
{
  if(m_sPrevBindings.size() == 0)
    return false;
  EV_EditMethodContainer * pEMC = m_pApp->getEditMethodContainer();
  g_return_val_if_fail (pEMC != 0, FALSE);
  UT_sint32 i = m_pApp->setInputMode(m_sPrevBindings.c_str());
  if(i <=0 )
    return false;

  // get a handle to the actual EditMethod

  EV_EditMethod * pFullScreen = pEMC->findEditMethodByName ("viewFullScreen");
  g_return_val_if_fail (pFullScreen != 0, false);
  const char * sz ="";
  EV_EditMethodCallData calldata(sz,0);
  calldata.m_xPos = 0;
  calldata.m_yPos = 0;
  XAP_Frame * pFrame = static_cast<XAP_Frame*>(m_pView->getParentData());
  pFrame->hideMenuScroll(false);
  bool b= (pFullScreen->Fn(static_cast<AV_View *>(m_pView),&calldata) ? TRUE : FALSE);
  pFrame->setZoomType(m_OldZoomType);
  pFrame->setZoomPercentage(m_iOldZoom);
  pFrame->quickZoom(m_iOldZoom);
  return b;
}


bool Presentation::drawNthPage(UT_sint32 iPage)
{
  GR_Graphics * pG = m_pView->getGraphics();
  GR_Painter p(pG);
#if USE_PIXMAP
  GR_Image * pImage = renderPageToImage(iPage,pG->getZoomPercentage());
  UT_DEBUGMSG(("Image Display Width %d Image Display Height %d Zoom %d \n",pImage->getDisplayWidth(),pImage->getDisplayHeight(),pG->getZoomPercentage()));
  p.drawImage(pImage,0,0);
  delete pImage;
#else
  dg_DrawArgs da;
  da.pG = pG;
  da.xoff = 0;
  da.yoff = 0;
  m_pView->draw(iPage, &da);
  fp_Page * pPage = m_pView->getLayout()->getNthPage(iPage);
  UT_sint32 iTotalHeight = (pPage->getHeight() + m_pView->getPageViewSep())*iPage;
  m_pView->setYScrollOffset(iTotalHeight);
  if(pG)
    pG->allCarets()->disable();
#endif
  return true;
}
#if USE_PIXMAP
/*!
 * Caller must delete the returned image.
 */
GR_Image * Presentation::renderPageToImage(UT_sint32 iPage, UT_uint32 iZoom)
{
  GR_UnixPangoGraphics  * pVG = static_cast<GR_UnixPangoGraphics *>(m_pView->getGraphics());
  UT_sint32 iWidth = pVG->tdu(m_pView->getWindowWidth());
  UT_sint32 iHeight = pVG->tdu(m_pView->getWindowHeight());
	double ZoomRat = static_cast<double>(iZoom)/static_cast<double>(pVG->getZoomPercentage());
	iWidth = static_cast<UT_sint32>(static_cast<double>(iWidth)*ZoomRat);
	iHeight = static_cast<UT_sint32>(static_cast<double>(iHeight)*ZoomRat);
	//
	// Create an offscreen Graphics to draw into
	//
	UT_DEBUGMSG(("rederpagetoimage Width %d Height %d zoom %d \n",iWidth,iHeight,iZoom));
	GdkPixmap*  pPixmap = gdk_pixmap_new(pVG->getWindow(),iWidth,iHeight,-1);

	GR_UnixPixmapAllocInfo ai(pPixmap);

	GR_UnixPangoPixmapGraphics * pG = (GR_UnixPangoPixmapGraphics*)GR_UnixPangoPixmapGraphics::graphicsAllocator(ai);
	pG->setZoomPercentage(iZoom);
	GR_Painter * pPaint = new GR_Painter(pG);
	pPaint->clearArea(0,0,m_pView->getWindowWidth(),m_pView->getWindowHeight());
	dg_DrawArgs da;
	da.pG = pG;
	da.xoff = 0;
	da.yoff = 0;
	m_pView->getLayout()->setQuickPrint(pG);
	m_pView->draw(iPage, &da);
	UT_Rect r;
	r.left = 0;
	r.top = 0;
	r.width = pG->tlu(iWidth);
	r.height = pG->tlu(iHeight);
	GR_Image * pImage = pPaint->genImageFromRectangle(r);
	m_pView->getLayout()->setQuickPrint(NULL);
	DELETEP(pPaint);
	DELETEP(pG);
	return pImage;
}

#endif
bool  Presentation::showNext(void)
{
  return showNextPage();
}


bool  Presentation::showNextPage(void)
{
  if(m_bDrewPrev && (m_iPage + 1< static_cast<UT_sint32>(m_pView->getLayout()->countPages())))
  { 
      m_iPage++;
  }
  drawNthPage(m_iPage);
  if(m_iPage+1 < static_cast<UT_sint32>(m_pView->getLayout()->countPages()))
      m_iPage++;
  m_bDrewNext = true;
  m_bDrewPrev = false;
  return true;
}

bool  Presentation::showPrevPage(void)
{
  if(m_iPage > 0)
  {
    if(m_iPage > 1 && m_bDrewNext && (m_iPage +1 < m_pView->getLayout()->countPages()))
	  m_iPage--;
      m_iPage--;
  }
  else
    return false;
  drawNthPage(m_iPage);
  m_bDrewNext = false;
  m_bDrewPrev = true;
  return true;
}