Bump version to 5.0-14
[LibreOffice.git] / editeng / source / outliner / outleeng.cxx
blobea0af4fb794f9e11348bfba47e6135255ff0f9bb
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <svl/intitem.hxx>
21 #include <editeng/editeng.hxx>
22 #include <editeng/editview.hxx>
23 #include <editeng/editdata.hxx>
24 #include <editeng/eerdll.hxx>
25 #include <editeng/lrspitem.hxx>
26 #include <editeng/fhgtitem.hxx>
28 #include <editeng/outliner.hxx>
29 #include <outleeng.hxx>
30 #include <paralist.hxx>
31 #include <editeng/editrids.hrc>
32 #include <svl/itemset.hxx>
33 #include <editeng/eeitem.hxx>
34 #include <editeng/editstat.hxx>
35 #include "outlundo.hxx"
37 OutlinerEditEng::OutlinerEditEng( Outliner* pEngOwner, SfxItemPool* pPool )
38 : EditEngine( pPool )
40 pOwner = pEngOwner;
43 OutlinerEditEng::~OutlinerEditEng()
47 void OutlinerEditEng::PaintingFirstLine( sal_Int32 nPara, const Point& rStartPos, long nBaseLineY, const Point& rOrigin, short nOrientation, OutputDevice* pOutDev )
49 if( GetControlWord() & EEControlBits::OUTLINER )
51 PaintFirstLineInfo aInfo( nPara, rStartPos, nBaseLineY, rOrigin, nOrientation, pOutDev );
52 pOwner->maPaintFirstLineHdl.Call( &aInfo );
55 pOwner->PaintBullet( nPara, rStartPos, rOrigin, nOrientation, pOutDev );
58 const SvxNumberFormat* OutlinerEditEng::GetNumberFormat( sal_Int32 nPara ) const
60 const SvxNumberFormat* pFmt = NULL;
61 if (pOwner)
62 pFmt = pOwner->GetNumberFormat( nPara );
63 return pFmt;
67 Rectangle OutlinerEditEng::GetBulletArea( sal_Int32 nPara )
69 Rectangle aBulletArea = Rectangle( Point(), Point() );
70 if ( nPara < pOwner->pParaList->GetParagraphCount() )
72 if ( pOwner->ImplHasNumberFormat( nPara ) )
73 aBulletArea = pOwner->ImpCalcBulletArea( nPara, false, false );
75 return aBulletArea;
78 void OutlinerEditEng::ParagraphInserted( sal_Int32 nNewParagraph )
80 pOwner->ParagraphInserted( nNewParagraph );
82 EditEngine::ParagraphInserted( nNewParagraph );
85 void OutlinerEditEng::ParagraphDeleted( sal_Int32 nDeletedParagraph )
87 pOwner->ParagraphDeleted( nDeletedParagraph );
89 EditEngine::ParagraphDeleted( nDeletedParagraph );
92 void OutlinerEditEng::ParagraphConnected( sal_Int32 /*nLeftParagraph*/, sal_Int32 nRightParagraph )
94 if( pOwner && pOwner->IsUndoEnabled() && !const_cast<EditEngine&>(pOwner->GetEditEngine()).IsInUndo() )
96 Paragraph* pPara = pOwner->GetParagraph( nRightParagraph );
97 if( pPara && Outliner::HasParaFlag( pPara, ParaFlag::ISPAGE ) )
99 pOwner->InsertUndo( new OutlinerUndoChangeParaFlags( pOwner, nRightParagraph, ParaFlag::ISPAGE, ParaFlag::NONE ) );
105 void OutlinerEditEng::StyleSheetChanged( SfxStyleSheet* pStyle )
107 pOwner->StyleSheetChanged( pStyle );
110 void OutlinerEditEng::ParaAttribsChanged( sal_Int32 nPara )
112 pOwner->ParaAttribsChanged( nPara );
115 bool OutlinerEditEng::SpellNextDocument()
117 return pOwner->SpellNextDocument();
120 bool OutlinerEditEng::ConvertNextDocument()
122 return pOwner->ConvertNextDocument();
125 OUString OutlinerEditEng::GetUndoComment( sal_uInt16 nUndoId ) const
127 switch( nUndoId )
129 case OLUNDO_DEPTH:
130 return EE_RESSTR(RID_OUTLUNDO_DEPTH);
132 case OLUNDO_EXPAND:
133 return EE_RESSTR(RID_OUTLUNDO_EXPAND);
135 case OLUNDO_COLLAPSE:
136 return EE_RESSTR(RID_OUTLUNDO_COLLAPSE);
138 case OLUNDO_ATTR:
139 return EE_RESSTR(RID_OUTLUNDO_ATTR);
141 case OLUNDO_INSERT:
142 return EE_RESSTR(RID_OUTLUNDO_INSERT);
144 default:
145 return EditEngine::GetUndoComment( nUndoId );
149 void OutlinerEditEng::DrawingText( const Point& rStartPos, const OUString& rText, sal_Int32 nTextStart, sal_Int32 nTextLen,
150 const long* pDXArray, const SvxFont& rFont, sal_Int32 nPara, sal_Int32 nIndex, sal_uInt8 nRightToLeft,
151 const EEngineData::WrongSpellVector* pWrongSpellVector,
152 const SvxFieldData* pFieldData,
153 bool bEndOfLine,
154 bool bEndOfParagraph,
155 bool bEndOfBullet,
156 const ::com::sun::star::lang::Locale* pLocale,
157 const Color& rOverlineColor,
158 const Color& rTextLineColor)
160 pOwner->DrawingText(rStartPos,rText,nTextStart,nTextLen,pDXArray,rFont,nPara,nIndex,nRightToLeft,
161 pWrongSpellVector, pFieldData, bEndOfLine, bEndOfParagraph, bEndOfBullet, pLocale, rOverlineColor, rTextLineColor);
164 void OutlinerEditEng::DrawingTab( const Point& rStartPos, long nWidth, const OUString& rChar,
165 const SvxFont& rFont, sal_Int32 nPara, sal_Int32 nIndex, sal_uInt8 nRightToLeft,
166 bool bEndOfLine, bool bEndOfParagraph,
167 const Color& rOverlineColor, const Color& rTextLineColor)
169 pOwner->DrawingTab(rStartPos, nWidth, rChar, rFont, nPara, nIndex, nRightToLeft,
170 bEndOfLine, bEndOfParagraph, rOverlineColor, rTextLineColor );
173 void OutlinerEditEng::FieldClicked( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos )
175 EditEngine::FieldClicked( rField, nPara, nPos ); // If URL
176 pOwner->FieldClicked( rField, nPara, nPos );
179 void OutlinerEditEng::FieldSelected( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos )
181 pOwner->FieldSelected( rField, nPara, nPos );
184 OUString OutlinerEditEng::CalcFieldValue( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos, Color*& rpTxtColor, Color*& rpFldColor )
186 return pOwner->CalcFieldValue( rField, nPara, nPos, rpTxtColor, rpFldColor );
189 void OutlinerEditEng::SetParaAttribs( sal_Int32 nPara, const SfxItemSet& rSet )
191 Paragraph* pPara = pOwner->pParaList->GetParagraph( nPara );
192 if( pPara )
194 if ( !IsInUndo() && IsUndoEnabled() )
195 pOwner->UndoActionStart( OLUNDO_ATTR );
197 EditEngine::SetParaAttribs( nPara, rSet );
199 pOwner->ImplCheckNumBulletItem( nPara );
200 // #i100014#
201 // It is not a good idea to subtract 1 from a count and cast the result
202 // to sal_uInt16 without check, if the count is 0.
203 pOwner->ImplCheckParagraphs( nPara, pOwner->pParaList->GetParagraphCount() );
205 if ( !IsInUndo() && IsUndoEnabled() )
206 pOwner->UndoActionEnd( OLUNDO_ATTR );
210 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */