LibreOffice Module sc (master) 1
XMLColumnRowGroupExport.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
21#include "xmlexprt.hxx"
23#include <xmloff/xmltoken.hxx>
25
26#include <algorithm>
27
28using namespace xmloff::token;
29
31 : nField(0)
32 , nLevel(0)
33 , bDisplay(false)
34{
35}
36
38{
39 if (rGroup.nField > nField)
40 return true;
41 else
42 if (rGroup.nField == nField && rGroup.nLevel > nLevel)
43 return true;
44 else
45 return false;
46}
47
49 : rExport(rTempExport),
50 rName(rExport.GetNamespaceMap().GetQNameByKey(XML_NAMESPACE_TABLE, GetXMLToken(XMLTokenEnum(nToken))))
51{
52}
53
55{
56}
57
59{
60 aTableStart.clear();
61 aTableEnd.clear();
62}
63
64void ScMyOpenCloseColumnRowGroup::AddGroup(const ScMyColumnRowGroup& aGroup, const sal_Int32 nEndField)
65{
66 aTableStart.push_back(aGroup);
67 aTableEnd.push_back(nEndField);
68}
69
71{
72 bool bGroupStart(false);
73 if (!aTableStart.empty())
74 {
75 // when used to find repeated rows at the beginning of a group,
76 // aTableStart may contain entries before nField. They must be skipped here
77 // (they will be used for OpenGroups later in the right order).
78
79 ScMyColumnRowGroupVec::iterator aItr = std::find_if_not(aTableStart.begin(), aTableStart.end(),
80 [&nField](const ScMyColumnRowGroup& rGroup) { return rGroup.nField < nField; });
81 bGroupStart = (aItr != aTableStart.end()) && (aItr->nField == nField);
82 }
83 return bGroupStart;
84}
85
87{
88 if (!rGroup.bDisplay)
91}
92
93void ScMyOpenCloseColumnRowGroup::OpenGroups(const sal_Int32 nField)
94{
95 ScMyColumnRowGroupVec::iterator aItr(aTableStart.begin());
96 bool bReady(false);
97 while(!bReady && aItr != aTableStart.end())
98 {
99 if (aItr->nField == nField)
100 {
101 OpenGroup(*aItr);
102 aItr = aTableStart.erase(aItr);
103 }
104 else
105 bReady = true;
106 }
107}
108
109bool ScMyOpenCloseColumnRowGroup::IsGroupEnd(const sal_Int32 nField)
110{
111 return (!aTableEnd.empty()) && (aTableEnd.front() == nField);
112}
113
115{
116 ScMyFieldGroupVec::iterator aItr(aTableEnd.begin());
117 bool bReady(false);
118 while(!bReady && aItr != aTableEnd.end())
119 {
120 if (*aItr == nField)
121 {
122 rExport.EndElement( rName, true );
123 aItr = aTableEnd.erase(aItr);
124 }
125 else
126 bReady = true;
127 }
128}
129
131{
132 sal_Int32 maximum(-1);
133 if (!aTableEnd.empty())
134 {
135 ScMyFieldGroupVec::iterator i(std::max_element(aTableEnd.begin(), aTableEnd.end()));
136 if (*i > maximum)
137 maximum = *i;
138 }
139 return maximum;
140}
141
143{
144 std::sort(aTableStart.begin(), aTableStart.end());
145 std::sort(aTableEnd.begin(), aTableEnd.end());
146}
147
148/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void CloseGroups(const sal_Int32 nField)
void AddGroup(const ScMyColumnRowGroup &aGroup, const sal_Int32 nEndField)
bool IsGroupEnd(const sal_Int32 nField)
void OpenGroup(const ScMyColumnRowGroup &rGroup)
ScMyOpenCloseColumnRowGroup(ScXMLExport &rExport, sal_uInt32 nToken)
void OpenGroups(const sal_Int32 nField)
bool IsGroupStart(const sal_Int32 nField)
void StartElement(sal_uInt16 nPrefix, enum ::xmloff::token::XMLTokenEnum eName, bool bIgnWSOutside)
void AddAttribute(sal_uInt16 nPrefix, const OUString &rName, const OUString &rValue)
void EndElement(sal_uInt16 nPrefix, enum ::xmloff::token::XMLTokenEnum eName, bool bIgnWSInside)
int i
XMLTokenEnum
XML_DISPLAY
XML_FALSE
const OUString & GetXMLToken(enum XMLTokenEnum eToken)
DefTokenId nToken
Definition: qproform.cxx:397
bool operator<(const ScMyColumnRowGroup &rGroup) const
constexpr sal_uInt16 XML_NAMESPACE_TABLE