Bump for 3.6-28
[LibreOffice.git] / editeng / source / outliner / outleeng.cxx
blob5d2f5f616b13d747aeac3c587e4d1454fd000eb1
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
29 #include <svl/intitem.hxx>
30 #include <editeng/editeng.hxx>
31 #include <editeng/editview.hxx>
32 #include <editeng/editdata.hxx>
33 #include <editeng/eerdll.hxx>
34 #include <editeng/lrspitem.hxx>
35 #include <editeng/fhgtitem.hxx>
37 #define _OUTLINER_CXX
38 #include <editeng/outliner.hxx>
39 #include <outleeng.hxx>
40 #include <paralist.hxx>
41 #include <editeng/editrids.hrc>
42 #include <svl/itemset.hxx>
43 #include <editeng/eeitem.hxx>
44 #include <editeng/editstat.hxx>
45 #include "outlundo.hxx"
47 OutlinerEditEng::OutlinerEditEng( Outliner* pEngOwner, SfxItemPool* pPool )
48 : EditEngine( pPool )
50 pOwner = pEngOwner;
53 OutlinerEditEng::~OutlinerEditEng()
57 void OutlinerEditEng::PaintingFirstLine( sal_uInt16 nPara, const Point& rStartPos, long nBaseLineY, const Point& rOrigin, short nOrientation, OutputDevice* pOutDev )
59 if( GetControlWord() & EE_CNTRL_OUTLINER )
61 PaintFirstLineInfo aInfo( nPara, rStartPos, nBaseLineY, rOrigin, nOrientation, pOutDev );
62 pOwner->maPaintFirstLineHdl.Call( &aInfo );
65 pOwner->PaintBullet( nPara, rStartPos, rOrigin, nOrientation, pOutDev );
68 const SvxNumberFormat* OutlinerEditEng::GetNumberFormat( sal_uInt16 nPara ) const
70 const SvxNumberFormat* pFmt = NULL;
71 if (pOwner)
72 pFmt = pOwner->GetNumberFormat( nPara );
73 return pFmt;
77 Rectangle OutlinerEditEng::GetBulletArea( sal_uInt16 nPara )
79 Rectangle aBulletArea = Rectangle( Point(), Point() );
80 if ( nPara < pOwner->pParaList->GetParagraphCount() )
82 if ( pOwner->ImplHasBullet( nPara ) )
83 aBulletArea = pOwner->ImpCalcBulletArea( nPara, sal_False, sal_False );
85 return aBulletArea;
88 void OutlinerEditEng::ParagraphInserted( sal_uInt16 nNewParagraph )
90 pOwner->ParagraphInserted( nNewParagraph );
92 EditEngine::ParagraphInserted( nNewParagraph );
95 void OutlinerEditEng::ParagraphDeleted( sal_uInt16 nDeletedParagraph )
97 pOwner->ParagraphDeleted( nDeletedParagraph );
99 EditEngine::ParagraphDeleted( nDeletedParagraph );
102 void OutlinerEditEng::ParagraphConnected( sal_uInt16 /*nLeftParagraph*/, sal_uInt16 nRightParagraph )
104 if( pOwner && pOwner->IsUndoEnabled() && !const_cast<EditEngine&>(pOwner->GetEditEngine()).IsInUndo() )
106 Paragraph* pPara = pOwner->GetParagraph( nRightParagraph );
107 if( pPara && pOwner->HasParaFlag( pPara, PARAFLAG_ISPAGE ) )
109 pOwner->InsertUndo( new OutlinerUndoChangeParaFlags( pOwner, nRightParagraph, PARAFLAG_ISPAGE, 0 ) );
115 void OutlinerEditEng::StyleSheetChanged( SfxStyleSheet* pStyle )
117 pOwner->StyleSheetChanged( pStyle );
120 void OutlinerEditEng::ParaAttribsChanged( sal_uInt16 nPara )
122 pOwner->ParaAttribsChanged( nPara );
125 sal_Bool OutlinerEditEng::SpellNextDocument()
127 return pOwner->SpellNextDocument();
130 sal_Bool OutlinerEditEng::ConvertNextDocument()
132 return pOwner->ConvertNextDocument();
135 XubString OutlinerEditEng::GetUndoComment( sal_uInt16 nUndoId ) const
137 switch( nUndoId )
139 case OLUNDO_DEPTH:
140 return EE_RESSTR(RID_OUTLUNDO_DEPTH);
142 case OLUNDO_EXPAND:
143 return EE_RESSTR(RID_OUTLUNDO_EXPAND);
145 case OLUNDO_COLLAPSE:
146 return EE_RESSTR(RID_OUTLUNDO_COLLAPSE);
148 case OLUNDO_ATTR:
149 return EE_RESSTR(RID_OUTLUNDO_ATTR);
151 case OLUNDO_INSERT:
152 return EE_RESSTR(RID_OUTLUNDO_INSERT);
154 default:
155 return EditEngine::GetUndoComment( nUndoId );
159 void OutlinerEditEng::DrawingText( const Point& rStartPos, const XubString& rText, sal_uInt16 nTextStart, sal_uInt16 nTextLen,
160 const sal_Int32* pDXArray, const SvxFont& rFont, sal_uInt16 nPara, sal_uInt16 nIndex, sal_uInt8 nRightToLeft,
161 const EEngineData::WrongSpellVector* pWrongSpellVector,
162 const SvxFieldData* pFieldData,
163 bool bEndOfLine,
164 bool bEndOfParagraph,
165 bool bEndOfBullet,
166 const ::com::sun::star::lang::Locale* pLocale,
167 const Color& rOverlineColor,
168 const Color& rTextLineColor)
170 pOwner->DrawingText(rStartPos,rText,nTextStart,nTextLen,pDXArray,rFont,nPara,nIndex,nRightToLeft,
171 pWrongSpellVector, pFieldData, bEndOfLine, bEndOfParagraph, bEndOfBullet, pLocale, rOverlineColor, rTextLineColor);
174 void OutlinerEditEng::DrawingTab( const Point& rStartPos, long nWidth, const String& rChar,
175 const SvxFont& rFont, sal_uInt16 nPara, xub_StrLen nIndex, sal_uInt8 nRightToLeft,
176 bool bEndOfLine, bool bEndOfParagraph,
177 const Color& rOverlineColor, const Color& rTextLineColor)
179 pOwner->DrawingTab(rStartPos, nWidth, rChar, rFont, nPara, nIndex, nRightToLeft,
180 bEndOfLine, bEndOfParagraph, rOverlineColor, rTextLineColor );
183 void OutlinerEditEng::FieldClicked( const SvxFieldItem& rField, sal_uInt16 nPara, sal_uInt16 nPos )
185 EditEngine::FieldClicked( rField, nPara, nPos ); // If URL
186 pOwner->FieldClicked( rField, nPara, nPos );
189 void OutlinerEditEng::FieldSelected( const SvxFieldItem& rField, sal_uInt16 nPara, sal_uInt16 nPos )
191 pOwner->FieldSelected( rField, nPara, nPos );
194 XubString OutlinerEditEng::CalcFieldValue( const SvxFieldItem& rField, sal_uInt16 nPara, sal_uInt16 nPos, Color*& rpTxtColor, Color*& rpFldColor )
196 return pOwner->CalcFieldValue( rField, nPara, nPos, rpTxtColor, rpFldColor );
199 void OutlinerEditEng::SetParaAttribs( sal_uInt16 nPara, const SfxItemSet& rSet )
201 Paragraph* pPara = pOwner->pParaList->GetParagraph( nPara );
202 if( pPara )
204 if ( !IsInUndo() && IsUndoEnabled() )
205 pOwner->UndoActionStart( OLUNDO_ATTR );
207 EditEngine::SetParaAttribs( (sal_uInt16)nPara, rSet );
209 pOwner->ImplCheckNumBulletItem( (sal_uInt16)nPara );
210 // #i100014#
211 // It is not a good idea to substract 1 from a count and cast the result
212 // to USHORT without check, if the count is 0.
213 pOwner->ImplCheckParagraphs( (sal_uInt16)nPara, (sal_uInt16) (pOwner->pParaList->GetParagraphCount()) );
215 if ( !IsInUndo() && IsUndoEnabled() )
216 pOwner->UndoActionEnd( OLUNDO_ATTR );
220 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */