LibreOffice Module editeng (master) 1
outleeng.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20#include <editeng/editeng.hxx>
21#include <editeng/eerdll.hxx>
22
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"
31
33 : EditEngine( pPool )
34{
35 pOwner = pEngOwner;
36}
37
39{
40}
41
42void OutlinerEditEng::PaintingFirstLine(sal_Int32 nPara, const Point& rStartPos, const Point& rOrigin, Degree10 nOrientation, OutputDevice& rOutDev)
43{
45 {
46 PaintFirstLineInfo aInfo(nPara, rStartPos, &rOutDev);
48 }
49
50 pOwner->PaintBullet(nPara, rStartPos, rOrigin, nOrientation, rOutDev);
51}
52
54{
55 const SvxNumberFormat* pFmt = nullptr;
56 if (pOwner)
57 pFmt = pOwner->GetNumberFormat( nPara );
58 return pFmt;
59}
60
61
63{
64 tools::Rectangle aBulletArea { Point(), Point() };
65 if ( nPara < pOwner->pParaList->GetParagraphCount() )
66 {
67 if ( pOwner->ImplHasNumberFormat( nPara ) )
68 aBulletArea = pOwner->ImpCalcBulletArea( nPara, false, false );
69 }
70 return aBulletArea;
71}
72
74{
75 if(pOwner)
76 {
77 return pOwner->GetCompatFlag(eFlag);
78 }
79 return {};
80}
81
82void OutlinerEditEng::ParagraphInserted( sal_Int32 nNewParagraph )
83{
84 pOwner->ParagraphInserted( nNewParagraph );
85
86 EditEngine::ParagraphInserted( nNewParagraph );
87}
88
89void OutlinerEditEng::ParagraphDeleted( sal_Int32 nDeletedParagraph )
90{
91 pOwner->ParagraphDeleted( nDeletedParagraph );
92
93 EditEngine::ParagraphDeleted( nDeletedParagraph );
94}
95
96void OutlinerEditEng::ParagraphConnected( sal_Int32 /*nLeftParagraph*/, sal_Int32 nRightParagraph )
97{
99 {
100 Paragraph* pPara = pOwner->GetParagraph( nRightParagraph );
101 if( pPara && Outliner::HasParaFlag( pPara, ParaFlag::ISPAGE ) )
102 {
103 pOwner->InsertUndo( std::make_unique<OutlinerUndoChangeParaFlags>( pOwner, nRightParagraph, ParaFlag::ISPAGE, ParaFlag::NONE ) );
104 }
105 }
106}
107
108
110{
111 pOwner->StyleSheetChanged( pStyle );
112}
113
115{
116 pOwner->ParaAttribsChanged( nPara );
117}
118
120{
121 return pOwner->SpellNextDocument();
122}
123
125{
126 return pOwner->ConvertNextDocument();
127}
128
129OUString OutlinerEditEng::GetUndoComment( sal_uInt16 nUndoId ) const
130{
131 switch( nUndoId )
132 {
133 case OLUNDO_DEPTH:
134 return EditResId(RID_OUTLUNDO_DEPTH);
135
136 case OLUNDO_EXPAND:
137 return EditResId(RID_OUTLUNDO_EXPAND);
138
139 case OLUNDO_COLLAPSE:
140 return EditResId(RID_OUTLUNDO_COLLAPSE);
141
142 case OLUNDO_ATTR:
143 return EditResId(RID_OUTLUNDO_ATTR);
144
145 case OLUNDO_INSERT:
146 return EditResId(RID_OUTLUNDO_INSERT);
147
148 default:
149 return EditEngine::GetUndoComment( nUndoId );
150 }
151}
152
153void OutlinerEditEng::DrawingText( const Point& rStartPos, const OUString& rText, sal_Int32 nTextStart, sal_Int32 nTextLen,
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)
163{
164 pOwner->DrawingText(rStartPos,rText,nTextStart,nTextLen,pDXArray,pKashidaArray,rFont,nPara,nRightToLeft,
165 pWrongSpellVector, pFieldData, bEndOfLine, bEndOfParagraph, false/*bEndOfBullet*/, pLocale, rOverlineColor, rTextLineColor);
166}
167
168void 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)
172{
173 pOwner->DrawingTab(rStartPos, nWidth, rChar, rFont, nPara, nRightToLeft,
174 bEndOfLine, bEndOfParagraph, rOverlineColor, rTextLineColor );
175}
176
177OUString OutlinerEditEng::CalcFieldValue( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos, std::optional<Color>& rpTxtColor, std::optional<Color>& rpFldColor, std::optional<FontLineStyle>& rpFldLineStyle )
178{
179 return pOwner->CalcFieldValue( rField, nPara, nPos, rpTxtColor, rpFldColor, rpFldLineStyle );
180}
181
182void OutlinerEditEng::SetParaAttribs( sal_Int32 nPara, const SfxItemSet& rSet )
183{
184 Paragraph* pPara = pOwner->pParaList->GetParagraph( nPara );
185 if( !pPara )
186 return;
187
188 if ( !IsInUndo() && IsUndoEnabled() )
190
192
194 // #i100014#
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() );
198
199 if ( !IsInUndo() && IsUndoEnabled() )
201}
202
203/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual OUString GetUndoComment(sal_uInt16 nUndoId) const
Definition: editeng.cxx:2564
EEControlBits GetControlWord() const
Definition: editeng.cxx:1953
virtual void ParagraphDeleted(sal_Int32 nDeletedParagraph)
Definition: editeng.cxx:2529
bool IsUndoEnabled() const
Definition: editeng.cxx:105
bool IsInUndo() const
Definition: editeng.cxx:110
virtual void ParagraphInserted(sal_Int32 nNewParagraph)
Definition: editeng.cxx:2518
virtual void SetParaAttribs(sal_Int32 nPara, const SfxItemSet &rSet)
Definition: editeng.cxx:1747
virtual bool ConvertNextDocument() override
Definition: outleeng.cxx:124
virtual void SetParaAttribs(sal_Int32 nPara, const SfxItemSet &rSet) override
Definition: outleeng.cxx:182
virtual void ParagraphConnected(sal_Int32 nLeftParagraph, sal_Int32 nRightParagraph) override
Definition: outleeng.cxx:96
virtual void ParaAttribsChanged(sal_Int32 nPara) override
Definition: outleeng.cxx:114
virtual OUString GetUndoComment(sal_uInt16 nUndoId) const override
Definition: outleeng.cxx:129
virtual OUString CalcFieldValue(const SvxFieldItem &rField, sal_Int32 nPara, sal_Int32 nPos, std::optional< Color > &rTxtColor, std::optional< Color > &rFldColor, std::optional< FontLineStyle > &rFldLineStyle) override
Definition: outleeng.cxx:177
virtual void ParagraphDeleted(sal_Int32 nDeletedParagraph) override
Definition: outleeng.cxx:89
virtual void ParagraphInserted(sal_Int32 nNewParagraph) override
Definition: outleeng.cxx:82
virtual ~OutlinerEditEng() override
Definition: outleeng.cxx:38
virtual void DrawingTab(const Point &rStartPos, tools::Long nWidth, const OUString &rChar, const SvxFont &rFont, sal_Int32 nPara, sal_uInt8 nRightToLeft, bool bEndOfLine, bool bEndOfParagraph, const Color &rOverlineColor, const Color &rTextLineColor) override
Definition: outleeng.cxx:168
OutlinerEditEng(Outliner *pOwner, SfxItemPool *pPool)
Definition: outleeng.cxx:32
virtual bool SpellNextDocument() override
Definition: outleeng.cxx:119
virtual void StyleSheetChanged(SfxStyleSheet *pStyle) override
Definition: outleeng.cxx:109
virtual const SvxNumberFormat * GetNumberFormat(sal_Int32 nPara) const override
Definition: outleeng.cxx:53
virtual tools::Rectangle GetBulletArea(sal_Int32 nPara) override
Definition: outleeng.cxx:62
virtual void PaintingFirstLine(sal_Int32 nPara, const Point &rStartPos, const Point &rOrigin, Degree10 nOrientation, OutputDevice &rOutDev) override
Definition: outleeng.cxx:42
std::optional< bool > GetCompatFlag(SdrCompatibilityFlag eFlag) const
Definition: outleeng.cxx:73
virtual void DrawingText(const Point &rStartPos, const OUString &rText, sal_Int32 nTextStart, sal_Int32 nTextLen, o3tl::span< const sal_Int32 > pDXArray, o3tl::span< const sal_Bool > pKashidaArray, const SvxFont &rFont, sal_Int32 nPara, sal_uInt8 nRightToLeft, const EEngineData::WrongSpellVector *pWrongSpellVector, const SvxFieldData *pFieldData, bool bEndOfLine, bool bEndOfParagraph, const css::lang::Locale *pLocale, const Color &rOverlineColor, const Color &rTextLineColor) override
Definition: outleeng.cxx:153
Outliner * pOwner
Definition: outleeng.hxx:30
void DrawingText(const Point &rStartPos, const OUString &rText, sal_Int32 nTextStart, sal_Int32 nTextLen, o3tl::span< const sal_Int32 > pDXArray, o3tl::span< const sal_Bool > pKashidaArray, const SvxFont &rFont, sal_Int32 nPara, sal_uInt8 nRightToLeft, const EEngineData::WrongSpellVector *pWrongSpellVector, const SvxFieldData *pFieldData, bool bEndOfLine, bool bEndOfParagraph, bool bEndOfBullet, const css::lang::Locale *pLocale, const Color &rOverlineColor, const Color &rTextLineColor)
Definition: outliner.cxx:1651
virtual bool ConvertNextDocument()
Definition: outlin2.cxx:346
static bool HasParaFlag(const Paragraph *pPara, ParaFlag nFlag)
Definition: outliner.cxx:1976
void ImplCheckParagraphs(sal_Int32 nStart, sal_Int32 nEnd)
Definition: outliner.cxx:1417
const EditEngine & GetEditEngine() const
Definition: outlin2.cxx:515
tools::Rectangle ImpCalcBulletArea(sal_Int32 nPara, bool bAdjust, bool bReturnPaperPos)
Definition: outliner.cxx:1484
void DrawingTab(const Point &rStartPos, tools::Long nWidth, const OUString &rChar, const SvxFont &rFont, sal_Int32 nPara, sal_uInt8 nRightToLeft, bool bEndOfLine, bool bEndOfParagraph, const Color &rOverlineColor, const Color &rTextLineColor)
Definition: outliner.cxx:1673
Paragraph * GetParagraph(sal_Int32 nAbsPos) const
Definition: outliner.cxx:1345
const SvxNumberFormat * GetNumberFormat(sal_Int32 nPara) const
Definition: outliner.cxx:1360
void PaintBullet(sal_Int32 nPara, const Point &rStartPos, const Point &rOrigin, Degree10 nOrientation, OutputDevice &rOutDev)
Definition: outliner.cxx:875
bool ImplHasNumberFormat(sal_Int32 nPara) const
Definition: outliner.cxx:1355
void InsertUndo(std::unique_ptr< EditUndo > pUndo)
Definition: outlin2.cxx:306
void ParaAttribsChanged(sal_Int32 nParagraph)
Definition: outliner.cxx:1441
void ImplCheckNumBulletItem(sal_Int32 nPara)
Definition: outliner.cxx:676
bool IsUndoEnabled() const
Definition: outlin2.cxx:65
virtual bool SpellNextDocument()
Definition: outlin2.cxx:376
virtual OUString CalcFieldValue(const SvxFieldItem &rField, sal_Int32 nPara, sal_Int32 nPos, std::optional< Color > &rTxtColor, std::optional< Color > &rFldColor, std::optional< FontLineStyle > &rFldLineStyle)
Definition: outliner.cxx:637
void UndoActionStart(sal_uInt16 nId)
Definition: outlin2.cxx:296
std::unique_ptr< ParagraphList > pParaList
Definition: outliner.hxx:589
void StyleSheetChanged(SfxStyleSheet const *pStyle)
Definition: outliner.cxx:1463
virtual std::optional< bool > GetCompatFlag(SdrCompatibilityFlag) const
Definition: outliner.hxx:1000
void ParagraphInserted(sal_Int32 nParagraph)
Definition: outliner.cxx:115
Link< PaintFirstLineInfo *, void > maPaintFirstLineHdl
Definition: outliner.hxx:603
void ParagraphDeleted(sal_Int32 nParagraph)
Definition: outliner.cxx:150
void UndoActionEnd()
Definition: outlin2.cxx:301
This item stores a field (SvxFieldData).
Definition: flditem.hxx:70
SdrCompatibilityFlag
OUString EditResId(TranslateId aId)
Definition: eerdll.cxx:192
sal_uInt16 nPos
const char * pLocale
std::vector< WrongSpellClass > WrongSpellVector
Definition: eedata.hxx:42
long Long
#define OLUNDO_INSERT
Definition: outliner.hxx:114
#define OLUNDO_DEPTH
Definition: outliner.hxx:108
#define OLUNDO_COLLAPSE
Definition: outliner.hxx:111
#define OLUNDO_EXPAND
Definition: outliner.hxx:110
#define OLUNDO_ATTR
Definition: outliner.hxx:113
static SfxItemSet & rSet
unsigned char sal_uInt8