1*b3f79822SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*b3f79822SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*b3f79822SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*b3f79822SAndrew Rist  * distributed with this work for additional information
6*b3f79822SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*b3f79822SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*b3f79822SAndrew Rist  * "License"); you may not use this file except in compliance
9*b3f79822SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*b3f79822SAndrew Rist  *
11*b3f79822SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*b3f79822SAndrew Rist  *
13*b3f79822SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*b3f79822SAndrew Rist  * software distributed under the License is distributed on an
15*b3f79822SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*b3f79822SAndrew Rist  * KIND, either express or implied.  See the License for the
17*b3f79822SAndrew Rist  * specific language governing permissions and limitations
18*b3f79822SAndrew Rist  * under the License.
19*b3f79822SAndrew Rist  *
20*b3f79822SAndrew Rist  *************************************************************/
21*b3f79822SAndrew Rist 
22*b3f79822SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sc.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir 
28cdf0e10cSrcweir 
29cdf0e10cSrcweir // INCLUDE ---------------------------------------------------------------
30cdf0e10cSrcweir #include "XMLExportSharedData.hxx"
31cdf0e10cSrcweir #include "XMLExportIterator.hxx"
32cdf0e10cSrcweir #include <tools/debug.hxx>
33cdf0e10cSrcweir 
34cdf0e10cSrcweir using namespace com::sun::star;
35cdf0e10cSrcweir 
ScMySharedData(const sal_Int32 nTempTableCount)36cdf0e10cSrcweir ScMySharedData::ScMySharedData(const sal_Int32 nTempTableCount) :
37cdf0e10cSrcweir 	nLastColumns(nTempTableCount, 0),
38cdf0e10cSrcweir 	nLastRows(nTempTableCount, 0),
39cdf0e10cSrcweir 	pTableShapes(NULL),
40cdf0e10cSrcweir 	pDrawPages(NULL),
41cdf0e10cSrcweir 	pShapesContainer(NULL),
42cdf0e10cSrcweir 	pDetectiveObjContainer(new ScMyDetectiveObjContainer()),
43cdf0e10cSrcweir     pNoteShapes(NULL),
44cdf0e10cSrcweir 	nTableCount(nTempTableCount)
45cdf0e10cSrcweir {
46cdf0e10cSrcweir }
47cdf0e10cSrcweir 
~ScMySharedData()48cdf0e10cSrcweir ScMySharedData::~ScMySharedData()
49cdf0e10cSrcweir {
50cdf0e10cSrcweir 	if (pShapesContainer)
51cdf0e10cSrcweir 		delete pShapesContainer;
52cdf0e10cSrcweir 	if (pTableShapes)
53cdf0e10cSrcweir 		delete pTableShapes;
54cdf0e10cSrcweir 	if (pDrawPages)
55cdf0e10cSrcweir 		delete pDrawPages;
56cdf0e10cSrcweir 	if (pDetectiveObjContainer)
57cdf0e10cSrcweir 		delete pDetectiveObjContainer;
58cdf0e10cSrcweir     if (pNoteShapes)
59cdf0e10cSrcweir         delete pNoteShapes;
60cdf0e10cSrcweir }
61cdf0e10cSrcweir 
SetLastColumn(const sal_Int32 nTable,const sal_Int32 nCol)62cdf0e10cSrcweir void ScMySharedData::SetLastColumn(const sal_Int32 nTable, const sal_Int32 nCol)
63cdf0e10cSrcweir {
64cdf0e10cSrcweir 	if(nCol > nLastColumns[nTable]) nLastColumns[nTable] = nCol;
65cdf0e10cSrcweir }
66cdf0e10cSrcweir 
GetLastColumn(const sal_Int32 nTable)67cdf0e10cSrcweir sal_Int32 ScMySharedData::GetLastColumn(const sal_Int32 nTable)
68cdf0e10cSrcweir {
69cdf0e10cSrcweir 	return nLastColumns[nTable];
70cdf0e10cSrcweir }
71cdf0e10cSrcweir 
SetLastRow(const sal_Int32 nTable,const sal_Int32 nRow)72cdf0e10cSrcweir void ScMySharedData::SetLastRow(const sal_Int32 nTable, const sal_Int32 nRow)
73cdf0e10cSrcweir {
74cdf0e10cSrcweir 	if(nRow > nLastRows[nTable]) nLastRows[nTable] = nRow;
75cdf0e10cSrcweir }
76cdf0e10cSrcweir 
GetLastRow(const sal_Int32 nTable)77cdf0e10cSrcweir sal_Int32 ScMySharedData::GetLastRow(const sal_Int32 nTable)
78cdf0e10cSrcweir {
79cdf0e10cSrcweir 	return nLastRows[nTable];
80cdf0e10cSrcweir }
81cdf0e10cSrcweir 
AddDrawPage(const ScMyDrawPage & aDrawPage,const sal_Int32 nTable)82cdf0e10cSrcweir void ScMySharedData::AddDrawPage(const ScMyDrawPage& aDrawPage, const sal_Int32 nTable)
83cdf0e10cSrcweir {
84cdf0e10cSrcweir 	if (!pDrawPages)
85cdf0e10cSrcweir 		pDrawPages = new ScMyDrawPages(nTableCount, ScMyDrawPage());
86cdf0e10cSrcweir 	(*pDrawPages)[nTable] = aDrawPage;
87cdf0e10cSrcweir }
88cdf0e10cSrcweir 
SetDrawPageHasForms(const sal_Int32 nTable,sal_Bool bHasForms)89cdf0e10cSrcweir void ScMySharedData::SetDrawPageHasForms(const sal_Int32 nTable, sal_Bool bHasForms)
90cdf0e10cSrcweir {
91cdf0e10cSrcweir 	DBG_ASSERT(pDrawPages, "DrawPages not collected");
92cdf0e10cSrcweir 	if (pDrawPages)
93cdf0e10cSrcweir 		(*pDrawPages)[nTable].bHasForms = bHasForms;
94cdf0e10cSrcweir }
95cdf0e10cSrcweir 
GetDrawPage(const sal_Int32 nTable)96cdf0e10cSrcweir uno::Reference<drawing::XDrawPage> ScMySharedData::GetDrawPage(const sal_Int32 nTable)
97cdf0e10cSrcweir {
98cdf0e10cSrcweir 	DBG_ASSERT(pDrawPages, "DrawPages not collected");
99cdf0e10cSrcweir 	if (pDrawPages)
100cdf0e10cSrcweir 		return (*pDrawPages)[nTable].xDrawPage;
101cdf0e10cSrcweir 	else
102cdf0e10cSrcweir 		return uno::Reference<drawing::XDrawPage>();
103cdf0e10cSrcweir }
104cdf0e10cSrcweir 
HasForm(const sal_Int32 nTable,uno::Reference<drawing::XDrawPage> & xDrawPage)105cdf0e10cSrcweir sal_Bool ScMySharedData::HasForm(const sal_Int32 nTable, uno::Reference<drawing::XDrawPage>& xDrawPage)
106cdf0e10cSrcweir {
107cdf0e10cSrcweir 	sal_Bool bResult(sal_False);
108cdf0e10cSrcweir 	if (pDrawPages)
109cdf0e10cSrcweir 	{
110cdf0e10cSrcweir 		if ((*pDrawPages)[nTable].bHasForms)
111cdf0e10cSrcweir 		{
112cdf0e10cSrcweir 			bResult = sal_True;
113cdf0e10cSrcweir 			xDrawPage = (*pDrawPages)[nTable].xDrawPage;
114cdf0e10cSrcweir 		}
115cdf0e10cSrcweir 	}
116cdf0e10cSrcweir 	return bResult;
117cdf0e10cSrcweir }
118cdf0e10cSrcweir 
AddNewShape(const ScMyShape & aMyShape)119cdf0e10cSrcweir void ScMySharedData::AddNewShape(const ScMyShape& aMyShape)
120cdf0e10cSrcweir {
121cdf0e10cSrcweir 	if (!pShapesContainer)
122cdf0e10cSrcweir 		pShapesContainer = new ScMyShapesContainer();
123cdf0e10cSrcweir 	pShapesContainer->AddNewShape(aMyShape);
124cdf0e10cSrcweir }
125cdf0e10cSrcweir 
SortShapesContainer()126cdf0e10cSrcweir void ScMySharedData::SortShapesContainer()
127cdf0e10cSrcweir {
128cdf0e10cSrcweir 	if (pShapesContainer)
129cdf0e10cSrcweir 		pShapesContainer->Sort();
130cdf0e10cSrcweir }
131cdf0e10cSrcweir 
HasShapes()132cdf0e10cSrcweir sal_Bool ScMySharedData::HasShapes()
133cdf0e10cSrcweir {
134cdf0e10cSrcweir 	return ((pShapesContainer && pShapesContainer->HasShapes()) ||
135cdf0e10cSrcweir 			(pTableShapes && !pTableShapes->empty()));
136cdf0e10cSrcweir }
137cdf0e10cSrcweir 
AddTableShape(const sal_Int32 nTable,const uno::Reference<drawing::XShape> & xShape)138cdf0e10cSrcweir void ScMySharedData::AddTableShape(const sal_Int32 nTable, const uno::Reference<drawing::XShape>& xShape)
139cdf0e10cSrcweir {
140cdf0e10cSrcweir 	if (!pTableShapes)
141cdf0e10cSrcweir 		pTableShapes = new ScMyTableShapes(nTableCount);
142cdf0e10cSrcweir 	(*pTableShapes)[nTable].push_back(xShape);
143cdf0e10cSrcweir }
144cdf0e10cSrcweir 
AddNoteObj(const uno::Reference<drawing::XShape> & xShape,const ScAddress & rPos)145cdf0e10cSrcweir void ScMySharedData::AddNoteObj(const uno::Reference<drawing::XShape>& xShape, const ScAddress& rPos)
146cdf0e10cSrcweir {
147cdf0e10cSrcweir     if (!pNoteShapes)
148cdf0e10cSrcweir         pNoteShapes = new ScMyNoteShapesContainer();
149cdf0e10cSrcweir     ScMyNoteShape aNote;
150cdf0e10cSrcweir     aNote.xShape = xShape;
151cdf0e10cSrcweir     aNote.aPos = rPos;
152cdf0e10cSrcweir     pNoteShapes->AddNewNote(aNote);
153cdf0e10cSrcweir }
154cdf0e10cSrcweir 
SortNoteShapes()155cdf0e10cSrcweir void ScMySharedData::SortNoteShapes()
156cdf0e10cSrcweir {
157cdf0e10cSrcweir     if (pNoteShapes)
158cdf0e10cSrcweir         pNoteShapes->Sort();
159cdf0e10cSrcweir }
160