xref: /AOO41X/main/editeng/source/outliner/outleeng.cxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
29*cdf0e10cSrcweir #include "precompiled_editeng.hxx"
30*cdf0e10cSrcweir #include <svl/intitem.hxx>
31*cdf0e10cSrcweir #include <editeng/editeng.hxx>
32*cdf0e10cSrcweir #include <editeng/editview.hxx>
33*cdf0e10cSrcweir #include <editeng/editdata.hxx>
34*cdf0e10cSrcweir #include <editeng/eerdll.hxx>
35*cdf0e10cSrcweir #include <editeng/lrspitem.hxx>
36*cdf0e10cSrcweir #include <editeng/fhgtitem.hxx>
37*cdf0e10cSrcweir 
38*cdf0e10cSrcweir #define _OUTLINER_CXX
39*cdf0e10cSrcweir #include <editeng/outliner.hxx>
40*cdf0e10cSrcweir #include <outleeng.hxx>
41*cdf0e10cSrcweir #include <paralist.hxx>
42*cdf0e10cSrcweir #include <editeng/editrids.hrc>
43*cdf0e10cSrcweir #include <svl/itemset.hxx>
44*cdf0e10cSrcweir #include <editeng/eeitem.hxx>
45*cdf0e10cSrcweir #include <editeng/editstat.hxx>
46*cdf0e10cSrcweir #include "outlundo.hxx"
47*cdf0e10cSrcweir 
48*cdf0e10cSrcweir OutlinerEditEng::OutlinerEditEng( Outliner* pEngOwner, SfxItemPool* pPool )
49*cdf0e10cSrcweir  : EditEngine( pPool )
50*cdf0e10cSrcweir {
51*cdf0e10cSrcweir 	pOwner = pEngOwner;
52*cdf0e10cSrcweir }
53*cdf0e10cSrcweir 
54*cdf0e10cSrcweir OutlinerEditEng::~OutlinerEditEng()
55*cdf0e10cSrcweir {
56*cdf0e10cSrcweir }
57*cdf0e10cSrcweir 
58*cdf0e10cSrcweir void OutlinerEditEng::PaintingFirstLine( sal_uInt16 nPara, const Point& rStartPos, long nBaseLineY, const Point& rOrigin, short nOrientation, OutputDevice* pOutDev )
59*cdf0e10cSrcweir {
60*cdf0e10cSrcweir 	if( GetControlWord() && EE_CNTRL_OUTLINER )
61*cdf0e10cSrcweir 	{
62*cdf0e10cSrcweir 		PaintFirstLineInfo aInfo( nPara, rStartPos, nBaseLineY, rOrigin, nOrientation, pOutDev );
63*cdf0e10cSrcweir 		pOwner->maPaintFirstLineHdl.Call( &aInfo );
64*cdf0e10cSrcweir 	}
65*cdf0e10cSrcweir 
66*cdf0e10cSrcweir     pOwner->PaintBullet( nPara, rStartPos, rOrigin, nOrientation, pOutDev );
67*cdf0e10cSrcweir }
68*cdf0e10cSrcweir 
69*cdf0e10cSrcweir const SvxNumberFormat* OutlinerEditEng::GetNumberFormat( sal_uInt16 nPara ) const
70*cdf0e10cSrcweir {
71*cdf0e10cSrcweir     const SvxNumberFormat* pFmt = NULL;
72*cdf0e10cSrcweir     if (pOwner)
73*cdf0e10cSrcweir         pFmt = pOwner->GetNumberFormat( nPara );
74*cdf0e10cSrcweir     return pFmt;
75*cdf0e10cSrcweir }
76*cdf0e10cSrcweir 
77*cdf0e10cSrcweir 
78*cdf0e10cSrcweir Rectangle OutlinerEditEng::GetBulletArea( sal_uInt16 nPara )
79*cdf0e10cSrcweir {
80*cdf0e10cSrcweir 	Rectangle aBulletArea = Rectangle( Point(), Point() );
81*cdf0e10cSrcweir 	if ( nPara < pOwner->pParaList->GetParagraphCount() )
82*cdf0e10cSrcweir 	{
83*cdf0e10cSrcweir 		if ( pOwner->ImplHasBullet( nPara ) )
84*cdf0e10cSrcweir 			aBulletArea = pOwner->ImpCalcBulletArea( nPara, sal_False, sal_False );
85*cdf0e10cSrcweir 	}
86*cdf0e10cSrcweir 	return aBulletArea;
87*cdf0e10cSrcweir }
88*cdf0e10cSrcweir 
89*cdf0e10cSrcweir void OutlinerEditEng::ParagraphInserted( sal_uInt16 nNewParagraph )
90*cdf0e10cSrcweir {
91*cdf0e10cSrcweir 	pOwner->ParagraphInserted( nNewParagraph );
92*cdf0e10cSrcweir 
93*cdf0e10cSrcweir     EditEngine::ParagraphInserted( nNewParagraph );
94*cdf0e10cSrcweir }
95*cdf0e10cSrcweir 
96*cdf0e10cSrcweir void OutlinerEditEng::ParagraphDeleted( sal_uInt16 nDeletedParagraph )
97*cdf0e10cSrcweir {
98*cdf0e10cSrcweir 	pOwner->ParagraphDeleted( nDeletedParagraph );
99*cdf0e10cSrcweir 
100*cdf0e10cSrcweir     EditEngine::ParagraphDeleted( nDeletedParagraph );
101*cdf0e10cSrcweir }
102*cdf0e10cSrcweir 
103*cdf0e10cSrcweir void OutlinerEditEng::ParagraphConnected( sal_uInt16 /*nLeftParagraph*/, sal_uInt16 nRightParagraph )
104*cdf0e10cSrcweir {
105*cdf0e10cSrcweir     if( pOwner && pOwner->IsUndoEnabled() && !const_cast<EditEngine&>(pOwner->GetEditEngine()).IsInUndo() )
106*cdf0e10cSrcweir     {
107*cdf0e10cSrcweir         Paragraph* pPara = pOwner->GetParagraph( nRightParagraph );
108*cdf0e10cSrcweir         if( pPara && pOwner->HasParaFlag( pPara, PARAFLAG_ISPAGE ) )
109*cdf0e10cSrcweir         {
110*cdf0e10cSrcweir             pOwner->InsertUndo( new OutlinerUndoChangeParaFlags( pOwner, nRightParagraph, PARAFLAG_ISPAGE, 0 ) );
111*cdf0e10cSrcweir         }
112*cdf0e10cSrcweir     }
113*cdf0e10cSrcweir }
114*cdf0e10cSrcweir 
115*cdf0e10cSrcweir 
116*cdf0e10cSrcweir void OutlinerEditEng::StyleSheetChanged( SfxStyleSheet* pStyle )
117*cdf0e10cSrcweir {
118*cdf0e10cSrcweir 	pOwner->StyleSheetChanged( pStyle );
119*cdf0e10cSrcweir }
120*cdf0e10cSrcweir 
121*cdf0e10cSrcweir void OutlinerEditEng::ParaAttribsChanged( sal_uInt16 nPara )
122*cdf0e10cSrcweir {
123*cdf0e10cSrcweir 	pOwner->ParaAttribsChanged( nPara );
124*cdf0e10cSrcweir }
125*cdf0e10cSrcweir 
126*cdf0e10cSrcweir sal_Bool OutlinerEditEng::SpellNextDocument()
127*cdf0e10cSrcweir {
128*cdf0e10cSrcweir 	return pOwner->SpellNextDocument();
129*cdf0e10cSrcweir }
130*cdf0e10cSrcweir 
131*cdf0e10cSrcweir sal_Bool OutlinerEditEng::ConvertNextDocument()
132*cdf0e10cSrcweir {
133*cdf0e10cSrcweir     return pOwner->ConvertNextDocument();
134*cdf0e10cSrcweir }
135*cdf0e10cSrcweir 
136*cdf0e10cSrcweir XubString OutlinerEditEng::GetUndoComment( sal_uInt16 nUndoId ) const
137*cdf0e10cSrcweir {
138*cdf0e10cSrcweir 	switch( nUndoId )
139*cdf0e10cSrcweir 	{
140*cdf0e10cSrcweir 		case OLUNDO_DEPTH:
141*cdf0e10cSrcweir 			return XubString( EditResId( RID_OUTLUNDO_DEPTH ));
142*cdf0e10cSrcweir 
143*cdf0e10cSrcweir 		case OLUNDO_EXPAND:
144*cdf0e10cSrcweir 			return XubString( EditResId( RID_OUTLUNDO_EXPAND ));
145*cdf0e10cSrcweir 
146*cdf0e10cSrcweir 		case OLUNDO_COLLAPSE:
147*cdf0e10cSrcweir 			return XubString( EditResId( RID_OUTLUNDO_COLLAPSE ));
148*cdf0e10cSrcweir 
149*cdf0e10cSrcweir 		case OLUNDO_ATTR:
150*cdf0e10cSrcweir 			return XubString( EditResId( RID_OUTLUNDO_ATTR ));
151*cdf0e10cSrcweir 
152*cdf0e10cSrcweir 		case OLUNDO_INSERT:
153*cdf0e10cSrcweir 			return XubString( EditResId( RID_OUTLUNDO_INSERT ));
154*cdf0e10cSrcweir 
155*cdf0e10cSrcweir 		default:
156*cdf0e10cSrcweir 			return EditEngine::GetUndoComment( nUndoId );
157*cdf0e10cSrcweir 	}
158*cdf0e10cSrcweir }
159*cdf0e10cSrcweir 
160*cdf0e10cSrcweir // #101498#
161*cdf0e10cSrcweir void OutlinerEditEng::DrawingText( const Point& rStartPos, const XubString& rText, sal_uInt16 nTextStart, sal_uInt16 nTextLen,
162*cdf0e10cSrcweir     const sal_Int32* pDXArray, const SvxFont& rFont, sal_uInt16 nPara, sal_uInt16 nIndex, sal_uInt8 nRightToLeft,
163*cdf0e10cSrcweir     const EEngineData::WrongSpellVector* pWrongSpellVector,
164*cdf0e10cSrcweir     const SvxFieldData* pFieldData,
165*cdf0e10cSrcweir     bool bEndOfLine,
166*cdf0e10cSrcweir     bool bEndOfParagraph,
167*cdf0e10cSrcweir     bool bEndOfBullet,
168*cdf0e10cSrcweir     const ::com::sun::star::lang::Locale* pLocale,
169*cdf0e10cSrcweir     const Color& rOverlineColor,
170*cdf0e10cSrcweir     const Color& rTextLineColor)
171*cdf0e10cSrcweir {
172*cdf0e10cSrcweir     // why do bullet here at all? Just use GetEditEnginePtr()->PaintingFirstLine
173*cdf0e10cSrcweir     // inside of ImpEditEngine::Paint which calls pOwner->PaintBullet with the correct
174*cdf0e10cSrcweir     // values for hor and ver. No change for not-layouting (painting).
175*cdf0e10cSrcweir     // changed, bullet rendering now using PaintBullet via
176*cdf0e10cSrcweir /*	if ( nIndex == 0 )
177*cdf0e10cSrcweir 	{
178*cdf0e10cSrcweir 		// Dann das Bullet 'malen', dort wird bStrippingPortions ausgewertet
179*cdf0e10cSrcweir 		// und Outliner::DrawingText gerufen
180*cdf0e10cSrcweir 
181*cdf0e10cSrcweir 		// DrawingText liefert die BaseLine, DrawBullet braucht Top().
182*cdf0e10cSrcweir 
183*cdf0e10cSrcweir 		if(true)
184*cdf0e10cSrcweir 		{
185*cdf0e10cSrcweir 			// ##
186*cdf0e10cSrcweir 			// another error: This call happens when only stripping, but the position
187*cdf0e10cSrcweir 			// is already aligned to text output. For bullet rendering, it needs to be reset
188*cdf0e10cSrcweir 			// to the correct value in x and y. PaintBullet takes care of X-start offset itself
189*cdf0e10cSrcweir 			const Point aDocPosTopLeft(GetDocPosTopLeft( nPara ));
190*cdf0e10cSrcweir 			const Point aCorrectedPos(rStartPos.X() - aDocPosTopLeft.X(), aDocPosTopLeft.Y() + GetFirstLineOffset( nPara ));
191*cdf0e10cSrcweir 			pOwner->PaintBullet( nPara, aCorrectedPos, Point(), 0, GetRefDevice() );
192*cdf0e10cSrcweir 		}
193*cdf0e10cSrcweir 		else
194*cdf0e10cSrcweir 		{
195*cdf0e10cSrcweir 			Point aCorrectedPos( rStartPos );
196*cdf0e10cSrcweir 			aCorrectedPos.Y() = GetDocPosTopLeft( nPara ).Y();
197*cdf0e10cSrcweir 			aCorrectedPos.Y() += GetFirstLineOffset( nPara );
198*cdf0e10cSrcweir 			pOwner->PaintBullet( nPara, aCorrectedPos, Point(), 0, GetRefDevice() );
199*cdf0e10cSrcweir 		}
200*cdf0e10cSrcweir 	} */
201*cdf0e10cSrcweir 
202*cdf0e10cSrcweir 	// #101498#
203*cdf0e10cSrcweir 	pOwner->DrawingText(rStartPos,rText,nTextStart,nTextLen,pDXArray,rFont,nPara,nIndex,nRightToLeft,
204*cdf0e10cSrcweir         pWrongSpellVector, pFieldData, bEndOfLine, bEndOfParagraph, bEndOfBullet, pLocale, rOverlineColor, rTextLineColor);
205*cdf0e10cSrcweir }
206*cdf0e10cSrcweir 
207*cdf0e10cSrcweir void OutlinerEditEng::FieldClicked( const SvxFieldItem& rField, sal_uInt16 nPara, sal_uInt16 nPos )
208*cdf0e10cSrcweir {
209*cdf0e10cSrcweir 	EditEngine::FieldClicked( rField, nPara, nPos );	// Falls URL
210*cdf0e10cSrcweir 	pOwner->FieldClicked( rField, nPara, nPos );
211*cdf0e10cSrcweir }
212*cdf0e10cSrcweir 
213*cdf0e10cSrcweir void OutlinerEditEng::FieldSelected( const SvxFieldItem& rField, sal_uInt16 nPara, sal_uInt16 nPos )
214*cdf0e10cSrcweir {
215*cdf0e10cSrcweir 	pOwner->FieldSelected( rField, nPara, nPos );
216*cdf0e10cSrcweir }
217*cdf0e10cSrcweir 
218*cdf0e10cSrcweir XubString OutlinerEditEng::CalcFieldValue( const SvxFieldItem& rField, sal_uInt16 nPara, sal_uInt16 nPos, Color*& rpTxtColor, Color*& rpFldColor )
219*cdf0e10cSrcweir {
220*cdf0e10cSrcweir 	return pOwner->CalcFieldValue( rField, nPara, nPos, rpTxtColor, rpFldColor );
221*cdf0e10cSrcweir }
222*cdf0e10cSrcweir 
223*cdf0e10cSrcweir void OutlinerEditEng::SetParaAttribs( sal_uInt16 nPara, const SfxItemSet& rSet )
224*cdf0e10cSrcweir {
225*cdf0e10cSrcweir 	Paragraph* pPara = pOwner->pParaList->GetParagraph( nPara );
226*cdf0e10cSrcweir 	if( pPara )
227*cdf0e10cSrcweir 	{
228*cdf0e10cSrcweir 		if ( !IsInUndo() && IsUndoEnabled() )
229*cdf0e10cSrcweir 			pOwner->UndoActionStart( OLUNDO_ATTR );
230*cdf0e10cSrcweir 
231*cdf0e10cSrcweir         EditEngine::SetParaAttribs( (sal_uInt16)nPara, rSet );
232*cdf0e10cSrcweir 
233*cdf0e10cSrcweir 		pOwner->ImplCheckNumBulletItem( (sal_uInt16)nPara );
234*cdf0e10cSrcweir         // --> OD 2009-03-10 #i100014#
235*cdf0e10cSrcweir         // It is not a good idea to substract 1 from a count and cast the result
236*cdf0e10cSrcweir         // to sal_uInt16 without check, if the count is 0.
237*cdf0e10cSrcweir         pOwner->ImplCheckParagraphs( (sal_uInt16)nPara, (sal_uInt16) (pOwner->pParaList->GetParagraphCount()) );
238*cdf0e10cSrcweir         // <--
239*cdf0e10cSrcweir 
240*cdf0e10cSrcweir 		if ( !IsInUndo() && IsUndoEnabled() )
241*cdf0e10cSrcweir 			pOwner->UndoActionEnd( OLUNDO_ATTR );
242*cdf0e10cSrcweir 	}
243*cdf0e10cSrcweir }
244*cdf0e10cSrcweir 
245