1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 <editeng/editeng.hxx>
21 #include <editeng/eerdll.hxx>
23 #include <editeng/outliner.hxx>
24 #include "outleeng.hxx"
25 #include "paralist.hxx"
26 #include <editeng/editrids.hrc>
27 #include <svl/itemset.hxx>
28 #include <editeng/editstat.hxx>
29 #include "outlundo.hxx"
31 OutlinerEditEng::OutlinerEditEng( Outliner
* pEngOwner
, SfxItemPool
* pPool
)
37 OutlinerEditEng::~OutlinerEditEng()
41 void OutlinerEditEng::PaintingFirstLine( sal_Int32 nPara
, const Point
& rStartPos
, tools::Long
/*nBaseLineY*/, const Point
& rOrigin
, Degree10 nOrientation
, OutputDevice
* pOutDev
)
43 if( GetControlWord() & EEControlBits::OUTLINER
)
45 PaintFirstLineInfo
aInfo( nPara
, rStartPos
, pOutDev
);
46 pOwner
->maPaintFirstLineHdl
.Call( &aInfo
);
49 pOwner
->PaintBullet( nPara
, rStartPos
, rOrigin
, nOrientation
, pOutDev
);
52 const SvxNumberFormat
* OutlinerEditEng::GetNumberFormat( sal_Int32 nPara
) const
54 const SvxNumberFormat
* pFmt
= nullptr;
56 pFmt
= pOwner
->GetNumberFormat( nPara
);
61 tools::Rectangle
OutlinerEditEng::GetBulletArea( sal_Int32 nPara
)
63 tools::Rectangle aBulletArea
{ Point(), Point() };
64 if ( nPara
< pOwner
->pParaList
->GetParagraphCount() )
66 if ( pOwner
->ImplHasNumberFormat( nPara
) )
67 aBulletArea
= pOwner
->ImpCalcBulletArea( nPara
, false, false );
72 void OutlinerEditEng::ParagraphInserted( sal_Int32 nNewParagraph
)
74 pOwner
->ParagraphInserted( nNewParagraph
);
76 EditEngine::ParagraphInserted( nNewParagraph
);
79 void OutlinerEditEng::ParagraphDeleted( sal_Int32 nDeletedParagraph
)
81 pOwner
->ParagraphDeleted( nDeletedParagraph
);
83 EditEngine::ParagraphDeleted( nDeletedParagraph
);
86 void OutlinerEditEng::ParagraphConnected( sal_Int32
/*nLeftParagraph*/, sal_Int32 nRightParagraph
)
88 if( pOwner
&& pOwner
->IsUndoEnabled() && !pOwner
->GetEditEngine().IsInUndo() )
90 Paragraph
* pPara
= pOwner
->GetParagraph( nRightParagraph
);
91 if( pPara
&& Outliner::HasParaFlag( pPara
, ParaFlag::ISPAGE
) )
93 pOwner
->InsertUndo( std::make_unique
<OutlinerUndoChangeParaFlags
>( pOwner
, nRightParagraph
, ParaFlag::ISPAGE
, ParaFlag::NONE
) );
99 void OutlinerEditEng::StyleSheetChanged( SfxStyleSheet
* pStyle
)
101 pOwner
->StyleSheetChanged( pStyle
);
104 void OutlinerEditEng::ParaAttribsChanged( sal_Int32 nPara
)
106 pOwner
->ParaAttribsChanged( nPara
);
109 bool OutlinerEditEng::SpellNextDocument()
111 return pOwner
->SpellNextDocument();
114 bool OutlinerEditEng::ConvertNextDocument()
116 return pOwner
->ConvertNextDocument();
119 OUString
OutlinerEditEng::GetUndoComment( sal_uInt16 nUndoId
) const
124 return EditResId(RID_OUTLUNDO_DEPTH
);
127 return EditResId(RID_OUTLUNDO_EXPAND
);
129 case OLUNDO_COLLAPSE
:
130 return EditResId(RID_OUTLUNDO_COLLAPSE
);
133 return EditResId(RID_OUTLUNDO_ATTR
);
136 return EditResId(RID_OUTLUNDO_INSERT
);
139 return EditEngine::GetUndoComment( nUndoId
);
143 void OutlinerEditEng::DrawingText( const Point
& rStartPos
, const OUString
& rText
, sal_Int32 nTextStart
, sal_Int32 nTextLen
,
144 const tools::Long
* pDXArray
, const SvxFont
& rFont
, sal_Int32 nPara
, sal_uInt8 nRightToLeft
,
145 const EEngineData::WrongSpellVector
* pWrongSpellVector
,
146 const SvxFieldData
* pFieldData
,
148 bool bEndOfParagraph
,
149 const css::lang::Locale
* pLocale
,
150 const Color
& rOverlineColor
,
151 const Color
& rTextLineColor
)
153 pOwner
->DrawingText(rStartPos
,rText
,nTextStart
,nTextLen
,pDXArray
,rFont
,nPara
,nRightToLeft
,
154 pWrongSpellVector
, pFieldData
, bEndOfLine
, bEndOfParagraph
, false/*bEndOfBullet*/, pLocale
, rOverlineColor
, rTextLineColor
);
157 void OutlinerEditEng::DrawingTab( const Point
& rStartPos
, tools::Long nWidth
, const OUString
& rChar
,
158 const SvxFont
& rFont
, sal_Int32 nPara
, sal_uInt8 nRightToLeft
,
159 bool bEndOfLine
, bool bEndOfParagraph
,
160 const Color
& rOverlineColor
, const Color
& rTextLineColor
)
162 pOwner
->DrawingTab(rStartPos
, nWidth
, rChar
, rFont
, nPara
, nRightToLeft
,
163 bEndOfLine
, bEndOfParagraph
, rOverlineColor
, rTextLineColor
);
166 OUString
OutlinerEditEng::CalcFieldValue( const SvxFieldItem
& rField
, sal_Int32 nPara
, sal_Int32 nPos
, std::optional
<Color
>& rpTxtColor
, std::optional
<Color
>& rpFldColor
)
168 return pOwner
->CalcFieldValue( rField
, nPara
, nPos
, rpTxtColor
, rpFldColor
);
171 void OutlinerEditEng::SetParaAttribs( sal_Int32 nPara
, const SfxItemSet
& rSet
)
173 Paragraph
* pPara
= pOwner
->pParaList
->GetParagraph( nPara
);
177 if ( !IsInUndo() && IsUndoEnabled() )
178 pOwner
->UndoActionStart( OLUNDO_ATTR
);
180 EditEngine::SetParaAttribs( nPara
, rSet
);
182 pOwner
->ImplCheckNumBulletItem( nPara
);
184 // It is not a good idea to subtract 1 from a count and cast the result
185 // to sal_uInt16 without check, if the count is 0.
186 pOwner
->ImplCheckParagraphs( nPara
, pOwner
->pParaList
->GetParagraphCount() );
188 if ( !IsInUndo() && IsUndoEnabled() )
189 pOwner
->UndoActionEnd();
192 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */