Subversion Repositories Scribus

Compare Revisions

Ignore whitespace Rev 2440 → Rev 2441

/branches/Version13x/Scribus/scribus/Makefile.am
157,6 → 157,7
tabruler.cpp\
tabtools.cpp\
tabtypography.cpp\
tocgenerator.cpp\
tocindexprefs.ui\
tree.cpp\
undogui.cpp\
200,7 → 201,7
$(mkinstalldirs) $(prefix)/include/scribus/
$(INSTALL_DATA) $(srcdir)/about.h $(prefix)/include/scribus/about.h
$(INSTALL_DATA) $(srcdir)/actionmanager.h $(prefix)/include/scribus/actionmanager.h
$(INSTALL_DATA) $(srcdir)/aligndistribute.h $(prefix)/include/scribus/aligndistribute.h
$(INSTALL_DATA) $(srcdir)/aligndistribute.h $(prefix)/include/scribus/aligndistribute.h
$(INSTALL_DATA) $(srcdir)/alignselect.h $(prefix)/include/scribus/alignselect.h
$(INSTALL_DATA) $(srcdir)/annot.h $(prefix)/include/scribus/annot.h
$(INSTALL_DATA) $(srcdir)/annota.h $(prefix)/include/scribus/annota.h
349,6 → 350,7
$(INSTALL_DATA) $(srcdir)/tabruler.h $(prefix)/include/scribus/tabruler.h
$(INSTALL_DATA) $(srcdir)/tabtools.h $(prefix)/include/scribus/tabtools.h
$(INSTALL_DATA) $(srcdir)/tabtypography.h $(prefix)/include/scribus/tabtypography.h
$(INSTALL_DATA) $(srcdir)/tocgenerator.h $(prefix)/include/scribus/tocgenerator.h
$(INSTALL_DATA) $(srcdir)/tocindexprefs.h $(prefix)/include/scribus/tocindexprefs.h
$(INSTALL_DATA) $(srcdir)/tree.h $(prefix)/include/scribus/tree.h
$(INSTALL_DATA) $(srcdir)/undogui.h $(prefix)/include/scribus/undogui.h
523,6 → 525,7
-rm -f $(prefix)/include/scribus/tabtools.h
-rm -f $(prefix)/include/scribus/tabtypography.h
-rm -f $(prefix)/include/scribus/tocindexprefs.h
-rm -f $(prefix)/include/scribus/tocgenerator.h
-rm -f $(prefix)/include/scribus/tree.h
-rm -f $(prefix)/include/scribus/undogui.h
-rm -f $(prefix)/include/scribus/undomanager.h
/branches/Version13x/Scribus/scribus/tocgenerator.h
0,0 → 1,41
/***************************************************************************
begin : Jun 2005
copyright : (C) 2005 by Craig Bradney
email : cbradney@zip.com.au
***************************************************************************/
 
/***************************************************************************
* *
* 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. *
* *
***************************************************************************/
#ifndef TOCGENERATOR_H
#define TOCGENERATOR_H
 
#include <qobject.h>
 
class ScribusDoc;
 
/**
@author Craig Bradney
*/
class TOCGenerator : public QObject
{
Q_OBJECT
public:
TOCGenerator(QObject *parent = NULL, const char *name = NULL, ScribusDoc *doc = NULL);
~TOCGenerator();
void setDoc(ScribusDoc *doc = NULL);
public slots:
void generateDefault();
 
private:
ScribusDoc *currDoc;
};
 
