xref: /AOO41X/main/sw/source/core/text/portox.cxx (revision 1ecadb572e7010ff3b3382ad9bf179dbc6efadbb)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_sw.hxx"
30 
31 
32 #include <SwPortionHandler.hxx>
33 #include "viewopt.hxx"	// SwViewOptions
34 
35 #include "txtcfg.hxx"
36 #include "portox.hxx"
37 #include "inftxt.hxx"       // GetTxtSize()
38 
39 /*************************************************************************
40  *               virtual SwToxPortion::Paint()
41  *************************************************************************/
42 
43 void SwToxPortion::Paint( const SwTxtPaintInfo &rInf ) const
44 {
45 	if( Width() )
46 	{
47 		rInf.DrawViewOpt( *this, POR_TOX );
48 		SwTxtPortion::Paint( rInf );
49 	}
50 }
51 
52 /*************************************************************************
53  *                      class SwIsoToxPortion
54  *************************************************************************/
55 
56 SwLinePortion *SwIsoToxPortion::Compress() { return this; }
57 
58 SwIsoToxPortion::SwIsoToxPortion() : nViewWidth(0)
59 {
60 	SetLen(1);
61 	SetWhichPor( POR_ISOTOX );
62 }
63 
64 /*************************************************************************
65  *				 virtual SwIsoToxPortion::GetViewWidth()
66  *************************************************************************/
67 
68 KSHORT SwIsoToxPortion::GetViewWidth( const SwTxtSizeInfo &rInf ) const
69 {
70 	// Wir stehen zwar im const, aber nViewWidth sollte erst im letzten
71 	// Moment errechnet werden:
72 	SwIsoToxPortion* pThis = (SwIsoToxPortion*)this;
73 	// nViewWidth muss errechnet werden.
74     if( !Width() && rInf.OnWin() &&
75         !rInf.GetOpt().IsPagePreview() &&
76             !rInf.GetOpt().IsReadonly() && SwViewOption::IsFieldShadings()   )
77 	{
78 		if( !nViewWidth )
79 			pThis->nViewWidth = rInf.GetTxtSize( ' ' ).Width();
80 	}
81 	else
82 		pThis->nViewWidth = 0;
83 	return nViewWidth;
84 }
85 
86 /*************************************************************************
87  *                 virtual SwIsoToxPortion::Format()
88  *************************************************************************/
89 
90 sal_Bool SwIsoToxPortion::Format( SwTxtFormatInfo &rInf )
91 {
92 	const sal_Bool bFull = SwLinePortion::Format( rInf );
93 	return bFull;
94 }
95 
96 /*************************************************************************
97  *               virtual SwIsoToxPortion::Paint()
98  *************************************************************************/
99 
100 void SwIsoToxPortion::Paint( const SwTxtPaintInfo &rInf ) const
101 {
102 	if( Width() )
103 		rInf.DrawViewOpt( *this, POR_TOX );
104 }
105 
106 /*************************************************************************
107  *              virtual SwIsoToxPortion::HandlePortion()
108  *************************************************************************/
109 
110 void SwIsoToxPortion::HandlePortion( SwPortionHandler& rPH ) const
111 {
112     String aString;
113     rPH.Special( GetLen(), aString, GetWhichPor() );
114 }
115 
116