tdf#130857 qt weld: Implement QtInstanceWidget::get_text_height
[LibreOffice.git] / editeng / source / outliner / outleeng.cxx
blobda297400382b630314a787890132546ddc1427b5
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 <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 <optional>
28 #include <svl/itemset.hxx>
29 #include <editeng/editstat.hxx>
30 #include "outlundo.hxx"
32 OutlinerEditEng::OutlinerEditEng( Outliner* pEngOwner, SfxItemPool* pPool )
33 : EditEngine( pPool )
35 pOwner = pEngOwner;
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;
56 if (pOwner)
57 pFmt = pOwner->GetNumberFormat( nPara );
58 return pFmt;
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 );
70 return aBulletArea;
73 std::optional<bool> OutlinerEditEng::GetCompatFlag(SdrCompatibilityFlag eFlag) const
75 if(pOwner)
77 return pOwner->GetCompatFlag(eFlag);
79 return {};
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
131 switch( nUndoId )
133 case OLUNDO_DEPTH:
134 return EditResId(RID_OUTLUNDO_DEPTH);
136 case OLUNDO_EXPAND:
137 return EditResId(RID_OUTLUNDO_EXPAND);
139 case OLUNDO_COLLAPSE:
140 return EditResId(RID_OUTLUNDO_COLLAPSE);
142 case OLUNDO_ATTR:
143 return EditResId(RID_OUTLUNDO_ATTR);
145 case OLUNDO_INSERT:
146 return EditResId(RID_OUTLUNDO_INSERT);
148 default:
149 return EditEngine::GetUndoComment( nUndoId );
153 void OutlinerEditEng::DrawingText( const Point& rStartPos, const OUString& rText, sal_Int32 nTextStart, sal_Int32 nTextLen,
154 KernArraySpan 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,
158 bool bEndOfLine,
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 OUString OutlinerEditEng::CalcFieldValue( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos, std::optional<Color>& rpTxtColor, std::optional<Color>& rpFldColor, std::optional<FontLineStyle>& rpFldLineStyle )
170 return pOwner->CalcFieldValue( rField, nPara, nPos, rpTxtColor, rpFldColor, rpFldLineStyle );
173 void OutlinerEditEng::SetParaAttribs( sal_Int32 nPara, const SfxItemSet& rSet )
175 Paragraph* pPara = pOwner->pParaList->GetParagraph( nPara );
176 if( !pPara )
177 return;
179 if ( !IsInUndo() && IsUndoEnabled() )
180 pOwner->UndoActionStart( OLUNDO_ATTR );
182 EditEngine::SetParaAttribs( nPara, rSet );
184 pOwner->ImplCheckNumBulletItem( nPara );
185 // #i100014#
186 // It is not a good idea to subtract 1 from a count and cast the result
187 // to sal_uInt16 without check, if the count is 0.
188 pOwner->ImplCheckParagraphs( nPara, pOwner->pParaList->GetParagraphCount() );
190 if ( !IsInUndo() && IsUndoEnabled() )
191 pOwner->UndoActionEnd();
194 sal_Int16 OutlinerEditEng::GetDepth(sal_Int32 nPara) const
196 return pOwner->GetDepth(nPara);
199 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */