Move setting of LD_LIBRARY_PATH closer to invocation of cppunittester
[LibreOffice.git] / xmloff / inc / txtlists.hxx
blob59454e79802f5d586542afa339b14c0d6fdb9a07
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #pragma once
22 #include <rtl/ustring.hxx>
23 #include <map>
24 #include <memory>
25 #include <stack>
26 #include <string_view>
27 #include <tuple>
28 #include <vector>
29 #include <com/sun/star/container/XIndexReplace.hpp>
30 #include <xmloff/xmlictxt.hxx>
32 class SvXMLImport;
33 class XMLTextListBlockContext;
34 class XMLTextListItemContext;
35 class XMLNumberedParaContext;
37 class XMLTextListsHelper
39 public:
40 XMLTextListsHelper();
41 XMLTextListsHelper(const XMLTextListsHelper&) = delete;
42 XMLTextListsHelper& operator=(const XMLTextListsHelper&) = delete;
44 /// list stack for importing:
46 /// push a list context on the list context stack
47 void PushListContext(XMLTextListBlockContext *i_pListBlock);
48 void PushListContext(XMLNumberedParaContext *i_pNumberedParagraph);
49 /// pop the list context stack
50 void PopListContext();
51 /// peek at the top of the list context stack
52 void ListContextTop(XMLTextListBlockContext*& o_pListBlockContext,
53 XMLTextListItemContext*& o_pListItemContext,
54 XMLNumberedParaContext*& o_pNumberedParagraphContext );
55 /// set list item on top of the list context stack
56 void SetListItem( XMLTextListItemContext *pListItem );
59 // keeping track of processed lists for import and export
60 // Add optional parameter <sListStyleDefaultListId> (#i92811#)
61 void KeepListAsProcessed( const OUString& sListId,
62 const OUString& sListStyleName,
63 const OUString& sContinueListId,
64 const OUString& sListStyleDefaultListId = OUString() );
66 bool IsListProcessed( const OUString& sListId ) const;
67 const OUString & GetListStyleOfProcessedList(
68 const OUString& sListId ) const;
69 const OUString & GetContinueListIdOfProcessedList(
70 const OUString& sListId ) const;
71 const OUString& GetLastProcessedListId() const { return msLastProcessedListId;}
72 const OUString& GetListStyleOfLastProcessedList() const { return msListStyleOfLastProcessedList;}
74 OUString GenerateNewListId() const;
76 // Provide list id for a certain list block for import (#i92811#)
77 OUString GetListIdForListBlock( XMLTextListBlockContext const & rListBlock );
79 // keep track of continue list chain for export
80 void StoreLastContinuingList( const OUString& sListId,
81 const OUString& sContinuingListId );
83 OUString GetLastContinuingListId( const OUString& sListId ) const;
85 // keep track of opened list elements of a certain list for export
86 void PushListOnStack( const OUString& sListId,
87 const OUString& sListStyleName );
88 void PopListFromStack();
89 bool EqualsToTopListStyleOnStack( std::u16string_view sListId ) const;
91 /** for importing numbered-paragraph
92 note that the ID namespace for numbered-paragraph and regular list
93 is distinct; we never combine a list and a n-p
95 css::uno::Reference< css::container::XIndexReplace>
96 EnsureNumberedParagraph(
97 SvXMLImport & i_rImport,
98 const OUString& i_ListId,
99 sal_Int16 & io_rLevel, const OUString& i_StyleName);
101 /// get ID of the last numbered-paragraph iff it has given style-name
102 OUString GetNumberedParagraphListId(
103 const sal_uInt16 i_Level,
104 std::u16string_view i_StyleName);
106 /** Creates a NumRule from given style-name.
107 @param i_rImport the SvXMLImport
108 @param i_xNumRule parent num rule
109 @param i_ParentStyleName parent list style name
110 @param i_StyleName the list style name
111 @param io_rLevel the list level (may be reset if too large)
112 @param o_rRestartNumbering set to true if no style (defaulting)
113 @param io_rSetDefaults set to true if no style (defaulting)
115 static css::uno::Reference< css::container::XIndexReplace> MakeNumRule(
116 SvXMLImport & i_rImport,
117 const css::uno::Reference< css::container::XIndexReplace>& i_xNumRule,
118 std::u16string_view i_ParentStyleName,
119 const OUString& i_StyleName,
120 sal_Int16 & io_rLevel,
121 bool* o_pRestartNumbering = nullptr,
122 bool* io_pSetDefaults = nullptr);
124 /// Looks up the last list id of a given list style, by name.
125 OUString GetLastIdOfStyleName(const OUString& sListStyleName) const;
127 private:
129 /** list context: list, list-item, numbered-paragraph
130 XMLTextListBlockContext, XMLTextListItemContext,
131 XMLNumberedParaContext
133 typedef std::tuple<SvXMLImportContextRef,
134 SvXMLImportContextRef, SvXMLImportContextRef> ListStackFrame_t;
135 std::stack< ListStackFrame_t > mListStack;
137 // container type for processed lists:
138 // map with <ListId> as key and pair( <ListStyleName, ContinueListId> )
139 // as value
140 typedef ::std::map< OUString,
141 ::std::pair< OUString, OUString > > tMapForLists;
142 std::unique_ptr<tMapForLists> mpProcessedLists;
143 OUString msLastProcessedListId;
144 OUString msListStyleOfLastProcessedList;
146 /* additional container for processed lists.
147 map with <ListStyleName> as key and pair( <ListId, ListStyleDefaultListId> )
148 as value. (#i92811#)
150 std::unique_ptr<tMapForLists> mpMapListIdToListStyleDefaultListId;
152 // container type to build up continue list chain:
153 // map with <ListId> of master list as key and <ListId> of last list
154 // continuing the master list as value
155 typedef ::std::map< OUString, OUString > tMapForContinuingLists;
156 std::unique_ptr<tMapForContinuingLists> mpContinuingLists;
158 std::unique_ptr<std::map<OUString, OUString>> mpStyleNameLastListIds;
160 // stack type for opened list elements and its list style:
161 // vector with pair( <ListId>, <ListStyleName> ) as value
162 typedef ::std::vector< ::std::pair< OUString, OUString > >
163 tStackForLists;
164 std::unique_ptr<tStackForLists> mpListStack;
166 /// to connect numbered-paragraphs that have no list-id attribute:
167 /// vector of pair of style-name and list-id (indexed by level)
168 typedef ::std::vector< ::std::pair< OUString, OUString > >
169 LastNumberedParagraphs_t;
171 LastNumberedParagraphs_t mLastNumberedParagraphs;
173 /// numbered-paragraphs
174 typedef ::std::vector<
175 ::std::pair<
176 OUString,
177 css::uno::Reference< css::container::XIndexReplace > > > NumParaList_t;
178 ::std::map< OUString, NumParaList_t > mNPLists;
182 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */