xref: /AOO41X/main/editeng/source/outliner/outleeng.cxx (revision d3e0dd8eb215533c15e891ee35bd141abe9397ee)
1190118d0SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3190118d0SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4190118d0SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5190118d0SAndrew Rist  * distributed with this work for additional information
6190118d0SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7190118d0SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8190118d0SAndrew Rist  * "License"); you may not use this file except in compliance
9190118d0SAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
11190118d0SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
13190118d0SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14190118d0SAndrew Rist  * software distributed under the License is distributed on an
15190118d0SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16190118d0SAndrew Rist  * KIND, either express or implied.  See the License for the
17190118d0SAndrew Rist  * specific language governing permissions and limitations
18190118d0SAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
20190118d0SAndrew Rist  *************************************************************/
21190118d0SAndrew Rist 
22190118d0SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_editeng.hxx"
26cdf0e10cSrcweir #include <svl/intitem.hxx>
27cdf0e10cSrcweir #include <editeng/editeng.hxx>
28cdf0e10cSrcweir #include <editeng/editview.hxx>
29cdf0e10cSrcweir #include <editeng/editdata.hxx>
30cdf0e10cSrcweir #include <editeng/eerdll.hxx>
31cdf0e10cSrcweir #include <editeng/lrspitem.hxx>
32cdf0e10cSrcweir #include <editeng/fhgtitem.hxx>
33cdf0e10cSrcweir 
34cdf0e10cSrcweir #define _OUTLINER_CXX
35cdf0e10cSrcweir #include <editeng/outliner.hxx>
36cdf0e10cSrcweir #include <outleeng.hxx>
37cdf0e10cSrcweir #include <paralist.hxx>
38cdf0e10cSrcweir #include <editeng/editrids.hrc>
39cdf0e10cSrcweir #include <svl/itemset.hxx>
40cdf0e10cSrcweir #include <editeng/eeitem.hxx>
41cdf0e10cSrcweir #include <editeng/editstat.hxx>
42cdf0e10cSrcweir #include "outlundo.hxx"
43cdf0e10cSrcweir 
OutlinerEditEng(Outliner * pEngOwner,SfxItemPool * pPool)44cdf0e10cSrcweir OutlinerEditEng::OutlinerEditEng( Outliner* pEngOwner, SfxItemPool* pPool )
45cdf0e10cSrcweir  : EditEngine( pPool )
46cdf0e10cSrcweir {
47cdf0e10cSrcweir 	pOwner = pEngOwner;
48cdf0e10cSrcweir }
49cdf0e10cSrcweir 
~OutlinerEditEng()50cdf0e10cSrcweir OutlinerEditEng::~OutlinerEditEng()
51cdf0e10cSrcweir {
52cdf0e10cSrcweir }
53cdf0e10cSrcweir 
PaintingFirstLine(sal_uInt16 nPara,const Point & rStartPos,long nBaseLineY,const Point & rOrigin,short nOrientation,OutputDevice * pOutDev)54cdf0e10cSrcweir void OutlinerEditEng::PaintingFirstLine( sal_uInt16 nPara, const Point& rStartPos, long nBaseLineY, const Point& rOrigin, short nOrientation, OutputDevice* pOutDev )
55cdf0e10cSrcweir {
566cb7d399SHerbert Dürr 	if( GetControlWord() & EE_CNTRL_OUTLINER )
57cdf0e10cSrcweir 	{
58cdf0e10cSrcweir 		PaintFirstLineInfo aInfo( nPara, rStartPos, nBaseLineY, rOrigin, nOrientation, pOutDev );
59cdf0e10cSrcweir 		pOwner->maPaintFirstLineHdl.Call( &aInfo );
60cdf0e10cSrcweir 	}
61cdf0e10cSrcweir 
62cdf0e10cSrcweir     pOwner->PaintBullet( nPara, rStartPos, rOrigin, nOrientation, pOutDev );
63cdf0e10cSrcweir }
64cdf0e10cSrcweir 
GetNumberFormat(sal_uInt16 nPara) const65cdf0e10cSrcweir const SvxNumberFormat* OutlinerEditEng::GetNumberFormat( sal_uInt16 nPara ) const
66cdf0e10cSrcweir {
67cdf0e10cSrcweir     const SvxNumberFormat* pFmt = NULL;
68cdf0e10cSrcweir     if (pOwner)
69cdf0e10cSrcweir         pFmt = pOwner->GetNumberFormat( nPara );
70cdf0e10cSrcweir     return pFmt;
71cdf0e10cSrcweir }
72cdf0e10cSrcweir 
73cdf0e10cSrcweir 
GetBulletArea(sal_uInt16 nPara)74cdf0e10cSrcweir Rectangle OutlinerEditEng::GetBulletArea( sal_uInt16 nPara )
75cdf0e10cSrcweir {
76cdf0e10cSrcweir 	Rectangle aBulletArea = Rectangle( Point(), Point() );
77cdf0e10cSrcweir 	if ( nPara < pOwner->pParaList->GetParagraphCount() )
78cdf0e10cSrcweir 	{
79*af89ca6eSOliver-Rainer Wittmann 		if ( pOwner->ImplHasNumberFormat( nPara ) )
80cdf0e10cSrcweir 			aBulletArea = pOwner->ImpCalcBulletArea( nPara, sal_False, sal_False );
81cdf0e10cSrcweir 	}
82cdf0e10cSrcweir 	return aBulletArea;
83cdf0e10cSrcweir }
84cdf0e10cSrcweir 
ParagraphInserted(sal_uInt16 nNewParagraph)85cdf0e10cSrcweir void OutlinerEditEng::ParagraphInserted( sal_uInt16 nNewParagraph )
86cdf0e10cSrcweir {
87cdf0e10cSrcweir 	pOwner->ParagraphInserted( nNewParagraph );
88cdf0e10cSrcweir 
89cdf0e10cSrcweir     EditEngine::ParagraphInserted( nNewParagraph );
90cdf0e10cSrcweir }
91cdf0e10cSrcweir 
ParagraphDeleted(sal_uInt16 nDeletedParagraph)92cdf0e10cSrcweir void OutlinerEditEng::ParagraphDeleted( sal_uInt16 nDeletedParagraph )
93cdf0e10cSrcweir {
94cdf0e10cSrcweir 	pOwner->ParagraphDeleted( nDeletedParagraph );
95cdf0e10cSrcweir 
96cdf0e10cSrcweir     EditEngine::ParagraphDeleted( nDeletedParagraph );
97cdf0e10cSrcweir }
98cdf0e10cSrcweir 
ParagraphConnected(sal_uInt16,sal_uInt16 nRightParagraph)99cdf0e10cSrcweir void OutlinerEditEng::ParagraphConnected( sal_uInt16 /*nLeftParagraph*/, sal_uInt16 nRightParagraph )
100cdf0e10cSrcweir {
101cdf0e10cSrcweir     if( pOwner && pOwner->IsUndoEnabled() && !const_cast<EditEngine&>(pOwner->GetEditEngine()).IsInUndo() )
102cdf0e10cSrcweir     {
103cdf0e10cSrcweir         Paragraph* pPara = pOwner->GetParagraph( nRightParagraph );
104cdf0e10cSrcweir         if( pPara && pOwner->HasParaFlag( pPara, PARAFLAG_ISPAGE ) )
105cdf0e10cSrcweir         {
106cdf0e10cSrcweir             pOwner->InsertUndo( new OutlinerUndoChangeParaFlags( pOwner, nRightParagraph, PARAFLAG_ISPAGE, 0 ) );
107cdf0e10cSrcweir         }
108cdf0e10cSrcweir     }
109cdf0e10cSrcweir }
110cdf0e10cSrcweir 
111cdf0e10cSrcweir 
StyleSheetChanged(SfxStyleSheet * pStyle)112cdf0e10cSrcweir void OutlinerEditEng::StyleSheetChanged( SfxStyleSheet* pStyle )
113cdf0e10cSrcweir {
114cdf0e10cSrcweir 	pOwner->StyleSheetChanged( pStyle );
115cdf0e10cSrcweir }
116cdf0e10cSrcweir 
ParaAttribsChanged(sal_uInt16 nPara)117cdf0e10cSrcweir void OutlinerEditEng::ParaAttribsChanged( sal_uInt16 nPara )
118cdf0e10cSrcweir {
119cdf0e10cSrcweir 	pOwner->ParaAttribsChanged( nPara );
120cdf0e10cSrcweir }
121cdf0e10cSrcweir 
SpellNextDocument()122cdf0e10cSrcweir sal_Bool OutlinerEditEng::SpellNextDocument()
123cdf0e10cSrcweir {
124cdf0e10cSrcweir 	return pOwner->SpellNextDocument();
125cdf0e10cSrcweir }
126cdf0e10cSrcweir 
ConvertNextDocument()127cdf0e10cSrcweir sal_Bool OutlinerEditEng::ConvertNextDocument()
128cdf0e10cSrcweir {
129cdf0e10cSrcweir     return pOwner->ConvertNextDocument();
130cdf0e10cSrcweir }
131cdf0e10cSrcweir 
GetUndoComment(sal_uInt16 nUndoId) const132cdf0e10cSrcweir XubString OutlinerEditEng::GetUndoComment( sal_uInt16 nUndoId ) const
133cdf0e10cSrcweir {
134cdf0e10cSrcweir 	switch( nUndoId )
135cdf0e10cSrcweir 	{
136cdf0e10cSrcweir 		case OLUNDO_DEPTH:
137cdf0e10cSrcweir 			return XubString( EditResId( RID_OUTLUNDO_DEPTH ));
138cdf0e10cSrcweir 
139cdf0e10cSrcweir 		case OLUNDO_EXPAND:
140cdf0e10cSrcweir 			return XubString( EditResId( RID_OUTLUNDO_EXPAND ));
141cdf0e10cSrcweir 
142cdf0e10cSrcweir 		case OLUNDO_COLLAPSE:
143cdf0e10cSrcweir 			return XubString( EditResId( RID_OUTLUNDO_COLLAPSE ));
144cdf0e10cSrcweir 
145cdf0e10cSrcweir 		case OLUNDO_ATTR:
146cdf0e10cSrcweir 			return XubString( EditResId( RID_OUTLUNDO_ATTR ));
147cdf0e10cSrcweir 
148cdf0e10cSrcweir 		case OLUNDO_INSERT:
149cdf0e10cSrcweir 			return XubString( EditResId( RID_OUTLUNDO_INSERT ));
150cdf0e10cSrcweir 
151cdf0e10cSrcweir 		default:
152cdf0e10cSrcweir 			return EditEngine::GetUndoComment( nUndoId );
153cdf0e10cSrcweir 	}
154cdf0e10cSrcweir }
155cdf0e10cSrcweir 
156cdf0e10cSrcweir // #101498#
DrawingText(const Point & rStartPos,const XubString & rText,sal_uInt16 nTextStart,sal_uInt16 nTextLen,const sal_Int32 * pDXArray,const SvxFont & rFont,sal_uInt16 nPara,sal_uInt16 nIndex,sal_uInt8 nRightToLeft,const EEngineData::WrongSpellVector * pWrongSpellVector,const SvxFieldData * pFieldData,bool bEndOfLine,bool bEndOfParagraph,bool bEndOfBullet,const::com::sun::star::lang::Locale * pLocale,const Color & rOverlineColor,const Color & rTextLineColor)157cdf0e10cSrcweir void OutlinerEditEng::DrawingText( const Point& rStartPos, const XubString& rText, sal_uInt16 nTextStart, sal_uInt16 nTextLen,
158cdf0e10cSrcweir     const sal_Int32* pDXArray, const SvxFont& rFont, sal_uInt16 nPara, sal_uInt16 nIndex, sal_uInt8 nRightToLeft,
159cdf0e10cSrcweir     const EEngineData::WrongSpellVector* pWrongSpellVector,
160cdf0e10cSrcweir     const SvxFieldData* pFieldData,
161cdf0e10cSrcweir     bool bEndOfLine,
162cdf0e10cSrcweir     bool bEndOfParagraph,
163cdf0e10cSrcweir     bool bEndOfBullet,
164cdf0e10cSrcweir     const ::com::sun::star::lang::Locale* pLocale,
165cdf0e10cSrcweir     const Color& rOverlineColor,
166cdf0e10cSrcweir     const Color& rTextLineColor)
167cdf0e10cSrcweir {
168cdf0e10cSrcweir     // why do bullet here at all? Just use GetEditEnginePtr()->PaintingFirstLine
169cdf0e10cSrcweir     // inside of ImpEditEngine::Paint which calls pOwner->PaintBullet with the correct
170cdf0e10cSrcweir     // values for hor and ver. No change for not-layouting (painting).
171cdf0e10cSrcweir     // changed, bullet rendering now using PaintBullet via
172cdf0e10cSrcweir /*	if ( nIndex == 0 )
173cdf0e10cSrcweir 	{
174cdf0e10cSrcweir 		// Dann das Bullet 'malen', dort wird bStrippingPortions ausgewertet
175cdf0e10cSrcweir 		// und Outliner::DrawingText gerufen
176cdf0e10cSrcweir 
177cdf0e10cSrcweir 		// DrawingText liefert die BaseLine, DrawBullet braucht Top().
178cdf0e10cSrcweir 
179cdf0e10cSrcweir 		if(true)
180cdf0e10cSrcweir 		{
181cdf0e10cSrcweir 			// ##
182cdf0e10cSrcweir 			// another error: This call happens when only stripping, but the position
183cdf0e10cSrcweir 			// is already aligned to text output. For bullet rendering, it needs to be reset
184cdf0e10cSrcweir 			// to the correct value in x and y. PaintBullet takes care of X-start offset itself
185cdf0e10cSrcweir 			const Point aDocPosTopLeft(GetDocPosTopLeft( nPara ));
186cdf0e10cSrcweir 			const Point aCorrectedPos(rStartPos.X() - aDocPosTopLeft.X(), aDocPosTopLeft.Y() + GetFirstLineOffset( nPara ));
187cdf0e10cSrcweir 			pOwner->PaintBullet( nPara, aCorrectedPos, Point(), 0, GetRefDevice() );
188cdf0e10cSrcweir 		}
189cdf0e10cSrcweir 		else
190cdf0e10cSrcweir 		{
191cdf0e10cSrcweir 			Point aCorrectedPos( rStartPos );
192cdf0e10cSrcweir 			aCorrectedPos.Y() = GetDocPosTopLeft( nPara ).Y();
193cdf0e10cSrcweir 			aCorrectedPos.Y() += GetFirstLineOffset( nPara );
194cdf0e10cSrcweir 			pOwner->PaintBullet( nPara, aCorrectedPos, Point(), 0, GetRefDevice() );
195cdf0e10cSrcweir 		}
196cdf0e10cSrcweir 	} */
197cdf0e10cSrcweir 
198cdf0e10cSrcweir 	// #101498#
199cdf0e10cSrcweir 	pOwner->DrawingText(rStartPos,rText,nTextStart,nTextLen,pDXArray,rFont,nPara,nIndex,nRightToLeft,
200cdf0e10cSrcweir         pWrongSpellVector, pFieldData, bEndOfLine, bEndOfParagraph, bEndOfBullet, pLocale, rOverlineColor, rTextLineColor);
201cdf0e10cSrcweir }
202cdf0e10cSrcweir 
FieldClicked(const SvxFieldItem & rField,sal_uInt16 nPara,sal_uInt16 nPos)203cdf0e10cSrcweir void OutlinerEditEng::FieldClicked( const SvxFieldItem& rField, sal_uInt16 nPara, sal_uInt16 nPos )
204cdf0e10cSrcweir {
205cdf0e10cSrcweir 	EditEngine::FieldClicked( rField, nPara, nPos );	// Falls URL
206cdf0e10cSrcweir 	pOwner->FieldClicked( rField, nPara, nPos );
207cdf0e10cSrcweir }
208cdf0e10cSrcweir 
FieldSelected(const SvxFieldItem & rField,sal_uInt16 nPara,sal_uInt16 nPos)209cdf0e10cSrcweir void OutlinerEditEng::FieldSelected( const SvxFieldItem& rField, sal_uInt16 nPara, sal_uInt16 nPos )
210cdf0e10cSrcweir {
211cdf0e10cSrcweir 	pOwner->FieldSelected( rField, nPara, nPos );
212cdf0e10cSrcweir }
213cdf0e10cSrcweir 
CalcFieldValue(const SvxFieldItem & rField,sal_uInt16 nPara,sal_uInt16 nPos,Color * & rpTxtColor,Color * & rpFldColor)214cdf0e10cSrcweir XubString OutlinerEditEng::CalcFieldValue( const SvxFieldItem& rField, sal_uInt16 nPara, sal_uInt16 nPos, Color*& rpTxtColor, Color*& rpFldColor )
215cdf0e10cSrcweir {
216cdf0e10cSrcweir 	return pOwner->CalcFieldValue( rField, nPara, nPos, rpTxtColor, rpFldColor );
217cdf0e10cSrcweir }
218cdf0e10cSrcweir 
SetParaAttribs(sal_uInt16 nPara,const SfxItemSet & rSet)219cdf0e10cSrcweir void OutlinerEditEng::SetParaAttribs( sal_uInt16 nPara, const SfxItemSet& rSet )
220cdf0e10cSrcweir {
221cdf0e10cSrcweir 	Paragraph* pPara = pOwner->pParaList->GetParagraph( nPara );
222cdf0e10cSrcweir 	if( pPara )
223cdf0e10cSrcweir 	{
224cdf0e10cSrcweir 		if ( !IsInUndo() && IsUndoEnabled() )
225cdf0e10cSrcweir 			pOwner->UndoActionStart( OLUNDO_ATTR );
226cdf0e10cSrcweir 
227cdf0e10cSrcweir         EditEngine::SetParaAttribs( (sal_uInt16)nPara, rSet );
228cdf0e10cSrcweir 
229cdf0e10cSrcweir 		pOwner->ImplCheckNumBulletItem( (sal_uInt16)nPara );
230cdf0e10cSrcweir         // --> OD 2009-03-10 #i100014#
231cdf0e10cSrcweir         // It is not a good idea to substract 1 from a count and cast the result
232cdf0e10cSrcweir         // to sal_uInt16 without check, if the count is 0.
233cdf0e10cSrcweir         pOwner->ImplCheckParagraphs( (sal_uInt16)nPara, (sal_uInt16) (pOwner->pParaList->GetParagraphCount()) );
234cdf0e10cSrcweir         // <--
235cdf0e10cSrcweir 
236cdf0e10cSrcweir 		if ( !IsInUndo() && IsUndoEnabled() )
237cdf0e10cSrcweir 			pOwner->UndoActionEnd( OLUNDO_ATTR );
238cdf0e10cSrcweir 	}
239cdf0e10cSrcweir }
240cdf0e10cSrcweir 
241