Update ooo320-m1
[ooovba.git] / svx / source / outliner / outleeng.cxx
blob43fea6e316bfbb8b21c95f0a0cfd7cdebb28d611
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: outleeng.cxx,v $
10 * $Revision: 1.19 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_svx.hxx"
33 #include <outl_pch.hxx>
35 #define _OUTLINER_CXX
36 #include <svx/outliner.hxx>
37 #include <outleeng.hxx>
38 #include <paralist.hxx>
39 #include <outliner.hrc>
40 #include <svtools/itemset.hxx>
41 #include <svx/eeitem.hxx>
42 #include "editstat.hxx"
43 #include "outlundo.hxx"
45 OutlinerEditEng::OutlinerEditEng( Outliner* pEngOwner, SfxItemPool* pPool )
46 : EditEngine( pPool )
48 pOwner = pEngOwner;
51 OutlinerEditEng::~OutlinerEditEng()
55 void OutlinerEditEng::PaintingFirstLine( USHORT nPara, const Point& rStartPos, long nBaseLineY, const Point& rOrigin, short nOrientation, OutputDevice* pOutDev )
57 if( GetControlWord() && EE_CNTRL_OUTLINER )
59 PaintFirstLineInfo aInfo( nPara, rStartPos, nBaseLineY, rOrigin, nOrientation, pOutDev );
60 pOwner->maPaintFirstLineHdl.Call( &aInfo );
63 pOwner->PaintBullet( nPara, rStartPos, rOrigin, nOrientation, pOutDev );
66 const SvxNumberFormat* OutlinerEditEng::GetNumberFormat( USHORT nPara ) const
68 const SvxNumberFormat* pFmt = NULL;
69 if (pOwner)
70 pFmt = pOwner->GetNumberFormat( nPara );
71 return pFmt;
75 Rectangle OutlinerEditEng::GetBulletArea( USHORT nPara )
77 Rectangle aBulletArea = Rectangle( Point(), Point() );
78 if ( nPara < pOwner->pParaList->GetParagraphCount() )
80 if ( pOwner->ImplHasBullet( nPara ) )
81 aBulletArea = pOwner->ImpCalcBulletArea( nPara, FALSE, FALSE );
83 return aBulletArea;
86 void OutlinerEditEng::ParagraphInserted( USHORT nNewParagraph )
88 pOwner->ParagraphInserted( nNewParagraph );
90 EditEngine::ParagraphInserted( nNewParagraph );
93 void OutlinerEditEng::ParagraphDeleted( USHORT nDeletedParagraph )
95 pOwner->ParagraphDeleted( nDeletedParagraph );
97 EditEngine::ParagraphDeleted( nDeletedParagraph );
100 void OutlinerEditEng::ParagraphConnected( USHORT /*nLeftParagraph*/, USHORT nRightParagraph )
102 if( pOwner && pOwner->IsUndoEnabled() && !const_cast<EditEngine&>(pOwner->GetEditEngine()).IsInUndo() )
104 Paragraph* pPara = pOwner->GetParagraph( nRightParagraph );
105 if( pPara && pOwner->HasParaFlag( pPara, PARAFLAG_ISPAGE ) )
107 pOwner->InsertUndo( new OutlinerUndoChangeParaFlags( pOwner, nRightParagraph, PARAFLAG_ISPAGE, 0 ) );
113 void OutlinerEditEng::StyleSheetChanged( SfxStyleSheet* pStyle )
115 pOwner->StyleSheetChanged( pStyle );
118 void OutlinerEditEng::ParaAttribsChanged( USHORT nPara )
120 pOwner->ParaAttribsChanged( nPara );
123 BOOL OutlinerEditEng::SpellNextDocument()
125 return pOwner->SpellNextDocument();
128 BOOL OutlinerEditEng::ConvertNextDocument()
130 return pOwner->ConvertNextDocument();
133 XubString OutlinerEditEng::GetUndoComment( USHORT nUndoId ) const
135 switch( nUndoId )
137 case OLUNDO_DEPTH:
138 return XubString( EditResId( RID_OUTLUNDO_DEPTH ));
140 case OLUNDO_EXPAND:
141 return XubString( EditResId( RID_OUTLUNDO_EXPAND ));
143 case OLUNDO_COLLAPSE:
144 return XubString( EditResId( RID_OUTLUNDO_COLLAPSE ));
146 case OLUNDO_ATTR:
147 return XubString( EditResId( RID_OUTLUNDO_ATTR ));
149 case OLUNDO_INSERT:
150 return XubString( EditResId( RID_OUTLUNDO_INSERT ));
152 default:
153 return EditEngine::GetUndoComment( nUndoId );
157 // #101498#
158 void OutlinerEditEng::DrawingText( const Point& rStartPos, const XubString& rText, USHORT nTextStart, USHORT nTextLen,
159 const sal_Int32* pDXArray, const SvxFont& rFont, USHORT nPara, USHORT nIndex, BYTE nRightToLeft,
160 const EEngineData::WrongSpellVector* pWrongSpellVector,
161 const SvxFieldData* pFieldData,
162 bool bEndOfLine,
163 bool bEndOfParagraph,
164 bool bEndOfBullet,
165 const ::com::sun::star::lang::Locale* pLocale,
166 const Color& rOverlineColor,
167 const Color& rTextLineColor)
169 // why do bullet here at all? Just use GetEditEnginePtr()->PaintingFirstLine
170 // inside of ImpEditEngine::Paint which calls pOwner->PaintBullet with the correct
171 // values for hor and ver. No change for not-layouting (painting).
172 // changed, bullet rendering now using PaintBullet via
173 /* if ( nIndex == 0 )
175 // Dann das Bullet 'malen', dort wird bStrippingPortions ausgewertet
176 // und Outliner::DrawingText gerufen
178 // DrawingText liefert die BaseLine, DrawBullet braucht Top().
180 if(true)
182 // ##
183 // another error: This call happens when only stripping, but the position
184 // is already aligned to text output. For bullet rendering, it needs to be reset
185 // to the correct value in x and y. PaintBullet takes care of X-start offset itself
186 const Point aDocPosTopLeft(GetDocPosTopLeft( nPara ));
187 const Point aCorrectedPos(rStartPos.X() - aDocPosTopLeft.X(), aDocPosTopLeft.Y() + GetFirstLineOffset( nPara ));
188 pOwner->PaintBullet( nPara, aCorrectedPos, Point(), 0, GetRefDevice() );
190 else
192 Point aCorrectedPos( rStartPos );
193 aCorrectedPos.Y() = GetDocPosTopLeft( nPara ).Y();
194 aCorrectedPos.Y() += GetFirstLineOffset( nPara );
195 pOwner->PaintBullet( nPara, aCorrectedPos, Point(), 0, GetRefDevice() );
197 } */
199 // #101498#
200 pOwner->DrawingText(rStartPos,rText,nTextStart,nTextLen,pDXArray,rFont,nPara,nIndex,nRightToLeft,
201 pWrongSpellVector, pFieldData, bEndOfLine, bEndOfParagraph, bEndOfBullet, pLocale, rOverlineColor, rTextLineColor);
204 void OutlinerEditEng::FieldClicked( const SvxFieldItem& rField, USHORT nPara, USHORT nPos )
206 EditEngine::FieldClicked( rField, nPara, nPos ); // Falls URL
207 pOwner->FieldClicked( rField, nPara, nPos );
210 void OutlinerEditEng::FieldSelected( const SvxFieldItem& rField, USHORT nPara, USHORT nPos )
212 pOwner->FieldSelected( rField, nPara, nPos );
215 XubString OutlinerEditEng::CalcFieldValue( const SvxFieldItem& rField, USHORT nPara, USHORT nPos, Color*& rpTxtColor, Color*& rpFldColor )
217 return pOwner->CalcFieldValue( rField, nPara, nPos, rpTxtColor, rpFldColor );
220 void OutlinerEditEng::SetParaAttribs( USHORT nPara, const SfxItemSet& rSet )
222 Paragraph* pPara = pOwner->pParaList->GetParagraph( nPara );
223 if( pPara )
225 if ( !IsInUndo() && IsUndoEnabled() )
226 pOwner->UndoActionStart( OLUNDO_ATTR );
228 EditEngine::SetParaAttribs( (USHORT)nPara, rSet );
230 pOwner->ImplCheckNumBulletItem( (USHORT)nPara );
231 // --> OD 2009-03-10 #i100014#
232 // It is not a good idea to substract 1 from a count and cast the result
233 // to USHORT without check, if the count is 0.
234 pOwner->ImplCheckParagraphs( (USHORT)nPara, (USHORT) (pOwner->pParaList->GetParagraphCount()) );
235 // <--
237 if ( !IsInUndo() && IsUndoEnabled() )
238 pOwner->UndoActionEnd( OLUNDO_ATTR );