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 : #include <SwPortionHandler.hxx>
21 : #include "viewopt.hxx" // SwViewOptions
22 :
23 : #include "porref.hxx"
24 : #include "inftxt.hxx" // GetTxtSize()
25 :
26 : /*************************************************************************
27 : * virtual SwRefPortion::Paint()
28 : *************************************************************************/
29 :
30 0 : void SwRefPortion::Paint( const SwTxtPaintInfo &rInf ) const
31 : {
32 0 : if( Width() )
33 : {
34 0 : rInf.DrawViewOpt( *this, POR_REF );
35 0 : SwTxtPortion::Paint( rInf );
36 : }
37 0 : }
38 :
39 : /*************************************************************************
40 : * class SwIsoRefPortion
41 : *************************************************************************/
42 :
43 0 : SwLinePortion *SwIsoRefPortion::Compress() { return this; }
44 :
45 0 : SwIsoRefPortion::SwIsoRefPortion() : nViewWidth(0)
46 : {
47 0 : SetLen(1);
48 0 : SetWhichPor( POR_ISOREF );
49 0 : }
50 :
51 : /*************************************************************************
52 : * virtual SwIsoRefPortion::GetViewWidth()
53 : *************************************************************************/
54 :
55 0 : KSHORT SwIsoRefPortion::GetViewWidth( const SwTxtSizeInfo &rInf ) const
56 : {
57 : // Although we are const, nViewWidth should be calculated in the last
58 : // moment possible
59 0 : SwIsoRefPortion* pThis = (SwIsoRefPortion*)this;
60 0 : if( !Width() && rInf.OnWin() && SwViewOption::IsFieldShadings() &&
61 0 : !rInf.GetOpt().IsReadonly() && !rInf.GetOpt().IsPagePreview() )
62 : {
63 0 : if( !nViewWidth )
64 0 : pThis->nViewWidth = rInf.GetTxtSize(OUString(' ')).Width();
65 : }
66 : else
67 0 : pThis->nViewWidth = 0;
68 0 : return nViewWidth;
69 : }
70 :
71 : /*************************************************************************
72 : * virtual SwIsoRefPortion::Format()
73 : *************************************************************************/
74 :
75 0 : sal_Bool SwIsoRefPortion::Format( SwTxtFormatInfo &rInf )
76 : {
77 0 : const sal_Bool bFull = SwLinePortion::Format( rInf );
78 0 : return bFull;
79 : }
80 :
81 : /*************************************************************************
82 : * virtual SwIsoRefPortion::Paint()
83 : *************************************************************************/
84 :
85 0 : void SwIsoRefPortion::Paint( const SwTxtPaintInfo &rInf ) const
86 : {
87 0 : if( Width() )
88 0 : rInf.DrawViewOpt( *this, POR_REF );
89 0 : }
90 :
91 : /*************************************************************************
92 : * virtual SwIsoRefPortion::HandlePortion()
93 : *************************************************************************/
94 :
95 0 : void SwIsoRefPortion::HandlePortion( SwPortionHandler& rPH ) const
96 : {
97 0 : String aString;
98 0 : rPH.Special( GetLen(), aString, GetWhichPor() );
99 0 : }
100 :
101 :
102 :
103 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|