Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #include "XMLExportSharedData.hxx"
21 : #include "XMLExportIterator.hxx"
22 :
23 : using namespace com::sun::star;
24 :
25 2 : ScMySharedData::ScMySharedData(const sal_Int32 nTempTableCount) :
26 : nLastColumns(nTempTableCount, 0),
27 : nLastRows(nTempTableCount, 0),
28 : pTableShapes(NULL),
29 : pDrawPages(NULL),
30 : pShapesContainer(NULL),
31 0 : pDetectiveObjContainer(new ScMyDetectiveObjContainer()),
32 : pNoteShapes(NULL),
33 2 : nTableCount(nTempTableCount)
34 : {
35 2 : }
36 :
37 4 : ScMySharedData::~ScMySharedData()
38 : {
39 2 : if (pShapesContainer)
40 0 : delete pShapesContainer;
41 2 : if (pTableShapes)
42 0 : delete pTableShapes;
43 2 : if (pDrawPages)
44 2 : delete pDrawPages;
45 2 : if (pDetectiveObjContainer)
46 2 : delete pDetectiveObjContainer;
47 2 : if (pNoteShapes)
48 0 : delete pNoteShapes;
49 2 : }
50 :
51 4 : void ScMySharedData::SetLastColumn(const sal_Int32 nTable, const sal_Int32 nCol)
52 : {
53 4 : if(nCol > nLastColumns[nTable]) nLastColumns[nTable] = nCol;
54 4 : }
55 :
56 10 : sal_Int32 ScMySharedData::GetLastColumn(const sal_Int32 nTable) const
57 : {
58 10 : return nLastColumns[nTable];
59 : }
60 :
61 4 : void ScMySharedData::SetLastRow(const sal_Int32 nTable, const sal_Int32 nRow)
62 : {
63 4 : if(nRow > nLastRows[nTable]) nLastRows[nTable] = nRow;
64 4 : }
65 :
66 8 : sal_Int32 ScMySharedData::GetLastRow(const sal_Int32 nTable) const
67 : {
68 8 : return nLastRows[nTable];
69 : }
70 :
71 2 : void ScMySharedData::AddDrawPage(const ScMyDrawPage& aDrawPage, const sal_Int32 nTable)
72 : {
73 2 : if (!pDrawPages)
74 2 : pDrawPages = new ScMyDrawPages(nTableCount, ScMyDrawPage());
75 2 : (*pDrawPages)[nTable] = aDrawPage;
76 2 : }
77 :
78 0 : void ScMySharedData::SetDrawPageHasForms(const sal_Int32 nTable, bool bHasForms)
79 : {
80 : OSL_ENSURE(pDrawPages, "DrawPages not collected");
81 0 : if (pDrawPages)
82 0 : (*pDrawPages)[nTable].bHasForms = bHasForms;
83 0 : }
84 :
85 4 : uno::Reference<drawing::XDrawPage> ScMySharedData::GetDrawPage(const sal_Int32 nTable)
86 : {
87 : OSL_ENSURE(pDrawPages, "DrawPages not collected");
88 4 : if (pDrawPages)
89 4 : return (*pDrawPages)[nTable].xDrawPage;
90 : else
91 0 : return uno::Reference<drawing::XDrawPage>();
92 : }
93 :
94 2 : bool ScMySharedData::HasForm(const sal_Int32 nTable, uno::Reference<drawing::XDrawPage>& xDrawPage)
95 : {
96 2 : bool bResult(false);
97 2 : if (pDrawPages)
98 : {
99 2 : if ((*pDrawPages)[nTable].bHasForms)
100 : {
101 0 : bResult = true;
102 0 : xDrawPage = (*pDrawPages)[nTable].xDrawPage;
103 : }
104 : }
105 2 : return bResult;
106 : }
107 :
108 0 : void ScMySharedData::AddNewShape(const ScMyShape& aMyShape)
109 : {
110 0 : if (!pShapesContainer)
111 0 : pShapesContainer = new ScMyShapesContainer();
112 0 : pShapesContainer->AddNewShape(aMyShape);
113 0 : }
114 :
115 2 : void ScMySharedData::SortShapesContainer()
116 : {
117 2 : if (pShapesContainer)
118 0 : pShapesContainer->Sort();
119 2 : }
120 :
121 2 : bool ScMySharedData::HasShapes()
122 : {
123 0 : return ((pShapesContainer && pShapesContainer->HasShapes()) ||
124 2 : (pTableShapes && !pTableShapes->empty()));
125 : }
126 :
127 0 : void ScMySharedData::AddTableShape(const sal_Int32 nTable, const uno::Reference<drawing::XShape>& xShape)
128 : {
129 0 : if (!pTableShapes)
130 0 : pTableShapes = new ScMyTableShapes(nTableCount);
131 0 : (*pTableShapes)[nTable].push_back(xShape);
132 0 : }
133 :
134 0 : void ScMySharedData::AddNoteObj(const uno::Reference<drawing::XShape>& xShape, const ScAddress& rPos)
135 : {
136 0 : if (!pNoteShapes)
137 0 : pNoteShapes = new ScMyNoteShapesContainer();
138 0 : ScMyNoteShape aNote;
139 0 : aNote.xShape = xShape;
140 0 : aNote.aPos = rPos;
141 0 : pNoteShapes->AddNewNote(aNote);
142 0 : }
143 :
144 4 : void ScMySharedData::SortNoteShapes()
145 : {
146 4 : if (pNoteShapes)
147 0 : pNoteShapes->Sort();
148 4 : }
149 :
150 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|