21#include "KPrDocument.h"
26#include "KPrLineObject.h"
27#include "KPrRectObject.h"
28#include "KPrEllipseObject.h"
29#include "KPrAutoformObject.h"
30#include "KPrTextObject.h"
31#include "KPrTextDocument.h"
32#include "KPrPixmapObject.h"
33#include "KPrPieObject.h"
34#include "KPrPartObject.h"
35#include "KPrGroupObject.h"
36#include "KPrCommand.h"
37#include "insertpagedia.h"
38#include "KPrFreehandObject.h"
39#include "KPrPolylineObject.h"
40#include "KPrBezierCurveObject.h"
41#include "KPrPolygonObject.h"
42#include "KPrClosedLineObject.h"
43#include "KPrSVGPathParser.h"
45#include <tqpopupmenu.h>
46#include <tqclipboard.h>
48#include <tqfileinfo.h>
58#include <tdeapplication.h>
60#include <tdetempfile.h>
62#include <tdefiledialog.h>
64#include <kstandarddirs.h>
65#include <tdemessagebox.h>
67#include <tdeio/netaccess.h>
69#include <KoTemplateChooseDia.h>
71#include <KoGenStyles.h>
72#include <KoFilterManager.h>
74#include <KoStoreDevice.h>
75#include <KoQueryTrader.h>
76#include <KoXmlWriter.h>
77#include <KoOasisSettings.h>
78#include <KoMainWindow.h>
86#include <KoRichText.h>
87#include <KoTextObject.h>
88#include <KoTextZoomHandler.h>
89#include <KoStyleCollection.h>
91#include "KPrDocumentIface.h"
93#include <tdespell2/settings.h>
95#include <KoVariable.h>
96#include <KoAutoFormat.h>
97#include <KoDocumentInfo.h>
98#include "KPrVariableCollection.h"
99#include "KPrBackground.h"
100#include "KPrNoteBar.h"
101#include "KPrBgSpellCheck.h"
102#include <tdeglobalsettings.h>
103#include <KoCommandHistory.h>
104#include "KoApplication.h"
105#include <KoOasisStyles.h>
106#include <KoOasisContext.h>
108#include "KPrLoadingInfo.h"
112static const int CURRENT_SYNTAX_VERSION = 2;
114static const char * CURRENT_DTD_VERSION =
"1.2";
116KPrChild::KPrChild( KPrDocument *_kpr, KoDocument* _doc,
const TQRect& _rect )
117 : KoDocumentChild( _kpr, _doc, _rect )
122KPrChild::KPrChild( KPrDocument *_kpr ) :
123 KoDocumentChild( _kpr )
132KoDocument *KPrChild::hitTest(
const TQPoint &,
const TQWMatrix & )
139KPrDocument::KPrDocument( TQWidget *parentWidget,
const char *widgetName, TQObject* parent,
const char* name,
140 bool singleViewMode )
141 : KoDocument( parentWidget,widgetName, parent, name, singleViewMode ),
142 _gradientCollection(), m_customListTest( 0L ),
143 m_childCountBeforeInsert( 0 )
145 setInstance( KPrFactory::global() );
146 setTemplateType(
"kpresenter_template" );
148 m_pageWhereLoadObject=0L;
150 m_tabStop = MM_TO_POINT( 15.0 );
151 m_styleColl=
new KoStyleCollection();
152 m_insertFilePage = 0;
153 m_picturePath= TDEGlobalSettings::documentPath();
154 m_globalLanguage = TDEGlobal::locale()->language();
155 m_bGlobalHyphenation =
false;
156 _duplicatePage=
false;
158 KoParagStyle* m_standardStyle =
new KoParagStyle(
"Standard" );
159 m_styleColl->addStyle( m_standardStyle );
161 TDEConfig *config = KPrFactory::global()->config();
162 config->setGroup(
"Document defaults" );
163 TQString defaultFontname=config->readEntry(
"DefaultFont");
164 if ( !defaultFontname.isEmpty() )
165 m_defaultFont.fromString( defaultFontname );
169 m_defaultFont.setStyleStrategy( TQFont::ForceOutline );
173 int ptSize = m_defaultFont.pointSize();
175 ptSize = TQFontInfo(m_defaultFont).pointSize();
178 ptSize = TQMAX( 20, ptSize );
180 m_standardStyle->format().setFont( m_defaultFont );
183 m_standardStyle->format().setColor( TQt::black );
185 if( config->hasGroup(
"Interface") ) {
186 config->setGroup(
"Interface" );
187 m_globalLanguage=config->readEntry(
"language", TDEGlobal::locale()->language());
188 m_bGlobalHyphenation=config->readBoolEntry(
"hyphenation",
false);
191 m_standardStyle->format().setLanguage( m_globalLanguage);
193 m_zoomHandler =
new KoTextZoomHandler;
195 m_varFormatCollection =
new KoVariableFormatCollection;
196 m_varColl =
new KPrVariableCollection(
new KoVariableSettings(), m_varFormatCollection );
197 m_bgSpellCheck =
new KPrBgSpellCheck(
this);
199 m_initialActivePage=0;
200 m_bShowStatusBar =
true;
201 m_autoFormat =
new KoAutoFormat(
this,m_varColl,m_varFormatCollection);
203 _spInfiniteLoop =
false;
204 _spShowEndOfPresentationSlide =
true;
205 _spManualSwitch =
true;
206 _showPresentationDuration =
false;
207 tmpSoundFileList = TQPtrList<KTempFile>();
210 _txtBackCol = lightGray;
211 _otxtBackCol = lightGray;
214 m_bAllowAutoFormat =
true;
216 m_bViewFormattingChars =
false;
217 m_bShowGuideLines =
true;
221 m_bSnapToGrid =
true;
223 m_cursorInProtectectedArea=
true;
225 usedSoundFile = TQStringList();
226 haveNotOwnDiskSoundFile = TQStringList();
228 m_zoomHandler->setZoomAndResolution( 100, KoGlobal::dpiX(), KoGlobal::dpiY() );
229 newZoomAndResolution(
false,
false);
246 m_indent = MM_TO_POINT( 10.0 );
247 m_gridX = MM_TO_POINT( 5.0 );
248 m_gridY = MM_TO_POINT( 5.0 );
253 m_masterPage=
new KPrPage(
this);
254 KPrPage *newpage =
new KPrPage(
this, m_masterPage );
255 m_pageList.insert( 0,newpage);
256 m_bInsertDirectCursor =
false;
259 _presPen = TQPen( red, 3, SolidLine );
262 m_gridColor=TQt::black;
264 _header =
new KPrTextObject(
this );
265 _header->setDrawEditRect(
false );
266 _header->setDrawEmpty(
false );
268 _footer =
new KPrTextObject(
this );
269 _footer->setDrawEditRect(
false );
270 _footer->setDrawEmpty(
false );
273 m_maxRecentFiles = 10;
275 connect( TQApplication::clipboard(), TQ_SIGNAL( dataChanged() ),
276 this, TQ_SLOT( clipboardDataChanged() ) );
278 m_commandHistory =
new KoCommandHistory( actionCollection(),
true ) ;
281 connect( m_commandHistory, TQ_SIGNAL( documentRestored() ),
this, TQ_SLOT( slotDocumentRestored() ) );
282 connect( m_commandHistory, TQ_SIGNAL( commandExecuted() ),
this, TQ_SLOT( slotCommandExecuted() ) );
287void KPrDocument::refreshMenuCustomVariable()
289 emit sig_refreshMenuCustomVariable();
292void KPrDocument::slotDocumentRestored()
294 setModified(
false );
297void KPrDocument::slotCommandExecuted()
302void KPrDocument::saveConfig()
306 TDEConfigGroup group( KoGlobal::kofficeConfig(),
"Spelling" );
307 group.writeEntry(
"PersonalDict", m_spellCheckPersonalDict );
310 TDEConfig *config = KPrFactory::global()->config();
311 config->setGroup(
"Interface" );
312 config->writeEntry(
"Zoom", m_zoomHandler->zoom() );
313 config->writeEntry(
"AllowAutoFormat" , m_bAllowAutoFormat );
314 config->writeEntry(
"ViewFormattingChars", m_bViewFormattingChars );
315 config->writeEntry(
"ShowGrid" , m_bShowGrid );
316 config->writeEntry(
"SnapToGrid" , m_bSnapToGrid );
317 config->writeEntry(
"ResolutionX", m_gridX );
318 config->writeEntry(
"ResolutionY", m_gridY );
322void KPrDocument::initConfig()
325 TDEConfig* config = KPrFactory::global()->config();
326 if( config->hasGroup(
"Interface") ) {
327 config->setGroup(
"Interface" );
328 setAutoSave( config->readNumEntry(
"AutoSave", defaultAutoSave()/60 ) * 60 );
329 setBackupFile( config->readBoolEntry(
"BackupFile",
true));
330 setCursorInProtectedArea( config->readBoolEntry(
"cursorInProtectArea",
true ));
333 double indent = config->readDoubleNumEntry(
"Indent", MM_TO_POINT(10.0) ) ;
334 setIndentValue(indent);
335 m_maxRecentFiles = config->readNumEntry(
"NbRecentFile", 10 );
336 setShowRuler(config->readBoolEntry(
"Rulers",
true));
337 zoom = config->readNumEntry(
"Zoom", 100 );
338 setShowStatusBar( config->readBoolEntry(
"ShowStatusBar" ,
true ));
339 setAllowAutoFormat( config->readBoolEntry(
"AllowAutoFormat" ,
true ));
340 setViewFormattingChars( config->readBoolEntry(
"ViewFormattingChars",
false ) );
341 setShowGrid( config->readBoolEntry(
"ShowGrid" ,
true ));
342 setSnapToGrid( config->readBoolEntry(
"SnapToGrid",
true ));
343 setGridX( config->readDoubleNumEntry(
"ResolutionX", MM_TO_POINT( 5.0 ) ));
344 setGridY( config->readDoubleNumEntry(
"ResolutionY", MM_TO_POINT( 5.0 ) ));
346 m_bInsertDirectCursor= config->readBoolEntry(
"InsertDirectCursor",
false );
347 m_globalLanguage=config->readEntry(
"language", TDEGlobal::locale()->language());
353 TQColor oldBgColor = TQt::white;
354 TQColor oldGridColor = TQt::black;
355 if ( config->hasGroup(
"KPresenter Color" ) ) {
356 config->setGroup(
"KPresenter Color" );
357 setTxtBackCol(config->readColorEntry(
"BackgroundColor", &oldBgColor ));
358 setGridColor(config->readColorEntry(
"GridColor", &oldGridColor ));
362 if( config->hasGroup(
"KSpell kpresenter" ) )
364 config->setGroup(
"KSpell kpresenter" );
369 m_bgSpellCheck->setEnabled(config->readBoolEntry(
"SpellCheck",
false ));
371 m_bgSpellCheck->setEnabled(
false );
374 if(config->hasGroup(
"Misc" ) )
376 config->setGroup(
"Misc" );
377 undo=config->readNumEntry(
"UndoRedo",-1);
380 setUndoRedoLimit(undo);
382 if(config->hasGroup(
"Kpresenter Path" ) )
384 config->setGroup(
"Kpresenter Path" );
385 m_picturePath=config->readPathEntry(
"picture path",TDEGlobalSettings::documentPath());
386 setBackupPath(config->readPathEntry(
"backup path" ));
390 TDEConfigGroup group( KoGlobal::kofficeConfig(),
"Spelling" );
391 m_spellCheckPersonalDict = group.readListEntry(
"PersonalDict" );
394 replaceObjs(
false );
395 zoomHandler()->setZoom( zoom );
396 newZoomAndResolution(
false,
false);
399DCOPObject* KPrDocument::dcopObject()
402 dcop =
new KPrDocumentIface(
this );
407KPrDocument::~KPrDocument()
411 clearTestCustomSlideShow();
418 delete m_commandHistory;
419 delete m_zoomHandler;
422 delete m_varFormatCollection;
425 delete m_bgSpellCheck;
428 m_pageList.setAutoDelete(
true );
430 m_deletedPageList.setAutoDelete(
true );
431 m_deletedPageList.clear();
432 tmpSoundFileList.setAutoDelete(
true );
433 tmpSoundFileList.clear();
436void KPrDocument::addCommand( KCommand * cmd )
438 kdDebug(33001) <<
"KPrDocument::addCommand " << cmd->name() << endl;
439 m_commandHistory->addCommand( cmd,
false );
443bool KPrDocument::saveChildren( KoStore* _store )
447 TQPtrListIterator<KoDocumentChild> it( children() );
448 for( ; it.current(); ++it ) {
451 TQPtrListIterator<KPrPage> pageIt( m_pageList );
452 for (
int pagePos = 0; pageIt.current(); ++pageIt, ++pagePos )
454 if ( saveOnlyPage == -1 || pagePos == saveOnlyPage )
456 TQPtrListIterator<KPrObject> oIt(pageIt.current()->objectList());
457 for (; oIt.current(); ++oIt )
459 if ( oIt.current()->getType() == OT_PART &&
460 dynamic_cast<KPrPartObject*
>( oIt.current() )->getChild() == it.current() )
462 if (((KoDocumentChild*)(it.current()))->document()!=0)
463 if ( !((KoDocumentChild*)(it.current()))->document()->saveToStore( _store, TQString::number( i++ ) ) )
469 if ( saveOnlyPage == -1 )
471 TQPtrListIterator<KPrObject> oIt(m_masterPage->objectList());
472 for (; oIt.current(); ++oIt )
474 if ( oIt.current()->getType() == OT_PART &&
475 dynamic_cast<KPrPartObject*
>( oIt.current() )->getChild() == it.current() )
477 if (((KoDocumentChild*)(it.current()))->document()!=0)
478 if ( !((KoDocumentChild*)(it.current()))->document()->saveToStore( _store, TQString::number( i++ ) ) )
487TQDomDocument KPrDocument::saveXML()
489 if ( saveOnlyPage == -1 ) {
490 emit sigProgress( 0 );
493 m_varColl->variableSetting()->setModificationDate(TQDateTime::currentDateTime());
494 recalcVariables( VT_DATE );
495 recalcVariables( VT_TIME );
496 recalcVariables( VT_STATISTIC );
497 TQDomDocument doc = createDomDocument(
"DOC", CURRENT_DTD_VERSION );
498 TQDomElement presenter=doc.documentElement();
499 presenter.setAttribute(
"editor",
"KPresenter");
500 presenter.setAttribute(
"mime",
"application/x-kpresenter");
501 presenter.setAttribute(
"syntaxVersion", CURRENT_SYNTAX_VERSION);
502 TQDomElement paper=doc.createElement(
"PAPER");
503 paper.setAttribute(
"format",
static_cast<int>( m_pageLayout.format ));
504 paper.setAttribute(
"ptWidth", TQString::number( m_pageLayout.ptWidth,
'g', 10 ));
505 paper.setAttribute(
"ptHeight", TQString::number( m_pageLayout.ptHeight,
'g', 10 ));
507 paper.setAttribute(
"orientation",
static_cast<int>( m_pageLayout.orientation ));
508 paper.setAttribute(
"unit", unit() );
509 paper.setAttribute(
"tabStopValue", m_tabStop );
511 TQDomElement paperBorders=doc.createElement(
"PAPERBORDERS");
513 paperBorders.setAttribute(
"ptLeft", m_pageLayout.ptLeft);
514 paperBorders.setAttribute(
"ptTop", m_pageLayout.ptTop);
515 paperBorders.setAttribute(
"ptRight", m_pageLayout.ptRight);
516 paperBorders.setAttribute(
"ptBottom", m_pageLayout.ptBottom);
517 paper.appendChild(paperBorders);
518 presenter.appendChild(paper);
520 m_varColl->variableSetting()->save(presenter );
522 presenter.appendChild(saveAttribute( doc ));
524 if ( saveOnlyPage == -1 )
525 emit sigProgress( 5 );
527 TQDomElement element=doc.createElement(
"BACKGROUND");
528 element.appendChild(saveBackground( doc ));
529 presenter.appendChild(element);
531 if ( saveOnlyPage == -1 )
532 emit sigProgress( 10 );
535 element=doc.createElement(
"HEADER");
536 element.setAttribute(
"show",
static_cast<int>( m_pageList.at(0)->hasHeader() ));
537 element.appendChild(_header->save( doc,0 ));
538 presenter.appendChild(element);
540 element=doc.createElement(
"FOOTER");
541 element.setAttribute(
"show",
static_cast<int>( m_pageList.at(0)->hasFooter() ));
542 element.appendChild(_footer->save( doc,0 ));
543 presenter.appendChild(element);
545 element = doc.createElement(
"HEADERFOOTERBYPAGE" );
546 element.setAttribute(
"value",
"true" );
547 presenter.appendChild( element );
549 element=doc.createElement(
"HELPLINES");
550 element.setAttribute(
"show",
static_cast<int>( showGuideLines() ));
551 saveGuideLines( doc, element );
552 presenter.appendChild(element);
554 if ( saveOnlyPage == -1 )
556 if( !m_spellCheckIgnoreList.isEmpty() )
558 TQDomElement spellCheckIgnore = doc.createElement(
"SPELLCHECKIGNORELIST" );
559 presenter.appendChild( spellCheckIgnore );
560 for ( TQStringList::Iterator it = m_spellCheckIgnoreList.begin(); it != m_spellCheckIgnoreList.end(); ++it )
562 TQDomElement spellElem = doc.createElement(
"SPELLCHECKIGNOREWORD" );
563 spellCheckIgnore.appendChild( spellElem );
564 spellElem.setAttribute(
"word", *it );
569 if ( saveOnlyPage == -1 )
570 emit sigProgress( 20 );
572 presenter.appendChild(saveTitle( doc ));
574 presenter.appendChild(saveNote( doc ));
576 if ( saveOnlyPage == -1 )
577 emit sigProgress( 30 );
579 presenter.appendChild(saveObjects(doc));
582 element=doc.createElement(
"INFINITLOOP");
583 element.setAttribute(
"value", _spInfiniteLoop);
584 element=doc.createElement(
"SHOWENDOFPRESENTATIONSLIDE");
585 element.setAttribute(
"value", _spShowEndOfPresentationSlide);
586 presenter.appendChild(element);
587 element=doc.createElement(
"MANUALSWITCH");
588 element.setAttribute(
"value", _spManualSwitch);
589 presenter.appendChild(element);
590 element=doc.createElement(
"PRESSPEED");
593 presenter.appendChild(element);
594 element=doc.createElement(
"SHOWPRESENTATIONDURATION");
595 element.setAttribute(
"value", _showPresentationDuration);
596 presenter.appendChild(element);
598 if ( saveOnlyPage == -1 )
600 if ( !m_customListSlideShow.isEmpty() )
602 TQMap<KPrPage *, TQString> page2name;
604 for ( TQPtrListIterator<KPrPage> it( m_pageList ); it.current(); ++it )
606 page2name.insert( it.current(),
"page" + TQString::number( pos++ ) ) ;
609 element = doc.createElement(
"CUSTOMSLIDESHOWCONFIG" );
610 CustomSlideShowMap::Iterator it;
611 for ( it = m_customListSlideShow.begin(); it != m_customListSlideShow.end(); ++it )
613 TQDomElement slide=doc.createElement(
"CUSTOMSLIDESHOW");
614 slide.setAttribute(
"name", it.key() );
616 TQValueListIterator<KPrPage*> itPage ;
617 for( itPage = ( *it ).begin(); itPage != ( *it ).end(); ++itPage )
619 int posPage = m_pageList.find( *itPage );
622 if ( itPage != ( *it ).begin() )
624 tmp += page2name[*itPage];
627 slide.setAttribute(
"pages", tmp );
628 element.appendChild(slide);
630 presenter.appendChild(element);
634 if ( !m_presentationName.isEmpty() )
636 element = doc.createElement(
"DEFAULTCUSTOMSLIDESHOWNAME" );
637 element.setAttribute(
"name", m_presentationName );
638 presenter.appendChild(element);
642 if ( saveOnlyPage == -1 )
643 emit sigProgress( 40 );
645 if ( saveOnlyPage == -1 )
647 element=doc.createElement(
"SELSLIDES");
648 for ( uint i = 0; i < m_pageList.count(); i++ ) {
649 TQDomElement slide=doc.createElement(
"SLIDE");
650 slide.setAttribute(
"nr", i);
651 slide.setAttribute(
"show", m_pageList.at(i)->isSlideSelected());
652 element.appendChild(slide);
654 presenter.appendChild(element);
656 emit sigProgress( 50 );
659 if ( saveOnlyPage == -1 )
661 TQDomElement styles = doc.createElement(
"STYLES" );
662 presenter.appendChild( styles );
663 TQValueList<KoUserStyle *> styleList(m_styleColl->styleList());
664 for ( TQValueList<KoUserStyle *>::const_iterator it = styleList.begin(), end = styleList.end();
666 saveStyle(
static_cast<KoParagStyle *
>( *it ), styles );
668 emit sigProgress( 60 );
672 TQPtrListIterator<KoDocumentChild> chl( children() );
673 for( ; chl.current(); ++chl ) {
676 for (
int i = 0; i < static_cast<int>( m_pageList.count() ); i++ ) {
677 if ( saveOnlyPage != -1 && i != saveOnlyPage )
680 if ( saveOnlyPage == -1 )
682 offset = i * m_pageList.at(i)->getPageRect().height();
684 saveEmbeddedObject(m_pageList.at(i), chl.current(),doc,presenter,offset );
686 if ( saveOnlyPage == -1 )
688 saveEmbeddedObject(m_masterPage, chl.current(),doc,presenter,0.0 );
692 if ( saveOnlyPage == -1 )
693 emit sigProgress( 70 );
694 makeUsedPixmapList();
696 TQDomElement pictures = m_pictureCollection.saveXML( KoPictureCollection::CollectionPicture, doc, usedPictures );
697 presenter.appendChild( pictures );
699 if ( saveOnlyPage == -1 )
700 emit sigProgress( 90 );
703 makeUsedSoundFileList();
704 TQDomElement soundFiles = saveUsedSoundFileToXML( doc, usedSoundFile );
705 presenter.appendChild( soundFiles );
707 if ( saveOnlyPage == -1 )
708 setModified(
false );
712void KPrDocument::saveEmbeddedObject(KPrPage *page,
const TQPtrList<KoDocumentChild>& childList,
713 TQDomDocument &doc,TQDomElement &presenter )
715 TQPtrListIterator<KoDocumentChild> chl( childList );
718 if ( m_pageList.findRef( page ) )
720 offset=m_pageList.findRef(page)*page->getPageRect().height();
722 for( ; chl.current(); ++chl )
723 saveEmbeddedObject(page, chl.current(),doc,presenter, offset );
726void KPrDocument::saveEmbeddedObject(KPrPage *page, KoDocumentChild *chl, TQDomDocument &doc,
727 TQDomElement &presenter,
double offset )
729 TQPtrListIterator<KPrObject> oIt(page->objectList());
730 for (
int pos = 0; oIt.current(); ++oIt, ++pos )
732 if ( oIt.current()->getType() == OT_PART &&
733 static_cast<KPrPartObject*
>( oIt.current() )->getChild() == chl )
735 TQDomElement embedded=doc.createElement(
"EMBEDDED");
736 KPrChild* curr = (KPrChild*)chl;
739 TQRect _rect = curr->geometry();
740 int tmpX = (int)zoomHandler()->unzoomItX( _rect.x() );
741 int tmpY = (int)zoomHandler()->unzoomItY( _rect.y() );
742 int tmpWidth = (int)zoomHandler()->unzoomItX( _rect.width() );
743 int tmpHeight = (int)zoomHandler()->unzoomItY( _rect.height() );
744 curr->setGeometry( TQRect( tmpX, tmpY, tmpWidth, tmpHeight ) );
746 embedded.appendChild(curr->save(doc,
true));
748 curr->setGeometry( _rect );
750 TQDomElement settings=doc.createElement(
"SETTINGS");
751 settings.setAttribute(
"z-index", pos );
752 if ( page == m_masterPage )
753 settings.setAttribute(
"sticky", 1 );
754 TQPtrListIterator<KPrObject> setOIt(page->objectList());
755 for (; setOIt.current(); ++setOIt )
757 if ( setOIt.current()->getType() == OT_PART &&
758 dynamic_cast<KPrPartObject*
>( setOIt.current() )->getChild() == curr )
759 settings.appendChild(setOIt.current()->save( doc,offset ));
761 embedded.appendChild(settings);
762 presenter.appendChild(embedded);
769void KPrDocument::compatibilityFromOldFileFormat()
773 if ( m_loadingInfo && m_loadingInfo->oldFormat() )
775 EffectSpeed newValue = ES_MEDIUM;
776 bool presSpeedChanged = ( m_loadingInfo->presSpeed != -1 );
777 if ( presSpeedChanged )
779 if ( m_loadingInfo->presSpeed < 3 )
781 else if ( m_loadingInfo->presSpeed > 7 )
784 if ( !m_loadingInfo->m_headerFooterByPage )
786 for (
int i = 0; i < static_cast<int>( m_pageList.count() ); i++ )
788 if ( presSpeedChanged )
789 m_pageList.at(i)->setPageEffectSpeed( newValue );
790 m_pageList.at( i )->setHeader( m_loadingInfo->m_header );
791 m_pageList.at( i )->setFooter( m_loadingInfo->m_footer );
796 delete m_loadingInfo;
801void KPrDocument::enableEmbeddedParts(
bool f )
803 TQPtrListIterator<KPrPage> it( m_pageList );
804 for ( ; it.current(); ++it )
805 it.current()->enableEmbeddedParts(f);
808TQDomDocumentFragment KPrDocument::saveBackground( TQDomDocument &doc )
810 TQDomDocumentFragment fragment=doc.createDocumentFragment();
811 for (
int i = 0; i < static_cast<int>( m_pageList.count() ); i++ ) {
812 if ( saveOnlyPage != -1 && i != saveOnlyPage )
814 fragment.appendChild( m_pageList.at(i)->save( doc ) );
817 if ( saveOnlyPage == -1 )
819 fragment.appendChild( m_masterPage->save( doc ) );
824TQDomElement KPrDocument::saveObjects( TQDomDocument &doc )
826 TQDomElement objects=doc.createElement(
"OBJECTS");
828 for (
int i = 0; i < static_cast<int>( m_pageList.count() ); i++ ) {
829 if ( saveOnlyPage != -1 && saveOnlyPage!=i)
831 yoffset=i*m_pageList.at(i)->getPageRect().height();
832 objects=m_pageList.at(i)->saveObjects( doc, objects, yoffset, saveOnlyPage );
835 if ( !_duplicatePage )
837 objects = m_masterPage->saveObjects( doc, objects, 0.0, saveOnlyPage );
843TQDomElement KPrDocument::saveTitle( TQDomDocument &doc )
845 TQDomElement titles=doc.createElement(
"PAGETITLES");
847 if ( saveOnlyPage == -1 )
849 for (
int i = 0; i < static_cast<int>( m_pageList.count() ); i++ )
851 TQDomElement title=doc.createElement(
"Title");
852 title.setAttribute(
"title", m_pageList.at(i)->manualTitle());
853 titles.appendChild(title);
858 TQDomElement title=doc.createElement(
"Title");
859 title.setAttribute(
"title", m_pageList.at(saveOnlyPage)->manualTitle());
860 titles.appendChild(title);
865TQDomElement KPrDocument::saveNote( TQDomDocument &doc )
867 TQDomElement notes=doc.createElement(
"PAGENOTES");
869 if ( saveOnlyPage == -1 ) {
870 for (
int i = 0; i < static_cast<int>( m_pageList.count() ); i++ )
872 TQDomElement note=doc.createElement(
"Note");
873 note.setAttribute(
"note", m_pageList.at(i)->noteText( ));
874 notes.appendChild(note);
878 TQDomElement note=doc.createElement(
"Note");
879 note.setAttribute(
"note", m_pageList.at(saveOnlyPage)->noteText( ));
880 notes.appendChild(note);
886TQDomElement KPrDocument::saveAttribute( TQDomDocument &doc )
888 TQDomElement attributes=doc.createElement(
"ATTRIBUTES");
892 if ( m_initialActivePage )
893 activePage=m_pageList.findRef(m_initialActivePage);
894 activePage = TQMAX( activePage, 0);
895 attributes.setAttribute(
"activePage",activePage );
896 attributes.setAttribute(
"gridx", m_gridX );
897 attributes.setAttribute(
"gridy", m_gridY );
898 attributes.setAttribute(
"snaptogrid", (
int)m_bSnapToGrid );
902TQDomElement KPrDocument::saveUsedSoundFileToXML( TQDomDocument &_doc, TQStringList _list )
904 TQDomElement soundFiles = _doc.createElement(
"SOUNDS" );
907 TQStringList::Iterator it = _list.begin();
908 for ( ; it != _list.end(); ++it ) {
909 TQString soundFileName = *it;
910 int position = soundFileName.findRev(
'.' );
911 TQString format = soundFileName.right( soundFileName.length() - position - 1 );
912 TQString _name = TQString(
"sounds/sound%1.%2" ).arg( ++i ).arg( format.lower() );
914 TQDomElement fileElem = _doc.createElement(
"FILE" );
915 soundFiles.appendChild( fileElem );
916 fileElem.setAttribute(
"filename", soundFileName );
917 fileElem.setAttribute(
"name", _name );
923bool KPrDocument::completeSaving( KoStore* _store )
926 if ( saveOnlyPage == -1 ) {
927 emit sigProgress( 100 );
928 emit sigProgress( -1 );
933 m_pictureCollection.saveToStore( KoPictureCollection::CollectionPicture, _store, usedPictures );
935 saveUsedSoundFileToStore( _store, usedSoundFile );
937 if ( saveOnlyPage == -1 ) {
938 emit sigProgress( 100 );
939 emit sigProgress( -1 );
945int KPrDocument::supportedSpecialFormats()
const
947 return KoDocument::supportedSpecialFormats();
950void KPrDocument::saveUsedSoundFileToStore( KoStore *_store, TQStringList _list )
953 TQStringList::Iterator it = _list.begin();
954 for ( ; it != _list.end(); ++it ) {
955 TQString soundFileName = *it;
956 int position = soundFileName.findRev(
'.' );
957 TQString format = soundFileName.right( soundFileName.length() - position - 1 );
958 TQString _storeURL = TQString(
"sounds/sound%1.%2" ).arg( ++i ).arg( format.lower() );
960 if ( _store->open( _storeURL ) ) {
961 KoStoreDevice dev( _store );
962 TQFile _file( soundFileName );
963 if ( _file.open( IO_ReadOnly ) ) {
964 dev.writeBlock( ( _file.readAll() ).data(), _file.size() );
972bool KPrDocument::loadChildren( KoStore* _store )
974 if ( objStartY == 0 && _clean)
976 TQPtrListIterator<KoDocumentChild> it( children() );
977 for( ; it.current(); ++it ) {
978 if ( !((KoDocumentChild*)it.current())->loadDocument( _store ) )
984 TQPtrListIterator<KoDocumentChild> it( children() );
985 for(
int i = 0; it.current(); ++it, ++i ) {
986 if ( i < m_childCountBeforeInsert )
988 if ( !((KoDocumentChild*)it.current())->loadDocument( _store ) )
995bool KPrDocument::saveOasis( KoStore* store, KoXmlWriter* manifestWriter )
999 if ( saveOnlyPage == -1 ) {
1000 emit sigProgress( 0 );
1002 if ( !store->open(
"content.xml" ) )
1004 m_pictureCollection.assignUniqueIds();
1005 KoStoreDevice contentDev( store );
1006 KoXmlWriter* contentWriter = createOasisXmlWriter( &contentDev,
"office:document-content" );
1009 m_varColl->variableSetting()->setModificationDate(TQDateTime::currentDateTime());
1010 recalcVariables( VT_DATE );
1011 recalcVariables( VT_TIME );
1012 recalcVariables( VT_STATISTIC );
1013 KoGenStyles mainStyles;
1014 KoSavingContext savingContext( mainStyles, 0,
false, KoSavingContext::Store );
1017 m_styleColl->saveOasis( mainStyles, KoGenStyle::STYLE_USER, savingContext );
1019 KTempFile contentTmpFile;
1020 contentTmpFile.setAutoDelete(
true );
1021 TQFile* tmpFile = contentTmpFile.file();
1022 KoXmlWriter contentTmpWriter( tmpFile, 1 );
1026 KTempFile stickyTmpFile;
1027 stickyTmpFile.setAutoDelete(
true );
1028 TQFile* masterStyles = stickyTmpFile.file();
1029 KoXmlWriter stickyTmpWriter( masterStyles, 1 );
1032 contentTmpWriter.startElement(
"office:body" );
1033 contentTmpWriter.startElement(
"office:presentation" );
1035 saveOasisCustomFied( contentTmpWriter );
1038 int partIndexObj = 0;
1041 TQMap<TQString, int> pageNames;
1043 if ( !_duplicatePage )
1045 m_masterPage->saveOasisPage( store, stickyTmpWriter, 0, savingContext, indexObj, partIndexObj, manifestWriter, pageNames );
1048 TQValueList<KoGenStyles::NamedStyle> autoStyles = mainStyles.styles( KoGenStyle::STYLE_AUTO );
1049 for ( TQValueList<KoGenStyles::NamedStyle>::const_iterator it = autoStyles.begin();
1050 it != autoStyles.end(); ++it ) {
1051 kdDebug() <<
"marking for styles.xml:" << ( *it ).name << endl;
1052 mainStyles.markStyleForStylesXml( ( *it ).name );
1057 if ( saveOnlyPage != -1 )
1059 m_pageList.at( saveOnlyPage )->saveOasisPage( store, contentTmpWriter, ( saveOnlyPage+1 ), savingContext, indexObj, partIndexObj , manifestWriter, pageNames );
1063 for (
int i = 0; i < static_cast<int>( m_pageList.count() ); i++ )
1065 m_pageList.at( i )->saveOasisPage( store, contentTmpWriter, ( i+1 ), savingContext, indexObj, partIndexObj , manifestWriter, pageNames );
1068 if ( saveOnlyPage == -1 )
1070 TQMap<int, TQString> page2name;
1071 TQMap<TQString, int>::ConstIterator it( pageNames.begin() );
1072 for ( ; it != pageNames.end(); ++it )
1074 page2name.insert( it.data(), it.key() );
1076 saveOasisPresentationSettings( contentTmpWriter, page2name );
1079 contentTmpWriter.endElement();
1080 contentTmpWriter.endElement();
1082 writeAutomaticStyles( *contentWriter, mainStyles, savingContext,
false );
1086 contentWriter->addCompleteElement( tmpFile );
1087 contentTmpFile.close();
1089 contentWriter->endElement();
1090 contentWriter->endDocument();
1091 delete contentWriter;
1093 if ( !store->close() )
1097 manifestWriter->addManifestEntry(
"content.xml",
"text/xml" );
1099 if ( !store->open(
"styles.xml" ) )
1102 manifestWriter->addManifestEntry(
"styles.xml",
"text/xml" );
1105 masterStyles->close();
1106 saveOasisDocumentStyles( store, mainStyles, masterStyles, savingContext );
1107 stickyTmpFile.close();
1109 if ( !store->close() )
1113 if ( saveOnlyPage == -1 )
1114 emit sigProgress( 90 );
1120 makeUsedPixmapList();
1122 m_pictureCollection.saveOasisToStore( store, usedPictures, manifestWriter);
1124 if(!store->open(
"settings.xml"))
1127 KoXmlWriter& settingsWriter = *createOasisXmlWriter(&contentDev,
"office:document-settings");
1128 settingsWriter.startElement(
"office:settings");
1130 settingsWriter.startElement(
"config:config-item-set");
1131 settingsWriter.addAttribute(
"config:name",
"view-settings");
1133 KoUnit::saveOasis(&settingsWriter, unit());
1134 saveOasisSettings( settingsWriter );
1136 settingsWriter.endElement();
1138 settingsWriter.startElement(
"config:config-item-set");
1139 settingsWriter.addAttribute(
"config:name",
"configuration-settings");
1140 settingsWriter.addConfigItem(
"SpellCheckerIgnoreList", m_spellCheckIgnoreList.join(
"," ) );
1141 settingsWriter.addConfigItem(
"ShowPresentationDuration", _showPresentationDuration );
1142 settingsWriter.endElement();
1144 m_varColl->variableSetting()->saveOasis( settingsWriter );
1146 settingsWriter.endElement();
1147 settingsWriter.endElement();
1148 settingsWriter.endDocument();
1149 delete &settingsWriter;
1154 manifestWriter->addManifestEntry(
"settings.xml",
"text/xml");
1157 emit sigProgress( 100 );
1158 emit sigProgress( -1 );
1160 setModified(
false );
1165void KPrDocument::saveOasisCustomFied( KoXmlWriter &writer )
const
1167 bool customVariableFound =
false;
1168 TQPtrListIterator<KoVariable> it( m_varColl->getVariables() );
1169 for ( ; it.current() ; ++it )
1171 if ( it.current()->type() == VT_CUSTOM )
1173 if ( !customVariableFound )
1175 writer.startElement(
"text:user-field-decls" );
1176 customVariableFound =
true;
1179 writer.startElement(
"text:user-field-decl" );
1180 writer.addAttribute(
"office:value-type",
"string" );
1181 writer.addAttribute(
"office:string-value",
static_cast<KoCustomVariable *
>( it.current() )->value() );
1182 writer.addAttribute(
"text:name",
static_cast<KoCustomVariable*
>( it.current() )->name() );
1183 writer.endElement();
1186 if ( customVariableFound )
1187 writer.endElement();
1190void KPrDocument::loadOasisIgnoreList(
const KoOasisSettings& settings )
1192 KoOasisSettings::Items configurationSettings = settings.itemSet(
"configuration-settings" );
1193 if ( !configurationSettings.isNull() )
1195 _showPresentationDuration = configurationSettings.parseConfigItemBool(
"ShowPresentationDuration",
false );
1196 const TQString ignorelist = configurationSettings.parseConfigItemString(
"SpellCheckerIgnoreList" );
1197 m_spellCheckIgnoreList = TQStringList::split(
',', ignorelist );
1201void KPrDocument::writeAutomaticStyles( KoXmlWriter& contentWriter, KoGenStyles& mainStyles, KoSavingContext& context,
bool stylesDotXml )
1203 if ( !stylesDotXml )
1205 context.writeFontFaces( contentWriter );
1206 contentWriter.startElement(
"office:automatic-styles" );
1208 TQValueList<KoGenStyles::NamedStyle> styles = mainStyles.styles( KoGenStyle::STYLE_AUTO, stylesDotXml );
1209 TQValueList<KoGenStyles::NamedStyle>::const_iterator it = styles.begin();
1210 for ( ; it != styles.end() ; ++it ) {
1211 (*it).style->writeStyle( &contentWriter, mainStyles,
"style:style", (*it).name,
"style:paragraph-properties" );
1214 styles = mainStyles.styles( KoGenStyle::STYLE_AUTO_LIST, stylesDotXml );
1215 it = styles.begin();
1216 for ( ; it != styles.end() ; ++it ) {
1217 ( *it ).style->writeStyle( &contentWriter, mainStyles,
"text:list-style", (*it).name, 0 );
1220 styles = mainStyles.styles( STYLE_BACKGROUNDPAGEAUTO, stylesDotXml );
1221 it = styles.begin();
1222 for ( ; it != styles.end() ; ++it ) {
1223 (*it).style->writeStyle( &contentWriter, mainStyles,
"style:style", (*it).name,
"style:drawing-page-properties" );
1226 styles = mainStyles.styles( KoGenStyle::STYLE_GRAPHICAUTO, stylesDotXml );
1227 it = styles.begin();
1228 for ( ; it != styles.end() ; ++it ) {
1229 (*it).style->writeStyle( &contentWriter, mainStyles,
"style:style", (*it).name ,
"style:graphic-properties" );
1232 styles = mainStyles.styles( KoGenStyle::STYLE_NUMERIC_DATE, stylesDotXml );
1233 it = styles.begin();
1234 for ( ; it != styles.end() ; ++it ) {
1235 (*it).style->writeStyle( &contentWriter, mainStyles,
"number:date-style", (*it).name, 0 );
1237 styles = mainStyles.styles( KoGenStyle::STYLE_NUMERIC_TIME, stylesDotXml );
1238 it = styles.begin();
1239 for ( ; it != styles.end() ; ++it ) {
1240 (*it).style->writeStyle( &contentWriter, mainStyles,
"number:time-style", (*it).name, 0 );
1243 if ( !stylesDotXml )
1245 contentWriter.endElement();
1249void KPrDocument::loadOasisHeaderFooter(TQDomNode & drawPage, KoOasisContext & context)
1251 TQDomNode tmp = KoDom::namedItemNS( drawPage, KoXmlNS::style,
"header" );
1252 if ( !tmp.isNull() )
1255 _header->textObject()->loadOasisContent( tmp.toElement(), context, styleCollection() );
1257 tmp = KoDom::namedItemNS( drawPage, KoXmlNS::style,
"footer" );
1258 if ( !tmp.isNull() )
1261 _footer->textObject()->loadOasisContent( tmp.toElement(), context, styleCollection() );
1265void KPrDocument::saveOasisSettings( KoXmlWriter &settingsWriter )
1267 settingsWriter.startElement(
"config:config-item-map-indexed");
1268 settingsWriter.addAttribute(
"config:name",
"Views");
1269 settingsWriter.startElement(
"config:config-item-map-entry" );
1273 TQString guideLinesOasis;
1275 for( TQValueList<double>::Iterator it = m_vGuideLines.begin(); it != m_vGuideLines.end(); ++it )
1277 int tmpX = ( int ) ( KoUnit::toMM( *it )*100 );
1278 guideLinesOasis +=
"V" + TQString::number( tmpX );
1281 for( TQValueList<double>::Iterator it = m_hGuideLines.begin(); it != m_hGuideLines.end(); ++it )
1283 int tmpY = ( int ) ( KoUnit::toMM( *it )*100 );
1284 guideLinesOasis +=
"H" + TQString::number( tmpY );
1286 if ( !guideLinesOasis.isEmpty() )
1288 settingsWriter.addConfigItem(
"SnapLinesDrawing", guideLinesOasis );
1291 settingsWriter.addConfigItem(
"IsSnapToGrid", m_bSnapToGrid );
1294 settingsWriter.addConfigItem(
"GridFineWidth", ( (
int ) ( KoUnit::toMM( ( m_gridX ) )*100 ) ) );
1298 settingsWriter.addConfigItem(
"GridFineHeight", ( (
int ) ( KoUnit::toMM( ( m_gridY ) )*100 ) ) );
1303 if ( m_initialActivePage )
1304 activePage=m_pageList.findRef(m_initialActivePage);
1305 activePage = TQMAX( activePage, 0);
1306 settingsWriter.addConfigItem(
"SelectedPage", activePage );
1309 settingsWriter.addConfigItem(
"SnapLineIsVisible", showGuideLines() );
1310 settingsWriter.endElement();
1311 settingsWriter.endElement();
1314void KPrDocument::loadOasisSettings(
const TQDomDocument&settingsDoc)
1316 kdDebug(33001)<<
"void KPrDocument::loadOasisSettings(const TQDomDocument&settingsDoc)**********\n";
1317 KoOasisSettings settings( settingsDoc );
1318 KoOasisSettings::Items viewSettings = settings.itemSet(
"view-settings" );
1319 setUnit(KoUnit::unit(viewSettings.parseConfigItemString(
"unit")));
1320 KoOasisSettings::IndexedMap viewMap = viewSettings.indexedMap(
"Views" );
1321 KoOasisSettings::Items firstView = viewMap.entry( 0 );
1322 if ( !firstView.isNull() )
1324 parseOasisGuideLines( firstView.parseConfigItemString(
"SnapLinesDrawing" ) );
1325 setShowGuideLines( firstView.parseConfigItemBool(
"SnapLineIsVisible" ) );
1326 int valx = firstView.parseConfigItemInt(
"GridFineWidth" );
1327 m_gridX = MM_TO_POINT( valx / 100.0 );
1328 int valy = firstView.parseConfigItemInt(
"GridFineHeight" );
1329 m_gridY = MM_TO_POINT( valy / 100.0 );
1331 m_bSnapToGrid = firstView.parseConfigItemBool(
"IsSnapToGrid" );
1333 int activePage = firstView.parseConfigItemInt(
"SelectedPage" );
1334 kdDebug(33001)<<
" activePage :"<<activePage<<endl;
1336 m_initialActivePage=m_pageList.at(activePage);
1338 loadOasisIgnoreList( settings );
1339 m_varColl->variableSetting()->loadOasis( settings );
1342void KPrDocument::parseOasisGuideLines(
const TQString &text )
1345 int newPos = text.length()-1;
1346 for (
int pos = text.length()-1; pos >=0;--pos )
1348 if ( text[pos]==
'V' )
1351 str = text.mid( pos+1, ( newPos-pos ) );
1353 double posX = ( str.toInt() / 100.0 );
1354 m_vGuideLines.append( MM_TO_POINT( posX ) );
1357 else if ( text[pos]==
'H' )
1360 str = text.mid( pos+1, ( newPos-pos ) );
1362 double posY = ( str.toInt() / 100.0 );
1363 m_hGuideLines.append( MM_TO_POINT( posY ) );
1369void KPrDocument::loadOasisPresentationSettings( TQDomNode &settingsDoc )
1372 TQDomElement settings( settingsDoc.toElement() );
1374 if (settings.attributeNS( KoXmlNS::presentation,
"endless", TQString())==
"true")
1375 _spInfiniteLoop =
true;
1376 if (settings.attributeNS( KoXmlNS::presentation,
"show-end-of-presentation-slide", TQString())==
"true")
1377 _spShowEndOfPresentationSlide =
true;
1378 if (settings.attributeNS( KoXmlNS::presentation,
"force-manual", TQString())==
"true")
1379 _spManualSwitch =
true;
1380 if ( settings.hasAttributeNS( KoXmlNS::presentation,
"start-page" ) )
1385 if ( settings.hasAttributeNS( KoXmlNS::presentation,
"show" ) )
1387 m_presentationName = settings.attributeNS( KoXmlNS::presentation,
"show", TQString() );
1388 kdDebug()<<
" default presentation name :"<<m_presentationName<<endl;
1390 loadOasisPresentationCustomSlideShow( settingsDoc );
1393void KPrDocument::loadOasisPresentationCustomSlideShow( TQDomNode &settingsDoc )
1396 for ( TQDomNode element = settingsDoc.firstChild(); !element.isNull(); element = element.nextSibling() )
1398 TQDomElement e = element.toElement();
1399 TQCString tagName = e.tagName().latin1();
1401 if ( tagName ==
"show" && e.namespaceURI() == KoXmlNS::presentation )
1404 TQString name = e.attributeNS( KoXmlNS::presentation,
"name", TQString() );
1405 TQStringList tmp = TQStringList::split(
",", e.attributeNS( KoXmlNS::presentation,
"pages", TQString()) );
1406 TQValueList<KPrPage *> pageList;
1407 for ( TQStringList::Iterator it = tmp.begin(); it != tmp.end(); ++it )
1409 if ( m_loadingInfo->m_name2page.contains( *it ) )
1411 kdDebug(33001) <<
"slide show " << name <<
" page = " << *it << endl;
1412 pageList.push_back( m_loadingInfo->m_name2page[*it] );
1415 if ( ! pageList.empty() )
1417 m_customListSlideShow.insert( name, pageList );
1423void KPrDocument::saveOasisPresentationSettings( KoXmlWriter &contentTmpWriter, TQMap<int, TQString> &page2name )
1427 contentTmpWriter.startElement(
"presentation:settings" );
1428 contentTmpWriter.addAttribute(
"presentation:endless", ( _spInfiniteLoop ?
"true" :
"false" ) );
1429 contentTmpWriter.addAttribute(
"presentation:show-end-of-presentation-slide", ( _spShowEndOfPresentationSlide ?
"true" :
"false" ) );
1430 contentTmpWriter.addAttribute(
"presentation:force-manual", ( _spManualSwitch ?
"true" :
"false" ) );
1432 if ( !m_presentationName.isEmpty() )
1433 contentTmpWriter.addAttribute(
"presentation:show", m_presentationName );
1435 saveOasisPresentationCustomSlideShow( contentTmpWriter, page2name );
1436 contentTmpWriter.endElement();
1439void KPrDocument::saveOasisPresentationCustomSlideShow( KoXmlWriter &contentTmpWriter, TQMap<int, TQString> &page2name )
1441 if ( m_customListSlideShow.isEmpty() )
1444 CustomSlideShowMap::Iterator it;
1445 for ( it = m_customListSlideShow.begin(); it != m_customListSlideShow.end(); ++it )
1447 contentTmpWriter.startElement(
"presentation:show" );
1448 contentTmpWriter.addAttribute(
"presentation:name", it.key() );
1450 TQValueListIterator<KPrPage*> itPage ;
1451 for( itPage = ( *it ).begin(); itPage != ( *it ).end(); ++itPage )
1453 int posPage = m_pageList.find(*itPage );
1454 if ( posPage != -1 )
1456 if ( itPage != ( *it ).begin() )
1459 tmp += page2name[posPage + 1];
1462 contentTmpWriter.addAttribute(
"presentation:pages", tmp );
1463 contentTmpWriter.endElement();
1468void KPrDocument::saveOasisDocumentStyles( KoStore* store, KoGenStyles& mainStyles, TQFile* masterStyles,
1469 KoSavingContext & savingContext, SaveFlag saveFlag )
const
1471 KoStoreDevice stylesDev( store );
1472 KoXmlWriter* stylesWriter = createOasisXmlWriter( &stylesDev,
"office:document-styles" );
1475 savingContext.writeFontFaces( *stylesWriter );
1477 stylesWriter->startElement(
"office:styles" );
1478 TQValueList<KoGenStyles::NamedStyle> styles = mainStyles.styles( KoGenStyle::STYLE_USER );
1479 TQValueList<KoGenStyles::NamedStyle>::const_iterator it = styles.begin();
1480 for ( ; it != styles.end() ; ++it ) {
1481 (*it).style->writeStyle( stylesWriter, mainStyles,
"style:style", (*it).name,
"style:paragraph-properties" );
1483 styles = mainStyles.styles( KoGenStyle::STYLE_LIST );
1484 it = styles.begin();
1485 for ( ; it != styles.end() ; ++it ) {
1486 (*it).style->writeStyle( stylesWriter, mainStyles,
"text:list-style", (*it).name, 0 );
1488 styles = mainStyles.styles( KoGenStyle::STYLE_HATCH );
1489 it = styles.begin();
1490 for ( ; it != styles.end() ; ++it ) {
1491 (*it).style->writeStyle( stylesWriter, mainStyles,
"draw:hatch", (*it).name,
"style:graphic-properties" ,
true,
true );
1493 styles = mainStyles.styles( STYLE_GRADIENT );
1494 it = styles.begin();
1495 for ( ; it != styles.end() ; ++it ) {
1496 (*it).style->writeStyle( stylesWriter, mainStyles,
"draw:gradient", (*it).name,
"style:graphic-properties" ,
true,
true );
1499 styles = mainStyles.styles( STYLE_STROKE );
1500 it = styles.begin();
1501 for ( ; it != styles.end() ; ++it ) {
1502 (*it).style->writeStyle( stylesWriter, mainStyles,
"draw:stroke-dash", (*it).name,
"style:graphic-properties" ,
true,
true );
1505 styles = mainStyles.styles( STYLE_MARKER );
1506 it = styles.begin();
1507 for ( ; it != styles.end() ; ++it ) {
1508 (*it).style->writeStyle( stylesWriter, mainStyles,
"draw:marker", (*it).name,
"style:graphic-properties" ,
true,
true );
1510 styles = mainStyles.styles( STYLE_PICTURE );
1511 it = styles.begin();
1512 for ( ; it != styles.end() ; ++it ) {
1513 (*it).style->writeStyle( stylesWriter, mainStyles,
"draw:fill-image", (*it).name,
"style:image-properties" ,
true,
true );
1516 stylesWriter->endElement();
1518 if ( saveFlag == SaveAll )
1520 stylesWriter->startElement(
"office:automatic-styles" );
1524 writeAutomaticStyles( *stylesWriter, mainStyles, savingContext,
true );
1527 styles = mainStyles.styles( STYLE_BACKGROUNDPAGE );
1528 it = styles.begin();
1529 for ( ; it != styles.end() ; ++it ) {
1530 (*it).style->writeStyle( stylesWriter, mainStyles,
"style:style", (*it).name ,
"style:drawing-page-properties" );
1534 styles = mainStyles.styles( KoGenStyle::STYLE_PAGELAYOUT );
1535 Q_ASSERT( styles.count() == 1 );
1536 it = styles.begin();
1537 for ( ; it != styles.end() ; ++it ) {
1538 (*it).style->writeStyle( stylesWriter, mainStyles,
"style:page-layout", (*it).name,
"style:page-layout-properties",
false );
1539 stylesWriter->endElement();
1542 styles = mainStyles.styles( STYLE_PRESENTATIONSTICKYOBJECT );
1543 it = styles.begin();
1544 for ( ; it != styles.end() ; ++it ) {
1546 (*it).style->writeStyle( stylesWriter, mainStyles,
"style:style", (*it).name ,
"style:graphic-properties" );
1549 stylesWriter->endElement();
1554 stylesWriter->startElement(
"office:master-styles" );
1555 stylesWriter->addCompleteElement( masterStyles );
1556 stylesWriter->endElement();
1560 stylesWriter->endElement();
1561 stylesWriter->endDocument();
1562 delete stylesWriter;
1565bool KPrDocument::loadOasis(
const TQDomDocument& doc, KoOasisStyles&oasisStyles,
const TQDomDocument&settingsDoc, KoStore*store )
1570 ignoreSticky =
false;
1571 emit sigProgress( 0 );
1576 m_styleColl->clear();
1579 KoParagStyle * standardStyle =
new KoParagStyle(
"Standard" );
1581 standardStyle->format().setFont( m_defaultFont );
1582 m_styleColl->addStyle( standardStyle );
1584 __pgLayout = KoPageLayout::standardLayout();
1585 _spInfiniteLoop =
false;
1586 _spShowEndOfPresentationSlide =
true;
1587 _spManualSwitch =
true;
1588 _showPresentationDuration =
false;
1591 urlIntern = url().path();
1594 m_spellCheckIgnoreList.clear();
1595 emit sigProgress( 5 );
1597 TQDomElement content = doc.documentElement();
1598 TQDomElement realBody (KoDom::namedItemNS( content, KoXmlNS::office,
"body" ) );
1599 if ( realBody.isNull() )
1601 kdError(33001) <<
"No office:body found!" << endl;
1602 setErrorMessage( i18n(
"Invalid OASIS OpenDocument file. No office:body tag found." ) );
1605 TQDomElement body = KoDom::namedItemNS( realBody, KoXmlNS::office,
"presentation" );
1606 if ( body.isNull() )
1608 kdError(33001) <<
"No office:presentation found!" << endl;
1609 TQDomElement childElem;
1611 forEachElement( childElem, realBody ) {
1612 localName = childElem.localName();
1614 if ( localName.isEmpty() )
1615 setErrorMessage( i18n(
"Invalid OASIS OpenDocument file. No tag found inside office:body." ) );
1617 setErrorMessage( i18n(
"This document is not a presentation, but a %1. Please try opening it with the appropriate application." ).arg( KoDocument::tagNameToDocumentType( localName ) ) );
1623 TQDomNode drawPage = KoDom::namedItemNS( body, KoXmlNS::draw,
"page" );
1624 if ( drawPage.isNull() )
1626 TQDomElement dp = drawPage.toElement();
1631 if ( !isReadWrite())
1632 getVariableCollection()->variableSetting()->setDisplayFieldCode(
false);
1634 KoOasisContext context(
this, *m_varColl, oasisStyles, store );
1635 Q_ASSERT( !oasisStyles.officeStyle().isNull() );
1638 m_styleColl->loadOasisStyles( context );
1642 if ( !m_pageWhereLoadObject && _clean )
1644 TQString masterPageName = drawPage.toElement().attributeNS( KoXmlNS::draw,
"master-page-name", TQString() );
1645 TQDomElement *master = oasisStyles.masterPages()[ masterPageName];
1647 kdDebug()<<
" master :"<<master<<endl;
1648 kdDebug()<<
" masterPageName:"<<masterPageName<<endl;
1651 masterPageName =
"Standard";
1652 master = oasisStyles.masterPages()[ masterPageName];
1654 master = oasisStyles.masterPages()[
"Default"];
1659 setErrorMessage( i18n(
"Invalid OASIS OpenDocument file. No master-style found inside office:master-styles." ) );
1663 kdDebug()<<
" load oasis master styles\n";
1664 TQDomNode node = *master;
1665 TQDomElement masterElement = node.toElement();
1666 kdDebug()<<
" node.isNull() :"<<node.isNull()<<
", " << masterElement.attributeNS( KoXmlNS::draw,
"style-name", TQString() ) << endl;
1668 const TQDomElement* masterPageStyle = context.oasisStyles().findStyleAutoStyle( masterElement.attributeNS( KoXmlNS::draw,
"style-name", TQString() ),
"drawing-page" );
1669 if (masterPageStyle)
1670 context.styleStack().push( *masterPageStyle );
1672 context.setUseStylesAutoStyles(
true );
1673 m_masterPage->loadOasis( context );
1675 createPresentationAnimation( KoDom::namedItemNS( node, KoXmlNS::presentation,
"animations"));
1677 loadOasisObject( m_masterPage, node , context);
1679 m_loadingInfo->clearAnimationShowDict();
1680 m_loadingInfo->clearAnimationHideDict();
1682 loadOasisHeaderFooter( node,context );
1683 context.setUseStylesAutoStyles(
false );
1685 kdDebug()<<
" end load oasis master style \n";
1688 const TQDomElement *style = master ? oasisStyles.findStyle(master->attributeNS( KoXmlNS::style,
"page-layout-name", TQString() )) : 0;
1689 const TQDomElement *backgroundStyle = oasisStyles.findStyle(
"Standard-background",
"presentation" );
1690 kdDebug()<<
"Standard background "<<backgroundStyle<<endl;
1695 __pgLayout.loadOasis( *style );
1696 kdDebug()<<
"Page size __pgLayout.ptWidth :"<<__pgLayout.ptWidth<<
" __pgLayout.ptHeight :"<<__pgLayout.ptHeight<<endl;
1697 kdDebug()<<
"Page orientation :"<<(( __pgLayout.orientation== PG_LANDSCAPE )?
" landscape " :
" portrait ")<<endl;
1699 kdDebug()<<
" margin right:"<< __pgLayout.ptRight <<
" __pgLayout.ptBottom :"<<__pgLayout.ptBottom<<
" __pgLayout.ptLeft :"<<__pgLayout.ptLeft<<
" __pgLayout.ptTop :"<<__pgLayout.ptTop<<endl;
1704 setPageLayout( __pgLayout );
1708 int pos = m_insertFilePage;
1709 for ( drawPage = body.firstChild(); !drawPage.isNull(); drawPage = drawPage.nextSibling() )
1711 dp = drawPage.toElement();
1712 kdDebug()<<
"dp.tagName() :"<<dp.tagName()<<endl;
1713 if ( dp.tagName()==
"page" && dp.namespaceURI() == KoXmlNS::draw )
1715 context.styleStack().clear();
1716 fillStyleStack( dp, context,
"drawing-page" );
1717 context.styleStack().save();
1718 kdDebug ()<<
"insert new page "<<pos<<endl;
1719 KPrPage *newpage = 0L;
1720 if ( m_pageWhereLoadObject )
1722 newpage = m_pageWhereLoadObject;
1728 newpage =
new KPrPage(
this, m_masterPage );
1729 m_pageList.insert( pos,newpage);
1733 newpage = m_pageList.at(pos);
1737 TQString str = dp.attributeNS( KoXmlNS::draw,
"name", TQString() );
1738 m_loadingInfo->m_name2page.insert( str, newpage );
1739 TQString idPage = dp.attributeNS( KoXmlNS::draw,
"id", TQString() );
1741 if ( dp.hasAttributeNS( KoXmlNS::koffice,
"name" ) )
1743 str = dp.attributeNS( KoXmlNS::koffice,
"name", TQString() );
1744 newpage->insertManualTitle(str);
1749 TQRegExp rx(
"^page[0-9]+$" );
1750 if ( rx.search( str ) == -1 )
1751 newpage->insertManualTitle(str);
1753 context.styleStack().setTypeProperties(
"drawing-page" );
1755 newpage->loadOasis( context );
1758 createPresentationAnimation(KoDom::namedItemNS( drawPage, KoXmlNS::presentation,
"animations"));
1760 loadOasisObject( newpage, drawPage, context );
1762 context.styleStack().restore();
1763 m_loadingInfo->clearAnimationShowDict();
1764 m_loadingInfo->clearAnimationHideDict();
1770 TQDomNode settings = KoDom::namedItemNS( body, KoXmlNS::presentation,
"settings" );
1771 kdDebug()<<
"settings :"<<settings.isNull()<<endl;
1772 if (!settings.isNull() && _clean )
1773 loadOasisPresentationSettings( settings );
1775 ignoreSticky =
true;
1776 kdDebug()<<
" _clean :"<<_clean<<endl;
1782 startBackgroundSpellCheck();
1785 kdDebug(33001) <<
"Loading took " << (float)(dt.elapsed()) / 1000.0 <<
" seconds" << endl;
1787 if ( !settingsDoc.isNull() )
1789 loadOasisSettings( settingsDoc );
1793 if ( m_initialActivePage == 0 )
1795 m_initialActivePage = m_pageList.at( 0 );
1798 emit sigProgress( 100 );
1799 recalcVariables( VT_ALL );
1800 emit sigProgress( -1 );
1802 setModified(
false );
1807void KPrDocument::loadOasisObject( KPrPage * newpage, TQDomNode & drawPage, KoOasisContext & context, KPrGroupObject *groupObject )
1809 for ( TQDomNode
object = drawPage.firstChild(); !
object.isNull();
object =
object.nextSibling() )
1811 TQDomElement o =
object.toElement();
1812 TQString name = o.tagName();
1813 if ( !name.isEmpty() )
1815 kdDebug()<<
" name :"<<name<<endl;
1816 if ( o.hasAttributeNS( KoXmlNS::presentation,
"placeholder" ) &&
1817 o.attributeNS( KoXmlNS::presentation,
"placeholder", TQString() ) ==
"true" )
1819 kdDebug(33001) <<
"Placeholder" << endl;
1822 context.styleStack().save();
1823 const bool isDrawNS = o.namespaceURI() == KoXmlNS::draw;
1825 if ( name ==
"frame" && isDrawNS )
1827 fillStyleStack( o, context,
"graphic" );
1829 forEachElement( elem, o )
1831 if ( elem.namespaceURI() != KoXmlNS::draw )
1833 const TQString localName = elem.localName();
1834 if ( localName ==
"text-box" )
1836 KPrTextObject *kptextobject =
new KPrTextObject(
this );
1837 kptextobject->loadOasis(o, context, m_loadingInfo);
1839 groupObject->addObjects( kptextobject );
1841 newpage->appendObject(kptextobject);
1844 else if ( localName ==
"image" )
1846 KPrPixmapObject *kppixmapobject =
new KPrPixmapObject( pictureCollection() );
1847 kppixmapobject->loadOasis( o, context, m_loadingInfo);
1849 groupObject->addObjects( kppixmapobject );
1851 newpage->appendObject(kppixmapobject);
1854 else if ( localName ==
"object" )
1856 KPrChild *ch =
new KPrChild(
this );
1858 KPrPartObject *kppartobject =
new KPrPartObject( ch );
1859 kppartobject->loadOasis( o, context, m_loadingInfo );
1862 groupObject->addObjects( kppartobject );
1864 newpage->appendObject(kppartobject);
1866 kppartobject->setOrig( r.x(), r.y() );
1867 kppartobject->setSize( r.width(), r.height() );
1872 else if ( name ==
"rect" && isDrawNS)
1874 fillStyleStack( o, context,
"graphic" );
1875 KPrRectObject *kprectobject =
new KPrRectObject();
1876 kprectobject->loadOasis(o, context , m_loadingInfo);
1878 groupObject->addObjects( kprectobject );
1880 newpage->appendObject(kprectobject);
1882 else if ( ( name ==
"circle" || name ==
"ellipse" )&& isDrawNS)
1884 fillStyleStack( o, context,
"graphic" );
1885 if ( o.hasAttributeNS( KoXmlNS::draw,
"kind" ) )
1887 KPrPieObject *kppieobject =
new KPrPieObject();
1888 kppieobject->loadOasis(o, context, m_loadingInfo);
1890 groupObject->addObjects( kppieobject );
1892 newpage->appendObject(kppieobject);
1896 KPrEllipseObject *kpellipseobject =
new KPrEllipseObject();
1897 kpellipseobject->loadOasis(o,context, m_loadingInfo);
1899 groupObject->addObjects( kpellipseobject );
1901 newpage->appendObject(kpellipseobject);
1904 else if ( name ==
"line" && isDrawNS)
1906 fillStyleStack( o, context,
"graphic" );
1907 KPrLineObject *kplineobject =
new KPrLineObject();
1908 kplineobject->loadOasis(o, context, m_loadingInfo);
1910 groupObject->addObjects( kplineobject );
1912 newpage->appendObject( kplineobject );
1914 else if (name==
"polyline" && isDrawNS) {
1915 fillStyleStack( o, context,
"graphic" );
1916 KPrPolylineObject *kppolylineobject =
new KPrPolylineObject();
1917 kppolylineobject->loadOasis(o, context, m_loadingInfo);
1919 groupObject->addObjects( kppolylineobject );
1921 newpage->appendObject(kppolylineobject);
1923 else if (name==
"polygon" && isDrawNS) {
1924 fillStyleStack( o, context,
"graphic" );
1925 KPrClosedLineObject *kpClosedObject =
new KPrClosedLineObject();
1926 kpClosedObject->loadOasis( o, context, m_loadingInfo);
1928 groupObject->addObjects( kpClosedObject );
1930 newpage->appendObject(kpClosedObject);
1932 else if (name==
"regular-polygon"&& isDrawNS) {
1933 fillStyleStack( o, context,
"graphic" );
1934 KPrPolygonObject *kpPolygoneObject =
new KPrPolygonObject();
1935 kpPolygoneObject->loadOasis( o, context, m_loadingInfo);
1937 groupObject->addObjects( kpPolygoneObject );
1939 newpage->appendObject(kpPolygoneObject);
1941 else if ( name ==
"path" && isDrawNS)
1943 fillStyleStack( o, context,
"graphic" );
1944 TQString d = o.attributeNS( KoXmlNS::svg,
"d", TQString());
1946 KPrSVGPathParser parser;
1947 ObjType objType = parser.getType( d );
1951 case OT_CUBICBEZIERCURVE:
1953 kdDebug(33001) <<
"Cubicbeziercurve" << endl;
1954 KPrCubicBezierCurveObject *kpCurveObject =
new KPrCubicBezierCurveObject();
1955 kpCurveObject->loadOasis( o, context, m_loadingInfo );
1957 groupObject->addObjects( kpCurveObject );
1959 newpage->appendObject( kpCurveObject );
1961 case OT_QUADRICBEZIERCURVE:
1963 kdDebug(33001) <<
"Quadricbeziercurve" << endl;
1964 KPrQuadricBezierCurveObject *kpQuadricObject =
new KPrQuadricBezierCurveObject();
1965 kpQuadricObject->loadOasis( o, context, m_loadingInfo );
1967 groupObject->addObjects( kpQuadricObject );
1969 newpage->appendObject( kpQuadricObject );
1973 kdDebug(33001) <<
"Freehand" << endl;
1974 KPrFreehandObject *kpFreeHandObject =
new KPrFreehandObject();
1975 kpFreeHandObject->loadOasis( o, context, m_loadingInfo );
1977 groupObject->addObjects( kpFreeHandObject );
1979 newpage->appendObject( kpFreeHandObject );
1981 case OT_CLOSED_LINE:
1983 kdDebug(33001) <<
"Closed Line" << endl;
1984 KPrClosedLineObject *kpClosedObject =
new KPrClosedLineObject();
1985 kpClosedObject->loadOasis( o, context, m_loadingInfo );
1987 groupObject->addObjects( kpClosedObject );
1989 newpage->appendObject( kpClosedObject );
1992 kdDebug(33001) <<
"draw:path found unsupported object type " << objType <<
" in svg:d " << d << endl;
1996 else if ( name ==
"custom-shape" && isDrawNS )
1998 fillStyleStack( o, context,
"graphic" );
2000 TQDomElement enhancedGeometry = KoDom::namedItemNS( o, KoXmlNS::draw,
"enhanced-geometry" );
2002 if ( !enhancedGeometry.isNull() )
2004 TQString d = enhancedGeometry.attributeNS( KoXmlNS::draw,
"enhanced-path", TQString() );
2005 TQRegExp rx(
"^([0-9 ML]+Z) N$" );
2006 if ( rx.search( d ) != -1 )
2009 KPrSVGPathParser parser;
2010 ObjType objType = parser.getType( d );
2015 case OT_CUBICBEZIERCURVE:
2017 kdDebug(33001) <<
"Cubicbeziercurve" << endl;
2018 KPrCubicBezierCurveObject *kpCurveObject =
new KPrCubicBezierCurveObject();
2019 kpCurveObject->loadOasis( o, context, m_loadingInfo );
2021 groupObject->addObjects( kpCurveObject );
2023 newpage->appendObject( kpCurveObject );
2025 case OT_QUADRICBEZIERCURVE:
2027 kdDebug(33001) <<
"Quadricbeziercurve" << endl;
2028 KPrQuadricBezierCurveObject *kpQuadricObject =
new KPrQuadricBezierCurveObject();
2029 kpQuadricObject->loadOasis( o, context, m_loadingInfo );
2031 groupObject->addObjects( kpQuadricObject );
2033 newpage->appendObject( kpQuadricObject );
2037 kdDebug(33001) <<
"Freehand" << endl;
2038 KPrFreehandObject *kpFreeHandObject =
new KPrFreehandObject();
2039 kpFreeHandObject->loadOasis( o, context, m_loadingInfo );
2041 groupObject->addObjects( kpFreeHandObject );
2043 newpage->appendObject( kpFreeHandObject );
2046 case OT_CLOSED_LINE:
2048 kdDebug(33001) <<
"Closed Line" << endl;
2049 KPrClosedLineObject *kpClosedObject =
new KPrClosedLineObject();
2050 kpClosedObject->loadOasis( o, context, m_loadingInfo );
2052 groupObject->addObjects( kpClosedObject );
2054 newpage->appendObject( kpClosedObject );
2057 kdDebug(33001) <<
"draw:custom-shape found unsupported object type " << objType <<
" in draw:enhanced-path " << d << endl;
2063 kdDebug(33001) <<
"draw:custom-shape not supported" << endl;
2067 else if ( name ==
"g" && isDrawNS)
2069 fillStyleStack( o, context,
"graphic" );
2070 KPrGroupObject *kpgroupobject =
new KPrGroupObject();
2071 TQDomNode nodegroup =
object.firstChild();
2073 kpgroupobject->loadOasisGroupObject(
this, newpage,
object, context, m_loadingInfo);
2075 groupObject->addObjects( kpgroupobject );
2077 newpage->appendObject(kpgroupobject);
2079 else if ( name ==
"notes" && o.namespaceURI() == KoXmlNS::presentation )
2083 TQDomNode frameBox = KoDom::namedItemNS( o, KoXmlNS::draw,
"frame" );
2086 while ( !frameBox.isNull() )
2089 if ( !note.isEmpty() )
2093 TQDomNode textBox = KoDom::namedItemNS( frameBox, KoXmlNS::draw,
"text-box" );
2095 if ( !textBox.isNull() )
2097 for ( TQDomNode text = textBox.firstChild(); !text.isNull(); text = text.nextSibling() )
2101 TQDomElement t = text.toElement();
2102 if ( t.tagName() ==
"p" )
2104 note += t.text() +
"\n";
2108 frameBox = frameBox.nextSibling();
2110 newpage->setNoteText( note );
2112 else if ( ( name ==
"header" || name ==
"footer" ) && o.namespaceURI() == KoXmlNS::style ||
2113 ( name ==
"animations" && o.namespaceURI() == KoXmlNS::presentation) )
2119 kdDebug() <<
"Unsupported object '" << name <<
"'" << endl;
2121 context.styleStack().restore();
2127int KPrDocument::createPresentationAnimation(
const TQDomElement& element,
int order,
bool increaseOrder)
2129 kdDebug()<<
"void KPrDocument::createPresentationAnimation(const TQDomElement& element)\n";
2130 int orderAnimation = increaseOrder ? 0 : order;
2131 for ( TQDomNode n = element.firstChild(); !n.isNull(); n = n.nextSibling() )
2133 TQDomElement e = n.toElement();
2134 TQCString tagName = e.tagName().latin1();
2135 if ( ! tagName.isEmpty() )
2137 const bool isPresentationNS = e.namespaceURI() == KoXmlNS::presentation;
2138 if ( isPresentationNS &&
2139 ( tagName ==
"show-shape" || tagName ==
"hide-shape" ) )
2141 Q_ASSERT( e.hasAttributeNS( KoXmlNS::draw,
"shape-id" ) );
2142 TQString name = e.attributeNS( KoXmlNS::draw,
"shape-id", TQString() );
2143 kdDebug()<<
" insert animation " << tagName <<
" name :" << name << endl;
2145 if ( e.hasAttributeNS( KoXmlNS::koffice,
"order-id" ) )
2147 orderAnimation = e.attributeNS( KoXmlNS::koffice,
"order-id", TQString() ).toInt();
2150 lstAnimation *tmp =
new lstAnimation;
2151 tmp->element =
new TQDomElement( e );
2152 tmp->order = orderAnimation;
2153 if ( tagName ==
"show-shape" )
2155 m_loadingInfo->storePresentationShowAnimation( tmp, name );
2159 m_loadingInfo->storePresentationHideAnimation( tmp, name );
2161 if ( increaseOrder )
2164 else if ( tagName ==
"animation-group" && isPresentationNS )
2166 orderAnimation = createPresentationAnimation( e, orderAnimation,
false );
2172 return orderAnimation;
2175void KPrDocument::fillStyleStack(
const TQDomElement&
object, KoOasisContext & context,
const char* family )
2179 if (
object.hasAttributeNS( KoXmlNS::presentation,
"style-name" ))
2181 context.fillStyleStack(
object, KoXmlNS::presentation,
"style-name",
"presentation" );
2183 if (
object.hasAttributeNS( KoXmlNS::draw,
"style-name" ) )
2185 context.fillStyleStack(
object, KoXmlNS::draw,
"style-name", family );
2188 if (
object.hasAttributeNS( KoXmlNS::draw,
"text-style-name" ) )
2190 context.fillStyleStack(
object, KoXmlNS::draw,
"text-style-name",
"paragraph" );
2192 if (
object.hasAttributeNS( KoXmlNS::text,
"style-name" ) )
2194 context.fillStyleStack(
object, KoXmlNS::text,
"style-name", family );
2198bool KPrDocument::loadXML( TQIODevice * dev,
const TQDomDocument& doc )
2204 ignoreSticky =
false;
2206 TQDomElement docelem = doc.documentElement();
2207 const int syntaxVersion = docelem.attribute(
"syntaxVersion" ).toInt();
2208 if ( syntaxVersion < 2 )
2212 kdWarning(33001) <<
"KPresenter document version 1. Launching perl script to convert it." << endl;
2215 KTempFile tmpFileIn;
2216 tmpFileIn.setAutoDelete(
true );
2218 tmpFileIn.file()->writeBlock( dev->readAll() );
2222 KTempFile tmpFileOut;
2223 tmpFileOut.setAutoDelete(
true );
2224 TQString cmd = TDEGlobal::dirs()->findExe(
"perl");
2227 setErrorMessage( i18n(
"You don't appear to have PERL installed.\nIt is needed to convert this document.\nPlease install PERL and try again."));
2231 cmd += locate(
"exe",
"kprconverter.pl" );
2233 cmd += TDEProcess::quote( tmpFileIn.name() );
2235 cmd += TDEProcess::quote( tmpFileOut.name() );
2236 system( TQFile::encodeName(cmd) );
2242 TQDomDocument newdoc;
2243 if ( ! newdoc.setContent( tmpFileOut.file(), &errorMsg, &errorLine, &errorColumn ) )
2245 kdError (33001) <<
"Parsing Error! Aborting! (in KPrDocument::loadXML)" << endl
2246 <<
" Line: " << errorLine <<
" Column: " << errorColumn << endl
2247 <<
" Message: " << errorMsg << endl;
2248 setErrorMessage( i18n(
"parsing error in the main document (converted from an old KPresenter format) at line %1, column %2\nError message: %3" )
2249 .arg( errorLine ).arg( errorColumn ).arg( i18n ( errorMsg.utf8() ) ) );
2252 b = loadXML( newdoc );
2257 ignoreSticky =
true;
2261 startBackgroundSpellCheck();
2263 if ( m_pageWhereLoadObject == 0 && m_insertFilePage == 0 )
2264 setModified(
false );
2265 kdDebug(33001) <<
"Loading took " << (float)(dt.elapsed()) / 1000.0 <<
" seconds" << endl;
2269void KPrDocument::createHeaderFooter()
2272 KoRect pageRect=m_masterPage->getPageRect();
2273 _header->setOrig(pageRect.topLeft());
2274 _header->setSize(pageRect.width(),20);
2276 _footer->setOrig(pageRect.left(),pageRect.bottom()-20);
2277 _footer->setSize(pageRect.width(),20);
2279 m_masterPage->appendObject(_header);
2280 m_masterPage->appendObject(_footer);
2283void KPrDocument::insertEmbedded( KoStore *store, TQDomElement topElem, KMacroCommand * macroCmd, KPrPage *page,
int pos )
2285 TQDomElement elem = topElem.firstChild().toElement();
2286 for ( ; !elem.isNull() ; elem = elem.nextSibling().toElement() )
2288 kdDebug(33001) <<
"Element name: " << elem.tagName() << endl;
2289 if(elem.tagName()==
"EMBEDDED") {
2290 KPrChild *ch =
new KPrChild(
this );
2291 KPrPartObject *kppartobject = 0L;
2294 TQDomElement
object=elem.namedItem(
"OBJECT").toElement();
2295 if(!
object.isNull()) {
2296 ch->load(
object,
true);
2298 ch->loadDocument( store );
2300 kppartobject =
new KPrPartObject( ch );
2302 TQDomElement settings=elem.namedItem(
"SETTINGS").toElement();
2304 if ( settings.hasAttribute(
"z-index" ) )
2306 zIndex = settings.attribute(
"z-index" ).toInt();
2308 double offset = 0.0;
2309 if(!settings.isNull() && kppartobject!=0)
2310 offset=kppartobject->load(settings);
2311 else if ( settings.isNull() )
2313 delete kppartobject;
2317 int index = m_pageList.findRef(page);
2318 int pageIndex = (int)(offset/__pgLayout.ptHeight)+index;
2319 int newPos=(int)((offset+index*__pgLayout.ptHeight)-pageIndex*__pgLayout.ptHeight);
2320 kppartobject->setOrig(kppartobject->getOrig().x(),newPos);
2322 KPrInsertCmd *insertCmd =
new KPrInsertCmd( i18n(
"Insert Part Object" ), kppartobject,
this,page );
2323 insertCmd->execute();
2325 macroCmd =
new KMacroCommand( i18n(
"Insert Part Object"));
2326 macroCmd->addCommand( insertCmd );
2329 const TQPtrList<KPrObject>& oldList( page->objectList() );
2331 if (
static_cast<int>( oldList.count() ) > pos + zIndex )
2333 page->takeObject( kppartobject );
2334 page->insertObject( kppartobject, pos + zIndex );
2335 KPrLowerRaiseCmd *lrCmd =
new KPrLowerRaiseCmd( i18n(
"Insert Part Object"),
2336 oldList, page->objectList(),
2338 macroCmd->addCommand( lrCmd );
2345bool KPrDocument::loadXML(
const TQDomDocument &doc )
2347 emit sigProgress( 0 );
2350 bool allSlides =
false;
2353 __pgLayout = KoPageLayout::standardLayout();
2354 _spInfiniteLoop =
false;
2355 _spShowEndOfPresentationSlide =
true;
2356 _spManualSwitch =
true;
2357 _showPresentationDuration =
false;
2361 urlIntern = url().path();
2364 m_spellCheckIgnoreList.clear();
2365 emit sigProgress( 5 );
2367 TQDomElement document=doc.documentElement();
2369 if(document.tagName()!=
"DOC") {
2370 kdWarning(33001) <<
"Missing DOC" << endl;
2371 setErrorMessage( i18n(
"Invalid document, DOC tag missing.") );
2375 if(!document.hasAttribute(
"mime") || (
2376 document.attribute(
"mime")!=
"application/x-kpresenter" &&
2377 document.attribute(
"mime")!=
"application/vnd.kde.kpresenter" ) ) {
2378 kdError(33001) <<
"Unknown mime type " << document.attribute(
"mime") << endl;
2379 setErrorMessage( i18n(
"Invalid document, expected mimetype application/x-kpresenter or application/vnd.kde.kpresenter, got %1").arg(document.attribute(
"mime")) );
2382 if(document.hasAttribute(
"url"))
2383 urlIntern=KURL(document.attribute(
"url")).path();
2385 emit sigProgress( 10 );
2387 TQDomElement elem=document.firstChild().toElement();
2389 uint childTotalCount=document.childNodes().count();
2390 uint childCount = 0;
2392 loadTextStyle( document );
2394 while(!elem.isNull()) {
2395 kdDebug(33001) <<
"Element name: " << elem.tagName() << endl;
2396 if(elem.tagName()==
"EMBEDDED") {
2397 KPrChild *ch =
new KPrChild(
this );
2398 KPrPartObject *kppartobject = 0L;
2401 TQDomElement
object=elem.namedItem(
"OBJECT").toElement();
2402 if(!
object.isNull()) {
2403 ch->load(
object,
true);
2406 kppartobject =
new KPrPartObject( ch );
2409 TQDomElement settings=elem.namedItem(
"SETTINGS").toElement();
2412 if ( settings.hasAttribute(
"z-index" ) )
2414 pos = settings.attribute(
"z-index" ).toInt();
2416 if(settings.hasAttribute(
"sticky"))
2417 tmp=settings.attribute(
"sticky").toInt();
2418 bool sticky=
static_cast<bool>(tmp);
2419 double offset = 0.0;
2420 if(!settings.isNull() && kppartobject!=0)
2422 offset=kppartobject->load(settings);
2424 else if ( settings.isNull() )
2426 delete kppartobject;
2430 if ( offset == -1.0 )
2432 if ( sticky && !ignoreSticky && kppartobject )
2436 m_masterPage->appendObject( kppartobject );
2440 m_masterPage->insertObject( kppartobject, pos );
2442 kppartobject->setOrig(kppartobject->getOrig().x(), offset);
2444 else if ( kppartobject ) {
2445 if ( m_pageWhereLoadObject )
2447 kppartobject->setOrig(kppartobject->getOrig().x(), offset);
2448 m_pageWhereLoadObject->insertObject( kppartobject, pos );
2452 insertObjectInPage( offset, kppartobject, pos );
2455 }
else if(elem.tagName()==
"PAPER" && _clean) {
2456 if(elem.hasAttribute(
"format"))
2457 __pgLayout.format=
static_cast<KoFormat
>(elem.attribute(
"format").toInt());
2458 if(elem.hasAttribute(
"orientation"))
2459 __pgLayout.orientation=
static_cast<KoOrientation
>(elem.attribute(
"orientation").toInt());
2460 if(elem.hasAttribute(
"ptWidth"))
2461 __pgLayout.ptWidth = elem.attribute(
"ptWidth").toDouble();
2462 else if(elem.hasAttribute(
"inchWidth"))
2463 __pgLayout.ptWidth = INCH_TO_POINT( elem.attribute(
"inchWidth").toDouble() );
2464 else if(elem.hasAttribute(
"mmWidth"))
2465 __pgLayout.ptWidth = MM_TO_POINT( elem.attribute(
"mmWidth").toDouble() );
2466 if(elem.hasAttribute(
"ptHeight"))
2467 __pgLayout.ptHeight = elem.attribute(
"ptHeight").toDouble();
2468 else if(elem.hasAttribute(
"inchHeight"))
2469 __pgLayout.ptHeight = INCH_TO_POINT( elem.attribute(
"inchHeight").toDouble() );
2470 else if(elem.hasAttribute(
"mmHeight"))
2471 __pgLayout.ptHeight = MM_TO_POINT( elem.attribute(
"mmHeight").toDouble() );
2472 if(elem.hasAttribute(
"unit"))
2473 setUnit(
static_cast<KoUnit::Unit
>(elem.attribute(
"unit").toInt()) );
2474 if ( elem.hasAttribute(
"tabStopValue"))
2475 m_tabStop = elem.attribute(
"tabStopValue").toDouble();
2477 if(elem.hasAttribute(
"width"))
2478 __pgLayout.ptWidth = MM_TO_POINT( elem.attribute(
"width").toDouble() );
2479 if(elem.hasAttribute(
"height"))
2480 __pgLayout.ptHeight = MM_TO_POINT( elem.attribute(
"height").toDouble() );
2482 TQDomElement borders=elem.namedItem(
"PAPERBORDERS").toElement();
2483 if(!borders.isNull()) {
2484 if(borders.hasAttribute(
"left"))
2485 __pgLayout.ptLeft = MM_TO_POINT( borders.attribute(
"left").toDouble() );
2486 if(borders.hasAttribute(
"top"))
2487 __pgLayout.ptTop = MM_TO_POINT( borders.attribute(
"top").toDouble() );
2488 if(borders.hasAttribute(
"right"))
2489 __pgLayout.ptRight = MM_TO_POINT( borders.attribute(
"right").toDouble() );
2490 if(borders.hasAttribute(
"bottom"))
2491 __pgLayout.ptBottom = MM_TO_POINT( borders.attribute(
"bottom").toDouble() );
2492 if(borders.hasAttribute(
"ptLeft"))
2493 __pgLayout.ptLeft = borders.attribute(
"ptLeft").toDouble();
2494 else if(borders.hasAttribute(
"inchLeft"))
2495 __pgLayout.ptLeft = INCH_TO_POINT( borders.attribute(
"inchLeft").toDouble() );
2496 else if(borders.hasAttribute(
"mmLeft"))
2497 __pgLayout.ptLeft = MM_TO_POINT( borders.attribute(
"mmLeft").toDouble() );
2498 if(borders.hasAttribute(
"ptRight"))
2499 __pgLayout.ptRight = borders.attribute(
"ptRight").toDouble();
2500 else if(borders.hasAttribute(
"inchRight"))
2501 __pgLayout.ptRight = INCH_TO_POINT( borders.attribute(
"inchRight").toDouble() );
2502 else if(borders.hasAttribute(
"mmRight"))
2503 __pgLayout.ptRight = MM_TO_POINT( borders.attribute(
"mmRight").toDouble() );
2504 if(borders.hasAttribute(
"ptTop"))
2505 __pgLayout.ptTop = borders.attribute(
"ptTop").toDouble();
2506 else if(borders.hasAttribute(
"inchTop"))
2507 __pgLayout.ptTop = INCH_TO_POINT( borders.attribute(
"inchTop").toDouble() );
2508 else if(borders.hasAttribute(
"mmTop"))
2509 __pgLayout.ptTop = MM_TO_POINT( borders.attribute(
"mmTop").toDouble() );
2510 if(borders.hasAttribute(
"ptBottom"))
2511 __pgLayout.ptBottom = borders.attribute(
"ptBottom").toDouble();
2512 else if(borders.hasAttribute(
"inchBottom"))
2513 __pgLayout.ptBottom = INCH_TO_POINT( borders.attribute(
"inchBottom").toDouble() );
2514 else if(borders.hasAttribute(
"mmBottom"))
2515 __pgLayout.ptBottom = MM_TO_POINT( borders.attribute(
"inchBottom").toDouble() );
2520 setPageLayout( __pgLayout );
2522 }
else if(elem.tagName()==
"VARIABLESETTINGS" && _clean){
2523 getVariableCollection()->variableSetting()->load(document);
2525 if ( !isReadWrite())
2526 getVariableCollection()->variableSetting()->setDisplayFieldCode(
false);
2529 else if(elem.tagName()==
"BACKGROUND") {
2530 int red=0, green=0, blue=0;
2531 if(elem.hasAttribute(
"xRnd"))
2532 _xRnd = elem.attribute(
"xRnd").toInt();
2533 if(elem.hasAttribute(
"yRnd"))
2534 _yRnd = elem.attribute(
"yRnd").toInt();
2535 if(elem.hasAttribute(
"bred"))
2536 red = elem.attribute(
"bred").toInt();
2537 if(elem.hasAttribute(
"bgreen"))
2538 green = elem.attribute(
"bgreen").toInt();
2539 if(elem.hasAttribute(
"bblue"))
2540 blue = elem.attribute(
"bblue").toInt();
2541 loadBackground(elem);
2542 }
else if(elem.tagName()==
"HEADER") {
2544 if(elem.hasAttribute(
"show")) {
2545 setHeader(
static_cast<bool>(elem.attribute(
"show").toInt()));
2547 _header->load(elem);
2549 }
else if ( elem.tagName()==
"HEADERFOOTERBYPAGE" ) {
2550 if ( elem.hasAttribute(
"value" ) ) {
2551 m_loadingInfo->m_headerFooterByPage =
true;
2553 }
else if(elem.tagName()==
"FOOTER") {
2555 if(elem.hasAttribute(
"show")) {
2556 setFooter(
static_cast<bool>(elem.attribute(
"show").toInt() ) );
2558 _footer->load(elem);
2560 }
else if( elem.tagName()==
"HELPLINES"){
2562 if(elem.hasAttribute(
"show")) {
2563 setShowGuideLines(
static_cast<bool>(elem.attribute(
"show").toInt() ) );
2565 loadGuideLines( elem );
2567 }
else if( elem.tagName()==
"SPELLCHECKIGNORELIST"){
2568 TQDomElement spellWord=elem.toElement();
2569 spellWord=spellWord.firstChild().toElement();
2570 while ( !spellWord.isNull() )
2572 if ( spellWord.tagName()==
"SPELLCHECKIGNOREWORD" )
2574 m_spellCheckIgnoreList.append(spellWord.attribute(
"word"));
2576 spellWord=spellWord.nextSibling().toElement();
2578 }
else if(elem.tagName()==
"ATTRIBUTES" && _clean) {
2579 if(elem.hasAttribute(
"activePage"))
2580 activePage=elem.attribute(
"activePage").toInt();
2581 if(elem.hasAttribute(
"gridx"))
2582 m_gridX = elem.attribute(
"gridx").toDouble();
2583 if(elem.hasAttribute(
"gridy"))
2584 m_gridY = elem.attribute(
"gridy").toDouble();
2585 if(elem.hasAttribute(
"snaptogrid"))
2586 m_bSnapToGrid = (bool)elem.attribute(
"snaptogrid").toInt();
2587 }
else if(elem.tagName()==
"PAGETITLES") {
2589 }
else if(elem.tagName()==
"PAGENOTES") {
2591 }
else if(elem.tagName()==
"OBJECTS") {
2594 lastObj = _objectList->count() - 1;
2597 KCommand * cmd =loadObjects(elem);
2600 }
else if(elem.tagName()==
"INFINITLOOP") {
2602 if(elem.hasAttribute(
"value"))
2603 _spInfiniteLoop =
static_cast<bool>(elem.attribute(
"value").toInt());
2605 }
else if(elem.tagName()==
"SHOWENDOFPRESENTATIONSLIDE") {
2607 if(elem.hasAttribute(
"value"))
2608 _spShowEndOfPresentationSlide =
static_cast<bool>(elem.attribute(
"value").toInt());
2610 }
else if(elem.tagName()==
"PRESSPEED") {
2612 if(elem.hasAttribute(
"value"))
2613 m_loadingInfo->presSpeed = elem.attribute(
"value").toInt();
2615 }
else if(elem.tagName()==
"MANUALSWITCH") {
2617 if(elem.hasAttribute(
"value"))
2618 _spManualSwitch =
static_cast<bool>(elem.attribute(
"value").toInt());
2620 }
else if(elem.tagName()==
"SHOWPRESENTATIONDURATION") {
2622 if(elem.hasAttribute(
"value"))
2623 _showPresentationDuration =
static_cast<bool>(elem.attribute(
"value").toInt());
2625 }
else if(elem.tagName()==
"PRESSLIDES") {
2626 if(elem.hasAttribute(
"value") && elem.attribute(
"value").toInt()==0)
2628 }
else if ( elem.tagName()==
"DEFAULTCUSTOMSLIDESHOWNAME" ) {
2629 if(elem.hasAttribute(
"name") )
2630 m_presentationName=elem.attribute(
"name" );
2631 }
else if ( elem.tagName()==
"CUSTOMSLIDESHOWCONFIG" ) {
2633 TQMap<TQString, KPrPage *> name2page;
2635 for ( TQPtrListIterator<KPrPage> it( m_pageList ); it.current(); ++it )
2637 name2page.insert(
"page" + TQString::number( pos++ ), it.current() ) ;
2640 TQDomElement slide=elem.firstChild().toElement();
2641 while(!slide.isNull()) {
2642 if(slide.tagName()==
"CUSTOMSLIDESHOW") {
2643 TQStringList tmp = TQStringList::split(
",", slide.attribute(
"pages" ) );
2644 TQValueList<KPrPage *> pageList;
2645 for ( TQStringList::Iterator it = tmp.begin(); it != tmp.end(); ++it )
2647 if ( name2page.contains( *it ) )
2649 kdDebug(33001) <<
"slide show " << slide.attribute(
"name" ) <<
" page = " << *it << endl;
2650 pageList.push_back( name2page[*it] );
2653 if ( ! pageList.empty() )
2655 m_customListSlideShow.insert( slide.attribute(
"name" ), pageList );
2658 slide=slide.nextSibling().toElement();
2661 }
else if(elem.tagName()==
"SELSLIDES") {
2663 TQDomElement slide=elem.firstChild().toElement();
2664 while(!slide.isNull()) {
2665 if(slide.tagName()==
"SLIDE") {
2668 if(slide.hasAttribute(
"nr"))
2669 nr=slide.attribute(
"nr").toInt();
2670 if(slide.hasAttribute(
"show"))
2671 show=
static_cast<bool>(slide.attribute(
"show").toInt());
2675 if ( nr > ( (
int)m_pageList.count() - 1 ) )
2677 for (
int i=(m_pageList.count()-1); i<nr;i++)
2678 m_pageList.append(
new KPrPage(
this, m_masterPage ) );
2680 m_pageList.at(nr)->slideSelected(show);
2681 }
else kdWarning(33001) <<
"Parse error. No nr in <SLIDE> !" << endl;
2683 slide=slide.nextSibling().toElement();
2686 }
else if ( elem.tagName() ==
"SOUNDS" ) {
2687 loadUsedSoundFileFromXML( elem );
2689 elem=elem.nextSibling().toElement();
2691 emit sigProgress( childCount * ( 70/childTotalCount ) + 15 );
2695 loadPictureMap( document );
2698 m_initialActivePage=m_pageList.at(activePage);
2699 if ( m_pageWhereLoadObject == 0 && m_insertFilePage == 0 )
2705void KPrDocument::loadTextStyle(
const TQDomElement& domElement )
2707 TQDomElement style = domElement.namedItem(
"STYLES" ).toElement();
2708 if ( _clean && ! style.isNull() )
2709 loadStyleTemplates( style );
2712void KPrDocument::loadPictureMap (
const TQDomElement& domElement )
2714 m_pictureMap.clear();
2717 TQDomElement picturesElem = domElement.namedItem(
"PICTURES" ).toElement();
2718 if ( !picturesElem.isNull() )
2719 m_pictureCollection.readXML( picturesElem, m_pictureMap );
2722 TQDomElement pixmapsElem = domElement.namedItem(
"PIXMAPS" ).toElement();
2723 if ( !pixmapsElem.isNull() )
2724 m_pictureCollection.readXML( pixmapsElem, m_pictureMap );
2727 TQDomElement clipartsElem = domElement.namedItem(
"CLIPARTS" ).toElement();
2728 if ( !clipartsElem.isNull() )
2729 m_pictureCollection.readXML( pixmapsElem, m_pictureMap );
2732void KPrDocument::loadBackground(
const TQDomElement &element )
2734 kdDebug(33001) <<
"KPrDocument::loadBackground" << endl;
2735 TQDomElement page=element.firstChild().toElement();
2736 int i=m_insertFilePage;
2737 while(!page.isNull()) {
2738 if(m_pageWhereLoadObject)
2740 kdDebug(33001) <<
"m_pageWhereLoadObject->load(...)" << m_pageWhereLoadObject << endl;
2741 m_pageWhereLoadObject->load(page);
2746 if ( page.tagName() ==
"MASTERPAGE" )
2748 m_masterPage->load( page );
2754 if ( i > ( (
int)m_pageList.count() - 1 ) )
2755 m_pageList.append(
new KPrPage(
this, m_masterPage ) );
2756 m_pageList.at(i)->load(page);
2760 page=page.nextSibling().toElement();
2764KCommand *KPrDocument::loadObjects(
const TQDomElement &element,
bool paste )
2766 ObjType t = OT_LINE;
2767 TQDomElement obj=element.firstChild().toElement();
2768 TQValueList<KPrObject *> pasteObjects;
2769 while(!obj.isNull()) {
2770 if(obj.tagName()==
"OBJECT" ) {
2773 if(obj.hasAttribute(
"type"))
2774 tmp=obj.attribute(
"type").toInt();
2775 t=
static_cast<ObjType
>(tmp);
2777 if(obj.hasAttribute(
"sticky"))
2778 tmp=obj.attribute(
"sticky").toInt();
2779 sticky=
static_cast<bool>(tmp);
2783 KPrLineObject *kplineobject =
new KPrLineObject();
2784 offset=kplineobject->load(obj);
2785 if ( sticky && !ignoreSticky)
2787 m_masterPage->appendObject(kplineobject);
2788 kplineobject->setOrig(kplineobject->getOrig().x(),offset);
2790 else if (m_pageWhereLoadObject && paste) {
2791 kplineobject->setOrig(kplineobject->getOrig().x(),offset);
2792 pasteObjects.append( kplineobject );
2794 else if( m_pageWhereLoadObject &&!paste)
2796 m_pageWhereLoadObject->appendObject(kplineobject);
2797 kplineobject->setOrig(kplineobject->getOrig().x(),offset);
2800 insertObjectInPage(offset, kplineobject);
2803 KPrRectObject *kprectobject =
new KPrRectObject();
2804 offset=kprectobject->load(obj);
2805 if ( sticky && !ignoreSticky)
2807 m_masterPage->appendObject(kprectobject);
2808 kprectobject->setOrig(kprectobject->getOrig().x(),offset);
2810 else if (m_pageWhereLoadObject && paste) {
2811 kprectobject->setOrig(kprectobject->getOrig().x(),offset);
2812 pasteObjects.append( kprectobject );
2814 else if( m_pageWhereLoadObject &&!paste)
2816 m_pageWhereLoadObject->appendObject(kprectobject);
2817 kprectobject->setOrig(kprectobject->getOrig().x(),offset);
2820 insertObjectInPage(offset, kprectobject);
2823 KPrEllipseObject *kpellipseobject =
new KPrEllipseObject();
2824 offset=kpellipseobject->load(obj);
2825 if ( sticky && !ignoreSticky)
2827 m_masterPage->appendObject(kpellipseobject);
2828 kpellipseobject->setOrig(kpellipseobject->getOrig().x(),offset);
2830 else if ( m_pageWhereLoadObject && paste)
2832 kpellipseobject->setOrig(kpellipseobject->getOrig().x(),offset);
2833 pasteObjects.append( kpellipseobject );
2835 else if( m_pageWhereLoadObject &&!paste)
2837 m_pageWhereLoadObject->appendObject(kpellipseobject);
2838 kpellipseobject->setOrig(kpellipseobject->getOrig().x(),offset);
2841 insertObjectInPage(offset, kpellipseobject);
2844 KPrPieObject *kppieobject =
new KPrPieObject();
2845 offset=kppieobject->load(obj);
2846 if ( sticky && !ignoreSticky)
2848 m_masterPage->appendObject(kppieobject);
2849 kppieobject->setOrig(kppieobject->getOrig().x(),offset);
2851 else if ( m_pageWhereLoadObject && paste) {
2852 kppieobject->setOrig(kppieobject->getOrig().x(),offset);
2853 pasteObjects.append( kppieobject );
2855 else if( m_pageWhereLoadObject &&!paste)
2857 m_pageWhereLoadObject->appendObject(kppieobject);
2858 kppieobject->setOrig(kppieobject->getOrig().x(),offset);
2861 insertObjectInPage(offset, kppieobject);
2864 KPrAutoformObject *kpautoformobject =
new KPrAutoformObject();
2865 offset=kpautoformobject->load(obj);
2866 if ( sticky && !ignoreSticky)
2868 m_masterPage->appendObject(kpautoformobject);
2869 kpautoformobject->setOrig(kpautoformobject->getOrig().x(),offset);
2871 else if ( m_pageWhereLoadObject&& paste) {
2872 kpautoformobject->setOrig(kpautoformobject->getOrig().x(),offset);
2873 pasteObjects.append( kpautoformobject );
2875 else if( m_pageWhereLoadObject &&!paste)
2877 m_pageWhereLoadObject->appendObject(kpautoformobject);
2878 kpautoformobject->setOrig(kpautoformobject->getOrig().x(),offset);
2881 insertObjectInPage(offset, kpautoformobject);
2884 KPrTextObject *kptextobject =
new KPrTextObject(
this );
2885 offset=kptextobject->load(obj);
2886 if ( sticky && !ignoreSticky)
2888 m_masterPage->appendObject(kptextobject);
2889 kptextobject->setOrig(kptextobject->getOrig().x(),offset);
2891 else if ( m_pageWhereLoadObject && paste) {
2892 kptextobject->setOrig(kptextobject->getOrig().x(),offset);
2893 pasteObjects.append( kptextobject );
2895 else if( m_pageWhereLoadObject &&!paste)
2897 m_pageWhereLoadObject->appendObject(kptextobject);
2898 kptextobject->setOrig(kptextobject->getOrig().x(),offset);
2901 insertObjectInPage(offset, kptextobject);
2905 KPrPixmapObject *kppixmapobject =
new KPrPixmapObject( pictureCollection() );
2906 offset=kppixmapobject->load(obj);
2907 if ( sticky && !ignoreSticky)
2909 m_masterPage->appendObject(kppixmapobject);
2910 kppixmapobject->setOrig(kppixmapobject->getOrig().x(),offset);
2912 else if ( m_pageWhereLoadObject && paste) {
2913 kppixmapobject->setOrig(kppixmapobject->getOrig().x(),offset);
2914 pasteObjects.append( kppixmapobject );
2915 kppixmapobject->reload();
2917 else if( m_pageWhereLoadObject &&!paste)
2919 m_pageWhereLoadObject->appendObject(kppixmapobject);
2920 kppixmapobject->setOrig(kppixmapobject->getOrig().x(),offset);
2923 insertObjectInPage(offset, kppixmapobject);
2926 KPrFreehandObject *kpfreehandobject =
new KPrFreehandObject();
2927 offset=kpfreehandobject->load(obj);
2929 if ( sticky && !ignoreSticky)
2931 m_masterPage->appendObject(kpfreehandobject);
2932 kpfreehandobject->setOrig(kpfreehandobject->getOrig().x(),offset);
2934 else if ( m_pageWhereLoadObject && paste) {
2935 kpfreehandobject->setOrig(kpfreehandobject->getOrig().x(),offset);
2936 pasteObjects.append( kpfreehandobject );
2938 else if( m_pageWhereLoadObject &&!paste)
2940 m_pageWhereLoadObject->appendObject(kpfreehandobject);
2941 kpfreehandobject->setOrig(kpfreehandobject->getOrig().x(),offset);
2944 insertObjectInPage(offset,kpfreehandobject);
2947 KPrPolylineObject *kppolylineobject =
new KPrPolylineObject();
2948 offset=kppolylineobject->load(obj);
2949 if ( sticky && !ignoreSticky)
2951 m_masterPage->appendObject(kppolylineobject);
2952 kppolylineobject->setOrig(kppolylineobject->getOrig().x(),offset);
2954 else if (m_pageWhereLoadObject && paste) {
2955 kppolylineobject->setOrig(kppolylineobject->getOrig().x(),offset);
2956 pasteObjects.append( kppolylineobject );
2958 else if( m_pageWhereLoadObject &&!paste)
2960 m_pageWhereLoadObject->appendObject(kppolylineobject);
2961 kppolylineobject->setOrig(kppolylineobject->getOrig().x(),offset);
2964 insertObjectInPage(offset, kppolylineobject);
2966 case OT_QUADRICBEZIERCURVE: {
2967 KPrQuadricBezierCurveObject *kpQuadricBezierCurveObject =
new KPrQuadricBezierCurveObject();
2968 offset=kpQuadricBezierCurveObject->load(obj);
2969 if ( sticky && !ignoreSticky)
2971 m_masterPage->appendObject(kpQuadricBezierCurveObject);
2972 kpQuadricBezierCurveObject->setOrig(kpQuadricBezierCurveObject->getOrig().x(),offset);
2974 else if ( m_pageWhereLoadObject && paste) {
2975 kpQuadricBezierCurveObject->setOrig(kpQuadricBezierCurveObject->getOrig().x(),offset);
2976 pasteObjects.append( kpQuadricBezierCurveObject );
2978 else if( m_pageWhereLoadObject &&!paste)
2980 m_pageWhereLoadObject->appendObject(kpQuadricBezierCurveObject);
2981 kpQuadricBezierCurveObject->setOrig(kpQuadricBezierCurveObject->getOrig().x(),offset);
2984 insertObjectInPage(offset, kpQuadricBezierCurveObject);
2986 case OT_CUBICBEZIERCURVE: {
2987 KPrCubicBezierCurveObject *kpCubicBezierCurveObject =
new KPrCubicBezierCurveObject();
2988 offset=kpCubicBezierCurveObject->load(obj);
2989 if ( sticky && !ignoreSticky)
2991 m_masterPage->appendObject(kpCubicBezierCurveObject);
2992 kpCubicBezierCurveObject->setOrig(kpCubicBezierCurveObject->getOrig().x(),offset);
2994 else if ( m_pageWhereLoadObject && paste) {
2995 kpCubicBezierCurveObject->setOrig(kpCubicBezierCurveObject->getOrig().x(),offset);
2996 pasteObjects.append( kpCubicBezierCurveObject );
2998 else if( m_pageWhereLoadObject &&!paste)
3000 m_pageWhereLoadObject->appendObject(kpCubicBezierCurveObject);
3001 kpCubicBezierCurveObject->setOrig(kpCubicBezierCurveObject->getOrig().x(),offset);
3004 insertObjectInPage(offset, kpCubicBezierCurveObject);
3007 KPrPolygonObject *kpPolygonObject =
new KPrPolygonObject();
3008 offset=kpPolygonObject->load( obj );
3009 if ( sticky && !ignoreSticky)
3011 m_masterPage->appendObject(kpPolygonObject);
3012 kpPolygonObject->setOrig(kpPolygonObject->getOrig().x(),offset);
3014 else if ( m_pageWhereLoadObject && paste) {
3015 kpPolygonObject->setOrig(kpPolygonObject->getOrig().x(),offset);
3016 pasteObjects.append( kpPolygonObject );
3018 else if( m_pageWhereLoadObject &&!paste)
3020 m_pageWhereLoadObject->appendObject(kpPolygonObject);
3021 kpPolygonObject->setOrig(kpPolygonObject->getOrig().x(),offset);
3024 insertObjectInPage(offset, kpPolygonObject);
3026 case OT_CLOSED_LINE: {
3027 KPrClosedLineObject *kpClosedLinneObject =
new KPrClosedLineObject();
3028 offset = kpClosedLinneObject->load( obj );
3029 if ( sticky && !ignoreSticky) {
3030 m_masterPage->appendObject( kpClosedLinneObject );
3031 kpClosedLinneObject->setOrig( kpClosedLinneObject->getOrig().x(), offset );
3033 else if ( m_pageWhereLoadObject && paste ) {
3034 kpClosedLinneObject->setOrig( kpClosedLinneObject->getOrig().x(), offset );
3035 pasteObjects.append( kpClosedLinneObject );
3037 else if( m_pageWhereLoadObject &&!paste)
3039 m_pageWhereLoadObject->appendObject( kpClosedLinneObject );
3040 kpClosedLinneObject->setOrig( kpClosedLinneObject->getOrig().x(), offset );
3043 insertObjectInPage( offset, kpClosedLinneObject );
3046 KPrGroupObject *kpgroupobject =
new KPrGroupObject();
3047 offset=kpgroupobject->load(obj,
this);
3048 if ( sticky && !ignoreSticky)
3050 m_masterPage->appendObject(kpgroupobject);
3051 kpgroupobject->setOrig(kpgroupobject->getOrig().x(),offset);
3053 else if ( m_pageWhereLoadObject && paste) {
3054 kpgroupobject->setOrig(kpgroupobject->getOrig().x(),offset);
3055 pasteObjects.append( kpgroupobject );
3057 else if( m_pageWhereLoadObject &&!paste)
3059 m_pageWhereLoadObject->appendObject(kpgroupobject);
3060 kpgroupobject->setOrig(kpgroupobject->getOrig().x(),offset);
3063 insertObjectInPage(offset, kpgroupobject);
3068 obj=obj.nextSibling().toElement();
3071 KPrInsertCmd *insertCmd = 0;
3072 if ( ! pasteObjects.empty() )
3074 insertCmd =
new KPrInsertCmd( i18n(
"Paste Objects" ), pasteObjects,
3075 this , m_pageWhereLoadObject );
3076 insertCmd->execute();
3081void KPrDocument::loadTitle(
const TQDomElement &element )
3083 TQDomElement title=element.firstChild().toElement();
3084 int i=m_insertFilePage;
3085 while ( !title.isNull() ) {
3086 if ( title.tagName()==
"Title" )
3090 if(!m_pageWhereLoadObject)
3092 if ( i > ( (
int)m_pageList.count() - 1 ) )
3093 m_pageList.append(
new KPrPage(
this, m_masterPage ) );
3094 m_pageList.at(i)->insertManualTitle(title.attribute(
"title"));
3098 m_pageWhereLoadObject->insertManualTitle(title.attribute(
"title"));
3100 title=title.nextSibling().toElement();
3104void KPrDocument::loadNote(
const TQDomElement &element )
3106 TQDomElement note=element.firstChild().toElement();
3107 int i=m_insertFilePage;
3108 while ( !note.isNull() ) {
3109 if ( note.tagName()==
"Note" )
3113 if(!m_pageWhereLoadObject)
3115 if ( i > ( (
int)m_pageList.count() - 1 ) )
3116 m_pageList.append(
new KPrPage(
this, m_masterPage ) );
3117 m_pageList.at(i)->setNoteText(note.attribute(
"note"));
3121 m_pageWhereLoadObject->setNoteText(note.attribute(
"note"));
3123 note=note.nextSibling().toElement();
3127void KPrDocument::loadUsedSoundFileFromXML(
const TQDomElement &element )
3129 usedSoundFile = TQStringList();
3130 haveNotOwnDiskSoundFile = TQStringList();
3131 TQDomElement fileElement = element.firstChild().toElement();
3132 while ( !fileElement.isNull() ) {
3133 if ( fileElement.tagName() ==
"FILE" ) {
3135 if ( fileElement.hasAttribute(
"name" ) )
3136 fileName = fileElement.attribute(
"name" );
3138 if ( fileElement.hasAttribute(
"filename" ) ) {
3139 TQString name = fileElement.attribute(
"filename" );
3140 TQFile _file( name );
3141 if ( _file.open( IO_ReadOnly ) ) {
3146 haveNotOwnDiskSoundFile.append( name );
3149 usedSoundFile.append( fileName );
3151 fileElement = fileElement.nextSibling().toElement();
3156void KPrDocument::loadImagesFromStore( KoStore *_store )
3159 m_pictureCollection.readFromStore( _store, m_pictureMap );
3160 m_pictureMap.clear();
3164bool KPrDocument::completeLoading( KoStore* _store )
3166 kdDebug()<<
"bool KPrDocument::completeLoading( KoStore* _store )*************************\n";
3167 emit sigProgress( 80 );
3170 loadImagesFromStore( _store );
3171 emit sigProgress( 90 );
3173 if ( !usedSoundFile.isEmpty() )
3174 loadUsedSoundFileFromStore( _store, usedSoundFile );
3177 createHeaderFooter();
3183 if ( saveOnlyPage == -1 ) {
3185 m_masterPage->completeLoading( _clean, lastObj );
3186 TQPtrListIterator<KPrPage> it( m_pageList );
3187 for ( ; it.current(); ++it )
3188 it.current()->completeLoading( _clean, lastObj );
3194 setPageLayout( __pgLayout );
3197 setPageLayout( m_pageLayout );
3200 compatibilityFromOldFileFormat();
3202 emit sigProgress( 100 );
3203 recalcVariables( VT_FIELD );
3204 emit sigProgress( -1 );
3206 connect( documentInfo(), TQ_SIGNAL( sigDocumentInfoModifed()),
this,TQ_SLOT(slotDocumentInfoModifed() ) );
3209 if ( !isReadWrite())
3210 enableBackgroundSpellCheck(
false );
3214void KPrDocument::loadUsedSoundFileFromStore( KoStore *_store, TQStringList _list )
3216 int i = m_insertFilePage;
3217 TQStringList::Iterator it = _list.begin();
3218 for ( ; it != _list.end(); ++it ) {
3219 TQString soundFile = *it;
3221 if ( _store->open( soundFile ) ) {
3222 kdDebug( 33001 ) <<
"Not found file on disk. Use this( " << soundFile <<
" ) file." << endl;
3223 KoStoreDevice dev( _store );
3224 int size = _store->size();
3225 char *data =
new char[size];
3226 dev.readBlock( data, size );
3228 int position = soundFile.findRev(
'.' );
3229 TQString format = soundFile.right( soundFile.length() - position );
3230 KTempFile *tmpFile =
new KTempFile( TQString(), format );
3231 tmpFile->setAutoDelete(
true );
3232 tmpFile->file()->writeBlock( data, size );
3235 TQString tmpFileName = tmpFile->name();
3236 tmpSoundFileList.append( tmpFile );
3238 TQString _fileName = *haveNotOwnDiskSoundFile.at( i );
3241 TQPtrListIterator<KPrPage> it( m_pageList );
3242 for ( ; it.current(); ++it ) {
3243 TQString _file = it.current()->getPageSoundFileName();
3244 if ( !_file.isEmpty() && _file == _fileName )
3245 it.current()->setPageSoundFileName( tmpFileName );
3247 TQPtrListIterator<KPrObject> oIt( it.current()->objectList() );
3248 for ( ; oIt.current(); ++oIt ) {
3249 _file = oIt.current()->getAppearSoundEffectFileName();
3250 if ( !_file.isEmpty() && _file == _fileName )
3251 oIt.current()->setAppearSoundEffectFileName( tmpFileName );
3253 _file = oIt.current()->getDisappearSoundEffectFileName();
3254 if ( !_file.isEmpty() && _file == _fileName )
3255 oIt.current()->setDisappearSoundEffectFileName( tmpFileName );
3263 kdDebug( 33001 ) <<
"Found this( " << soundFile <<
" ) file on disk" << endl;
3268void KPrDocument::setPageLayout(
const KoPageLayout &pgLayout )
3273 m_pageLayout = pgLayout;
3284void KPrDocument::updateHeaderFooterPosition( )
3286 KoRect pageRect=m_masterPage->getPageRect();
3287 TQRect oldBoundingRect = zoomHandler()->zoomRect( _header->getRepaintRect() );
3288 _header->setOrig(pageRect.topLeft ());
3289 _header->setSize(pageRect.width(),_header->getSize().height());
3290 repaint( oldBoundingRect );
3293 oldBoundingRect = zoomHandler()->zoomRect( _footer->getRepaintRect() );
3294 _footer->setOrig(pageRect.left(),pageRect.bottom()-_footer->getSize().height());
3295 _footer->setSize(pageRect.width(),_footer->getSize().height());
3296 repaint(oldBoundingRect);
3300bool KPrDocument::initDoc(InitDocFlags flags, TQWidget* parentWidget)
3303 if (flags==KoDocument::InitDocEmpty)
3305 TQString fileName( locate(
"kpresenter_template",
"Screenpresentations/.source/Plain.kpt",
3306 KPrFactory::global() ) );
3309 bool ok = loadNativeFormat( fileName );
3311 showLoadingErrorDialog();
3318 KoTemplateChooseDia::ReturnType ret;
3319 KoTemplateChooseDia::DialogType dlgtype;
3320 if (flags != InitDocFileNew)
3321 dlgtype = KoTemplateChooseDia::Everything;
3323 dlgtype = KoTemplateChooseDia::OnlyTemplates;
3325 ret = KoTemplateChooseDia::choose( KPrFactory::global(), file,
3326 dlgtype,
"kpresenter_template", parentWidget );
3327 if ( ret == KoTemplateChooseDia::Template ) {
3329 bool ok = loadNativeFormat( file );
3331 showLoadingErrorDialog();
3337 }
else if ( ret == KoTemplateChooseDia::File ) {
3341 bool ok = openURL( url );
3343 }
else if ( ret == KoTemplateChooseDia::Empty ) {
3344 TQString fileName( locate(
"kpresenter_template",
"Screenpresentations/.source/Plain.kpt",
3345 KPrFactory::global() ) );
3348 bool ok = loadNativeFormat( fileName );
3350 showLoadingErrorDialog();
3358void KPrDocument::openExistingFile(
const TQString& file )
3362 KoDocument::openExistingFile( file );
3365void KPrDocument::openTemplate(
const TQString& file )
3367 KoDocument::openTemplate( file );
3372void KPrDocument::initEmpty()
3374 TQString fileName( locate(
"kpresenter_template",
"Screenpresentations/.source/Plain.kpt",
3375 KPrFactory::global() ) );
3379 bool ok = loadNativeFormat( fileName );
3381 showLoadingErrorDialog();
3385void KPrDocument::setEmpty()
3387 KoDocument::setEmpty();
3389 m_varColl->variableSetting()->setCreationDate(TQDateTime::currentDateTime());
3390 recalcVariables( VT_DATE );
3394void KPrDocument::setGridValue(
double _x,
double _y,
bool _replace )
3404void KPrDocument::repaint(
bool erase )
3406 TQPtrListIterator<KoView> it( views() );
3407 for( ; it.current(); ++it ) {
3408 KPrCanvas* canvas = ((KPrView*)it.current())->getCanvas();
3409 canvas->repaint( erase );
3413void KPrDocument::repaint(
const TQRect& rect )
3416 TQPtrListIterator<KoView> it( views() );
3417 for( ; it.current(); ++it ) {
3419 KPrCanvas* canvas = ((KPrView*)it.current())->getCanvas();
3420 r.moveTopLeft( TQPoint( r.x() - canvas->diffx(),
3421 r.y() - canvas->diffy() ) );
3422 canvas->update( r );
3426void KPrDocument::layout(KPrObject *kpobject)
3428 KPrTextObject * obj =
dynamic_cast<KPrTextObject *
>( kpobject );
3433void KPrDocument::layout()
3435 TQPtrListIterator<KoView> it( views() );
3436 for( ; it.current(); ++it ) {
3437 KPrCanvas* canvas = ((KPrView*)it.current())->getCanvas();
3442void KPrDocument::repaint( KPrObject *kpobject )
3444 repaint( m_zoomHandler->zoomRect( kpobject->getRepaintRect() ) );
3447TQValueList<int> KPrDocument::getPageEffectSteps(
unsigned int num )
3449 return m_pageList.at(num)->getEffectSteps();
3452TQRect KPrDocument::getPageRect(
bool decBorders )
const
3454 int pw, ph, bl =
static_cast<int>(m_pageLayout.ptLeft);
3455 int br =
static_cast<int>(m_pageLayout.ptRight);
3456 int bt =
static_cast<int>(m_pageLayout.ptTop);
3457 int bb =
static_cast<int>(m_pageLayout.ptBottom);
3458 int wid =
static_cast<int>(m_pageLayout.ptWidth);
3459 int hei =
static_cast<int>(m_pageLayout.ptHeight);
3461 if ( !decBorders ) {
3468 pw = wid - ( bl + br );
3469 ph = hei - ( bt + bb );
3471 return TQRect( bl, bt, pw, ph );
3474int KPrDocument::getLeftBorder()
const
3476 return static_cast<int>(m_pageLayout.ptLeft);
3479int KPrDocument::getTopBorder()
const
3481 return static_cast<int>(m_pageLayout.ptTop);
3484int KPrDocument::getBottomBorder()
const
3486 return static_cast<int>(m_pageLayout.ptBottom);
3489int KPrDocument::getRightBorder()
const
3491 return static_cast<int>(m_pageLayout.ptRight);
3494void KPrDocument::deletePage(
int _page )
3496 kdDebug(33001) <<
"KPrDocument::deletePage " << _page << endl;
3498 if ( m_pageList.count()==1 )
3500 KPrDeletePageCmd *cmd =
new KPrDeletePageCmd( i18n(
"Delete Slide"), _page,
this );
3505void KPrDocument::insertPage( KPrPage *page,
int currentPageNum,
int insertPageNum )
3508 int pos = m_deletedPageList.findRef( page );
3510 m_deletedPageList.take( pos );
3512 m_pageList.insert( insertPageNum, page );
3516 TQPtrListIterator<KoView> it( views() );
3517 for (; it.current(); ++it )
3519 KPrView *view =
static_cast<KPrView*
>( it.current() );
3520 view->addSideBarItem( insertPageNum );
3523 if ( (
int)view->getCurrPgNum() - 1 == currentPageNum )
3525 view->skipToPage( insertPageNum );
3529 view->recalcCurrentPageNum();
3534void KPrDocument::takePage( KPrPage *page,
int pageNum )
3536 int pos = m_pageList.findRef( page );
3537 m_pageList.take( pos );
3538 m_deletedPageList.append( page );
3542 TQPtrListIterator<KoView> it( views() );
3543 for (; it.current(); ++it )
3545 KPrView *view =
static_cast<KPrView*
>( it.current() );
3546 view->removeSideBarItem( pos );
3549 if ( (
int)view->getCurrPgNum() - 1 == pos )
3551 view->skipToPage( pageNum );
3555 view->recalcCurrentPageNum();
3562void KPrDocument::pageOrderChanged()
3564 recalcVariables( VT_PGNUM );
3567 emit pageNumChanged();
3568 emit sig_updateMenuBar();
3571void KPrDocument::movePageTo(
int oldPos,
int newPos )
3573 kdDebug(33001) <<
"movePage oldPos = " << oldPos <<
", neuPos = " << newPos << endl;
3575 KPrPage * page = m_pageList.take( oldPos );
3576 m_pageList.insert( newPos, page );
3581 TQPtrListIterator<KoView> it( views() );
3582 for (; it.current(); ++it )
3584 KPrView *view =
static_cast<KPrView*
>( it.current() );
3585 view->moveSideBarItem( oldPos, newPos );
3588 if ( (
int)view->getCurrPgNum() - 1 == oldPos )
3590 view->skipToPage( newPos );
3594 view->recalcCurrentPageNum();
3599TQString KPrDocument::templateFileName(
bool chooseTemplate,
const TQString &theFile )
3602 if ( !chooseTemplate ) {
3603 if ( theFile.isEmpty() )
3604 fileName = locateLocal(
"data",
"kpresenter/default.kpr" );
3609 TQWidget* parentWidget = 0;
3611 if ( KoTemplateChooseDia::choose( KPrFactory::global(), _template,
3612 KoTemplateChooseDia::OnlyTemplates,
3613 "kpresenter_template", parentWidget ) == KoTemplateChooseDia::Cancel )
3615 TQFileInfo fileInfo( _template );
3616 fileName = fileInfo.dirPath(
true ) +
"/" + fileInfo.baseName() +
".kpt";
3619 src.setPath( fileName );
3620 dest.setPath( locateLocal(
"data",
"kpresenter/default.kpr" ) );
3621 kdDebug(33001) <<
"Copying template (in KPrDocument::templateFileName)" << endl
3622 <<
" from: " << src.prettyURL() << endl
3623 <<
" to: " << dest.prettyURL() << endl;
3624 TDEIO::NetAccess::file_copy( src,
3632int KPrDocument::insertNewPage(
const TQString &cmdName,
int _page, InsertPos _insPos,
3633 bool chooseTemplate,
const TQString &theFile )
3635 kdDebug(33001) <<
"KPrDocument::insertNewPage " << _page << endl;
3637 TQString fileName=templateFileName(chooseTemplate, theFile);
3638 if(fileName.isEmpty())
3646 KPrPage *newpage =
new KPrPage(
this, m_masterPage );
3648 m_pageWhereLoadObject=newpage;
3649 m_childCountBeforeInsert = children().count();
3651 bool ok = loadNativeFormat( fileName );
3653 showLoadingErrorDialog();
3657 KPrInsertPageCmd *cmd =
new KPrInsertPageCmd( cmdName, _page, _insPos, newpage,
this );
3662 m_pageWhereLoadObject=0L;
3663 m_childCountBeforeInsert = 0;
3667void KPrDocument::savePage(
const TQString &file,
int pgnum,
bool ignore )
3669 saveOnlyPage = pgnum;
3670 _duplicatePage=ignore;
3671 saveNativeFormat( file );
3672 _duplicatePage=
false;
3676void KPrDocument::replaceObjs(
bool createUndoRedo )
3678 KMacroCommand * macroCmd = 0L;
3679 TQPtrListIterator<KPrPage> oIt(m_pageList);
3680 for (; oIt.current(); ++oIt )
3682 KCommand *cmd=oIt.current()->replaceObjs( createUndoRedo, oldGridX,oldGridY,_txtBackCol, _otxtBackCol);
3683 if(cmd && createUndoRedo)
3686 macroCmd =
new KMacroCommand( i18n(
"Set New Options") );
3687 macroCmd->addCommand(cmd);
3695 macroCmd->execute();
3696 addCommand(macroCmd);
3700void KPrDocument::restoreBackground( KPrPage *page )
3702 page->background()->reload();
3705KCommand * KPrDocument::loadPastedObjs(
const TQString &in, KPrPage* _page )
3708 doc.setContent( in );
3710 TQDomElement document=doc.documentElement();
3713 if (document.tagName()!=
"DOC") {
3714 kdError(33001) <<
"Missing DOC" << endl;
3720 if(document.hasAttribute(
"mime") && document.attribute(
"mime")==
"application/x-kpresenter")
3725 m_pageWhereLoadObject=_page;
3726 KCommand *cmd = loadObjects(document,
true);
3727 m_pageWhereLoadObject=0L;
3730 setModified(
true );
3734void KPrDocument::deSelectAllObj()
3736 TQPtrListIterator<KoView> it( views() );
3737 for (; it.current(); ++it )
3738 ((KPrView*)it.current())->getCanvas()->deSelectAllObj();
3741void KPrDocument::deSelectObj(KPrObject *obj)
3743 TQPtrListIterator<KoView> it( views() );
3744 for (; it.current(); ++it )
3745 ((KPrView*)it.current())->getCanvas()->deSelectObj( obj );
3748void KPrDocument::setDisplayObjectMasterPage(
bool b )
3750 TQPtrListIterator<KoView> it( views() );
3751 for (; it.current(); ++it )
3752 ((KPrView*)it.current())->updateDisplayObjectMasterPageButton();
3756void KPrDocument::setDisplayBackground(
bool b )
3758 TQPtrListIterator<KoView> it( views() );
3759 for (; it.current(); ++it )
3760 ((KPrView*)it.current())->updateDisplayBackgroundButton();
3764void KPrDocument::setHeader(
bool b )
3766 _header->setDrawEditRect( b );
3767 _header->setDrawEmpty( b );
3770 terminateEditing(_header);
3771 deSelectObj(_header);
3773 m_masterPage->setHeader( b,
false );
3774 updateHeaderFooterButton();
3778void KPrDocument::setFooter(
bool b )
3780 _footer->setDrawEditRect( b );
3781 _footer->setDrawEmpty( b );
3784 terminateEditing(_footer);
3785 deSelectObj(_footer);
3787 m_masterPage->setFooter( b,
false );
3788 updateHeaderFooterButton();
3792void KPrDocument::updateHeaderFooterButton()
3794 TQPtrListIterator<KoView> it( views() );
3795 for (; it.current(); ++it )
3796 ((KPrView*)it.current())->updateHeaderFooterButton();
3799void KPrDocument::makeUsedPixmapList()
3801 usedPictures.clear();
3803 for ( uint i = 0; i < m_pageList.count(); i++ ) {
3804 if ( saveOnlyPage != -1 &&
3805 static_cast<int>(i) != saveOnlyPage )
3807 m_pageList.at(i)->makeUsedPixmapList();
3810 if ( saveOnlyPage == -1 )
3811 m_masterPage->makeUsedPixmapList();
3814void KPrDocument::makeUsedSoundFileList()
3816 if ( saveOnlyPage != -1 )
3819 usedSoundFile.clear();
3821 TQPtrListIterator<KPrPage> it( m_pageList );
3822 for ( ; it.current(); ++it ) {
3823 TQString _file = it.current()->getPageSoundFileName();
3824 if ( !_file.isEmpty() && usedSoundFile.findIndex( _file ) == -1 )
3825 usedSoundFile.append( _file );
3827 TQPtrListIterator<KPrObject> oIt( it.current()->objectList() );
3828 for ( ; oIt.current(); ++oIt ) {
3829 _file = oIt.current()->getAppearSoundEffectFileName();
3830 if ( !_file.isEmpty() && usedSoundFile.findIndex( _file ) == -1 )
3831 usedSoundFile.append( _file );
3833 _file = oIt.current()->getDisappearSoundEffectFileName();
3834 if ( !_file.isEmpty() && usedSoundFile.findIndex( _file ) == -1 )
3835 usedSoundFile.append( _file );
3840KoView* KPrDocument::createViewInstance( TQWidget* parent,
const char* name )
3845 return new KPrView(
this, parent, name );
3848void KPrDocument::paintContent( TQPainter& painter,
const TQRect& rect,
3849 bool ,
double zoomX,
double zoomY )
3851 m_zoomHandler->setZoom( 100 );
3852 if ( zoomHandler()->zoomedResolutionX() != zoomX || zoomHandler()->zoomedResolutionY() != zoomY )
3854 int zoomLevel = tqRound( 100 * zoomY / zoomHandler()->zoomedResolutionY() );
3855 zoomHandler()->setZoom( zoomLevel );
3856 bool forPrint = painter.device() && painter.device()->devType() == TQInternal::Printer;
3857 newZoomAndResolution(
false, forPrint );
3860 KPrPage *page=m_pageList.first();
3861 if( m_initialActivePage )
3862 page = m_initialActivePage;
3864 int pageNum = m_pageList.findRef( page );
3866 if ( page->displayBackground() )
3867 page->background()->drawBackground( &painter, zoomHandler(), rect,
false );
3868 if ( page->displayObjectFromMasterPage() )
3870 KPrPage *masterPage = page->masterPage();
3873 TQPtrListIterator<KPrObject> it( masterPage->objectList() );
3875 for ( ; it.current() ; ++it )
3877 if( (it.current()==_header && !page->hasHeader())||(it.current()==_footer && !page->hasFooter()))
3879 it.current()->draw( &painter, zoomHandler(), pageNum, SM_NONE );
3883 TQPtrListIterator<KPrObject> it( page->objectList() );
3884 for ( ; it.current() ; ++it )
3885 it.current()->draw( &painter, zoomHandler(), pageNum, SM_NONE );
3888TQPixmap KPrDocument::generatePreview(
const TQSize& size )
3890 int oldZoom = zoomHandler()->zoom();
3891 double oldResolutionX = zoomHandler()->resolutionX();
3892 double oldResolutionY = zoomHandler()->resolutionY();
3894 TQPixmap pix = KoDocument::generatePreview(size);
3896 zoomHandler()->setResolution( oldResolutionX, oldResolutionY );
3897 zoomHandler()->setZoom(oldZoom);
3898 newZoomAndResolution(
false,
false );
3903void KPrDocument::addShell( KoMainWindow *shell )
3905 connect( shell, TQ_SIGNAL( documentSaved() ), m_commandHistory, TQ_SLOT( documentSaved() ) );
3906 KoDocument::addShell( shell );
3909void KPrDocument::movePage(
int from,
int to )
3911 kdDebug(33001) <<
"KPrDocument::movePage from=" << from <<
" to=" << to << endl;
3912 KPrMovePageCmd *cmd =
new KPrMovePageCmd( i18n(
"Move Slide"), from, to,
this );
3917void KPrDocument::copyPage(
int from )
3920 m_childCountBeforeInsert = children().count();
3922 _duplicatePage=
true;
3924 kdDebug(33001) <<
"KPrDocument::copyPage from=" << from <<
" to=" << from + 1 << endl;
3925 kdDebug(33001) <<
"mimeType = " << mimeType() <<
", outputMimeType = " << outputMimeType() << endl;
3926 bool wasSelected = isSlideSelected( from );
3927 KTempFile tempFile( TQString(), mimeType() == nativeOasisMimeType() ?
".oop":
".kpr" );
3928 tempFile.setAutoDelete(
true );
3929 savePage( tempFile.name(), from,
true );
3932 KPrPage *newpage =
new KPrPage(
this, m_masterPage );
3934 m_pageWhereLoadObject = newpage;
3936 bool ok = loadNativeFormat( tempFile.name() );
3938 showLoadingErrorDialog();
3940 KPrInsertPageCmd *cmd =
new KPrInsertPageCmd( i18n(
"Duplicate Slide"), from, IP_AFTER, newpage,
this );
3944 _duplicatePage=
false;
3947 m_pageWhereLoadObject=0L;
3948 m_childCountBeforeInsert = 0;
3950 selectPage( from + 1, wasSelected );
3953void KPrDocument::copyPageToClipboard(
int pgnum )
3959 kdDebug(33001) <<
"KPrDocument::copyPageToClipboard pgnum=" << pgnum << endl;
3960 kdDebug(33001) <<
"mimeType = " << mimeType() <<
", outputMimeType = " << outputMimeType() << endl;
3961 KTempFile tempFile( TQString(), mimeType() == nativeOasisMimeType() ?
".oop":
".kpr" );
3962 savePage( tempFile.name(), pgnum,
true );
3963 KURL url; url.setPath( tempFile.name() );
3966 TQApplication::clipboard()->setData(
new KURLDrag( lst ) );
3967 m_tempFileInClipboard = tempFile.name();
3970void KPrDocument::pastePage(
const TQMimeSource * data,
int pgnum )
3973 if ( KURLDrag::decode( data, lst ) && !lst.isEmpty() )
3975 insertNewPage(i18n(
"Paste Slide"), pgnum, IP_BEFORE,
false, lst.first().path() );
3980void KPrDocument::clipboardDataChanged()
3982 if ( !m_tempFileInClipboard.isEmpty() )
3984 kdDebug(33001) <<
"KPrDocument::clipboardDataChanged, deleting temp file " << m_tempFileInClipboard << endl;
3985 unlink( TQFile::encodeName( m_tempFileInClipboard ) );
3986 m_tempFileInClipboard = TQString();
3995void KPrDocument::selectPage(
int pgNum ,
bool select )
3997 Q_ASSERT( pgNum >= 0 );
3998 KPrPage *page = m_pageList.at( pgNum );
3999 page->slideSelected(select);
4000 kdDebug(33001) <<
"KPrDocument::selectPage pgNum=" << pgNum <<
" select=" << select << endl;
4003 updateSideBarItem( page );
4004 updatePresentationButton();
4006 emit pageNumChanged();
4009KPrPage * KPrDocument::findPage(KPrObject *
object)
4011 TQPtrList<KPrObject> masterObjects( m_masterPage->objectList() );
4012 if ( masterObjects.findRef(
object ) != -1 )
4015 return m_masterPage;
4017 TQPtrListIterator<KPrPage> it( m_pageList );
4018 for ( ; it.current(); ++it ) {
4019 TQPtrList<KPrObject> list( it.current()->objectList() );
4020 if ( list.findRef(
object ) != -1 ) {
4022 return it.current();
4025 kdDebug(33001) <<
"Object not found on a page" << endl;
4029KPrPage * KPrDocument::findPage(TQPtrList<KPrObject> &objects)
4032 for (
object = objects.first(); object;
object=objects.next() ) {
4033 TQPtrList<KPrObject> list( m_masterPage->objectList() );
4034 if ( list.findRef(
object ) != -1 )
4037 return m_masterPage;
4040 object = objects.first();
4041 for ( KPrPage *page=m_pageList.first(); page; page=m_pageList.next() ) {
4042 TQPtrList<KPrObject> list( page->objectList() );
4043 if ( list.findRef(
object ) != -1 ) {
4048 kdDebug(33001) <<
"Objects not found on a page" << endl;
4052void KPrDocument::updateSideBarItem( KPrPage * page )
4055 TQPtrListIterator<KoView> it( views() );
4056 for (; it.current(); ++it )
4057 static_cast<KPrView*
>( it.current() )->updateSideBarItem( page );
4060bool KPrDocument::isSlideSelected(
int pgNum )
4062 Q_ASSERT( pgNum >= 0 );
4063 return m_pageList.at(pgNum)->isSlideSelected();
4066TQValueList<int> KPrDocument::listOfDisplaySelectedSlides(
const TQValueList<KPrPage*> & lst)
4068 TQValueList<int> result;
4069 TQValueListConstIterator<KPrPage*> itPage;
4070 TQValueListConstIterator<KPrPage*> itPageEnd = lst.end();
4071 for( itPage = lst.begin() ; itPage != itPageEnd; ++itPage )
4073 int pageNum = m_pageList.find(*itPage );
4074 if ( pageNum != -1 )
4076 kdDebug()<<
" KPrDocument::displaySelectedSlide : add slide number :"<<pageNum<<endl;
4084TQValueList<int> KPrDocument::displaySelectedSlides()
4086 TQValueList<int> result;
4087 if ( m_customListTest )
4088 return *m_customListTest;
4089 if ( m_presentationName.isEmpty() )
4090 return selectedSlides();
4093 kdDebug()<<
" KPrDocument::displaySelectedSlide m_presentationName : "<<m_presentationName<<endl;
4094 result = listOfDisplaySelectedSlides( m_customListSlideShow[m_presentationName]);
4099TQValueList<int> KPrDocument::selectedSlides()
4101 TQValueList<int> result;
4102 for (
int i = 0; i < static_cast<int>( m_pageList.count() ); i++ ) {
4103 if(m_pageList.at(i)->isSlideSelected())
4109TQString KPrDocument::selectedForPrinting() {
4111 int start=-1, end=-1;
4112 bool continuous=
false;
4113 for (
int i = 0; i < static_cast<int>( m_pageList.count() ); i++ ) {
4114 if(m_pageList.at(i)->isSlideSelected()) {
4126 ret+=TQString::number(start+1)+
",";
4128 ret+=TQString::number(start+1)+
"-"+TQString::number(end+1)+
",";
4135 ret+=TQString::number(start+1);
4137 ret+=TQString::number(start+1)+
"-"+TQString::number(end+1);
4139 if(
','==ret[ret.length()-1])
4140 ret.truncate(ret.length()-1);
4144void KPrDocument::slotRepaintChanged( KPrTextObject *kptextobj )
4148 repaint( kptextobj );
4152void KPrDocument::recalcVariables(
int type )
4155 TQValueList<KoVariable* > modifiedVariables = m_varColl->recalcVariables(type);
4156 if ( modifiedVariables.isEmpty() )
4160 TQPtrListIterator<KPrPage> it( m_pageList );
4161 for ( ; it.current(); ++it )
4162 it.current()->slotRepaintVariable();
4163 m_masterPage->slotRepaintVariable();
4166void KPrDocument::slotGuideLinesChanged( KoView *view )
4168 ( (KPrView*)view )->getCanvas()->guideLines().getGuideLines( m_hGuideLines, m_vGuideLines );
4169 TQPtrListIterator<KoView> it( views() );
4170 for (; it.current(); ++it )
4172 if ( it.current() != view )
4174 ( (KPrView*)it.current() )->getCanvas()->guideLines().setGuideLines( m_hGuideLines, m_vGuideLines );
4179void KPrDocument::slotDocumentInfoModifed()
4181 if (!getVariableCollection()->variableSetting()->displayFieldCode())
4182 recalcVariables( VT_FIELD );
4185void KPrDocument::reorganizeGUI()
4187 TQPtrListIterator<KoView> it( views() );
4188 for (; it.current(); ++it )
4189 ((KPrView*)it.current())->reorganize();
4192int KPrDocument::undoRedoLimit()
const
4194 return m_commandHistory->undoLimit();
4197void KPrDocument::setUndoRedoLimit(
int val)
4199 m_commandHistory->setUndoLimit(val);
4200 m_commandHistory->setRedoLimit(val);
4203void KPrDocument::updateRuler()
4205 emit sig_updateRuler();
4208void KPrDocument::recalcPageNum()
4210 TQPtrListIterator<KPrPage> it( m_pageList );
4211 for ( ; it.current(); ++it )
4212 it.current()->recalcPageNum();
4213 m_masterPage->recalcPageNum();
4216KPrPage * KPrDocument::activePage()
const
4218 return m_initialActivePage;
4221void KPrDocument::insertObjectInPage(
double offset, KPrObject *_obj,
int pos)
4224 int page = (int)(offset/__pgLayout.ptHeight)+m_insertFilePage;
4227 kdDebug(33001) <<
"insertObjectInPage object cound not be inserted page = " << page << endl;
4230 double newPos = offset - ( page - m_insertFilePage ) * __pgLayout.ptHeight;
4233 if ( __pgLayout.ptHeight - newPos < 1e-6 )
4238 if ( page > ( (
int)m_pageList.count()-1 ) )
4240 for (
int i=(m_pageList.count()-1); i<page;i++)
4241 m_pageList.append(
new KPrPage(
this, m_masterPage ) );
4243 _obj->setOrig(_obj->getOrig().x(),newPos);
4247 m_pageList.at(page)->appendObject(_obj);
4251 m_pageList.at( page )->insertObject( _obj, pos );
4255void KPrDocument::insertPixmapKey( KoPictureKey key )
4257 if ( !usedPictures.contains( key ) )
4258 usedPictures.append( key );
4261KPrPage * KPrDocument::initialActivePage()
const
4263 return m_initialActivePage;
4266void KPrDocument::displayActivePage(KPrPage * _page)
4268 m_initialActivePage = _page;
4271void KPrDocument::updateZoomRuler()
4273 TQPtrListIterator<KoView> it( views() );
4274 for (; it.current(); ++it )
4276 ((KPrView*)it.current())->getHRuler()->setZoom( m_zoomHandler->zoomedResolutionX() );
4277 ((KPrView*)it.current())->getVRuler()->setZoom( m_zoomHandler->zoomedResolutionY() );
4278 ((KPrView*)it.current())->slotUpdateRuler();
4282void KPrDocument::newZoomAndResolution(
bool updateViews,
bool )
4284 TQPtrListIterator<KPrPage> it( m_pageList );
4285 for ( ; it.current(); ++it ) {
4286 TQPtrListIterator<KPrObject> oit(it.current()->objectList());
4287 for ( ; oit.current(); ++oit ) {
4288 if ( oit.current()->getType() == OT_TEXT )
4289 static_cast<KPrTextObject *
>( oit.current() )->textDocument()->formatCollection()->zoomChanged();
4294 TQPtrListIterator<KoView> it( views() );
4295 for (; it.current(); ++it )
4297 static_cast<KPrView *
>( it.current() )->getCanvas()->update();
4298 static_cast<KPrView *
>( it.current() )->getCanvas()->layout();
4303bool KPrDocument::isHeader(
const KPrObject *obj)
const
4305 return (obj==_header);
4308bool KPrDocument::isFooter(
const KPrObject *obj)
const
4310 return (obj==_footer);
4313bool KPrDocument::isHeaderFooter(
const KPrObject *obj)
const
4315 return (obj==_header)||(obj==_footer);
4318void KPrDocument::updateRulerPageLayout()
4320 TQPtrListIterator<KoView> it( views() );
4321 for (; it.current(); ++it )
4323 ((KPrView*)it.current())->getHRuler()->setPageLayout(m_pageLayout );
4324 ((KPrView*)it.current())->getVRuler()->setPageLayout(m_pageLayout );
4329void KPrDocument::refreshAllNoteBarMasterPage(
const TQString &text, KPrView *exceptView)
4331 m_masterPage->setNoteText(text );
4332 TQPtrListIterator<KoView> it( views() );
4333 for (; it.current(); ++it )
4335 KPrView* view=(KPrView*)it.current();
4336 if ( view->getNoteBar() && view != exceptView && view->editMaster() )
4337 view->getNoteBar()->setCurrentNoteText(text );
4341void KPrDocument::refreshAllNoteBar(
int page,
const TQString &text, KPrView *exceptView)
4343 m_pageList.at(page)->setNoteText(text );
4344 TQPtrListIterator<KoView> it( views() );
4345 for (; it.current(); ++it )
4347 KPrView* view=(KPrView*)it.current();
4348 if ( view->getNoteBar() && view != exceptView && ((int)(view->getCurrPgNum())-1 == page))
4349 view->getNoteBar()->setCurrentNoteText(text );
4353void KPrDocument::loadStyleTemplates(
const TQDomElement &stylesElem )
4355 TQValueList<TQString> followingStyles;
4357 TQDomNodeList listStyles = stylesElem.elementsByTagName(
"STYLE" );
4358 if( listStyles.count() > 0) {
4359 KoParagStyle *s = m_styleColl->findStyle(
"Standard");
4360 kdDebug(32001) <<
"KPrDocument::loadStyleTemplates looking for Standard, to delete it. Found " << s << endl;
4362 m_styleColl->removeStyle(s);
4364 for (
unsigned int item = 0; item < listStyles.count(); item++) {
4365 TQDomElement styleElem = listStyles.item( item ).toElement();
4367 KoParagStyle *sty =
new KoParagStyle( TQString() );
4369 sty->loadStyle( styleElem );
4371 TQDomElement formatElem = styleElem.namedItem(
"FORMAT" ).toElement();
4372 if ( !formatElem.isNull() )
4373 sty->format() = KPrTextObject::loadFormat( formatElem, 0L, defaultFont(), globalLanguage(), globalHyphenation() );
4375 kdWarning(33001) <<
"No FORMAT tag in <STYLE>" << endl;
4378 sty = m_styleColl->addStyle( sty );
4379 kdDebug() << k_funcinfo << m_styleColl->styleList().count() <<
" styles, " << followingStyles.count() <<
" following styles" << endl;
4380 if(m_styleColl->styleList().count() > followingStyles.count() )
4382 TQString following = styleElem.namedItem(
"FOLLOWING").toElement().attribute(
"name");
4383 followingStyles.append( following );
4386 kdWarning (33001) <<
"Found duplicate style declaration, overwriting former " << sty->name() << endl;
4389 Q_ASSERT( followingStyles.count() == m_styleColl->styleList().count() );
4391 for( TQValueList<TQString>::Iterator it = followingStyles.begin(); it != followingStyles.end(); ++it ) {
4392 KoParagStyle * style = m_styleColl->findStyle(*it);
4393 m_styleColl->styleAt( i++)->setFollowingStyle( style );
4398void KPrDocument::updateAllStyleLists()
4400 TQPtrListIterator<KoView> it( views() );
4401 for (; it.current(); ++it )
4402 ((KPrView*)it.current())->updateStyleList();
4405void KPrDocument::applyStyleChange( KoStyleChangeDefMap changed )
4407 TQPtrListIterator<KPrPage> it( m_pageList );
4408 for ( ; it.current(); ++it )
4409 it.current()->applyStyleChange( changed );
4410 m_masterPage->applyStyleChange( changed );
4413void KPrDocument::saveStyle( KoParagStyle *sty, TQDomElement parentElem )
4415 TQDomDocument doc = parentElem.ownerDocument();
4416 TQDomElement styleElem = doc.createElement(
"STYLE" );
4417 parentElem.appendChild( styleElem );
4419 sty->saveStyle( styleElem );
4420 TQDomElement formatElem = doc.createElement(
"FORMAT");
4421 KPrTextObject::saveFormat( formatElem, &sty->format() );
4422 styleElem.appendChild( formatElem );
4425void KPrDocument::startBackgroundSpellCheck()
4428 if(backgroundSpellCheckEnabled() && isReadWrite())
4430 if(m_initialActivePage->allTextObjects().count()>0)
4432 m_bgSpellCheck->start();
4437void KPrDocument::enableBackgroundSpellCheck(
bool b )
4440 m_bgSpellCheck->setEnabled(b);
4441 TQPtrListIterator<KoView> it( views() );
4442 for( ; it.current(); ++it )
4443 ((KPrView*)it.current())->updateBgSpellCheckingState();
4446bool KPrDocument::backgroundSpellCheckEnabled()
const
4448 return m_bgSpellCheck->enabled();
4451void KPrDocument::reactivateBgSpellChecking(
bool refreshTextObj)
4453 TQPtrListIterator<KPrPage> it( m_pageList );
4455 if(m_kpresenterView && m_kpresenterView->getCanvas())
4456 activePage=m_kpresenterView->getCanvas()->activePage();
4458 KPrPage *activePage=m_initialActivePage;
4459 for ( ; it.current(); ++it )
4461 if( it.current()!=activePage)
4462 it.current()->reactivateBgSpellChecking(
false );
4464 it.current()->reactivateBgSpellChecking(
true);
4466 m_masterPage->reactivateBgSpellChecking(refreshTextObj);
4467 startBackgroundSpellCheck();
4470TQPtrList<KoTextObject> KPrDocument::allTextObjects()
const
4472 TQPtrList<KoTextObject> lst;
4473 TQPtrListIterator<KPrPage> it( m_pageList );
4474 for ( ; it.current(); ++it )
4475 it.current()->addTextObjects( lst );
4476 m_masterPage->addTextObjects( lst );
4480TQValueList<KoTextDocument *> KPrDocument::allTextDocuments()
const
4482 TQValueList<KoTextDocument *> lst;
4483 const TQPtrList<KoTextObject> textObjects = allTextObjects();
4484 TQPtrListIterator<KoTextObject> it( textObjects );
4485 for ( ; it.current() ; ++it ) {
4486 lst.append( it.current()->textDocument() );
4491TQValueList<KoTextObject *> KPrDocument::visibleTextObjects( )
const
4493 TQValueList<KoTextObject *> lst;
4494 TQPtrList<KoTextObject> textFramesets = allTextObjects( );
4497 for ( frm=textFramesets.first(); frm != 0; frm=textFramesets.next() ) {
4498 if ( frm && !frm->protectContent() )
4506void KPrDocument::setShowGuideLines(
bool b )
4508 m_bShowGuideLines = b;
4509 setModified(
true );
4512void KPrDocument::horizontalGuideLines(
const TQValueList<double> &lines )
4514 m_hGuideLines = lines;
4517void KPrDocument::verticalGuideLines(
const TQValueList<double> &lines )
4519 m_vGuideLines = lines;
4523void KPrDocument::addGuideLine( TQt::Orientation o,
double pos )
4525 if ( o == TQt::Horizontal )
4527 m_hGuideLines.append( pos );
4531 m_vGuideLines.append( pos );
4534 TQPtrListIterator<KoView> it( views() );
4535 for (; it.current(); ++it )
4537 ( (KPrView*)it.current() )->getCanvas()->guideLines().setGuideLines( m_hGuideLines, m_vGuideLines );
4542void KPrDocument::updateGuideLineButton()
4544 TQPtrListIterator<KoView> it( views() );
4545 for (; it.current(); ++it )
4546 ((KPrView*)it.current())->updateGuideLineButton();
4549void KPrDocument::loadGuideLines(
const TQDomElement &element )
4554 TQDomElement guidelines = element.namedItem(
"HELPLINES" ).toElement();
4555 if ( guidelines.isNull() )
4556 guidelines = element;
4558 guidelines = guidelines.firstChild().toElement();
4559 while ( !guidelines.isNull() )
4561 if ( guidelines.tagName() ==
"Vertical" )
4562 m_vGuideLines.append( guidelines.attribute(
"value" ).toDouble() );
4563 else if ( guidelines.tagName() ==
"Horizontal" )
4564 m_hGuideLines.append( guidelines.attribute(
"value" ).toDouble() );
4565 guidelines = guidelines.nextSibling().toElement();
4569void KPrDocument::saveGuideLines( TQDomDocument &doc, TQDomElement& element )
4571 for(TQValueList<double>::Iterator it = m_vGuideLines.begin(); it != m_vGuideLines.end(); ++it)
4573 TQDomElement lines=doc.createElement(
"Vertical");
4574 lines.setAttribute(
"value", (
double)*it);
4575 element.appendChild( lines );
4578 for(TQValueList<double>::Iterator it = m_hGuideLines.begin(); it != m_hGuideLines.end(); ++it)
4580 TQDomElement lines=doc.createElement(
"Horizontal");
4581 lines.setAttribute(
"value", *it);
4582 element.appendChild( lines );
4586void KPrDocument::updateGridButton()
4588 TQPtrListIterator<KoView> it( views() );
4589 for (; it.current(); ++it )
4590 ((KPrView*)it.current())->updateGridButton();
4594void KPrDocument::setSpellCheckIgnoreList(
const TQStringList& lst )
4596 m_spellCheckIgnoreList = lst;
4597 m_bgSpellCheck->settings()->setCurrentIgnoreList( m_spellCheckIgnoreList + m_spellCheckPersonalDict );
4598 setModified(
true );
4601void KPrDocument::addSpellCheckIgnoreWord(
const TQString & word )
4604 if( m_spellCheckIgnoreList.findIndex( word ) == -1 )
4605 m_spellCheckIgnoreList.append( word );
4606 setSpellCheckIgnoreList( m_spellCheckIgnoreList );
4609void KPrDocument::updateObjectStatusBarItem()
4611 TQPtrListIterator<KoView> it( views() );
4612 for (; it.current(); ++it )
4613 ((KPrView*)it.current())->updateObjectStatusBarItem();
4616void KPrDocument::updateObjectSelected()
4618 TQPtrListIterator<KoView> it( views() );
4619 for (; it.current(); ++it )
4620 ((KPrView*)it.current())->objectSelectedChanged();
4623void KPrDocument::setTabStopValue (
double _tabStop )
4625 m_tabStop = _tabStop;
4626 TQPtrListIterator<KPrPage> it( m_pageList );
4627 for ( ; it.current(); ++it )
4628 it.current()->changeTabStopValue( m_tabStop );
4630 m_masterPage->changeTabStopValue( m_tabStop );
4633void KPrDocument::changeBgSpellCheckingState(
bool b )
4635 enableBackgroundSpellCheck( b );
4636 reactivateBgSpellChecking();
4637 TDEConfig *config = KPrFactory::global()->config();
4638 config->setGroup(
"KSpell kpresenter" );
4639 config->writeEntry(
"SpellCheck", (
int)b );
4643bool KPrDocument::cursorInProtectedArea()
const
4645 return m_cursorInProtectectedArea;
4648void KPrDocument::setCursorInProtectedArea(
bool b )
4650 m_cursorInProtectectedArea=b;
4651 testAndCloseAllTextObjectProtectedContent();
4654void KPrDocument::testAndCloseAllTextObjectProtectedContent()
4656 if ( !m_cursorInProtectectedArea )
4658 TQPtrListIterator<KoView> it( views() );
4659 for (; it.current(); ++it )
4660 static_cast<KPrView*
>(it.current())->testAndCloseAllTextObjectProtectedContent();
4664void KPrDocument::insertFile(
const TQString & file )
4666 m_insertFilePage = m_pageList.count();
4668 m_childCountBeforeInsert = children().count();
4670 bool clean = _clean;
4672 bool ok = loadNativeFormat(file );
4675 showLoadingErrorDialog();
4678 KMacroCommand *macro = 0L;
4679 for (
int i = m_insertFilePage; i<(int)m_pageList.count();i++)
4682 macro =
new KMacroCommand( i18n(
"Insert File"));
4683 KPrInsertPageCmd * cmd =
new KPrInsertPageCmd( i18n(
"Insert File"), i - 1, IP_AFTER, m_pageList.at(i),
this ) ;
4684 macro->addCommand(cmd );
4687 addCommand( macro );
4689 m_insertFilePage = 0;
4690 m_childCountBeforeInsert = 0;
4692 int newPos = m_pageList.count()-1;
4693 TQPtrListIterator<KoView> it( views() );
4694 for (; it.current(); ++it )
4695 static_cast<KPrView*
>(it.current())->updateSideBar();
4697 updatePresentationButton();
4700 TQPtrListIterator<KoView>it2( views() );
4701 for (; it2.current(); ++it2 )
4702 static_cast<KPrView*
>(it2.current())->skipToPage(newPos);
4705void KPrDocument::spellCheckParagraphDeleted( KoTextParag * , KPrTextObject * )
4710void KPrDocument::updateRulerInProtectContentMode()
4712 TQPtrListIterator<KoView> it( views() );
4713 for (; it.current(); ++it )
4714 static_cast<KPrView*
>(it.current())->updateRulerInProtectContentMode();
4717void KPrDocument::updatePresentationButton()
4719 TQPtrListIterator<KoView> it( views() );
4720 for (; it.current(); ++it )
4721 static_cast<KPrView*
>(it.current())->updatePresentationButton((selectedSlides().count()>0));
4724void KPrDocument::refreshGroupButton()
4726 TQPtrListIterator<KoView> it( views() );
4727 for (; it.current(); ++it )
4728 static_cast<KPrView*
>(it.current())->refreshGroupButton();
4731void KPrDocument::addView( KoView *_view )
4733 KoDocument::addView( _view );
4734 TQPtrListIterator<KoView> it( views() );
4735 for (; it.current(); ++it )
4736 static_cast<KPrView*
>(it.current())->closeTextObject();
4739void KPrDocument::removeView( KoView *_view )
4741 KoDocument::removeView( _view );
4742 TQPtrListIterator<KoView> it( views() );
4743 for (; it.current(); ++it )
4744 static_cast<KPrView*
>(it.current())->deSelectAllObjects();
4747void KPrDocument::updateStyleListOrder(
const TQStringList &list )
4749 styleCollection()->updateStyleListOrder( list );
4752void KPrDocument::updateDirectCursorButton()
4754 TQPtrListIterator<KoView> it( views() );
4755 for (; it.current(); ++it )
4756 static_cast<KPrView*
>(it.current())->updateDirectCursorButton();
4759void KPrDocument::setInsertDirectCursor(
bool _b)
4761 m_bInsertDirectCursor=_b;
4762 TDEConfig *config = KPrFactory::global()->config();
4763 config->setGroup(
"Interface" );
4764 config->writeEntry(
"InsertDirectCursor", _b );
4765 updateDirectCursorButton();
4768KPrView *KPrDocument::firstView()
const
4770 if ( views().count()>0)
4771 return static_cast<KPrView*
>(views().getFirst());
4776void KPrDocument::addWordToDictionary(
const TQString & word)
4778 if ( m_bgSpellCheck )
4780 if( m_spellCheckPersonalDict.findIndex( word ) == -1 )
4781 m_spellCheckPersonalDict.append( word );
4782 m_bgSpellCheck->settings()->setCurrentIgnoreList( m_spellCheckIgnoreList + m_spellCheckPersonalDict );
4783 if ( backgroundSpellCheckEnabled() )
4785 reactivateBgSpellChecking();
4789TQValueList <KPrPage *> KPrDocument::customListPage(
const TQStringList & lst,
bool loadOasis )
4791 TQStringList tmp( lst );
4792 TQValueList <KPrPage *> tmpValueList;
4793 for ( TQStringList::Iterator itList = tmp.begin(); itList != tmp.end(); ++itList )
4795 for (
int i = 0; i < static_cast<int>( m_pageList.count() ); i++ )
4800 if ( m_pageList.at( i )->oasisNamePage(i+1)== ( *itList ) )
4802 tmpValueList.append( m_pageList.at( i ) );
4809 if ( m_pageList.at( i )->pageTitle()== ( *itList ) )
4811 tmpValueList.append( m_pageList.at( i ) );
4819 return tmpValueList;
4823void KPrDocument::setCustomSlideShows(
const CustomSlideShowMap & customSlideShows )
4825 m_customListSlideShow = customSlideShows;
4826 setModified(
true );
4829TQStringList KPrDocument::presentationList()
4832 if ( !m_customListSlideShow.isEmpty() )
4834 CustomSlideShowMap::Iterator it;
4835 for ( it = m_customListSlideShow.begin(); it != m_customListSlideShow.end(); ++it )
4841void KPrDocument::testCustomSlideShow(
const TQValueList<KPrPage *> &pages, KPrView *view )
4843 delete m_customListTest;
4844 m_customListTest =
new TQValueList<int>( listOfDisplaySelectedSlides( pages ) );
4846 view->screenStartFromFirst();
4850void KPrDocument::clearTestCustomSlideShow()
4852 delete m_customListTest;
4853 m_customListTest = 0L;
4857#include "KPrDocument.moc"
Class KPCanvas - There is a single instance of this class for a given view.
Temporary information used only during loading.