#endif
Property changes:
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Revision
\ No newline at end of property
Index: Version13x/Scribus/scribus/scribus.cpp
===================================================================
--- Version13x/Scribus/scribus/scribus.cpp (revision 2440)
+++ Version13x/Scribus/scribus/scribus.cpp (revision 2441)
@@ -96,6 +96,7 @@
#include "docitemattrprefs.h"
#include "pageitemattributes.h"
#include "tocindexprefs.h"
+#include "tocgenerator.h"
#ifdef _MSC_VER
#if (_MSC_VER >= 1200)
#include "win-config.h"
@@ -136,10 +137,6 @@
#include "effectsdialog.h"
#include "documentchecker.h"
-//CB TODO include for toc testing for now
-#include "gtwriter.h"
-//CB
-
extern QPixmap loadIcon(QString nam);
extern bool overwrite(QWidget *parent, QString filename);
extern void CopyPageItem(struct CopyPasteBuffer *Buffer, PageItem *currItem);
@@ -212,6 +209,7 @@
undoManager = UndoManager::instance();
objectSpecificUndo = false;
pluginManager = new PluginManager();
+ tocGenerator = new TOCGenerator();
initDefaultValues();
actionManager = new ActionManager(this, "actionManager");
@@ -2885,6 +2883,7 @@
doc->ASaveTimer->start(Prefs.AutoSaveTime);
scrActions["fileSave"]->setEnabled(false);
undoManager->switchStack(doc->DocName);
+ tocGenerator->setDoc(doc);
return true;
}
@@ -3016,6 +3015,7 @@
else
HaveNewSel(-1);
}
+ tocGenerator->setDoc(doc);
}
void ScribusApp::windowsMenuActivated( int id )
@@ -5248,6 +5248,7 @@
delete doc;
doc = NULL;
ActWin = NULL;
+ tocGenerator->setDoc(doc);
return true;
}
@@ -10791,73 +10792,7 @@
void ScribusApp::generateTableOfContents()
{
if (HaveDoc)
- {
- for(ToCSetupVector::Iterator tocSetupIt = doc->docToCSetups.begin() ; tocSetupIt != doc->docToCSetups.end(); ++tocSetupIt )
- {
- bool found=false;
- uint d;
- PageItem* tocFrame=NULL;
- for (d = 0; d < doc->DocItems.count(), found==false; ++d)
- {
- if (doc->DocItems.at(d) !=NULL )
- {
- if (doc->DocItems.at(d)->itemType()==PageItem::TextFrame && doc->DocItems.at(d)->itemName()==(*tocSetupIt).frameName)
- {
- found=true;
- tocFrame=doc->DocItems.at(d);
- }
- }
- }
- if (found && tocFrame!=NULL)
- {
- PageItem *currentDocItem;
- QMap<QString, QString> tocMap;
- tocMap.clear();
- uint pageCounter[doc->pageCount];
- for (int i=0;i<=doc->pageCount;++i)
- pageCounter[i]=0;
- unsigned int maxDataWidth=0;
- for (uint d = 0; d < doc->DocItems.count(); ++d)
- {
- currentDocItem = doc->DocItems.at(d);
- if (currentDocItem!=NULL)
- {
- //Item not on a page, continue
- if (currentDocItem->OwnPage==-1)
- continue;
- ObjectAttribute objattr=currentDocItem->getObjectAttribute((*tocSetupIt).itemAttrName);
- if (objattr.name!=QString::null)
- {
- //TODO Handle docs with non consecutive page numbers when that is possible
- QString key=QString("%1,%2").arg(currentDocItem->OwnPage + doc->FirstPnum).arg(pageCounter[currentDocItem->OwnPage]++);
- tocMap.insert(key, objattr.value);
- if (objattr.value.length()>maxDataWidth)
- maxDataWidth=objattr.value.length();
- }
- }
- }
- gtWriter* writer = new gtWriter(false, tocFrame);
- QString oldTocPage=QString::null;
- for (QMap<QString, QString>::Iterator tocIt=tocMap.begin();tocIt!=tocMap.end();++tocIt)
- {
- QString tocPage = tocIt.key().section( ',', 0, 0 );
- QString tocLine = tocIt.data();
- //QString tocPageItemNo = tocIt.key().section( ',', 1, 1 );
- if (oldTocPage!=tocPage)
- {
- oldTocPage=tocPage;
- tocLine = tocLine.leftJustify(maxDataWidth+5, '.');
- tocLine = tocLine + tocPage + "\n";
- }
- else
- tocLine += "\n";
- writer->append(tocLine);
- }
- if (writer!=NULL)
- delete writer;
- }
- }
- }
+ tocGenerator->generateDefault();
}
void ScribusApp::mouseReleaseEvent(QMouseEvent *m)
/branches/Version13x/Scribus/scribus/scribus.h
87,6 → 87,7
class PluginManager;
class ActionManager;
class AlignDistributePalette;
class TOCGenerator;
 
