Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / sw / source / core / layout / swselectionlist.cxx
blobb7628cbac93a691cf94ae57464fc612b38d5cbc8
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 #include <swselectionlist.hxx>
21 #include <flyfrm.hxx>
22 #include <ftnfrm.hxx>
24 /** This class is used as parameter for functions to create a rectangular text selection
27 namespace {
29 /** Find the context of a given frame
31 A context is the environment where text is allowed to flow.
32 The context is represented by
33 - the SwRootFrame if the frame is part of a page body
34 - the SwHeaderFrame if the frame is part of a page header
35 - the SwFooterFrame if the frame is part of a page footer
36 - the (master) SwFootnoteFrame if the frame is part of footnote
37 - the (first) SwFlyFrame if the frame is part of a (linked) fly frame
39 @param pFrame
40 the given frame
42 @return the context of the frame, represented by a SwFrame*
44 const SwFrame* getContext( const SwFrame* pFrame )
46 while( pFrame )
48 if( pFrame->IsRootFrame() || pFrame->IsHeaderFrame() || pFrame->IsFooterFrame() )
49 break;
50 if( pFrame->IsFlyFrame() )
52 const SwFlyFrame* pFly = static_cast<const SwFlyFrame*>( pFrame );
53 while( pFly->GetPrevLink() )
54 pFly = pFly->GetPrevLink();
55 break;
57 if( pFrame->IsFootnoteFrame() )
59 const SwFootnoteFrame* pFootnote = static_cast<const SwFootnoteFrame*>( pFrame );
60 while( pFootnote->GetMaster() )
61 pFootnote = pFootnote->GetMaster();
62 break;
64 pFrame = pFrame->GetUpper();
66 return pFrame;
70 SwSelectionList::SwSelectionList( const SwFrame* pInitCxt ) :
71 m_pContext( getContext( pInitCxt ) )
75 bool SwSelectionList::checkContext( const SwFrame* pCheck )
77 pCheck = getContext( pCheck );
78 if( !m_pContext )
79 m_pContext = pCheck;
80 return m_pContext == pCheck;
83 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */