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 "porref.hxx" 37 #include "inftxt.hxx" // GetTxtSize() 38 39 /************************************************************************* 40 * virtual SwRefPortion::Paint() 41 *************************************************************************/ 42 43 void SwRefPortion::Paint( const SwTxtPaintInfo &rInf ) const 44 { 45 if( Width() ) 46 { 47 rInf.DrawViewOpt( *this, POR_REF ); 48 SwTxtPortion::Paint( rInf ); 49 } 50 } 51 52 /************************************************************************* 53 * class SwIsoRefPortion 54 *************************************************************************/ 55 56 SwLinePortion *SwIsoRefPortion::Compress() { return this; } 57 58 SwIsoRefPortion::SwIsoRefPortion() : nViewWidth(0) 59 { 60 SetLen(1); 61 SetWhichPor( POR_ISOREF ); 62 } 63 64 /************************************************************************* 65 * virtual SwIsoRefPortion::GetViewWidth() 66 *************************************************************************/ 67 68 KSHORT SwIsoRefPortion::GetViewWidth( const SwTxtSizeInfo &rInf ) const 69 { 70 // Wir stehen zwar im const, aber nViewWidth sollte erst im letzten 71 // Moment errechnet werden: 72 SwIsoRefPortion* pThis = (SwIsoRefPortion*)this; 73 if( !Width() && rInf.OnWin() && SwViewOption::IsFieldShadings() && 74 !rInf.GetOpt().IsReadonly() && !rInf.GetOpt().IsPagePreview() ) 75 { 76 if( !nViewWidth ) 77 pThis->nViewWidth = rInf.GetTxtSize( ' ' ).Width(); 78 } 79 else 80 pThis->nViewWidth = 0; 81 return nViewWidth; 82 } 83 84 /************************************************************************* 85 * virtual SwIsoRefPortion::Format() 86 *************************************************************************/ 87 88 sal_Bool SwIsoRefPortion::Format( SwTxtFormatInfo &rInf ) 89 { 90 const sal_Bool bFull = SwLinePortion::Format( rInf ); 91 return bFull; 92 } 93 94 /************************************************************************* 95 * virtual SwIsoRefPortion::Paint() 96 *************************************************************************/ 97 98 void SwIsoRefPortion::Paint( const SwTxtPaintInfo &rInf ) const 99 { 100 if( Width() ) 101 rInf.DrawViewOpt( *this, POR_REF ); 102 } 103 104 /************************************************************************* 105 * virtual SwIsoRefPortion::HandlePortion() 106 *************************************************************************/ 107 108 void SwIsoRefPortion::HandlePortion( SwPortionHandler& rPH ) const 109 { 110 String aString; 111 rPH.Special( GetLen(), aString, GetWhichPor() ); 112 } 113 114 115 116