Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #include <SwPortionHandler.hxx>
30 : : #include "viewopt.hxx" // SwViewOptions
31 : :
32 : : #include "porref.hxx"
33 : : #include "inftxt.hxx" // GetTxtSize()
34 : :
35 : : /*************************************************************************
36 : : * virtual SwRefPortion::Paint()
37 : : *************************************************************************/
38 : :
39 : 37 : void SwRefPortion::Paint( const SwTxtPaintInfo &rInf ) const
40 : : {
41 [ + - ]: 37 : if( Width() )
42 : : {
43 : 37 : rInf.DrawViewOpt( *this, POR_REF );
44 : 37 : SwTxtPortion::Paint( rInf );
45 : : }
46 : 37 : }
47 : :
48 : : /*************************************************************************
49 : : * class SwIsoRefPortion
50 : : *************************************************************************/
51 : :
52 : 150 : SwLinePortion *SwIsoRefPortion::Compress() { return this; }
53 : :
54 : 150 : SwIsoRefPortion::SwIsoRefPortion() : nViewWidth(0)
55 : : {
56 : 150 : SetLen(1);
57 : 150 : SetWhichPor( POR_ISOREF );
58 : 150 : }
59 : :
60 : : /*************************************************************************
61 : : * virtual SwIsoRefPortion::GetViewWidth()
62 : : *************************************************************************/
63 : :
64 : 207 : KSHORT SwIsoRefPortion::GetViewWidth( const SwTxtSizeInfo &rInf ) const
65 : : {
66 : : // Although we are const, nViewWidth should be calculated in the last
67 : : // moment possible
68 : 207 : SwIsoRefPortion* pThis = (SwIsoRefPortion*)this;
69 [ + - ][ + - ]: 621 : if( !Width() && rInf.OnWin() && SwViewOption::IsFieldShadings() &&
[ + - + -
+ - ][ + - ]
70 : 414 : !rInf.GetOpt().IsReadonly() && !rInf.GetOpt().IsPagePreview() )
71 : : {
72 [ + + ]: 207 : if( !nViewWidth )
73 [ + - ][ + - ]: 121 : pThis->nViewWidth = rInf.GetTxtSize(rtl::OUString(' ')).Width();
[ + - ]
74 : : }
75 : : else
76 : 0 : pThis->nViewWidth = 0;
77 : 207 : return nViewWidth;
78 : : }
79 : :
80 : : /*************************************************************************
81 : : * virtual SwIsoRefPortion::Format()
82 : : *************************************************************************/
83 : :
84 : 150 : sal_Bool SwIsoRefPortion::Format( SwTxtFormatInfo &rInf )
85 : : {
86 : 150 : const sal_Bool bFull = SwLinePortion::Format( rInf );
87 : 150 : return bFull;
88 : : }
89 : :
90 : : /*************************************************************************
91 : : * virtual SwIsoRefPortion::Paint()
92 : : *************************************************************************/
93 : :
94 : 346 : void SwIsoRefPortion::Paint( const SwTxtPaintInfo &rInf ) const
95 : : {
96 [ + + ]: 346 : if( Width() )
97 : 207 : rInf.DrawViewOpt( *this, POR_REF );
98 : 346 : }
99 : :
100 : : /*************************************************************************
101 : : * virtual SwIsoRefPortion::HandlePortion()
102 : : *************************************************************************/
103 : :
104 : 0 : void SwIsoRefPortion::HandlePortion( SwPortionHandler& rPH ) const
105 : : {
106 [ # # ]: 0 : String aString;
107 [ # # ][ # # ]: 0 : rPH.Special( GetLen(), aString, GetWhichPor() );
108 : 0 : }
109 : :
110 : :
111 : :
112 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|