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 #ifndef INCLUDED_SC_SOURCE_FILTER_XML_XMLSTYLESIMPORTHELPER_HXX
21 #define INCLUDED_SC_SOURCE_FILTER_XML_XMLSTYLESIMPORTHELPER_HXX
22 
23 #include <rangelst.hxx>
24 #include <rtl/ustring.hxx>
25 #include <tools/ref.hxx>
26 
27 #include <list>
28 #include <memory>
29 #include <set>
30 #include <map>
31 #include <vector>
32 #include <optional>
33 
34 class ScXMLImport;
35 
37 {
38  OUString sStyleName;
39  sal_Int32 nNumberFormat;
40 
41  explicit ScMyStyleNumberFormat(const OUString& rStyleName) :
42  sStyleName(rStyleName), nNumberFormat(-1) {}
43  ScMyStyleNumberFormat(const OUString& rStyleName, const sal_Int32 nFormat) :
44  sStyleName(rStyleName), nNumberFormat(nFormat) {}
45 };
46 
48 {
49  bool operator() (const ScMyStyleNumberFormat& rValue1, const ScMyStyleNumberFormat& rValue2) const
50  {
51  return rValue1.sStyleName < rValue2.sStyleName;
52  }
53 };
54 
55 typedef std::set< ScMyStyleNumberFormat, LessStyleNumberFormat > ScMyStyleNumberFormatSet;
56 
58 {
60 
61 public:
62  void AddStyleNumberFormat(const OUString& rStyleName, const sal_Int32 nNumberFormat);
63  sal_Int32 GetStyleNumberFormat(const OUString& rStyleName);
64 };
65 
67 {
68  OUString sCurrency;
69  std::shared_ptr<ScRangeList> mpRanges;
70 
72  mpRanges(std::make_shared<ScRangeList>())
73  {}
74 };
75 
77 {
78  bool operator() (const ScMyCurrencyStyle& rValue1, const ScMyCurrencyStyle& rValue2) const
79  {
80  return rValue1.sCurrency < rValue2.sCurrency;
81  }
82 };
83 
84 typedef std::set<ScMyCurrencyStyle, LessCurrencyStyle> ScMyCurrencyStylesSet;
85 
87 {
88  std::shared_ptr<ScRangeList> mpTextList;
89  std::shared_ptr<ScRangeList> mpNumberList;
90  std::shared_ptr<ScRangeList> mpTimeList;
91  std::shared_ptr<ScRangeList> mpDateTimeList;
92  std::shared_ptr<ScRangeList> mpPercentList;
93  std::shared_ptr<ScRangeList> mpLogicalList;
94  std::shared_ptr<ScRangeList> mpUndefinedList;
95  std::unique_ptr<ScMyCurrencyStylesSet> pCurrencyList;
96 
97  static void SetStylesToRanges(const ScRangeList& rList,
98  const OUString* pStyleName, const sal_Int16 nCellType,
99  const OUString* pCurrency, ScXMLImport& rImport);
100 public:
101  ScMyStyleRanges();
103  void AddRange(const ScRange& rRange, const sal_Int16 nType);
104  void AddCurrencyRange(const ScRange& rRange, const std::optional<OUString> & pCurrency);
105  void InsertCol(const sal_Int32 nCol, const sal_Int32 nTab);
106  void SetStylesToRanges(const OUString* pStyleName, ScXMLImport& rImport);
107 };
108 
110 typedef std::map<OUString, std::unique_ptr<ScMyStyleRanges>> ScMyStylesMap;
111 
113 {
115  std::vector<ScMyStylesMap::iterator> aColDefaultStyles;
116  ScMyStylesMap::iterator aRowDefaultStyle;
118  std::optional<OUString>
120  std::optional<OUString>
122  std::optional<OUString>
124  std::optional<OUString>
127  sal_Int16 nCellType;
128  sal_Int16 nPrevCellType;
130 
131  void ResetAttributes();
132  ScMyStylesMap::iterator GetIterator(const OUString & rStyleName);
133  void AddDefaultRange(const ScRange& rRange);
134  void AddSingleRange(const ScRange& rRange);
135  void AddRange();
136 public:
137  explicit ScMyStylesImportHelper(ScXMLImport& rImport);
139  void AddColumnStyle(const OUString& rStyleName, const sal_Int32 nColumn, const sal_Int32 nRepeat);
140  void SetRowStyle(const OUString& rStyleName);
141  void SetAttributes(std::optional<OUString> pStyleName,
142  std::optional<OUString> pCurrency, const sal_Int16 nCellType);
143  void AddRange(const ScRange& rRange);
144  void AddCell(const ScAddress& rAddress);
145  void InsertCol(const sal_Int32 nCol, const sal_Int32 nTab); // a col is inserted before nCol
146  void EndTable();
147  void SetStylesToRanges();
148 };
149 
150 #endif
151 
152 /* 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:401
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)