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 "portox.hxx"
33 : : #include "inftxt.hxx" // GetTxtSize()
34 : :
35 : : /*************************************************************************
36 : : * virtual SwToxPortion::Paint()
37 : : *************************************************************************/
38 : :
39 : 51 : void SwToxPortion::Paint( const SwTxtPaintInfo &rInf ) const
40 : : {
41 [ + - ]: 51 : if( Width() )
42 : : {
43 : 51 : rInf.DrawViewOpt( *this, POR_TOX );
44 : 51 : SwTxtPortion::Paint( rInf );
45 : : }
46 : 51 : }
47 : :
48 : : /*************************************************************************
49 : : * class SwIsoToxPortion
50 : : *************************************************************************/
51 : :
52 : 112 : SwLinePortion *SwIsoToxPortion::Compress() { return this; }
53 : :
54 : 112 : SwIsoToxPortion::SwIsoToxPortion() : nViewWidth(0)
55 : : {
56 : 112 : SetLen(1);
57 : 112 : SetWhichPor( POR_ISOTOX );
58 : 112 : }
59 : :
60 : : /*************************************************************************
61 : : * virtual SwIsoToxPortion::GetViewWidth()
62 : : *************************************************************************/
63 : :
64 : 182 : KSHORT SwIsoToxPortion::GetViewWidth( const SwTxtSizeInfo &rInf ) const
65 : : {
66 : : // Although we are const, nViewWidth should be calculated in the last
67 : : // moment possible
68 : 182 : SwIsoToxPortion* pThis = (SwIsoToxPortion*)this;
69 : : // nViewWidth need to be calculated
70 [ + - ][ + - : 728 : if( !Width() && rInf.OnWin() &&
+ - + - +
- ][ + - ]
71 : 182 : !rInf.GetOpt().IsPagePreview() &&
72 : 364 : !rInf.GetOpt().IsReadonly() && SwViewOption::IsFieldShadings() )
73 : : {
74 [ + + ]: 182 : if( !nViewWidth )
75 [ + - ][ + - ]: 110 : pThis->nViewWidth = rInf.GetTxtSize(rtl::OUString(' ')).Width();
[ + - ]
76 : : }
77 : : else
78 : 0 : pThis->nViewWidth = 0;
79 : 182 : return nViewWidth;
80 : : }
81 : :
82 : : /*************************************************************************
83 : : * virtual SwIsoToxPortion::Format()
84 : : *************************************************************************/
85 : :
86 : 112 : sal_Bool SwIsoToxPortion::Format( SwTxtFormatInfo &rInf )
87 : : {
88 : 112 : const sal_Bool bFull = SwLinePortion::Format( rInf );
89 : 112 : return bFull;
90 : : }
91 : :
92 : : /*************************************************************************
93 : : * virtual SwIsoToxPortion::Paint()
94 : : *************************************************************************/
95 : :
96 : 308 : void SwIsoToxPortion::Paint( const SwTxtPaintInfo &rInf ) const
97 : : {
98 [ + + ]: 308 : if( Width() )
99 : 182 : rInf.DrawViewOpt( *this, POR_TOX );
100 : 308 : }
101 : :
102 : : /*************************************************************************
103 : : * virtual SwIsoToxPortion::HandlePortion()
104 : : *************************************************************************/
105 : :
106 : 0 : void SwIsoToxPortion::HandlePortion( SwPortionHandler& rPH ) const
107 : : {
108 [ # # ]: 0 : String aString;
109 [ # # ][ # # ]: 0 : rPH.Special( GetLen(), aString, GetWhichPor() );
110 : 0 : }
111 : :
112 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|