LibreOffice Module xmloff (master) 1
txtlists.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 <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>
31
32class SvXMLImport;
36
38{
39 public:
43
45
47 void PushListContext(XMLTextListBlockContext *i_pListBlock);
48 void PushListContext(XMLNumberedParaContext *i_pNumberedParagraph);
50 void PopListContext();
52 void ListContextTop(XMLTextListBlockContext*& o_pListBlockContext,
53 XMLTextListItemContext*& o_pListItemContext,
54 XMLNumberedParaContext*& o_pNumberedParagraphContext );
56 void SetListItem( XMLTextListItemContext *pListItem );
57
58
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() );
65
66 bool IsListProcessed( const OUString& sListId ) const;
68 const OUString& sListId ) const;
70 const OUString& sListId ) const;
71 const OUString& GetLastProcessedListId() const { return msLastProcessedListId;}
73
74 OUString GenerateNewListId() const;
75
76 // Provide list id for a certain list block for import (#i92811#)
77 OUString GetListIdForListBlock( XMLTextListBlockContext const & rListBlock );
78
79 // keep track of continue list chain for export
80 void StoreLastContinuingList( const OUString& sListId,
81 const OUString& sContinuingListId );
82
83 OUString GetLastContinuingListId( const OUString& sListId ) const;
84
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;
90
95 css::uno::Reference< css::container::XIndexReplace>
97 SvXMLImport & i_rImport,
98 const OUString& i_ListId,
99 sal_Int16 & io_rLevel, const OUString& i_StyleName);
100
103 const sal_uInt16 i_Level,
104 std::u16string_view i_StyleName);
105
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);
123
125 OUString GetLastIdOfStyleName(const OUString& sListStyleName) const;
126
127 private:
128
133 typedef std::tuple<SvXMLImportContextRef,
135 std::stack< ListStackFrame_t > mListStack;
136
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;
145
146 /* additional container for processed lists.
147 map with <ListStyleName> as key and pair( <ListId, ListStyleDefaultListId> )
148 as value. (#i92811#)
149 */
150 std::unique_ptr<tMapForLists> mpMapListIdToListStyleDefaultListId;
151
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;
157
158 std::unique_ptr<std::map<OUString, OUString>> mpStyleNameLastListIds;
159
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 > >
164 std::unique_ptr<tStackForLists> mpListStack;
165
168 typedef ::std::vector< ::std::pair< OUString, OUString > >
170
172
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;
179
180};
181
182/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void PopListContext()
pop the list context stack
Definition: txtlists.cxx:65
OUString msListStyleOfLastProcessedList
Definition: txtlists.hxx:144
bool EqualsToTopListStyleOnStack(std::u16string_view sListId) const
Definition: txtlists.cxx:307
std::unique_ptr< tMapForLists > mpProcessedLists
Definition: txtlists.hxx:142
::std::map< OUString, OUString > tMapForContinuingLists
Definition: txtlists.hxx:155
void StoreLastContinuingList(const OUString &sListId, const OUString &sContinuingListId)
Definition: txtlists.cxx:260
::std::vector< ::std::pair< OUString, OUString > > LastNumberedParagraphs_t
to connect numbered-paragraphs that have no list-id attribute: vector of pair of style-name and list-...
Definition: txtlists.hxx:169
XMLTextListsHelper & operator=(const XMLTextListsHelper &)=delete
const OUString & GetLastProcessedListId() const
Definition: txtlists.hxx:71
void PopListFromStack()
Definition: txtlists.cxx:298
std::unique_ptr< std::map< OUString, OUString > > mpStyleNameLastListIds
Definition: txtlists.hxx:158
void SetListItem(XMLTextListItemContext *pListItem)
set list item on top of the list context stack
Definition: txtlists.cxx:87
XMLTextListsHelper(const XMLTextListsHelper &)=delete
::std::vector< ::std::pair< OUString, css::uno::Reference< css::container::XIndexReplace > > > NumParaList_t
numbered-paragraphs
Definition: txtlists.hxx:177
void KeepListAsProcessed(const OUString &sListId, const OUString &sListStyleName, const OUString &sContinueListId, const OUString &sListStyleDefaultListId=OUString())
Definition: txtlists.cxx:103
OUString GetNumberedParagraphListId(const sal_uInt16 i_Level, std::u16string_view i_StyleName)
get ID of the last numbered-paragraph iff it has given style-name
Definition: txtlists.cxx:313
void PushListContext(XMLTextListBlockContext *i_pListBlock)
list stack for importing:
Definition: txtlists.cxx:49
OUString GenerateNewListId() const
Definition: txtlists.cxx:194
std::unique_ptr< tMapForLists > mpMapListIdToListStyleDefaultListId
Definition: txtlists.hxx:150
::std::vector< ::std::pair< OUString, OUString > > tStackForLists
Definition: txtlists.hxx:163
static css::uno::Reference< css::container::XIndexReplace > MakeNumRule(SvXMLImport &i_rImport, const css::uno::Reference< css::container::XIndexReplace > &i_xNumRule, std::u16string_view i_ParentStyleName, const OUString &i_StyleName, sal_Int16 &io_rLevel, bool *o_pRestartNumbering=nullptr, bool *io_pSetDefaults=nullptr)
Creates a NumRule from given style-name.
Definition: txtlists.cxx:407
std::unique_ptr< tMapForContinuingLists > mpContinuingLists
Definition: txtlists.hxx:156
OUString GetListIdForListBlock(XMLTextListBlockContext const &rListBlock)
Definition: txtlists.cxx:230
OUString msLastProcessedListId
Definition: txtlists.hxx:143
::std::map< OUString, NumParaList_t > mNPLists
Definition: txtlists.hxx:178
OUString GetListStyleOfProcessedList(const OUString &sListId) const
Definition: txtlists.cxx:163
void ListContextTop(XMLTextListBlockContext *&o_pListBlockContext, XMLTextListItemContext *&o_pListItemContext, XMLNumberedParaContext *&o_pNumberedParagraphContext)
peek at the top of the list context stack
Definition: txtlists.cxx:72
std::stack< ListStackFrame_t > mListStack
Definition: txtlists.hxx:135
std::tuple< SvXMLImportContextRef, SvXMLImportContextRef, SvXMLImportContextRef > ListStackFrame_t
list context: list, list-item, numbered-paragraph XMLTextListBlockContext, XMLTextListItemContext,...
Definition: txtlists.hxx:134
bool IsListProcessed(const OUString &sListId) const
Definition: txtlists.cxx:153
std::unique_ptr< tStackForLists > mpListStack
Definition: txtlists.hxx:164
LastNumberedParagraphs_t mLastNumberedParagraphs
Definition: txtlists.hxx:171
OUString GetContinueListIdOfProcessedList(const OUString &sListId) const
Definition: txtlists.cxx:178
void PushListOnStack(const OUString &sListId, const OUString &sListStyleName)
Definition: txtlists.cxx:287
const OUString & GetListStyleOfLastProcessedList() const
Definition: txtlists.hxx:72
OUString GetLastContinuingListId(const OUString &sListId) const
Definition: txtlists.cxx:271
css::uno::Reference< css::container::XIndexReplace > EnsureNumberedParagraph(SvXMLImport &i_rImport, const OUString &i_ListId, sal_Int16 &io_rLevel, const OUString &i_StyleName)
for importing numbered-paragraph note that the ID namespace for numbered-paragraph and regular list i...
Definition: txtlists.cxx:346
::std::map< OUString, ::std::pair< OUString, OUString > > tMapForLists
Definition: txtlists.hxx:141
OUString GetLastIdOfStyleName(const OUString &sListStyleName) const
Looks up the last list id of a given list style, by name.
Definition: txtlists.cxx:483
rtl::Reference< SvXMLImportContext > SvXMLImportContextRef
Definition: xmlictxt.hxx:37