diff --git a/kivio/kiviopart/kivio_doc.cpp b/kivio/kiviopart/kivio_doc.cpp new file mode 100644 index 00000000000..78fab47e073 --- /dev/null +++ b/kivio/kiviopart/kivio_doc.cpp @@ -0,0 +1,965 @@ +/* + * Kivio - Visual Modelling and Flowcharting + * Copyright (C) 2000-2001 theKompany.com & Dave Marotti + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ +#include +#include +#include +#include +#include + +#include "kivio_doc.h" +#include "kivio_page.h" +#include "kivio_map.h" +#include "kivio_view.h" +#include "kivio_factory.h" +#include "export_page_dialog.h" +#include "kivio_config.h" +#include "kivio_common.h" +#include "kivio_group_stencil.h" +#include "kivio_icon_view.h" +#include "kivio_layer.h" +#include "kivio_painter.h" +#include "kivio_screen_painter.h" +#include "kivio_stencil.h" +#include "kivio_stencil_spawner_set.h" +#include "kivio_viewmanager_panel.h" +#include "kivioglobal.h" +#include "kivio_rect.h" + +#include "stencilbarbutton.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +//using namespace std; + +/***************************************************************************** + * + * KivioDoc + * + *****************************************************************************/ + +QPtrList* KivioDoc::s_docs = 0; +int KivioDoc::s_docId = 0; + +KivioDoc::KivioDoc( QWidget *parentWidget, const char* widgetName, QObject* parent, const char* name, bool singleViewMode ) +: KoDocument( parentWidget, widgetName, parent, name, singleViewMode ) +{ + dcop = 0; + if (!s_docs) + s_docs = new QPtrList; + + s_docs->append(this); + + m_options = new KivioOptions(); + + m_pLstSpawnerSets = new QPtrList; + m_pLstSpawnerSets->setAutoDelete(true); + + setInstance( KivioFactory::global(), false ); + + if ( !name ) + { + QString tmp( "Document%1" ); //lukas: FIXME + tmp = tmp.arg( s_docId++ ); + setName( tmp.latin1() ); + } + + m_pClipboard = NULL; + + m_iPageId = 1; + m_pMap = 0L; + m_bLoading = false; + m_pMap = new KivioMap( this, "Map" ); + + // Load autoLoadStencils in internal StencilSpawnerSet + m_pInternalSet = new KivioStencilSpawnerSet("Kivio_Internal"); + m_pInternalSet->setId("Kivio - Internal - Do Not Touch"); + QStringList list = instance()->dirs()->findAllResources("data",instance()->instanceName()+"/autoloadStencils/*",true,false); + QStringList::ConstIterator pIt = list.begin(); + QStringList::ConstIterator pEnd = list.end(); + for (; pIt != pEnd; ++pIt ) + { + m_pInternalSet->loadFile(*pIt); + } + + m_units = KoUnit::U_MM; + m_font = KoGlobal::defaultFont(); + + viewItemList = new ViewItemList(this); + + m_commandHistory = new KCommandHistory( actionCollection(), false ) ; + connect( m_commandHistory, SIGNAL( documentRestored() ), this, SLOT( slotDocumentRestored() ) ); + connect( m_commandHistory, SIGNAL( commandExecuted() ), this, SLOT( slotCommandExecuted() ) ); + + + if ( name ) + dcopObject(); +} + +DCOPObject* KivioDoc::dcopObject() +{ + if ( !dcop ) { + dcop = new KIvioDocIface( this ); + } + + return dcop; +} + +QPtrList& KivioDoc::documents() +{ + if ( s_docs == 0 ) { + s_docs = new QPtrList; + } + + return *s_docs; +} + +bool KivioDoc::initDoc() +{ + QString f; + KoTemplateChooseDia::ReturnType ret; + KoTemplateChooseDia::DialogType dlgtype; + + if (initDocFlags() != KoDocument::InitDocFileNew) { + dlgtype = KoTemplateChooseDia::Everything; + initConfig(); + } else { + dlgtype = KoTemplateChooseDia::OnlyTemplates; + } + + ret = KoTemplateChooseDia::choose( KivioFactory::global(), f, + MIME_TYPE, "*.flw", i18n("Kivio"), + dlgtype, "kivio_template"); + + if ( ret == KoTemplateChooseDia::File ) { + KURL url(f); + return openURL(url); + } else if ( ret == KoTemplateChooseDia::Template ) { + QFileInfo fileInfo( f ); + QString fileName( fileInfo.dirPath( TRUE ) + "/" + fileInfo.baseName() + ".kft" ); + resetURL(); + bool ok = loadNativeFormat( fileName ); + KivioPage *t = createPage(); + m_pMap->addPage( t ); + setEmpty(); + return ok; + } else if ( ret == KoTemplateChooseDia::Empty ) { + KivioPage *t = createPage(); + m_pMap->addPage( t ); + setEmpty(); + return true; + } else { + return false; + } +} + +KoView* KivioDoc::createViewInstance( QWidget* parent, const char* name ) +{ + if (!name) { + name = "View"; + } + + return new KivioView( parent, name, this ); +} + +QDomDocument KivioDoc::saveXML() +{ + QDomDocument doc( "kiviodoc" ); + doc.appendChild( doc.createProcessingInstruction( "xml", "version=\"1.0\" encoding=\"UTF-8\"" ) ); + QDomElement kivio = doc.createElement( "kiviosheet" ); + kivio.setAttribute( "editor", "Kivio" ); + kivio.setAttribute( "mime", MIME_TYPE ); + + kivio.setAttribute( "units", KoUnit::unitName(m_units) ); + gridData.save(kivio,"grid"); + + QDomElement viewItemsElement = doc.createElement("ViewItems"); + kivio.appendChild(viewItemsElement); + viewItemList->save(viewItemsElement); + + QDomElement optionsElement = doc.createElement("Options"); + kivio.appendChild(optionsElement); + m_options->save(optionsElement); + + doc.appendChild(kivio); + + // Save the list of stencils spawners we have loaded. + // We save these as the following: + // + // + // + // + // + // .... + // + // This is so we can load them back in, and check that we actually + // have all these spawners on disk. + KivioStencilSpawnerSet *pSet = m_pLstSpawnerSets->first(); + while( pSet ) + { + kivio.appendChild( pSet->saveXML( doc ) ); + + pSet = m_pLstSpawnerSets->next(); + } + + + QDomElement e = m_pMap->save(doc); + kivio.appendChild(e); + + // Write it out to a tmp file + QFile f("filedump.xml"); + if ( f.open(IO_WriteOnly) ) { // file opened successfully + QTextStream t( &f ); // use a text stream + t << doc.toString(); + f.close(); + } + + setModified(false); + return doc; +} + +bool KivioDoc::loadXML( QIODevice *, const QDomDocument& doc ) +{ + m_bLoading = true; + + if ( doc.doctype().name() != "kiviodoc" ) { + m_bLoading = false; + return false; + } + + QDomElement kivio = doc.documentElement(); + if ( kivio.attribute( "mime" ) != "application/x-kivio" && + kivio.attribute( "mime" ) != "application/vnd.kde.kivio" ) + { + kdDebug(43000) << "KivioDoc::loadXML() - Invalid mime type" << endl; + m_bLoading = false; + return false; + } + + QDomNode node = kivio.firstChild(); + while( !node.isNull() ) + { + QString name = node.nodeName(); + if( name == "KivioMap" ) + { + if( !m_pMap->loadXML( node.toElement() ) ) + { + m_bLoading = false; + return false; + } + } + else if( name == "KivioStencilSpawnerSet" ) + { + QString id = XmlReadString( node.toElement(), "id", "" ); + + if( id.isEmpty() ) + { + kdDebug(43000) << "KivioDoc::loadXML() - Bad KivioStencilSpawnerSet found, it contains no id!" << endl; + } + else + { + loadStencilSpawnerSet( id ); + } + } + else if( name == "ViewItems" ) + { + viewItemList->load(node.toElement()); + } + else if( name == "Options" ) + { + m_options->load(node.toElement()); + } + else + { + kdDebug(43000) << "KivioDoc::loadXML() - Unknown node " << name << endl; + } + + node = node.nextSibling(); + } + + // + //QDomElement mymap = kivio.namedItem( "map" ).toElement(); + //if ( !mymap.isNull() ) + // if ( !m_pMap->loadXML(mymap) ) { + // m_bLoading = false; + // return false; + // } + + QString us = kivio.attribute("units","mm"); + bool isInt = false; + int u = us.toInt(&isInt); + + if(!isInt) { + setUnits(KoUnit::unit(us)); + } else { + setUnits(Kivio::convToKoUnit(u)); + } + + if(kivio.hasAttribute("gridIsShow")) { + gridData.load(kivio,"grid"); + } + + return true; +} + +bool KivioDoc::loadStencilSpawnerSet( const QString &id ) +{ + KStandardDirs *dirs = KGlobal::dirs(); + QStringList dirList = dirs->findDirs("data", "kivio/stencils"); + QString rootDir; + + // Iterate through all data directories + for( QStringList::Iterator it = dirList.begin(); it != dirList.end(); ++it ) + { + rootDir = (*it); + + // Within each data directory, iterate through all directories looking + // for a filename (dir) that matches the parameter + QDir d(rootDir); + d.setFilter( QDir::Dirs ); + d.setSorting( QDir::Name ); + + const QFileInfoList *list = d.entryInfoList(); + QFileInfoListIterator listIT( *list ); + QFileInfo *fi; + + // Loop through the outer directories (like BasicFlowcharting) + while( (fi=listIT.current()) ) + { + if( fi->fileName() != "." && + fi->fileName() != ".." ) + { + QDir innerD(fi->absFilePath() ); + innerD.setFilter( QDir::Dirs ); + innerD.setSorting( QDir::Name ); + + const QFileInfoList *innerList = innerD.entryInfoList(); + QFileInfoListIterator innerIT( *innerList ); + QFileInfo *innerFI; + + // Loop through the inner directories (like FlowChartingShapes1) + while( (innerFI = innerIT.current()) ) + { + if( innerFI->fileName() != ".." && + innerFI->fileName() != "." ) + { + // Compare the descriptions + QString foundId; + + // TODO: use ID system here for loading + foundId = KivioStencilSpawnerSet::readId(innerFI->absFilePath()); + if( foundId == id) + { + + // Load the spawner set with rootDir + "/" + fi.fileName() + KivioStencilSpawnerSet *pSet = addSpawnerSetDuringLoad( innerFI->absFilePath() ); + if( pSet ) + { + ; + } + else + { + kdDebug(43000) << "KivioDoc::loadStencilSpawnerSet() - Failed to load stencil: " + << innerFI->absFilePath() << endl; + } + return true; + } + } + ++innerIT; + } + } + ++listIT; + } + } + + return false; +} + +bool KivioDoc::completeLoading( KoStore* ) +{ + m_bLoading = false; + m_pMap->update(); + setModified( false ); + return true; +} + +KivioPage* KivioDoc::createPage() +{ + QString s( i18n("Page%1") ); + s = s.arg( m_iPageId++ ); + + KivioPage* t = new KivioPage(m_pMap, s); + t->setPageName(s,true); + + return t; +} + +void KivioDoc::addPage( KivioPage* page ) +{ + m_pMap->addPage(page); + setModified(true); + emit sig_addPage(page); +} + +void KivioDoc::insertPage( KivioPage * page ) +{ + QPtrListIterator it( views() ); + for (; it.current(); ++it ) + ((KivioView*)it.current())->insertPage( page ); +} + +void KivioDoc::takePage( KivioPage * page ) +{ + QPtrListIterator it( views() ); + for (; it.current(); ++it ) + ((KivioView*)it.current())->removePage( page ); +} + + +void KivioDoc::paintContent( QPainter& painter, const QRect& rect, bool transparent, double /*zoomX*/, double /*zoomY*/ ) +{ + // ## TODO - otherwise kivio isn't embeddable + KivioPage* page = m_pMap->firstPage(); + if ( !page ) + return; + + KoZoomHandler zoom; + zoom.setZoomAndResolution(100, QPaintDevice::x11AppDpiX(), + QPaintDevice::x11AppDpiY()); + KivioRect r = page->getRectForAllStencils(); + + float zw = (float) rect.width() / (float)zoom.zoomItX(r.w()); + float zh = (float) rect.height() / (float)zoom.zoomItY(r.h()); + float z = QMIN(zw, zh); + + zoom.setZoomAndResolution(qRound(z * 100), QPaintDevice::x11AppDpiX(), + QPaintDevice::x11AppDpiY()); + KivioScreenPainter ksp(&painter); + ksp.painter()->translate( - zoom.zoomItX(r.x()), - zoom.zoomItY(r.y()) ); + paintContent(ksp,rect,transparent,page, QPoint(zoom.zoomItX(r.x()), zoom.zoomItY(r.y())), &zoom, false); + ksp.setPainter(0L); // Important! Don't delete the QPainter!!! +} + +void KivioDoc::paintContent( KivioPainter& painter, const QRect& rect, bool transparent, KivioPage* page, QPoint p0, KoZoomHandler* zoom, bool drawHandles ) +{ + if ( isLoading() ) + return; + + page->paintContent(painter,rect,transparent,p0,zoom, drawHandles); +} + +void KivioDoc::printContent( KPrinter &prn ) +{ + KivioScreenPainter p; + QValueList pages = prn.pageList(); + KivioPage *pPage; + + // ### HACK: disable zooming-when-printing if embedded parts are used. + // No koffice app supports zooming in paintContent currently. + // Disable in ALL cases now + bool doZoom = false; + int dpiX = doZoom ? 300 : QPaintDevice::x11AppDpiX(); + int dpiY = doZoom ? 300 : QPaintDevice::x11AppDpiY(); + + p.start(&prn); + + QPaintDeviceMetrics metrics( &prn ); + p.painter()->scale( (double)metrics.logicalDpiX() / (double)dpiX, + (double)metrics.logicalDpiY() / (double)dpiY ); + + QValueList::iterator it; + + for(it = pages.begin(); it != pages.end(); ++it) { + pPage = m_pMap->pageList().at((*it)-1); + pPage->printContent(p, dpiX, dpiY); + + if( it != (--pages.end()) ) { + prn.newPage(); + } + } + + p.stop(); +} + +/* TODO: + * + * This entire function should probably be encapsulated in some sort of + * object or other class. + */ +bool KivioDoc::exportPage(KivioPage *pPage,const QString &fileName, ExportPageDialog *dlg) +{ + KoZoomHandler zoom; + zoom.setZoomAndResolution(100, QPaintDevice::x11AppDpiX(), + QPaintDevice::x11AppDpiY()); + QPixmap buffer; + + if(dlg->crop()) + { + if(dlg->fullPage()) { + buffer.resize(zoom.zoomItX(pPage->getRectForAllStencils().w()) + dlg->border()*2, + zoom.zoomItY(pPage->getRectForAllStencils().h()) + dlg->border()*2); + } else { + buffer.resize(zoom.zoomItX(pPage->getRectForAllSelectedStencils().w()) + dlg->border()*2, + zoom.zoomItY(pPage->getRectForAllSelectedStencils().h()) + dlg->border()*2); + } + } + else + { + buffer.resize(zoom.zoomItX(pPage->paperLayout().ptWidth) + dlg->border()*2, + zoom.zoomItY(pPage->paperLayout().ptHeight) + dlg->border()*2); + } + + kdDebug(43000) << "KivioDoc::exportCurPage() to " << fileName << "\n"; + + KivioScreenPainter p; + + buffer.fill(Qt::white); + + p.start( &buffer ); + p.setTranslation( dlg->border(), dlg->border() ); + + if( dlg->fullPage()==true ) + { + if(dlg->crop()) { + p.setTranslation(-zoom.zoomItX(pPage->getRectForAllStencils().x()), + -zoom.zoomItY(pPage->getRectForAllStencils().y())); + } + + pPage->printContent(p); + } + else + { + if(dlg->crop()) { + p.setTranslation(-zoom.zoomItX(pPage->getRectForAllSelectedStencils().x()), + -zoom.zoomItY(pPage->getRectForAllSelectedStencils().y())); + } + + pPage->printSelected(p); + } + + p.stop(); + + + QFileInfo finfo(fileName); + + return buffer.save( fileName, finfo.extension(false).upper().latin1(), dlg->quality()); +} + + +// TODO: Fix for id system +bool KivioDoc::setIsAlreadyLoaded( QString dirName, QString id ) +{ + KivioStencilSpawnerSet *pSet = m_pLstSpawnerSets->first(); + while(pSet) + { + if( pSet->dir() == dirName || pSet->id() == id ) + { + return true; + } + + pSet = m_pLstSpawnerSets->next(); + } + + return false; +} + +KivioStencilSpawnerSet *KivioDoc::addSpawnerSet( const QString &dirName ) +{ + KivioStencilSpawnerSet *set; + + QString id = KivioStencilSpawnerSet::readId( dirName ); + + if( setIsAlreadyLoaded( dirName, id ) ) + { + kdDebug(43000) << "KivioDoc::addSpawnerSet() - Cannot load duplicate stencil sets" << endl; + return NULL; + } + + + set = new KivioStencilSpawnerSet(); + + if( set->loadDir(dirName)==false ) + { + kdDebug(43000) << "KivioDoc::addSpawnerSet() - Error loading dir set" << endl; + delete set; + return NULL; + } + + + m_pLstSpawnerSets->append( set ); + setModified(true); + + emit sig_addSpawnerSet( set ); + + return set; +} + +KivioStencilSpawnerSet *KivioDoc::addSpawnerSetDuringLoad( const QString &dirName ) +{ + KivioStencilSpawnerSet *set; + + set = new KivioStencilSpawnerSet(); + if( set->loadDir(dirName)==false ) + { + kdDebug(43000) << "KivioDoc::addSpawnerSetDuringLoad() - Error loading dir set" << endl; + delete set; + return NULL; + } + + m_pLstSpawnerSets->append( set ); + + return set; +} + +KivioDoc::~KivioDoc() +{ + saveConfig(); + // ***MUST*** Delete the pages first because they may + // contain plugins which will be unloaded soon. The stencils which are + // spawned by plugins NEED the plugins still loaded when their destructor + // is called or the program will slit it's throat. + delete m_pMap; + delete dcop; + delete m_commandHistory; + if( m_pClipboard ) + { + delete m_pClipboard; + m_pClipboard = NULL; + } + + if( m_pLstSpawnerSets ) + { + delete m_pLstSpawnerSets; + m_pLstSpawnerSets = NULL; + } + + s_docs->removeRef(this); + + delete m_options; +} + +void KivioDoc::saveConfig() +{ + // Only save the config that is manipulated by the UI directly. + // The config from the config dialog is saved by the dialog itself. + KConfig *config = KivioFactory::global()->config(); + config->setGroup( "Interface" ); + config->writeEntry("ShowGrid", grid().isShow ); + config->writeEntry("SnapGrid",grid().isSnap); + config->writeEntry("GridColor",grid().color); + config->writeEntry("GridXSpacing", grid().freq.width()); + config->writeEntry("GridYSpacing", grid().freq.height()); + config->writeEntry("GridXSnap", grid().snap.width()); + config->writeEntry("GridYSnap", grid().snap.height()); + config->writeEntry("Unit", KoUnit::unitName(m_units)); + config->writeEntry("Font", m_font); +} + +void KivioDoc::initConfig() +{ + KConfig *config = KivioFactory::global()->config(); + if( config->hasGroup("Interface" ) ) + { + config->setGroup( "Interface" ); + KivioGridData d = grid(); + d.isShow = config->readBoolEntry( "ShowGrid", true ); + d.isSnap = config->readBoolEntry( "SnapGrid", true); + QColor color = QColor(200,200,200); + d.color = config->readColorEntry( "GridColor", &color ); + d.freq.setWidth(config->readDoubleNumEntry("GridXSpacing", 10.0)); + d.freq.setHeight(config->readDoubleNumEntry("GridYSpacing", 10.0)); + d.snap.setWidth(config->readDoubleNumEntry("GridXSnap", 10.0)); + d.snap.setHeight(config->readDoubleNumEntry("GridYSnap", 10.0)); + setGrid(d); + m_units = KoUnit::unit(config->readEntry("Unit", "mm")); + QFont def = KoGlobal::defaultFont(); + m_font = config->readFontEntry("Font", &def); + } +} + +bool KivioDoc::removeSpawnerSet( KivioStencilSpawnerSet *pSet ) +{ + return m_pLstSpawnerSets->removeRef( pSet ); +} + +/** + * Iterates through all spawner objects in the stencil set checking if + * they exist in any of the pages. + */ +void KivioDoc::slotDeleteStencilSet( DragBarButton *pBtn, QWidget *w, KivioStackBar *pBar ) +{ + // Iterate through all spawners in the set checking if they exist in any of + // the pages + KivioIconView *pIconView = (KivioIconView *)w; + KivioStencilSpawnerSet *pSet = pIconView->spawnerSet(); + + // Start the iteration + KivioStencilSpawner *pSpawner = pSet->spawners()->first(); + while( pSpawner ) + { + // Check for a spawner. If there is one, the set cannot be deleted + if( checkStencilsForSpawner( pSpawner )==true ) + { + KMessageBox::error(NULL, i18n("Cannot delete stencil set because there are still stencils in use."), + i18n("Cannot Delete Stencil Set")); + return; + } + + // Now check the clipboard against this spawner + if( m_pClipboard ) + { + if( checkGroupForSpawner( m_pClipboard, pSpawner )==true ) + { + if( KMessageBox::questionYesNo(NULL, i18n("The clipboard contains stencils which belong to the set you are trying to remove.\nWould you like to delete what is on the clipboard?\n(Saying no will cause this stencil set to not be removed.)"), + i18n("Clear the clipboard?"))==KMessageBox::Yes ) + { + delete m_pClipboard; + m_pClipboard = NULL; + } + else // abort because the user aborted + return; + } + } + + + pSpawner = pSet->spawners()->next(); + } + + + + // If we made it this far, it's ok to delete this stencil set, so do it +// if( KMessageBox::questionYesNo(NULL, i18n("Are you sure you want to delete this stencil set?"), +// i18n("Delete Stencil Set?"))==KMessageBox::Yes ) + { + // Destroying the IconView does not destroy the spawner set, so we remove + // it here + removeSpawnerSet( pIconView->spawnerSet() ); + + // And emit the signal to kill the set (page & button) + emit sig_deleteStencilSet( pBtn, w, pBar ); + } +} + +/** + * Checks if any stencils in the document use this spawner + */ +bool KivioDoc::checkStencilsForSpawner( KivioStencilSpawner *pSpawner ) +{ + KivioPage *pPage; + KivioLayer *pLayer; + KivioStencil *pStencil; + + // Iterate across all the pages + pPage = m_pMap->firstPage(); + while( pPage ) + { + pLayer = pPage->layers()->first(); + while( pLayer ) + { + pStencil = pLayer->stencilList()->first(); + while( pStencil ) + { + // If this is a group stencil, then we must check all child stencils + if( pStencil->groupList() && pStencil->groupList()->count() > 0 ) + { + if( checkGroupForSpawner( pStencil, pSpawner )==true ) + return true; + } + else if( pStencil->spawner() == pSpawner ) + return true; + + pStencil = pLayer->stencilList()->next(); + } + + pLayer = pPage->layers()->next(); + } + + pPage = m_pMap->nextPage(); + } + + return false; +} + +bool KivioDoc::checkGroupForSpawner( KivioStencil *pGroup, KivioStencilSpawner *pSpawner ) +{ + KivioStencil *pStencil; + + pStencil = pGroup->groupList()->first(); + while( pStencil ) + { + if( pStencil->groupList() && pStencil->groupList()->count() > 0 ) + { + if( checkGroupForSpawner( pStencil, pSpawner )==true ) + return true; + } + else if( pStencil->spawner() == pSpawner ) + { + return true; + } + + pStencil = pGroup->groupList()->next(); + } + + return false; +} + +void KivioDoc::setClipboard( KivioGroupStencil *p ) +{ + if( m_pClipboard ) + delete m_pClipboard; + + m_pClipboard = p; +} + +KivioGroupStencil *KivioDoc::clipboard() +{ + return m_pClipboard; +} + +void KivioDoc::slotSelectionChanged() +{ + emit sig_selectionChanged(); +} + +KivioStencilSpawner* KivioDoc::findStencilSpawner( const QString& setId, const QString& stencilId ) +{ + KivioStencilSpawnerSet *pSpawnerSet = m_pLstSpawnerSets->first(); + while( pSpawnerSet ) + { + if( pSpawnerSet->id() == setId && pSpawnerSet->find(stencilId) ) + { + return pSpawnerSet->find(stencilId); + // return pSpawnerSet->find(name) + } + pSpawnerSet = m_pLstSpawnerSets->next(); + } + + if( m_pInternalSet->id() == setId && m_pInternalSet->find(stencilId) ) + { + return m_pInternalSet->find(stencilId); + } + + return NULL; +} + +KivioStencilSpawner* KivioDoc::findInternalStencilSpawner( const QString& stencilId ) +{ + return m_pInternalSet->find(stencilId); +} + +void KivioDoc::setUnits(KoUnit::Unit unit) +{ + if (m_units == unit) + return; + + m_units = unit; + emit unitsChanged(unit); +} + +void KivioDoc::updateView(KivioPage* page) +{ + emit sig_updateView(page); +} + +void KivioDoc::updateButton() +{ + QPtrListIterator it( views() ); + for (; it.current(); ++it ) + ((KivioView*)it.current())->updateButton(); +} + +void KivioDoc::resetLayerPanel() +{ + QPtrListIterator it( views() ); + for (; it.current(); ++it ) + ((KivioView*)it.current())->resetLayerPanel(); +} + +void KivioDoc::addCommand( KCommand * cmd ) +{ + kdDebug(43000) << "KivioDoc::addCommand " << cmd->name() << endl; + m_commandHistory->addCommand( cmd, false ); + setModified( true ); +} + +int KivioDoc::undoRedoLimit() const +{ + return m_commandHistory->undoLimit(); +} + +void KivioDoc::setUndoRedoLimit(int val) +{ + m_commandHistory->setUndoLimit(val); + m_commandHistory->setRedoLimit(val); +} + +void KivioDoc::slotDocumentRestored() +{ + setModified( false ); +} + +void KivioDoc::slotCommandExecuted() +{ + setModified( true ); +} + +void KivioDoc::updateProtectPanelCheckBox() +{ + QPtrListIterator it( views() ); + for (; it.current(); ++it ) + ((KivioView*)it.current())->updateProtectPanelCheckBox(); +} + + +#include "kivio_doc.moc" diff --git a/kivio/kiviopart/ui/export_page_dialog_base.ui b/kivio/kiviopart/ui/export_page_dialog_base.ui new file mode 100644 index 00000000000..3f08b150f6a --- /dev/null +++ b/kivio/kiviopart/ui/export_page_dialog_base.ui @@ -0,0 +1,181 @@ + +ExportPageDialogBase + + + ExportPageDialogBase + + + + 0 + 0 + 290 + 208 + + + + + unnamed + + + + ButtonGroup1 + + + + 3 + 3 + 0 + 0 + + + + Export + + + + m_radioFullPage + + + + 10 + 20 + 246 + 20 + + + + &All stencils + + + true + + + 1 + + + Export all stencils on the current page + + + <b>All Stencils</b><br> +This will cause the entire page to be exported to the file. This means that <i>all</i> stencils will be exported. + + + + + m_radioSelectedStencils + + + + 10 + 48 + 249 + 20 + + + + &Selected stencils + + + Alt+S + + + Export the selected stencils on the current page + + + <b>Selected Stencils</b><br> +Export only the selected stencils to file. + + + + + m_checkCrop + + + true + + + + 9 + 82 + 242 + 20 + + + + C&rop picture to edges + + + Alt+R + + + Don't export extra blank space to file + + + <b>Crop picture to edges</b><br> +This will eliminate all blank portions of the drawing. The picture will only be as large as the stencils it contains. If your stencils are located in the upper right corner of the page, then only the upper right corner will be exported. + + + + + + TextLabel2 + + + &Quality: + + + m_spinQuality + + + + + m_spinQuality + + + 100 + + + 100 + + + The higher the quality, the more space the file takes up. + + + <b>Quality</b><br> +Not all file formats use this. But for those that do, this affects the quality of the image that gets exported. 100 is the maximum quality. The higher the number, the better the picture looks. The downside is the higher the number, the larger the filesize. + + + + + m_spinBorder + + + 10000 + + + An optional border of whitespace around the page, in pixels + + + <b>Border</b><br> +Places a blank border around the edges of the image. This can be used if for one reason or another, the stencils don't fit into the export page with a 0-pixel border (default). + + + + + TextLabel3 + + + &Border: + + + m_spinBorder + + + + + + kdialog.h + + + +