/**
* This Class is the base class for your application. It sets up the main
550,6 → 551,7
QString Dname;
QString Command;
} PDef ;
TOCGenerator *tocGenerator;
};
#endif
 
/branches/Version13x/Scribus/scribus/tocgenerator.cpp
0,0 → 1,111
/***************************************************************************
begin : Jun 2005
copyright : (C) 2005 by Craig Bradney
email : cbradney@zip.com.au
***************************************************************************/
 
/***************************************************************************
* *
* 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. *
* *
***************************************************************************/
#include "tocgenerator.h"
#include "tocgenerator.moc"
 
#include <qmap.h>
#include <qstring.h>
 
#include "scribusdoc.h"
#include "pagestructs.h"
#include "pageitem.h"
#include "gtwriter.h"
 
 
TOCGenerator::TOCGenerator(QObject *parent, const char *name, ScribusDoc *doc) : QObject(parent, name)
{
currDoc=doc;
}
 
 
TOCGenerator::~TOCGenerator()
{
}
 
void TOCGenerator::setDoc(ScribusDoc *doc)
{
currDoc=doc;
}
 
void TOCGenerator::generateDefault()
{
if (currDoc==NULL)
return;
for(ToCSetupVector::Iterator tocSetupIt = currDoc->docToCSetups.begin() ; tocSetupIt != currDoc->docToCSetups.end(); ++tocSetupIt )
{
bool found=false;
uint d;
PageItem* tocFrame=NULL;
for (d = 0; d < currDoc->DocItems.count(), found==false; ++d)
{
if (currDoc->DocItems.at(d) !=NULL )
{
if (currDoc->DocItems.at(d)->itemType()==PageItem::TextFrame && currDoc->DocItems.at(d)->itemName()==(*tocSetupIt).frameName)
{
found=true;
tocFrame=currDoc->DocItems.at(d);
}
}
}
if (found && tocFrame!=NULL)
{
PageItem *currentDocItem;
QMap<QString, QString> tocMap;
tocMap.clear();
uint pageCounter[currDoc->pageCount];
for (int i=0;i<=currDoc->pageCount;++i)
pageCounter[i]=0;
unsigned int maxDataWidth=0;
for (uint d = 0; d < currDoc->DocItems.count(); ++d)
{
currentDocItem = currDoc->DocItems.at(d);
if (currentDocItem!=NULL)
{
//Item not on a page, continue
if (currentDocItem->OwnPage==-1)
continue;
ObjectAttribute objattr=currentDocItem->getObjectAttribute((*tocSetupIt).itemAttrName);
if (objattr.name!=QString::null)
{
//TODO Handle docs with non consecutive page numbers when that is possible
QString key=QString("%1,%2").arg(currentDocItem->OwnPage + currDoc->FirstPnum).arg(pageCounter[currentDocItem->OwnPage]++);
tocMap.insert(key, objattr.value);
if (objattr.value.length()>maxDataWidth)
maxDataWidth=objattr.value.length();
}
}
}
gtWriter* writer = new gtWriter(false, tocFrame);
QString oldTocPage=QString::null;
for (QMap<QString, QString>::Iterator tocIt=tocMap.begin();tocIt!=tocMap.end();++tocIt)
{
QString tocPage = tocIt.key().section( ',', 0, 0 );
QString tocLine = tocIt.data();
//QString tocPageItemNo = tocIt.key().section( ',', 1, 1 );
if (oldTocPage!=tocPage)
{
oldTocPage=tocPage;
tocLine = tocLine.leftJustify(maxDataWidth+5, '.');
tocLine = tocLine + tocPage + "\n";
}
else
tocLine += "\n";
writer->append(tocLine);
}
if (writer!=NULL)
delete writer;
}
}
}
Property changes:
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Revision
\ No newline at end of property