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 48 : 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 48 : nTableCount(nTempTableCount)
34 : {
35 48 : }
36 :
37 96 : ScMySharedData::~ScMySharedData()
38 : {
39 48 : if (pShapesContainer)
40 4 : delete pShapesContainer;
41 48 : if (pTableShapes)
42 8 : delete pTableShapes;
43 48 : if (pDrawPages)
44 48 : delete pDrawPages;
45 48 : if (pDetectiveObjContainer)
46 48 : delete pDetectiveObjContainer;
47 48 : if (pNoteShapes)
48 2 : delete pNoteShapes;
49 48 : }
50 :
51 224 : void ScMySharedData::SetLastColumn(const sal_Int32 nTable, const sal_Int32 nCol)
52 : {
53 224 : if(nCol > nLastColumns[nTable]) nLastColumns[nTable] = nCol;
54 224 : }
55 :
56 8836 : sal_Int32 ScMySharedData::GetLastColumn(const sal_Int32 nTable) const
57 : {
58 8836 : return nLastColumns[nTable];
59 : }
60 :
61 224 : void ScMySharedData::SetLastRow(const sal_Int32 nTable, const sal_Int32 nRow)
62 : {
63 224 : if(nRow > nLastRows[nTable]) nLastRows[nTable] = nRow;
64 224 : }
65 :
66 224 : sal_Int32 ScMySharedData::GetLastRow(const sal_Int32 nTable) const
67 : {
68 224 : return nLastRows[nTable];
69 : }
70 :
71 56 : void ScMySharedData::AddDrawPage(const ScMyDrawPage& aDrawPage, const sal_Int32 nTable)
72 : {
73 56 : if (!pDrawPages)
74 48 : pDrawPages = new ScMyDrawPages(nTableCount, ScMyDrawPage());
75 56 : (*pDrawPages)[nTable] = aDrawPage;
76 56 : }
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 112 : uno::Reference<drawing::XDrawPage> ScMySharedData::GetDrawPage(const sal_Int32 nTable)
86 : {
87 : OSL_ENSURE(pDrawPages, "DrawPages not collected");
88 112 : if (pDrawPages)
89 112 : return (*pDrawPages)[nTable].xDrawPage;
90 : else
91 0 : return uno::Reference<drawing::XDrawPage>();
92 : }
93 :
94 56 : bool ScMySharedData::HasForm(const sal_Int32 nTable, uno::Reference<drawing::XDrawPage>& xDrawPage)
95 : {
96 56 : bool bResult(false);
97 56 : if (pDrawPages)
98 : {
99 56 : if ((*pDrawPages)[nTable].bHasForms)
100 : {
101 0 : bResult = true;
102 0 : xDrawPage = (*pDrawPages)[nTable].xDrawPage;
103 : }
104 : }
105 56 : return bResult;
106 : }
107 :
108 4 : void ScMySharedData::AddNewShape(const ScMyShape& aMyShape)
109 : {
110 4 : if (!pShapesContainer)
111 4 : pShapesContainer = new ScMyShapesContainer();
112 4 : pShapesContainer->AddNewShape(aMyShape);
113 4 : }
114 :
115 48 : void ScMySharedData::SortShapesContainer()
116 : {
117 48 : if (pShapesContainer)
118 4 : pShapesContainer->Sort();
119 48 : }
120 :
121 48 : bool ScMySharedData::HasShapes()
122 : {
123 60 : return ((pShapesContainer && pShapesContainer->HasShapes()) ||
124 56 : (pTableShapes && !pTableShapes->empty()));
125 : }
126 :
127 8 : void ScMySharedData::AddTableShape(const sal_Int32 nTable, const uno::Reference<drawing::XShape>& xShape)
128 : {
129 8 : if (!pTableShapes)
130 8 : pTableShapes = new ScMyTableShapes(nTableCount);
131 8 : (*pTableShapes)[nTable].push_back(xShape);
132 8 : }
133 :
134 4 : void ScMySharedData::AddNoteObj(const uno::Reference<drawing::XShape>& xShape, const ScAddress& rPos)
135 : {
136 4 : if (!pNoteShapes)
137 2 : pNoteShapes = new ScMyNoteShapesContainer();
138 4 : ScMyNoteShape aNote;
139 4 : aNote.xShape = xShape;
140 4 : aNote.aPos = rPos;
141 4 : pNoteShapes->AddNewNote(aNote);
142 4 : }
143 :
144 96 : void ScMySharedData::SortNoteShapes()
145 : {
146 96 : if (pNoteShapes)
147 4 : pNoteShapes->Sort();
148 324 : }
149 :
150 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|