1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
29*cdf0e10cSrcweir #include "precompiled_sc.hxx"
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir 
32*cdf0e10cSrcweir 
33*cdf0e10cSrcweir // INCLUDE ---------------------------------------------------------------
34*cdf0e10cSrcweir #include "XMLExportSharedData.hxx"
35*cdf0e10cSrcweir #include "XMLExportIterator.hxx"
36*cdf0e10cSrcweir #include <tools/debug.hxx>
37*cdf0e10cSrcweir 
38*cdf0e10cSrcweir using namespace com::sun::star;
39*cdf0e10cSrcweir 
40*cdf0e10cSrcweir ScMySharedData::ScMySharedData(const sal_Int32 nTempTableCount) :
41*cdf0e10cSrcweir 	nLastColumns(nTempTableCount, 0),
42*cdf0e10cSrcweir 	nLastRows(nTempTableCount, 0),
43*cdf0e10cSrcweir 	pTableShapes(NULL),
44*cdf0e10cSrcweir 	pDrawPages(NULL),
45*cdf0e10cSrcweir 	pShapesContainer(NULL),
46*cdf0e10cSrcweir 	pDetectiveObjContainer(new ScMyDetectiveObjContainer()),
47*cdf0e10cSrcweir     pNoteShapes(NULL),
48*cdf0e10cSrcweir 	nTableCount(nTempTableCount)
49*cdf0e10cSrcweir {
50*cdf0e10cSrcweir }
51*cdf0e10cSrcweir 
52*cdf0e10cSrcweir ScMySharedData::~ScMySharedData()
53*cdf0e10cSrcweir {
54*cdf0e10cSrcweir 	if (pShapesContainer)
55*cdf0e10cSrcweir 		delete pShapesContainer;
56*cdf0e10cSrcweir 	if (pTableShapes)
57*cdf0e10cSrcweir 		delete pTableShapes;
58*cdf0e10cSrcweir 	if (pDrawPages)
59*cdf0e10cSrcweir 		delete pDrawPages;
60*cdf0e10cSrcweir 	if (pDetectiveObjContainer)
61*cdf0e10cSrcweir 		delete pDetectiveObjContainer;
62*cdf0e10cSrcweir     if (pNoteShapes)
63*cdf0e10cSrcweir         delete pNoteShapes;
64*cdf0e10cSrcweir }
65*cdf0e10cSrcweir 
66*cdf0e10cSrcweir void ScMySharedData::SetLastColumn(const sal_Int32 nTable, const sal_Int32 nCol)
67*cdf0e10cSrcweir {
68*cdf0e10cSrcweir 	if(nCol > nLastColumns[nTable]) nLastColumns[nTable] = nCol;
69*cdf0e10cSrcweir }
70*cdf0e10cSrcweir 
71*cdf0e10cSrcweir sal_Int32 ScMySharedData::GetLastColumn(const sal_Int32 nTable)
72*cdf0e10cSrcweir {
73*cdf0e10cSrcweir 	return nLastColumns[nTable];
74*cdf0e10cSrcweir }
75*cdf0e10cSrcweir 
76*cdf0e10cSrcweir void ScMySharedData::SetLastRow(const sal_Int32 nTable, const sal_Int32 nRow)
77*cdf0e10cSrcweir {
78*cdf0e10cSrcweir 	if(nRow > nLastRows[nTable]) nLastRows[nTable] = nRow;
79*cdf0e10cSrcweir }
80*cdf0e10cSrcweir 
81*cdf0e10cSrcweir sal_Int32 ScMySharedData::GetLastRow(const sal_Int32 nTable)
82*cdf0e10cSrcweir {
83*cdf0e10cSrcweir 	return nLastRows[nTable];
84*cdf0e10cSrcweir }
85*cdf0e10cSrcweir 
86*cdf0e10cSrcweir void ScMySharedData::AddDrawPage(const ScMyDrawPage& aDrawPage, const sal_Int32 nTable)
87*cdf0e10cSrcweir {
88*cdf0e10cSrcweir 	if (!pDrawPages)
89*cdf0e10cSrcweir 		pDrawPages = new ScMyDrawPages(nTableCount, ScMyDrawPage());
90*cdf0e10cSrcweir 	(*pDrawPages)[nTable] = aDrawPage;
91*cdf0e10cSrcweir }
92*cdf0e10cSrcweir 
93*cdf0e10cSrcweir void ScMySharedData::SetDrawPageHasForms(const sal_Int32 nTable, sal_Bool bHasForms)
94*cdf0e10cSrcweir {
95*cdf0e10cSrcweir 	DBG_ASSERT(pDrawPages, "DrawPages not collected");
96*cdf0e10cSrcweir 	if (pDrawPages)
97*cdf0e10cSrcweir 		(*pDrawPages)[nTable].bHasForms = bHasForms;
98*cdf0e10cSrcweir }
99*cdf0e10cSrcweir 
100*cdf0e10cSrcweir uno::Reference<drawing::XDrawPage> ScMySharedData::GetDrawPage(const sal_Int32 nTable)
101*cdf0e10cSrcweir {
102*cdf0e10cSrcweir 	DBG_ASSERT(pDrawPages, "DrawPages not collected");
103*cdf0e10cSrcweir 	if (pDrawPages)
104*cdf0e10cSrcweir 		return (*pDrawPages)[nTable].xDrawPage;
105*cdf0e10cSrcweir 	else
106*cdf0e10cSrcweir 		return uno::Reference<drawing::XDrawPage>();
107*cdf0e10cSrcweir }
108*cdf0e10cSrcweir 
109*cdf0e10cSrcweir sal_Bool ScMySharedData::HasForm(const sal_Int32 nTable, uno::Reference<drawing::XDrawPage>& xDrawPage)
110*cdf0e10cSrcweir {
111*cdf0e10cSrcweir 	sal_Bool bResult(sal_False);
112*cdf0e10cSrcweir 	if (pDrawPages)
113*cdf0e10cSrcweir 	{
114*cdf0e10cSrcweir 		if ((*pDrawPages)[nTable].bHasForms)
115*cdf0e10cSrcweir 		{
116*cdf0e10cSrcweir 			bResult = sal_True;
117*cdf0e10cSrcweir 			xDrawPage = (*pDrawPages)[nTable].xDrawPage;
118*cdf0e10cSrcweir 		}
119*cdf0e10cSrcweir 	}
120*cdf0e10cSrcweir 	return bResult;
121*cdf0e10cSrcweir }
122*cdf0e10cSrcweir 
123*cdf0e10cSrcweir void ScMySharedData::AddNewShape(const ScMyShape& aMyShape)
124*cdf0e10cSrcweir {
125*cdf0e10cSrcweir 	if (!pShapesContainer)
126*cdf0e10cSrcweir 		pShapesContainer = new ScMyShapesContainer();
127*cdf0e10cSrcweir 	pShapesContainer->AddNewShape(aMyShape);
128*cdf0e10cSrcweir }
129*cdf0e10cSrcweir 
130*cdf0e10cSrcweir void ScMySharedData::SortShapesContainer()
131*cdf0e10cSrcweir {
132*cdf0e10cSrcweir 	if (pShapesContainer)
133*cdf0e10cSrcweir 		pShapesContainer->Sort();
134*cdf0e10cSrcweir }
135*cdf0e10cSrcweir 
136*cdf0e10cSrcweir sal_Bool ScMySharedData::HasShapes()
137*cdf0e10cSrcweir {
138*cdf0e10cSrcweir 	return ((pShapesContainer && pShapesContainer->HasShapes()) ||
139*cdf0e10cSrcweir 			(pTableShapes && !pTableShapes->empty()));
140*cdf0e10cSrcweir }
141*cdf0e10cSrcweir 
142*cdf0e10cSrcweir void ScMySharedData::AddTableShape(const sal_Int32 nTable, const uno::Reference<drawing::XShape>& xShape)
143*cdf0e10cSrcweir {
144*cdf0e10cSrcweir 	if (!pTableShapes)
145*cdf0e10cSrcweir 		pTableShapes = new ScMyTableShapes(nTableCount);
146*cdf0e10cSrcweir 	(*pTableShapes)[nTable].push_back(xShape);
147*cdf0e10cSrcweir }
148*cdf0e10cSrcweir 
149*cdf0e10cSrcweir void ScMySharedData::AddNoteObj(const uno::Reference<drawing::XShape>& xShape, const ScAddress& rPos)
150*cdf0e10cSrcweir {
151*cdf0e10cSrcweir     if (!pNoteShapes)
152*cdf0e10cSrcweir         pNoteShapes = new ScMyNoteShapesContainer();
153*cdf0e10cSrcweir     ScMyNoteShape aNote;
154*cdf0e10cSrcweir     aNote.xShape = xShape;
155*cdf0e10cSrcweir     aNote.aPos = rPos;
156*cdf0e10cSrcweir     pNoteShapes->AddNewNote(aNote);
157*cdf0e10cSrcweir }
158*cdf0e10cSrcweir 
159*cdf0e10cSrcweir void ScMySharedData::SortNoteShapes()
160*cdf0e10cSrcweir {
161*cdf0e10cSrcweir     if (pNoteShapes)
162*cdf0e10cSrcweir         pNoteShapes->Sort();
163*cdf0e10cSrcweir }
164