lwp build fixes
[LibreOffice.git] / xmloff / inc / txtlists.hxx
blob891fb7967337728507b18b926f1da2d89d630444
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 #ifndef INCLUDED_XMLOFF_INC_TXTLISTS_HXX
21 #define INCLUDED_XMLOFF_INC_TXTLISTS_HXX
23 #include <rtl/ustring.hxx>
24 #include <map>
25 #include <vector>
26 #include <stack>
27 #include <boost/utility.hpp>
28 #include <boost/tuple/tuple.hpp>
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 : private boost::noncopyable
39 public:
40 XMLTextListsHelper();
41 ~XMLTextListsHelper();
43 /// list stack for importing:
45 /// push a list context on the list context stack
46 void PushListContext(XMLTextListBlockContext *i_pListBlock = 0);
47 void PushListContext(XMLNumberedParaContext *i_pNumberedParagraph);
48 /// pop the list context stack
49 void PopListContext();
50 /// peek at the top of the list context stack
51 void ListContextTop(XMLTextListBlockContext*& o_pListBlockContext,
52 XMLTextListItemContext*& o_pListItemContext,
53 XMLNumberedParaContext*& o_pNumberedParagraphContext );
54 /// set list item on top of the list context stack
55 void SetListItem( XMLTextListItemContext *pListItem );
58 // keeping track of processed lists for import and export
59 // Add optional parameter <sListStyleDefaultListId> (#i92811#)
60 void KeepListAsProcessed( const OUString& sListId,
61 const OUString& sListStyleName,
62 const OUString& sContinueListId,
63 const OUString& sListStyleDefaultListId = OUString() );
65 bool IsListProcessed( const OUString& sListId ) const;
66 OUString GetListStyleOfProcessedList(
67 const OUString& sListId ) const;
68 OUString GetContinueListIdOfProcessedList(
69 const OUString& sListId ) const;
70 const OUString& GetLastProcessedListId() const { return msLastProcessedListId;}
71 const OUString& GetListStyleOfLastProcessedList() const { return msListStyleOfLastProcessedList;}
73 OUString GenerateNewListId() const;
75 // Provide list id for a certain list block for import (#i92811#)
76 OUString GetListIdForListBlock( XMLTextListBlockContext& rListBlock );
78 // keep track of continue list chain for export
79 void StoreLastContinuingList( const OUString& sListId,
80 const OUString& sContinuingListId );
82 OUString GetLastContinuingListId( const OUString& sListId ) const;
84 // keep track of opened list elements of a certain list for export
85 void PushListOnStack( const OUString& sListId,
86 const OUString& sListStyleName );
87 void PopListFromStack();
88 bool EqualsToTopListStyleOnStack( const OUString& sListId ) const;
90 /** for importing numbered-paragraph
91 note that the ID namespace for numbered-paragraph and regular list
92 is distinct; we never combine a list and a n-p
94 ::com::sun::star::uno::Reference<
95 ::com::sun::star::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 const OUString& 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 ::com::sun::star::uno::Reference<
116 ::com::sun::star::container::XIndexReplace> MakeNumRule(
117 SvXMLImport & i_rImport,
118 const ::com::sun::star::uno::Reference<
119 ::com::sun::star::container::XIndexReplace>& i_xNumRule,
120 const OUString& i_ParentStyleName,
121 const OUString& i_StyleName,
122 sal_Int16 & io_rLevel,
123 bool* o_pRestartNumbering = 0,
124 bool* io_pSetDefaults = 0);
126 private:
128 /** list context: list, list-item, numbered-paragraph
129 XMLTextListBlockContext, XMLTextListItemContext,
130 XMLNumberedParaContext
132 typedef ::boost::tuple<SvXMLImportContextRef,
133 SvXMLImportContextRef, SvXMLImportContextRef> ListStackFrame_t;
134 ::std::stack< ListStackFrame_t > mListStack;
136 // container type for processed lists:
137 // map with <ListId> as key and pair( <ListStyleName, ContinueListId> )
138 // as value
139 typedef ::std::map< OUString,
140 ::std::pair< OUString, OUString > > tMapForLists;
141 tMapForLists* mpProcessedLists;
142 OUString msLastProcessedListId;
143 OUString msListStyleOfLastProcessedList;
145 /* additional container for processed lists.
146 map with <ListStyleName> as key and pair( <ListId, ListStyleDefaultListId> )
147 as value. (#i92811#)
149 tMapForLists* mpMapListIdToListStyleDefaultListId;
151 // container type to build up continue list chain:
152 // map with <ListId> of master list as key and <ListId> of last list
153 // continuing the master list as value
154 typedef ::std::map< OUString, OUString > tMapForContinuingLists;
155 tMapForContinuingLists* mpContinuingLists;
157 // stack type for opened list elements and its list style:
158 // vector with pair( <ListId>, <ListStyleName> ) as value
159 typedef ::std::vector< ::std::pair< OUString, OUString > >
160 tStackForLists;
161 tStackForLists* mpListStack;
163 /// to connect numbered-paragraphs that have no list-id attribute:
164 /// vector of pair of style-name and list-id (indexed by level)
165 typedef ::std::vector< ::std::pair< OUString, OUString > >
166 LastNumberedParagraphs_t;
168 LastNumberedParagraphs_t mLastNumberedParagraphs;
170 /// numbered-paragraphs
171 typedef ::std::vector< ::std::pair< OUString,
172 ::com::sun::star::uno::Reference<
173 ::com::sun::star::container::XIndexReplace > > > NumParaList_t;
174 ::std::map< OUString, NumParaList_t > mNPLists;
177 #endif
179 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */