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 <vector>
29 #include <optional>
30 
31 class ScXMLImport;
32 
34 {
35  OUString sStyleName;
36  sal_Int32 nNumberFormat;
37 
38  explicit ScMyStyleNumberFormat(const OUString& rStyleName) :
39  sStyleName(rStyleName), nNumberFormat(-1) {}
40  ScMyStyleNumberFormat(const OUString& rStyleName, const sal_Int32 nFormat) :
41  sStyleName(rStyleName), nNumberFormat(nFormat) {}
42 };
43 
45 {
46  bool operator() (const ScMyStyleNumberFormat& rValue1, const ScMyStyleNumberFormat& rValue2) const
47  {
48  return rValue1.sStyleName < rValue2.sStyleName;
49  }
50 };
51 
52 typedef std::set< ScMyStyleNumberFormat, LessStyleNumberFormat > ScMyStyleNumberFormatSet;
53 
55 {
57 
58 public:
59  void AddStyleNumberFormat(const OUString& rStyleName, const sal_Int32 nNumberFormat);
60  sal_Int32 GetStyleNumberFormat(const OUString& rStyleName);
61 };
62 
64 {
65  OUString sCurrency;
66  std::shared_ptr<ScRangeList> mpRanges;
67 
69  mpRanges(std::make_shared<ScRangeList>())
70  {}
71 };
72 
74 {
75  bool operator() (const ScMyCurrencyStyle& rValue1, const ScMyCurrencyStyle& rValue2) const
76  {
77  return rValue1.sCurrency < rValue2.sCurrency;
78  }
79 };
80 
81 typedef std::set<ScMyCurrencyStyle, LessCurrencyStyle> ScMyCurrencyStylesSet;
82 
84 {
85  std::shared_ptr<ScRangeList> mpTextList;
86  std::shared_ptr<ScRangeList> mpNumberList;
87  std::shared_ptr<ScRangeList> mpTimeList;
88  std::shared_ptr<ScRangeList> mpDateTimeList;
89  std::shared_ptr<ScRangeList> mpPercentList;
90  std::shared_ptr<ScRangeList> mpLogicalList;
91  std::shared_ptr<ScRangeList> mpUndefinedList;
92  std::unique_ptr<ScMyCurrencyStylesSet> pCurrencyList;
93 
94  static void SetStylesToRanges(const ScRangeList& rList,
95  const OUString* pStyleName, const sal_Int16 nCellType,
96  const OUString* pCurrency, ScXMLImport& rImport);
97 public:
100  void AddRange(const ScRange& rRange, const sal_Int16 nType);
101  void AddCurrencyRange(const ScRange& rRange, const std::optional<OUString> & pCurrency);
102  void InsertCol(const sal_Int32 nCol, const sal_Int32 nTab);
103  void SetStylesToRanges(const OUString* pStyleName, ScXMLImport& rImport);
104 };
105 
107 typedef std::map<OUString, std::unique_ptr<ScMyStyleRanges>> ScMyStylesMap;
108 
110 {
112  std::vector<ScMyStylesMap::iterator> aColDefaultStyles;
113  ScMyStylesMap::iterator aRowDefaultStyle;
115  std::optional<OUString>
117  std::optional<OUString>
119  std::optional<OUString>
121  std::optional<OUString>
124  sal_Int16 nCellType;
125  sal_Int16 nPrevCellType;
127 
128  void ResetAttributes();
129  ScMyStylesMap::iterator GetIterator(const OUString & rStyleName);
130  void AddDefaultRange(const ScRange& rRange);
131  void AddSingleRange(const ScRange& rRange);
132  void AddRange();
133 public:
134  explicit ScMyStylesImportHelper(ScXMLImport& rImport);
136  void AddColumnStyle(const OUString& rStyleName, const sal_Int32 nColumn, const sal_Int32 nRepeat);
137  void SetRowStyle(const OUString& rStyleName);
138  void SetAttributes(std::optional<OUString> pStyleName,
139  std::optional<OUString> pCurrency, const sal_Int16 nCellType);
140  void AddRange(const ScRange& rRange);
141  void AddCell(const ScAddress& rAddress);
142  void InsertCol(const sal_Int32 nCol, const sal_Int32 nTab); // a col is inserted before nCol
143  void EndTable();
144  void SetStylesToRanges();
145 };
146 
147 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void InsertCol(const sal_Int32 nCol, const sal_Int32 nTab)
void AddCell(const ScAddress &rAddress)
void AddRange(const ScRange &rRange, const sal_Int16 nType)
std::optional< OUString > pPrevCurrency
void AddCurrencyRange(const ScRange &rRange, const std::optional< OUString > &pCurrency)
std::optional< OUString > pPrevStyleName
static void SetStylesToRanges(const ScRangeList &rList, const OUString *pStyleName, const sal_Int16 nCellType, const OUString *pCurrency, ScXMLImport &rImport)
std::shared_ptr< ScRangeList > mpRanges
std::shared_ptr< T > make_shared(Args &&...args)
ScMyStyleNumberFormatSet aSet
std::unique_ptr< ScMyCurrencyStylesSet > pCurrencyList
void SetRowStyle(const OUString &rStyleName)
void InsertCol(const sal_Int32 nCol, const sal_Int32 nTab)
void SetAttributes(std::optional< OUString > pStyleName, std::optional< OUString > pCurrency, const sal_Int16 nCellType)
ScMyStylesImportHelper(ScXMLImport &rImport)
std::shared_ptr< ScRangeList > mpNumberList
ScMyStyleNumberFormat(const OUString &rStyleName)
std::map< OUString, std::unique_ptr< ScMyStyleRanges > > ScMyStylesMap
map from style name to ScMyStyleRanges
void AddSingleRange(const ScRange &rRange)
std::shared_ptr< ScRangeList > mpTimeList
std::shared_ptr< ScRangeList > mpUndefinedList
ScMyStyleNumberFormat(const OUString &rStyleName, const sal_Int32 nFormat)
bool operator()(const ScMyCurrencyStyle &rValue1, const ScMyCurrencyStyle &rValue2) const
std::set< ScMyStyleNumberFormat, LessStyleNumberFormat > ScMyStyleNumberFormatSet
bool operator()(const ScMyStyleNumberFormat &rValue1, const ScMyStyleNumberFormat &rValue2) const
void AddColumnStyle(const OUString &rStyleName, const sal_Int32 nColumn, const sal_Int32 nRepeat)
std::shared_ptr< ScRangeList > mpDateTimeList
QPRO_FUNC_TYPE nType
Definition: qproform.cxx:398
ScMyStylesMap::iterator aRowDefaultStyle
void AddStyleNumberFormat(const OUString &rStyleName, const sal_Int32 nNumberFormat)
sal_Int32 GetStyleNumberFormat(const OUString &rStyleName)
std::vector< ScMyStylesMap::iterator > aColDefaultStyles
std::shared_ptr< ScRangeList > mpPercentList
std::set< ScMyCurrencyStyle, LessCurrencyStyle > ScMyCurrencyStylesSet
std::shared_ptr< ScRangeList > mpLogicalList
std::shared_ptr< ScRangeList > mpTextList
std::optional< OUString > pCurrency
std::optional< OUString > pStyleName
ScMyStylesMap::iterator GetIterator(const OUString &rStyleName)
void AddDefaultRange(const ScRange &rRange)