LibreOffice Module sc (master)  1
XMLExportSharedData.cxx
Go to the documentation of this file.
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 ScMySharedData::ScMySharedData(const sal_Int32 nTempTableCount) :
27  nLastColumns(nTempTableCount, 0),
28  nLastRows(nTempTableCount, 0),
29  pDetectiveObjContainer(new ScMyDetectiveObjContainer()),
30  nTableCount(nTempTableCount)
31 {
32 }
33 
35 {
36  pShapesContainer.reset();
37  pTableShapes.reset();
38  pDrawPages.reset();
39  pDetectiveObjContainer.reset();
40  pNoteShapes.reset();
41 }
42 
43 void ScMySharedData::SetLastColumn(const sal_Int32 nTable, const sal_Int32 nCol)
44 {
45  if(nCol > nLastColumns[nTable]) nLastColumns[nTable] = nCol;
46 }
47 
48 sal_Int32 ScMySharedData::GetLastColumn(const sal_Int32 nTable) const
49 {
50  return nLastColumns[nTable];
51 }
52 
53 void ScMySharedData::SetLastRow(const sal_Int32 nTable, const sal_Int32 nRow)
54 {
55  if(nRow > nLastRows[nTable]) nLastRows[nTable] = nRow;
56 }
57 
58 sal_Int32 ScMySharedData::GetLastRow(const sal_Int32 nTable) const
59 {
60  return nLastRows[nTable];
61 }
62 
63 void ScMySharedData::AddDrawPage(const ScMyDrawPage& aDrawPage, const sal_Int32 nTable)
64 {
65  if (!pDrawPages)
67  (*pDrawPages)[nTable] = aDrawPage;
68 }
69 
70 void ScMySharedData::SetDrawPageHasForms(const sal_Int32 nTable, bool bHasForms)
71 {
72  OSL_ENSURE(pDrawPages, "DrawPages not collected");
73  if (pDrawPages)
74  (*pDrawPages)[nTable].bHasForms = bHasForms;
75 }
76 
77 uno::Reference<drawing::XDrawPage> ScMySharedData::GetDrawPage(const sal_Int32 nTable)
78 {
79  OSL_ENSURE(pDrawPages, "DrawPages not collected");
80  if (pDrawPages)
81  return (*pDrawPages)[nTable].xDrawPage;
82  else
83  return uno::Reference<drawing::XDrawPage>();
84 }
85 
86 bool ScMySharedData::HasForm(const sal_Int32 nTable, uno::Reference<drawing::XDrawPage>& xDrawPage)
87 {
88  bool bResult(false);
89  if (pDrawPages)
90  {
91  if ((*pDrawPages)[nTable].bHasForms)
92  {
93  bResult = true;
94  xDrawPage = (*pDrawPages)[nTable].xDrawPage;
95  }
96  }
97  return bResult;
98 }
99 
101 {
102  if (!pShapesContainer)
104  pShapesContainer->AddNewShape(aMyShape);
105 }
106 
108 {
109  if (pShapesContainer)
110  pShapesContainer->Sort();
111 }
112 
114 {
115  return ((pShapesContainer && pShapesContainer->HasShapes()) ||
116  (pTableShapes && !pTableShapes->empty()));
117 }
118 
119 void ScMySharedData::AddTableShape(const sal_Int32 nTable, const uno::Reference<drawing::XShape>& xShape)
120 {
121  if (!pTableShapes)
123  (*pTableShapes)[nTable].push_back(xShape);
124 }
125 
126 void ScMySharedData::AddNoteObj(const uno::Reference<drawing::XShape>& xShape, const ScAddress& rPos)
127 {
128  if (!pNoteShapes)
129  pNoteShapes.reset( new ScMyNoteShapesContainer() );
130  ScMyNoteShape aNote;
131  aNote.xShape = xShape;
132  aNote.aPos = rPos;
133  pNoteShapes->AddNewNote(aNote);
134 }
135 
137 {
138  if (pNoteShapes)
139  pNoteShapes->Sort();
140 }
141 
142 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
std::vector< sal_Int32 > nLastRows
void AddNewShape(const ScMyShape &aMyShape)
bool HasShapes() const
void SetDrawPageHasForms(const sal_Int32 nTable, bool bHasForms)
void AddTableShape(const sal_Int32 nTable, const css::uno::Reference< css::drawing::XShape > &xShape)
bool HasForm(const sal_Int32 nTable, css::uno::Reference< css::drawing::XDrawPage > &xDrawPage)
std::unique_ptr< ScMyDetectiveObjContainer > pDetectiveObjContainer
ScMySharedData(const sal_Int32 nTableCount)
std::vector< sal_Int32 > nLastColumns
void AddDrawPage(const ScMyDrawPage &aDrawPage, const sal_Int32 nTable)
std::unique_ptr< ScMyShapesContainer > pShapesContainer
std::unique_ptr< ScMyTableShapes > pTableShapes
css::uno::Reference< css::drawing::XDrawPage > GetDrawPage(const sal_Int32 nTable)
std::vector< ScMyDrawPage > ScMyDrawPages
sal_Int32 GetLastColumn(const sal_Int32 nTable) const
std::unique_ptr< ScMyDrawPages > pDrawPages
css::uno::Reference< css::drawing::XShape > xShape
sal_Int32 GetLastRow(const sal_Int32 nTable) const
void SetLastRow(const sal_Int32 nTable, const sal_Int32 nRow)
void SetLastColumn(const sal_Int32 nTable, const sal_Int32 nCol)
std::vector< ScMyTableXShapes > ScMyTableShapes
std::unique_ptr< ScMyNoteShapesContainer > pNoteShapes
void AddNoteObj(const css::uno::Reference< css::drawing::XShape > &xShape, const ScAddress &rPos)