Line data Source code
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 <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>
27 :
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"
36 :
37 0 : OutlinerEditEng::OutlinerEditEng( Outliner* pEngOwner, SfxItemPool* pPool )
38 0 : : EditEngine( pPool )
39 : {
40 0 : pOwner = pEngOwner;
41 0 : }
42 :
43 0 : OutlinerEditEng::~OutlinerEditEng()
44 : {
45 0 : }
46 :
47 0 : void OutlinerEditEng::PaintingFirstLine( sal_Int32 nPara, const Point& rStartPos, long nBaseLineY, const Point& rOrigin, short nOrientation, OutputDevice* pOutDev )
48 : {
49 0 : if( GetControlWord() & EE_CNTRL_OUTLINER )
50 : {
51 0 : PaintFirstLineInfo aInfo( nPara, rStartPos, nBaseLineY, rOrigin, nOrientation, pOutDev );
52 0 : pOwner->maPaintFirstLineHdl.Call( &aInfo );
53 : }
54 :
55 0 : pOwner->PaintBullet( nPara, rStartPos, rOrigin, nOrientation, pOutDev );
56 0 : }
57 :
58 0 : const SvxNumberFormat* OutlinerEditEng::GetNumberFormat( sal_Int32 nPara ) const
59 : {
60 0 : const SvxNumberFormat* pFmt = NULL;
61 0 : if (pOwner)
62 0 : pFmt = pOwner->GetNumberFormat( nPara );
63 0 : return pFmt;
64 : }
65 :
66 :
67 0 : Rectangle OutlinerEditEng::GetBulletArea( sal_Int32 nPara )
68 : {
69 0 : Rectangle aBulletArea = Rectangle( Point(), Point() );
70 0 : if ( nPara < pOwner->pParaList->GetParagraphCount() )
71 : {
72 0 : if ( pOwner->ImplHasNumberFormat( nPara ) )
73 0 : aBulletArea = pOwner->ImpCalcBulletArea( nPara, false, false );
74 : }
75 0 : return aBulletArea;
76 : }
77 :
78 0 : void OutlinerEditEng::ParagraphInserted( sal_Int32 nNewParagraph )
79 : {
80 0 : pOwner->ParagraphInserted( nNewParagraph );
81 :
82 0 : EditEngine::ParagraphInserted( nNewParagraph );
83 0 : }
84 :
85 0 : void OutlinerEditEng::ParagraphDeleted( sal_Int32 nDeletedParagraph )
86 : {
87 0 : pOwner->ParagraphDeleted( nDeletedParagraph );
88 :
89 0 : EditEngine::ParagraphDeleted( nDeletedParagraph );
90 0 : }
91 :
92 0 : void OutlinerEditEng::ParagraphConnected( sal_Int32 /*nLeftParagraph*/, sal_Int32 nRightParagraph )
93 : {
94 0 : if( pOwner && pOwner->IsUndoEnabled() && !const_cast<EditEngine&>(pOwner->GetEditEngine()).IsInUndo() )
95 : {
96 0 : Paragraph* pPara = pOwner->GetParagraph( nRightParagraph );
97 0 : if( pPara && pOwner->HasParaFlag( pPara, PARAFLAG_ISPAGE ) )
98 : {
99 0 : pOwner->InsertUndo( new OutlinerUndoChangeParaFlags( pOwner, nRightParagraph, PARAFLAG_ISPAGE, 0 ) );
100 : }
101 : }
102 0 : }
103 :
104 :
105 0 : void OutlinerEditEng::StyleSheetChanged( SfxStyleSheet* pStyle )
106 : {
107 0 : pOwner->StyleSheetChanged( pStyle );
108 0 : }
109 :
110 0 : void OutlinerEditEng::ParaAttribsChanged( sal_Int32 nPara )
111 : {
112 0 : pOwner->ParaAttribsChanged( nPara );
113 0 : }
114 :
115 0 : bool OutlinerEditEng::SpellNextDocument()
116 : {
117 0 : return pOwner->SpellNextDocument();
118 : }
119 :
120 0 : bool OutlinerEditEng::ConvertNextDocument()
121 : {
122 0 : return pOwner->ConvertNextDocument();
123 : }
124 :
125 0 : OUString OutlinerEditEng::GetUndoComment( sal_uInt16 nUndoId ) const
126 : {
127 0 : switch( nUndoId )
128 : {
129 : case OLUNDO_DEPTH:
130 0 : return EE_RESSTR(RID_OUTLUNDO_DEPTH);
131 :
132 : case OLUNDO_EXPAND:
133 0 : return EE_RESSTR(RID_OUTLUNDO_EXPAND);
134 :
135 : case OLUNDO_COLLAPSE:
136 0 : return EE_RESSTR(RID_OUTLUNDO_COLLAPSE);
137 :
138 : case OLUNDO_ATTR:
139 0 : return EE_RESSTR(RID_OUTLUNDO_ATTR);
140 :
141 : case OLUNDO_INSERT:
142 0 : return EE_RESSTR(RID_OUTLUNDO_INSERT);
143 :
144 : default:
145 0 : return EditEngine::GetUndoComment( nUndoId );
146 : }
147 : }
148 :
149 0 : void OutlinerEditEng::DrawingText( const Point& rStartPos, const OUString& rText, sal_Int32 nTextStart, sal_Int32 nTextLen,
150 : const sal_Int32* 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)
159 : {
160 : pOwner->DrawingText(rStartPos,rText,nTextStart,nTextLen,pDXArray,rFont,nPara,nIndex,nRightToLeft,
161 0 : pWrongSpellVector, pFieldData, bEndOfLine, bEndOfParagraph, bEndOfBullet, pLocale, rOverlineColor, rTextLineColor);
162 0 : }
163 :
164 0 : 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)
168 : {
169 : pOwner->DrawingTab(rStartPos, nWidth, rChar, rFont, nPara, nIndex, nRightToLeft,
170 0 : bEndOfLine, bEndOfParagraph, rOverlineColor, rTextLineColor );
171 0 : }
172 :
173 0 : void OutlinerEditEng::FieldClicked( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos )
174 : {
175 0 : EditEngine::FieldClicked( rField, nPara, nPos ); // If URL
176 0 : pOwner->FieldClicked( rField, nPara, nPos );
177 0 : }
178 :
179 0 : void OutlinerEditEng::FieldSelected( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos )
180 : {
181 0 : pOwner->FieldSelected( rField, nPara, nPos );
182 0 : }
183 :
184 0 : OUString OutlinerEditEng::CalcFieldValue( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos, Color*& rpTxtColor, Color*& rpFldColor )
185 : {
186 0 : return pOwner->CalcFieldValue( rField, nPara, nPos, rpTxtColor, rpFldColor );
187 : }
188 :
189 0 : void OutlinerEditEng::SetParaAttribs( sal_Int32 nPara, const SfxItemSet& rSet )
190 : {
191 0 : Paragraph* pPara = pOwner->pParaList->GetParagraph( nPara );
192 0 : if( pPara )
193 : {
194 0 : if ( !IsInUndo() && IsUndoEnabled() )
195 0 : pOwner->UndoActionStart( OLUNDO_ATTR );
196 :
197 0 : EditEngine::SetParaAttribs( nPara, rSet );
198 :
199 0 : pOwner->ImplCheckNumBulletItem( nPara );
200 : // #i100014#
201 : // It is not a good idea to substract 1 from a count and cast the result
202 : // to sal_uInt16 without check, if the count is 0.
203 0 : pOwner->ImplCheckParagraphs( nPara, pOwner->pParaList->GetParagraphCount() );
204 :
205 0 : if ( !IsInUndo() && IsUndoEnabled() )
206 0 : pOwner->UndoActionEnd( OLUNDO_ATTR );
207 : }
208 0 : }
209 :
210 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|