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