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_editeng.hxx" 30 #include <svl/intitem.hxx> 31 #include <editeng/editeng.hxx> 32 #include <editeng/editview.hxx> 33 #include <editeng/editdata.hxx> 34 #include <editeng/eerdll.hxx> 35 #include <editeng/lrspitem.hxx> 36 #include <editeng/fhgtitem.hxx> 37 38 #define _OUTLINER_CXX 39 #include <editeng/outliner.hxx> 40 #include <outleeng.hxx> 41 #include <paralist.hxx> 42 #include <editeng/editrids.hrc> 43 #include <svl/itemset.hxx> 44 #include <editeng/eeitem.hxx> 45 #include <editeng/editstat.hxx> 46 #include "outlundo.hxx" 47 48 OutlinerEditEng::OutlinerEditEng( Outliner* pEngOwner, SfxItemPool* pPool ) 49 : EditEngine( pPool ) 50 { 51 pOwner = pEngOwner; 52 } 53 54 OutlinerEditEng::~OutlinerEditEng() 55 { 56 } 57 58 void OutlinerEditEng::PaintingFirstLine( sal_uInt16 nPara, const Point& rStartPos, long nBaseLineY, const Point& rOrigin, short nOrientation, OutputDevice* pOutDev ) 59 { 60 if( GetControlWord() && EE_CNTRL_OUTLINER ) 61 { 62 PaintFirstLineInfo aInfo( nPara, rStartPos, nBaseLineY, rOrigin, nOrientation, pOutDev ); 63 pOwner->maPaintFirstLineHdl.Call( &aInfo ); 64 } 65 66 pOwner->PaintBullet( nPara, rStartPos, rOrigin, nOrientation, pOutDev ); 67 } 68 69 const SvxNumberFormat* OutlinerEditEng::GetNumberFormat( sal_uInt16 nPara ) const 70 { 71 const SvxNumberFormat* pFmt = NULL; 72 if (pOwner) 73 pFmt = pOwner->GetNumberFormat( nPara ); 74 return pFmt; 75 } 76 77 78 Rectangle OutlinerEditEng::GetBulletArea( sal_uInt16 nPara ) 79 { 80 Rectangle aBulletArea = Rectangle( Point(), Point() ); 81 if ( nPara < pOwner->pParaList->GetParagraphCount() ) 82 { 83 if ( pOwner->ImplHasBullet( nPara ) ) 84 aBulletArea = pOwner->ImpCalcBulletArea( nPara, sal_False, sal_False ); 85 } 86 return aBulletArea; 87 } 88 89 void OutlinerEditEng::ParagraphInserted( sal_uInt16 nNewParagraph ) 90 { 91 pOwner->ParagraphInserted( nNewParagraph ); 92 93 EditEngine::ParagraphInserted( nNewParagraph ); 94 } 95 96 void OutlinerEditEng::ParagraphDeleted( sal_uInt16 nDeletedParagraph ) 97 { 98 pOwner->ParagraphDeleted( nDeletedParagraph ); 99 100 EditEngine::ParagraphDeleted( nDeletedParagraph ); 101 } 102 103 void OutlinerEditEng::ParagraphConnected( sal_uInt16 /*nLeftParagraph*/, sal_uInt16 nRightParagraph ) 104 { 105 if( pOwner && pOwner->IsUndoEnabled() && !const_cast<EditEngine&>(pOwner->GetEditEngine()).IsInUndo() ) 106 { 107 Paragraph* pPara = pOwner->GetParagraph( nRightParagraph ); 108 if( pPara && pOwner->HasParaFlag( pPara, PARAFLAG_ISPAGE ) ) 109 { 110 pOwner->InsertUndo( new OutlinerUndoChangeParaFlags( pOwner, nRightParagraph, PARAFLAG_ISPAGE, 0 ) ); 111 } 112 } 113 } 114 115 116 void OutlinerEditEng::StyleSheetChanged( SfxStyleSheet* pStyle ) 117 { 118 pOwner->StyleSheetChanged( pStyle ); 119 } 120 121 void OutlinerEditEng::ParaAttribsChanged( sal_uInt16 nPara ) 122 { 123 pOwner->ParaAttribsChanged( nPara ); 124 } 125 126 sal_Bool OutlinerEditEng::SpellNextDocument() 127 { 128 return pOwner->SpellNextDocument(); 129 } 130 131 sal_Bool OutlinerEditEng::ConvertNextDocument() 132 { 133 return pOwner->ConvertNextDocument(); 134 } 135 136 XubString OutlinerEditEng::GetUndoComment( sal_uInt16 nUndoId ) const 137 { 138 switch( nUndoId ) 139 { 140 case OLUNDO_DEPTH: 141 return XubString( EditResId( RID_OUTLUNDO_DEPTH )); 142 143 case OLUNDO_EXPAND: 144 return XubString( EditResId( RID_OUTLUNDO_EXPAND )); 145 146 case OLUNDO_COLLAPSE: 147 return XubString( EditResId( RID_OUTLUNDO_COLLAPSE )); 148 149 case OLUNDO_ATTR: 150 return XubString( EditResId( RID_OUTLUNDO_ATTR )); 151 152 case OLUNDO_INSERT: 153 return XubString( EditResId( RID_OUTLUNDO_INSERT )); 154 155 default: 156 return EditEngine::GetUndoComment( nUndoId ); 157 } 158 } 159 160 // #101498# 161 void OutlinerEditEng::DrawingText( const Point& rStartPos, const XubString& rText, sal_uInt16 nTextStart, sal_uInt16 nTextLen, 162 const sal_Int32* pDXArray, const SvxFont& rFont, sal_uInt16 nPara, sal_uInt16 nIndex, sal_uInt8 nRightToLeft, 163 const EEngineData::WrongSpellVector* pWrongSpellVector, 164 const SvxFieldData* pFieldData, 165 bool bEndOfLine, 166 bool bEndOfParagraph, 167 bool bEndOfBullet, 168 const ::com::sun::star::lang::Locale* pLocale, 169 const Color& rOverlineColor, 170 const Color& rTextLineColor) 171 { 172 // why do bullet here at all? Just use GetEditEnginePtr()->PaintingFirstLine 173 // inside of ImpEditEngine::Paint which calls pOwner->PaintBullet with the correct 174 // values for hor and ver. No change for not-layouting (painting). 175 // changed, bullet rendering now using PaintBullet via 176 /* if ( nIndex == 0 ) 177 { 178 // Dann das Bullet 'malen', dort wird bStrippingPortions ausgewertet 179 // und Outliner::DrawingText gerufen 180 181 // DrawingText liefert die BaseLine, DrawBullet braucht Top(). 182 183 if(true) 184 { 185 // ## 186 // another error: This call happens when only stripping, but the position 187 // is already aligned to text output. For bullet rendering, it needs to be reset 188 // to the correct value in x and y. PaintBullet takes care of X-start offset itself 189 const Point aDocPosTopLeft(GetDocPosTopLeft( nPara )); 190 const Point aCorrectedPos(rStartPos.X() - aDocPosTopLeft.X(), aDocPosTopLeft.Y() + GetFirstLineOffset( nPara )); 191 pOwner->PaintBullet( nPara, aCorrectedPos, Point(), 0, GetRefDevice() ); 192 } 193 else 194 { 195 Point aCorrectedPos( rStartPos ); 196 aCorrectedPos.Y() = GetDocPosTopLeft( nPara ).Y(); 197 aCorrectedPos.Y() += GetFirstLineOffset( nPara ); 198 pOwner->PaintBullet( nPara, aCorrectedPos, Point(), 0, GetRefDevice() ); 199 } 200 } */ 201 202 // #101498# 203 pOwner->DrawingText(rStartPos,rText,nTextStart,nTextLen,pDXArray,rFont,nPara,nIndex,nRightToLeft, 204 pWrongSpellVector, pFieldData, bEndOfLine, bEndOfParagraph, bEndOfBullet, pLocale, rOverlineColor, rTextLineColor); 205 } 206 207 void OutlinerEditEng::FieldClicked( const SvxFieldItem& rField, sal_uInt16 nPara, sal_uInt16 nPos ) 208 { 209 EditEngine::FieldClicked( rField, nPara, nPos ); // Falls URL 210 pOwner->FieldClicked( rField, nPara, nPos ); 211 } 212 213 void OutlinerEditEng::FieldSelected( const SvxFieldItem& rField, sal_uInt16 nPara, sal_uInt16 nPos ) 214 { 215 pOwner->FieldSelected( rField, nPara, nPos ); 216 } 217 218 XubString OutlinerEditEng::CalcFieldValue( const SvxFieldItem& rField, sal_uInt16 nPara, sal_uInt16 nPos, Color*& rpTxtColor, Color*& rpFldColor ) 219 { 220 return pOwner->CalcFieldValue( rField, nPara, nPos, rpTxtColor, rpFldColor ); 221 } 222 223 void OutlinerEditEng::SetParaAttribs( sal_uInt16 nPara, const SfxItemSet& rSet ) 224 { 225 Paragraph* pPara = pOwner->pParaList->GetParagraph( nPara ); 226 if( pPara ) 227 { 228 if ( !IsInUndo() && IsUndoEnabled() ) 229 pOwner->UndoActionStart( OLUNDO_ATTR ); 230 231 EditEngine::SetParaAttribs( (sal_uInt16)nPara, rSet ); 232 233 pOwner->ImplCheckNumBulletItem( (sal_uInt16)nPara ); 234 // --> OD 2009-03-10 #i100014# 235 // It is not a good idea to substract 1 from a count and cast the result 236 // to sal_uInt16 without check, if the count is 0. 237 pOwner->ImplCheckParagraphs( (sal_uInt16)nPara, (sal_uInt16) (pOwner->pParaList->GetParagraphCount()) ); 238 // <-- 239 240 if ( !IsInUndo() && IsUndoEnabled() ) 241 pOwner->UndoActionEnd( OLUNDO_ATTR ); 242 } 243 } 244 245