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