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