1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 #ifndef _SWSELECTIONLIST_HXX 24 #define _SWSELECTIONLIST_HXX 25 26 #include <list> 27 28 class SwPaM; 29 class SwFrm; 30 31 /** This class is used as parameter for creation of a block cursor selection 32 33 This class will be created by a block cursor. Its responsibility is 34 to collect a group of selected text portions which are part of a common 35 context. 36 Definition of context: 37 A page header is a context. 38 A page footer is a context. 39 A footnote is a context. 40 Every fly frame builds a context together with its linked colleagues. 41 The content of the page bodies builds a context. 42 */ 43 44 class SwSelectionList 45 { 46 std::list< SwPaM* > aList; // container for the selected text portions 47 const SwFrm* pContext; // the context of these text portions 48 public: 49 /** Ctor to create an empty list for a given context 50 51 @param pInitCxt 52 The frame (normally a SwTxtFrm) where the block cursor selection starts, 53 it will be used to get the allowed context for the text selections. 54 */ 55 explicit SwSelectionList( const SwFrm* pInitCxt ); 56 57 /** Start of the container for the selected text portions 58 */ getStart()59 std::list<SwPaM*>::iterator getStart() { return aList.begin(); } 60 61 /** End of the container for the selected text portions 62 */ getEnd()63 std::list<SwPaM*>::iterator getEnd() { return aList.end(); } 64 65 /** Adds a text portion to the selection list 66 67 @param pPam 68 represents a text portion to select 69 */ insertPaM(SwPaM * pPam)70 void insertPaM( SwPaM* pPam ) { aList.push_front( pPam ); } 71 72 /** Reports if the list does not contain any text portion 73 74 @return true, if list is empty 75 */ isEmpty() const76 bool isEmpty() const { return aList.empty(); } 77 78 /** Checks if the context of the list is equal to the context of the frame 79 80 If the list does not have already a context, the context of the frame 81 will define the list's context. 82 If the list has already a context, it will be compared to the context of 83 the given frame. 84 85 @param pCheck 86 The frame to check 87 88 @return true, if the context of the frame is equal to the one of the list 89 */ 90 bool checkContext( const SwFrm* pCheck ); 91 }; 92 93 #endif //_SWSELECTIONLIST_HXX 94