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"
22 :
23 : #include "porref.hxx"
24 : #include "inftxt.hxx"
25 :
26 36 : void SwRefPortion::Paint( const SwTxtPaintInfo &rInf ) const
27 : {
28 36 : if( Width() )
29 : {
30 36 : rInf.DrawViewOpt( *this, POR_REF );
31 36 : SwTxtPortion::Paint( rInf );
32 : }
33 36 : }
34 :
35 152 : SwLinePortion *SwIsoRefPortion::Compress() { return this; }
36 :
37 152 : SwIsoRefPortion::SwIsoRefPortion() : nViewWidth(0)
38 : {
39 152 : SetLen(1);
40 152 : SetWhichPor( POR_ISOREF );
41 152 : }
42 :
43 196 : sal_uInt16 SwIsoRefPortion::GetViewWidth( const SwTxtSizeInfo &rInf ) const
44 : {
45 : // Although we are const, nViewWidth should be calculated in the last
46 : // moment possible
47 196 : SwIsoRefPortion* pThis = (SwIsoRefPortion*)this;
48 784 : if( !Width() && rInf.OnWin() && SwViewOption::IsFieldShadings() &&
49 588 : !rInf.GetOpt().IsReadonly() && !rInf.GetOpt().IsPagePreview() )
50 : {
51 196 : if( !nViewWidth )
52 122 : pThis->nViewWidth = rInf.GetTxtSize(OUString(' ')).Width();
53 : }
54 : else
55 0 : pThis->nViewWidth = 0;
56 196 : return nViewWidth;
57 : }
58 :
59 152 : bool SwIsoRefPortion::Format( SwTxtFormatInfo &rInf )
60 : {
61 152 : return SwLinePortion::Format( rInf );
62 : }
63 :
64 324 : void SwIsoRefPortion::Paint( const SwTxtPaintInfo &rInf ) const
65 : {
66 324 : if( Width() )
67 196 : rInf.DrawViewOpt( *this, POR_REF );
68 324 : }
69 :
70 0 : void SwIsoRefPortion::HandlePortion( SwPortionHandler& rPH ) const
71 : {
72 0 : rPH.Special( GetLen(), OUString(), GetWhichPor() );
73 270 : }
74 :
75 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|