LibreOffice Module sc (master) 1
XMLStylesImportHelper.hxx
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#pragma once
21
22#include <rangelst.hxx>
23#include <rtl/ustring.hxx>
24
25#include <memory>
26#include <set>
27#include <map>
28#include <utility>
29#include <vector>
30#include <optional>
31
32class ScXMLImport;
33
35{
36 OUString sStyleName;
37 sal_Int32 nNumberFormat;
38
39 explicit ScMyStyleNumberFormat(OUString aStyleName) :
40 sStyleName(std::move(aStyleName)), nNumberFormat(-1) {}
41 ScMyStyleNumberFormat(OUString aStyleName, const sal_Int32 nFormat) :
42 sStyleName(std::move(aStyleName)), nNumberFormat(nFormat) {}
43};
44
46{
47 bool operator() (const ScMyStyleNumberFormat& rValue1, const ScMyStyleNumberFormat& rValue2) const
48 {
49 return rValue1.sStyleName < rValue2.sStyleName;
50 }
51};
52
53typedef std::set< ScMyStyleNumberFormat, LessStyleNumberFormat > ScMyStyleNumberFormatSet;
54
56{
58
59public:
60 void AddStyleNumberFormat(const OUString& rStyleName, const sal_Int32 nNumberFormat);
61 sal_Int32 GetStyleNumberFormat(const OUString& rStyleName);
62};
63
65{
66 OUString sCurrency;
67 std::shared_ptr<ScRangeList> mpRanges;
68
71 {}
72};
73
75{
76 bool operator() (const ScMyCurrencyStyle& rValue1, const ScMyCurrencyStyle& rValue2) const
77 {
78 return rValue1.sCurrency < rValue2.sCurrency;
79 }
80};
81
82typedef std::set<ScMyCurrencyStyle, LessCurrencyStyle> ScMyCurrencyStylesSet;
83
85{
86 std::shared_ptr<ScRangeList> mpTextList;
87 std::shared_ptr<ScRangeList> mpNumberList;
88 std::shared_ptr<ScRangeList> mpTimeList;
89 std::shared_ptr<ScRangeList> mpDateTimeList;
90 std::shared_ptr<ScRangeList> mpPercentList;
91 std::shared_ptr<ScRangeList> mpLogicalList;
92 std::shared_ptr<ScRangeList> mpUndefinedList;
93 std::unique_ptr<ScMyCurrencyStylesSet> pCurrencyList;
94
95 static void SetStylesToRanges(const ScRangeList& rList,
96 const OUString* pStyleName, const sal_Int16 nCellType,
97 const OUString* pCurrency, ScXMLImport& rImport);
98public:
101 void AddRange(const ScRange& rRange, const sal_Int16 nType);
102 void AddCurrencyRange(const ScRange& rRange, const std::optional<OUString> & pCurrency);
103 void InsertCol(const sal_Int32 nCol, const sal_Int32 nTab);
104 void SetStylesToRanges(const OUString* pStyleName, ScXMLImport& rImport);
105};
106
108typedef std::map<OUString, ScMyStyleRanges> ScMyStylesMap;
109
111{
113 std::vector<ScMyStylesMap::iterator> aColDefaultStyles;
114 ScMyStylesMap::iterator aRowDefaultStyle;
116 std::optional<OUString>
118 std::optional<OUString>
120 std::optional<OUString>
122 std::optional<OUString>
125 sal_Int16 nCellType;
126 sal_Int16 nPrevCellType;
128
129 void ResetAttributes();
130 ScMyStylesMap::iterator GetIterator(const OUString & rStyleName);
131 void AddDefaultRange(const ScRange& rRange);
132 void AddSingleRange(const ScRange& rRange);
133 void AddRange();
134public:
137 void AddColumnStyle(const OUString& rStyleName, const sal_Int32 nColumn, const sal_Int32 nRepeat);
138 void SetRowStyle(const OUString& rStyleName);
139 void SetAttributes(std::optional<OUString> pStyleName,
140 std::optional<OUString> pCurrency, const sal_Int16 nCellType);
141 void AddRange(const ScRange& rRange);
142 void AddCell(const ScAddress& rAddress);
143 void InsertCol(const sal_Int32 nCol, const sal_Int32 nTab); // a col is inserted before nCol
144 void EndTable();
145 void SetStylesToRanges();
146};
147
148/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
std::map< OUString, ScMyStyleRanges > ScMyStylesMap
map from style name to ScMyStyleRanges
std::set< ScMyCurrencyStyle, LessCurrencyStyle > ScMyCurrencyStylesSet
std::set< ScMyStyleNumberFormat, LessStyleNumberFormat > ScMyStyleNumberFormatSet
sal_Int32 GetStyleNumberFormat(const OUString &rStyleName)
ScMyStyleNumberFormatSet aSet
void AddStyleNumberFormat(const OUString &rStyleName, const sal_Int32 nNumberFormat)
void AddRange(const ScRange &rRange, const sal_Int16 nType)
static void SetStylesToRanges(const ScRangeList &rList, const OUString *pStyleName, const sal_Int16 nCellType, const OUString *pCurrency, ScXMLImport &rImport)
std::shared_ptr< ScRangeList > mpLogicalList
std::shared_ptr< ScRangeList > mpTextList
std::shared_ptr< ScRangeList > mpDateTimeList
std::unique_ptr< ScMyCurrencyStylesSet > pCurrencyList
void AddCurrencyRange(const ScRange &rRange, const std::optional< OUString > &pCurrency)
std::shared_ptr< ScRangeList > mpPercentList
std::shared_ptr< ScRangeList > mpUndefinedList
std::shared_ptr< ScRangeList > mpTimeList
std::shared_ptr< ScRangeList > mpNumberList
void InsertCol(const sal_Int32 nCol, const sal_Int32 nTab)
ScMyStylesMap::iterator aRowDefaultStyle
void AddDefaultRange(const ScRange &rRange)
void AddSingleRange(const ScRange &rRange)
std::optional< OUString > pStyleName
std::optional< OUString > pCurrency
void AddColumnStyle(const OUString &rStyleName, const sal_Int32 nColumn, const sal_Int32 nRepeat)
void InsertCol(const sal_Int32 nCol, const sal_Int32 nTab)
void SetRowStyle(const OUString &rStyleName)
void SetAttributes(std::optional< OUString > pStyleName, std::optional< OUString > pCurrency, const sal_Int16 nCellType)
std::optional< OUString > pPrevCurrency
std::optional< OUString > pPrevStyleName
ScMyStylesMap::iterator GetIterator(const OUString &rStyleName)
ScMyStylesImportHelper(ScXMLImport &rImport)
std::vector< ScMyStylesMap::iterator > aColDefaultStyles
void AddCell(const ScAddress &rAddress)
std::shared_ptr< T > make_shared(Args &&... args)
QPRO_FUNC_TYPE nType
Definition: qproform.cxx:398
bool operator()(const ScMyCurrencyStyle &rValue1, const ScMyCurrencyStyle &rValue2) const
bool operator()(const ScMyStyleNumberFormat &rValue1, const ScMyStyleNumberFormat &rValue2) const
std::shared_ptr< ScRangeList > mpRanges
ScMyStyleNumberFormat(OUString aStyleName)
ScMyStyleNumberFormat(OUString aStyleName, const sal_Int32 nFormat)