xref: /trunk/main/sw/source/core/text/porref.cxx (revision efeef26f)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_sw.hxx"
26 
27 
28 #include <SwPortionHandler.hxx>
29 #include "viewopt.hxx"	// SwViewOptions
30 
31 #include "txtcfg.hxx"
32 #include "porref.hxx"
33 #include "inftxt.hxx"       // GetTxtSize()
34 
35 /*************************************************************************
36  *               virtual SwRefPortion::Paint()
37  *************************************************************************/
38 
Paint(const SwTxtPaintInfo & rInf) const39 void SwRefPortion::Paint( const SwTxtPaintInfo &rInf ) const
40 {
41 	if( Width() )
42 	{
43 		rInf.DrawViewOpt( *this, POR_REF );
44 		SwTxtPortion::Paint( rInf );
45 	}
46 }
47 
48 /*************************************************************************
49  *                      class SwIsoRefPortion
50  *************************************************************************/
51 
Compress()52 SwLinePortion *SwIsoRefPortion::Compress() { return this; }
53 
SwIsoRefPortion()54 SwIsoRefPortion::SwIsoRefPortion() : nViewWidth(0)
55 {
56 	SetLen(1);
57 	SetWhichPor( POR_ISOREF );
58 }
59 
60 /*************************************************************************
61  *				 virtual SwIsoRefPortion::GetViewWidth()
62  *************************************************************************/
63 
GetViewWidth(const SwTxtSizeInfo & rInf) const64 KSHORT SwIsoRefPortion::GetViewWidth( const SwTxtSizeInfo &rInf ) const
65 {
66 	// Wir stehen zwar im const, aber nViewWidth sollte erst im letzten
67 	// Moment errechnet werden:
68 	SwIsoRefPortion* pThis = (SwIsoRefPortion*)this;
69     if( !Width() && rInf.OnWin() && SwViewOption::IsFieldShadings() &&
70             !rInf.GetOpt().IsReadonly() && !rInf.GetOpt().IsPagePreview() )
71 	{
72 		if( !nViewWidth )
73 			pThis->nViewWidth = rInf.GetTxtSize( ' ' ).Width();
74 	}
75 	else
76 		pThis->nViewWidth = 0;
77 	return nViewWidth;
78 }
79 
80 /*************************************************************************
81  *                 virtual SwIsoRefPortion::Format()
82  *************************************************************************/
83 
Format(SwTxtFormatInfo & rInf)84 sal_Bool SwIsoRefPortion::Format( SwTxtFormatInfo &rInf )
85 {
86 	const sal_Bool bFull = SwLinePortion::Format( rInf );
87 	return bFull;
88 }
89 
90 /*************************************************************************
91  *               virtual SwIsoRefPortion::Paint()
92  *************************************************************************/
93 
Paint(const SwTxtPaintInfo & rInf) const94 void SwIsoRefPortion::Paint( const SwTxtPaintInfo &rInf ) const
95 {
96 	if( Width() )
97 		rInf.DrawViewOpt( *this, POR_REF );
98 }
99 
100 /*************************************************************************
101  *              virtual SwIsoRefPortion::HandlePortion()
102  *************************************************************************/
103 
HandlePortion(SwPortionHandler & rPH) const104 void SwIsoRefPortion::HandlePortion( SwPortionHandler& rPH ) const
105 {
106     String aString;
107     rPH.Special( GetLen(), aString, GetWhichPor() );
108 }
109 
110 
111 
112