exports.cpp
changeset 804 14f2b1b15242
parent 791 f1006de05c54
child 807 f9f7922989d8
     1.1 --- a/exports.cpp	Fri Oct 02 14:31:03 2009 +0000
     1.2 +++ b/exports.cpp	Fri Nov 13 08:32:03 2009 +0000
     1.3 @@ -148,7 +148,7 @@
     1.4  	BranchItem *cur=NULL;
     1.5  	BranchItem *prev=NULL;
     1.6  
     1.7 -	cur=model->next (cur,prev);
     1.8 +	cur=model->nextBranch (cur,prev);
     1.9  	while (cur) 
    1.10  	{
    1.11  		if (cur->getType()==TreeItem::Branch || cur->getType()==TreeItem::MapCenter)
    1.12 @@ -195,7 +195,7 @@
    1.13  				}
    1.14  			}
    1.15  		}
    1.16 -		cur=model->next(cur,prev);
    1.17 +		cur=model->nextBranch(cur,prev);
    1.18  	}
    1.19  	file.close();
    1.20  }
    1.21 @@ -229,7 +229,7 @@
    1.22  	BranchObj *bo;  //FIXME-3 still needed?
    1.23  	BranchItem *cur=NULL;
    1.24  	BranchItem *prev=NULL;
    1.25 -	cur=model->next (cur,prev);
    1.26 +	cur=model->nextBranch (cur,prev);
    1.27  	while (cur) 
    1.28  	{
    1.29  		bo=(BranchObj*)(cur->getLMO());
    1.30 @@ -252,7 +252,7 @@
    1.31  			ts << curIndent << "\"" << cur->getHeading()<<"\""<<endl;
    1.32  		}
    1.33  		
    1.34 -		cur=model->next(cur,prev);
    1.35 +		cur=model->nextBranch(cur,prev);
    1.36  		curIndent="";
    1.37  	}
    1.38  	file.close();
    1.39 @@ -388,7 +388,7 @@
    1.40    BranchObj *bo;
    1.41    BranchItem *cur=NULL;
    1.42    BranchItem *prev=NULL;
    1.43 -  model->next(cur,prev);
    1.44 +  model->nextBranch(cur,prev);
    1.45    while (cur) 
    1.46    {
    1.47  	bo=(BranchObj*)(cur->getLMO());
    1.48 @@ -420,7 +420,7 @@
    1.49  		  ts << ("\n");
    1.50  		}
    1.51  	}
    1.52 -    cur=model->next(cur,prev);
    1.53 +    cur=model->nextBranch(cur,prev);
    1.54     }
    1.55    file.close();
    1.56  }
    1.57 @@ -443,7 +443,7 @@
    1.58  	BranchItem *bi=current->getFirstBranch();
    1.59  	if (bi)
    1.60      {
    1.61 -		if (true) //if (!bo->hasHiddenExportParent() )	// FIXME-2 use BranchItem...
    1.62 +		if (!bi->hasHiddenExportParent() )	// FIXME-3 use BranchItem...
    1.63  		{
    1.64  			// Start list
    1.65  			r+="<text:list text:style-name=\"vym-list\">\n";
    1.66 @@ -471,51 +471,73 @@
    1.67  {
    1.68  	QString allPages;
    1.69  
    1.70 -/* FIXME-2 not adapted to multiple mapCenters yet, see patch already done in 1.12.2...
    1.71 +	BranchItem *firstMCO=(BranchItem*)(model->getRootItem()->getFirstBranch());
    1.72 +	if (!firstMCO) 
    1.73 +	{
    1.74 +		QMessageBox::critical (0,QObject::tr("Critical Export Error"),QObject::tr("No objects in map!"));
    1.75 +		return;
    1.76 +	}
    1.77 +
    1.78  	// Insert new content
    1.79 -	content.replace ("<!-- INSERT TITLE -->",quotemeta(mapCenter->getHeading()));
    1.80 -	content.replace ("<!-- INSERT AUTHOR -->",quotemeta(mapCenter->getAuthor()));
    1.81 +	// FIXME add extra title in mapinfo for vym 1.13.x
    1.82 +	content.replace ("<!-- INSERT TITLE -->",quotemeta(firstMCO->getHeading()));
    1.83 +	content.replace ("<!-- INSERT AUTHOR -->",quotemeta(model->getAuthor()));
    1.84  
    1.85  	QString	onePage;
    1.86  	QString list;
    1.87  	
    1.88 -	BranchObj *sectionBO=mapCenter->getFirstBranch();
    1.89 +	BranchItem *sectionBI;	
    1.90      int i=0;
    1.91 -	BranchObj *pagesBO;
    1.92 +	BranchItem *pagesBI;
    1.93      int j=0;
    1.94  
    1.95 +	int mapcenters=model->getRootItem()->branchCount();
    1.96 +
    1.97 +	// useSections already has been set in setConfigFile 
    1.98 +	if (mapcenters>1)	
    1.99 +		sectionBI=firstMCO;
   1.100 +	else
   1.101 +		sectionBI=firstMCO->getFirstBranch();
   1.102 +
   1.103  	// Walk sections
   1.104 -	while (sectionBO && !sectionBO->hasHiddenExportParent() )
   1.105 +	while (sectionBI && !sectionBI->hasHiddenExportParent() )
   1.106  	{
   1.107  		if (useSections)
   1.108  		{
   1.109  			// Add page with section title
   1.110  			onePage=sectionTemplate;
   1.111 -			onePage.replace ("<!-- INSERT PAGE HEADING -->", quotemeta(sectionBO->getHeading() ) );
   1.112 +			onePage.replace ("<!-- INSERT PAGE HEADING -->", quotemeta(sectionBI->getHeading() ) );
   1.113  			allPages+=onePage;
   1.114 +			pagesBI=sectionBI->getFirstBranch();
   1.115  		} else
   1.116  		{
   1.117 -			i=-2;	// only use inner loop to 
   1.118 +			//i=-2;	// only use inner loop to 
   1.119  			        // turn mainbranches into pages
   1.120 -			sectionBO=mapCenter;
   1.121 +			//sectionBI=firstMCO;
   1.122 +			pagesBI=sectionBI;
   1.123  		}
   1.124  
   1.125 -		// Walk mainpages
   1.126 -		pagesBO=sectionBO->getFirstBranch();
   1.127  		j=0;
   1.128 -		while (pagesBO && !pagesBO->hasHiddenExportParent() )
   1.129 +		while (pagesBI && !pagesBI->hasHiddenExportParent() )
   1.130  		{
   1.131  			// Add page with list of items
   1.132  			onePage=pageTemplate;
   1.133 -			onePage.replace ("<!-- INSERT PAGE HEADING -->", quotemeta (pagesBO->getHeading() ) );
   1.134 -			list=buildList (pagesBO->getTreeItem() );  
   1.135 +			onePage.replace ("<!-- INSERT PAGE HEADING -->", quotemeta (pagesBI->getHeading() ) );
   1.136 +			list=buildList (pagesBI);
   1.137  			onePage.replace ("<!-- INSERT LIST -->", list);
   1.138  			allPages+=onePage;
   1.139 -			j++;
   1.140 -			pagesBO=sectionBO->getBranchNum(j);
   1.141 +			if (pagesBI!=sectionBI)
   1.142 +			{
   1.143 +				j++;
   1.144 +				pagesBI=((BranchItem*)pagesBI->parent())->getBranchNum(j);
   1.145 +			} else
   1.146 +				pagesBI=NULL;	// We are already iterating over the sectionBIs
   1.147  		}
   1.148  		i++;
   1.149 -		sectionBO=mapCenter->getBranchNum(i);
   1.150 +		if (mapcenters>1 )
   1.151 +			sectionBI=model->getRootItem()->getBranchNum (i);
   1.152 +		else
   1.153 +			sectionBI=firstMCO->getBranchNum (i);
   1.154  	}
   1.155  	
   1.156  	content.replace ("<!-- INSERT PAGES -->",allPages);
   1.157 @@ -535,7 +557,6 @@
   1.158  
   1.159  	// zip tmpdir to destination
   1.160  	zipDir (tmpDir,outputFile);	
   1.161 -*/
   1.162  }
   1.163  
   1.164  bool ExportOO::setConfigFile (const QString &cf)