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 24 // MARKER(update_precomp.py): autogen include statement, do not remove 25 #include "precompiled_sw.hxx" 26 27 #include <swselectionlist.hxx> 28 #include <layfrm.hxx> 29 #include <flyfrm.hxx> 30 #include <ftnfrm.hxx> 31 32 /** This class is used as parameter for functions to create a rectangular text selection 33 */ 34 35 namespace { 36 37 /** Find the context of a given frame 38 39 A context is the environment where text is allowed to flow. 40 The context is represented by 41 - the SwRootFrm if the frame is part of a page body 42 - the SwHeaderFrm if the frame is part of a page header 43 - the SwFooterFrm if the frame is part of a page footer 44 - the (master) SwFtnFrm if the frame is part of footnote 45 - the (first) SwFlyFrm if the frame is part of a (linked) fly frame 46 47 @param pFrm 48 the given frame 49 50 @return the context of the frame, represented by a SwFrm* 51 */ getContext(const SwFrm * pFrm)52 const SwFrm* getContext( const SwFrm* pFrm ) 53 { 54 while( pFrm ) 55 { 56 if( pFrm->IsRootFrm() || pFrm->IsHeaderFrm() || pFrm->IsFooterFrm() ) 57 break; 58 if( pFrm->IsFlyFrm() ) 59 { 60 const SwFlyFrm* pFly = static_cast<const SwFlyFrm*>( pFrm ); 61 while( pFly->GetPrevLink() ) 62 pFly = pFly->GetPrevLink(); 63 break; 64 } 65 if( pFrm->IsFtnFrm() ) 66 { 67 const SwFtnFrm* pFtn = static_cast<const SwFtnFrm*>( pFrm ); 68 while( pFtn->GetMaster() ) 69 pFtn = pFtn->GetMaster(); 70 break; 71 } 72 pFrm = pFrm->GetUpper(); 73 } 74 return pFrm; 75 } 76 } 77 SwSelectionList(const SwFrm * pInitCxt)78SwSelectionList::SwSelectionList( const SwFrm* pInitCxt ) : 79 pContext( getContext( pInitCxt ) ) 80 { 81 } 82 checkContext(const SwFrm * pCheck)83bool SwSelectionList::checkContext( const SwFrm* pCheck ) 84 { 85 pCheck = getContext( pCheck ); 86 if( !pContext ) 87 pContext = pCheck; 88 return pContext == pCheck; 89 } 90 91