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>
28 #include <svl/itemset.hxx>
29 #include <editeng/editstat.hxx>
30 #include "outlundo.hxx"
32 OutlinerEditEng::OutlinerEditEng( Outliner
* pEngOwner
, SfxItemPool
* pPool
)
38 OutlinerEditEng::~OutlinerEditEng()
42 void OutlinerEditEng::PaintingFirstLine(sal_Int32 nPara
, const Point
& rStartPos
, const Point
& rOrigin
, Degree10 nOrientation
, OutputDevice
& rOutDev
)
44 if( GetControlWord() & EEControlBits::OUTLINER
)
46 PaintFirstLineInfo
aInfo(nPara
, rStartPos
, &rOutDev
);
47 pOwner
->maPaintFirstLineHdl
.Call( &aInfo
);
50 pOwner
->PaintBullet(nPara
, rStartPos
, rOrigin
, nOrientation
, rOutDev
);
53 const SvxNumberFormat
* OutlinerEditEng::GetNumberFormat( sal_Int32 nPara
) const
55 const SvxNumberFormat
* pFmt
= nullptr;
57 pFmt
= pOwner
->GetNumberFormat( nPara
);
62 tools::Rectangle
OutlinerEditEng::GetBulletArea( sal_Int32 nPara
)
64 tools::Rectangle aBulletArea
{ Point(), Point() };
65 if ( nPara
< pOwner
->pParaList
->GetParagraphCount() )
67 if ( pOwner
->ImplHasNumberFormat( nPara
) )
68 aBulletArea
= pOwner
->ImpCalcBulletArea( nPara
, false, false );
73 std::optional
<bool> OutlinerEditEng::GetCompatFlag(SdrCompatibilityFlag eFlag
) const
77 return pOwner
->GetCompatFlag(eFlag
);
82 void OutlinerEditEng::ParagraphInserted( sal_Int32 nNewParagraph
)
84 pOwner
->ParagraphInserted( nNewParagraph
);
86 EditEngine::ParagraphInserted( nNewParagraph
);
89 void OutlinerEditEng::ParagraphDeleted( sal_Int32 nDeletedParagraph
)
91 pOwner
->ParagraphDeleted( nDeletedParagraph
);
93 EditEngine::ParagraphDeleted( nDeletedParagraph
);
96 void OutlinerEditEng::ParagraphConnected( sal_Int32
/*nLeftParagraph*/, sal_Int32 nRightParagraph
)
98 if( pOwner
&& pOwner
->IsUndoEnabled() && !pOwner
->GetEditEngine().IsInUndo() )
100 Paragraph
* pPara
= pOwner
->GetParagraph( nRightParagraph
);
101 if( pPara
&& Outliner::HasParaFlag( pPara
, ParaFlag::ISPAGE
) )
103 pOwner
->InsertUndo( std::make_unique
<OutlinerUndoChangeParaFlags
>( pOwner
, nRightParagraph
, ParaFlag::ISPAGE
, ParaFlag::NONE
) );
109 void OutlinerEditEng::StyleSheetChanged( SfxStyleSheet
* pStyle
)
111 pOwner
->StyleSheetChanged( pStyle
);
114 void OutlinerEditEng::ParaAttribsChanged( sal_Int32 nPara
)
116 pOwner
->ParaAttribsChanged( nPara
);
119 bool OutlinerEditEng::SpellNextDocument()
121 return pOwner
->SpellNextDocument();
124 bool OutlinerEditEng::ConvertNextDocument()
126 return pOwner
->ConvertNextDocument();
129 OUString
OutlinerEditEng::GetUndoComment( sal_uInt16 nUndoId
) const
134 return EditResId(RID_OUTLUNDO_DEPTH
);
137 return EditResId(RID_OUTLUNDO_EXPAND
);
139 case OLUNDO_COLLAPSE
:
140 return EditResId(RID_OUTLUNDO_COLLAPSE
);
143 return EditResId(RID_OUTLUNDO_ATTR
);
146 return EditResId(RID_OUTLUNDO_INSERT
);
149 return EditEngine::GetUndoComment( nUndoId
);
153 void OutlinerEditEng::DrawingText( const Point
& rStartPos
, const OUString
& rText
, sal_Int32 nTextStart
, sal_Int32 nTextLen
,
154 std::span
<const sal_Int32
> pDXArray
, std::span
<const sal_Bool
> pKashidaArray
,
155 const SvxFont
& rFont
, sal_Int32 nPara
, sal_uInt8 nRightToLeft
,
156 const EEngineData::WrongSpellVector
* pWrongSpellVector
,
157 const SvxFieldData
* pFieldData
,
159 bool bEndOfParagraph
,
160 const css::lang::Locale
* pLocale
,
161 const Color
& rOverlineColor
,
162 const Color
& rTextLineColor
)
164 pOwner
->DrawingText(rStartPos
,rText
,nTextStart
,nTextLen
,pDXArray
,pKashidaArray
,rFont
,nPara
,nRightToLeft
,
165 pWrongSpellVector
, pFieldData
, bEndOfLine
, bEndOfParagraph
, false/*bEndOfBullet*/, pLocale
, rOverlineColor
, rTextLineColor
);
168 void OutlinerEditEng::DrawingTab( const Point
& rStartPos
, tools::Long nWidth
, const OUString
& rChar
,
169 const SvxFont
& rFont
, sal_Int32 nPara
, sal_uInt8 nRightToLeft
,
170 bool bEndOfLine
, bool bEndOfParagraph
,
171 const Color
& rOverlineColor
, const Color
& rTextLineColor
)
173 pOwner
->DrawingTab(rStartPos
, nWidth
, rChar
, rFont
, nPara
, nRightToLeft
,
174 bEndOfLine
, bEndOfParagraph
, rOverlineColor
, rTextLineColor
);
177 OUString
OutlinerEditEng::CalcFieldValue( const SvxFieldItem
& rField
, sal_Int32 nPara
, sal_Int32 nPos
, std::optional
<Color
>& rpTxtColor
, std::optional
<Color
>& rpFldColor
, std::optional
<FontLineStyle
>& rpFldLineStyle
)
179 return pOwner
->CalcFieldValue( rField
, nPara
, nPos
, rpTxtColor
, rpFldColor
, rpFldLineStyle
);
182 void OutlinerEditEng::SetParaAttribs( sal_Int32 nPara
, const SfxItemSet
& rSet
)
184 Paragraph
* pPara
= pOwner
->pParaList
->GetParagraph( nPara
);
188 if ( !IsInUndo() && IsUndoEnabled() )
189 pOwner
->UndoActionStart( OLUNDO_ATTR
);
191 EditEngine::SetParaAttribs( nPara
, rSet
);
193 pOwner
->ImplCheckNumBulletItem( nPara
);
195 // It is not a good idea to subtract 1 from a count and cast the result
196 // to sal_uInt16 without check, if the count is 0.
197 pOwner
->ImplCheckParagraphs( nPara
, pOwner
->pParaList
->GetParagraphCount() );
199 if ( !IsInUndo() && IsUndoEnabled() )
200 pOwner
->UndoActionEnd();
203 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */