Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #include <svl/intitem.hxx>
30 : : #include <editeng/editeng.hxx>
31 : : #include <editeng/editview.hxx>
32 : : #include <editeng/editdata.hxx>
33 : : #include <editeng/eerdll.hxx>
34 : : #include <editeng/lrspitem.hxx>
35 : : #include <editeng/fhgtitem.hxx>
36 : :
37 : : #define _OUTLINER_CXX
38 : : #include <editeng/outliner.hxx>
39 : : #include <outleeng.hxx>
40 : : #include <paralist.hxx>
41 : : #include <editeng/editrids.hrc>
42 : : #include <svl/itemset.hxx>
43 : : #include <editeng/eeitem.hxx>
44 : : #include <editeng/editstat.hxx>
45 : : #include "outlundo.hxx"
46 : :
47 : 23229 : OutlinerEditEng::OutlinerEditEng( Outliner* pEngOwner, SfxItemPool* pPool )
48 [ + - ][ + - ]: 23229 : : EditEngine( pPool )
49 : : {
50 : 23229 : pOwner = pEngOwner;
51 : 23229 : }
52 : :
53 : 23004 : OutlinerEditEng::~OutlinerEditEng()
54 : : {
55 [ - + ]: 46008 : }
56 : :
57 : 15934 : void OutlinerEditEng::PaintingFirstLine( sal_uInt16 nPara, const Point& rStartPos, long nBaseLineY, const Point& rOrigin, short nOrientation, OutputDevice* pOutDev )
58 : : {
59 [ - + ]: 15934 : if( GetControlWord() & EE_CNTRL_OUTLINER )
60 : : {
61 : 0 : PaintFirstLineInfo aInfo( nPara, rStartPos, nBaseLineY, rOrigin, nOrientation, pOutDev );
62 [ # # ]: 0 : pOwner->maPaintFirstLineHdl.Call( &aInfo );
63 : : }
64 : :
65 : 15934 : pOwner->PaintBullet( nPara, rStartPos, rOrigin, nOrientation, pOutDev );
66 : 15934 : }
67 : :
68 : 393193 : const SvxNumberFormat* OutlinerEditEng::GetNumberFormat( sal_uInt16 nPara ) const
69 : : {
70 : 393193 : const SvxNumberFormat* pFmt = NULL;
71 [ + - ]: 393193 : if (pOwner)
72 : 393193 : pFmt = pOwner->GetNumberFormat( nPara );
73 : 393193 : return pFmt;
74 : : }
75 : :
76 : :
77 : 305016 : Rectangle OutlinerEditEng::GetBulletArea( sal_uInt16 nPara )
78 : : {
79 [ + - ]: 305016 : Rectangle aBulletArea = Rectangle( Point(), Point() );
80 [ + - ]: 305016 : if ( nPara < pOwner->pParaList->GetParagraphCount() )
81 : : {
82 [ + + ]: 305016 : if ( pOwner->ImplHasBullet( nPara ) )
83 : 2185 : aBulletArea = pOwner->ImpCalcBulletArea( nPara, sal_False, sal_False );
84 : : }
85 : 305016 : return aBulletArea;
86 : : }
87 : :
88 : 272082 : void OutlinerEditEng::ParagraphInserted( sal_uInt16 nNewParagraph )
89 : : {
90 : 272082 : pOwner->ParagraphInserted( nNewParagraph );
91 : :
92 : 272082 : EditEngine::ParagraphInserted( nNewParagraph );
93 : 272082 : }
94 : :
95 : 261795 : void OutlinerEditEng::ParagraphDeleted( sal_uInt16 nDeletedParagraph )
96 : : {
97 : 261795 : pOwner->ParagraphDeleted( nDeletedParagraph );
98 : :
99 : 261795 : EditEngine::ParagraphDeleted( nDeletedParagraph );
100 : 261795 : }
101 : :
102 : 315 : void OutlinerEditEng::ParagraphConnected( sal_uInt16 /*nLeftParagraph*/, sal_uInt16 nRightParagraph )
103 : : {
104 [ + - ][ + + ]: 315 : if( pOwner && pOwner->IsUndoEnabled() && !const_cast<EditEngine&>(pOwner->GetEditEngine()).IsInUndo() )
[ + - ][ + + ]
105 : : {
106 : 22 : Paragraph* pPara = pOwner->GetParagraph( nRightParagraph );
107 [ - + ][ - + ]: 22 : if( pPara && pOwner->HasParaFlag( pPara, PARAFLAG_ISPAGE ) )
[ + - ]
108 : : {
109 [ # # ]: 0 : pOwner->InsertUndo( new OutlinerUndoChangeParaFlags( pOwner, nRightParagraph, PARAFLAG_ISPAGE, 0 ) );
110 : : }
111 : : }
112 : 315 : }
113 : :
114 : :
115 : 0 : void OutlinerEditEng::StyleSheetChanged( SfxStyleSheet* pStyle )
116 : : {
117 : 0 : pOwner->StyleSheetChanged( pStyle );
118 : 0 : }
119 : :
120 : 345700 : void OutlinerEditEng::ParaAttribsChanged( sal_uInt16 nPara )
121 : : {
122 : 345700 : pOwner->ParaAttribsChanged( nPara );
123 : 345700 : }
124 : :
125 : 0 : sal_Bool OutlinerEditEng::SpellNextDocument()
126 : : {
127 : 0 : return pOwner->SpellNextDocument();
128 : : }
129 : :
130 : 0 : sal_Bool OutlinerEditEng::ConvertNextDocument()
131 : : {
132 : 0 : return pOwner->ConvertNextDocument();
133 : : }
134 : :
135 : 705398 : XubString OutlinerEditEng::GetUndoComment( sal_uInt16 nUndoId ) const
136 : : {
137 [ - - - + : 705398 : switch( nUndoId )
- + ]
138 : : {
139 : : case OLUNDO_DEPTH:
140 [ # # ][ # # ]: 0 : return EE_RESSTR(RID_OUTLUNDO_DEPTH);
141 : :
142 : : case OLUNDO_EXPAND:
143 [ # # ][ # # ]: 0 : return EE_RESSTR(RID_OUTLUNDO_EXPAND);
144 : :
145 : : case OLUNDO_COLLAPSE:
146 [ # # ][ # # ]: 0 : return EE_RESSTR(RID_OUTLUNDO_COLLAPSE);
147 : :
148 : : case OLUNDO_ATTR:
149 [ + - ][ + - ]: 429623 : return EE_RESSTR(RID_OUTLUNDO_ATTR);
150 : :
151 : : case OLUNDO_INSERT:
152 [ # # ][ # # ]: 0 : return EE_RESSTR(RID_OUTLUNDO_INSERT);
153 : :
154 : : default:
155 : 705398 : return EditEngine::GetUndoComment( nUndoId );
156 : : }
157 : : }
158 : :
159 : 18034 : void OutlinerEditEng::DrawingText( const Point& rStartPos, const XubString& rText, sal_uInt16 nTextStart, sal_uInt16 nTextLen,
160 : : const sal_Int32* pDXArray, const SvxFont& rFont, sal_uInt16 nPara, sal_uInt16 nIndex, sal_uInt8 nRightToLeft,
161 : : const EEngineData::WrongSpellVector* pWrongSpellVector,
162 : : const SvxFieldData* pFieldData,
163 : : bool bEndOfLine,
164 : : bool bEndOfParagraph,
165 : : bool bEndOfBullet,
166 : : const ::com::sun::star::lang::Locale* pLocale,
167 : : const Color& rOverlineColor,
168 : : const Color& rTextLineColor)
169 : : {
170 : : pOwner->DrawingText(rStartPos,rText,nTextStart,nTextLen,pDXArray,rFont,nPara,nIndex,nRightToLeft,
171 : 18034 : pWrongSpellVector, pFieldData, bEndOfLine, bEndOfParagraph, bEndOfBullet, pLocale, rOverlineColor, rTextLineColor);
172 : 18034 : }
173 : :
174 : 0 : void OutlinerEditEng::DrawingTab( const Point& rStartPos, long nWidth, const String& rChar,
175 : : const SvxFont& rFont, sal_uInt16 nPara, xub_StrLen nIndex, sal_uInt8 nRightToLeft,
176 : : bool bEndOfLine, bool bEndOfParagraph,
177 : : const Color& rOverlineColor, const Color& rTextLineColor)
178 : : {
179 : : pOwner->DrawingTab(rStartPos, nWidth, rChar, rFont, nPara, nIndex, nRightToLeft,
180 : 0 : bEndOfLine, bEndOfParagraph, rOverlineColor, rTextLineColor );
181 : 0 : }
182 : :
183 : 0 : void OutlinerEditEng::FieldClicked( const SvxFieldItem& rField, sal_uInt16 nPara, sal_uInt16 nPos )
184 : : {
185 : 0 : EditEngine::FieldClicked( rField, nPara, nPos ); // If URL
186 : 0 : pOwner->FieldClicked( rField, nPara, nPos );
187 : 0 : }
188 : :
189 : 0 : void OutlinerEditEng::FieldSelected( const SvxFieldItem& rField, sal_uInt16 nPara, sal_uInt16 nPos )
190 : : {
191 : 0 : pOwner->FieldSelected( rField, nPara, nPos );
192 : 0 : }
193 : :
194 : 2415 : XubString OutlinerEditEng::CalcFieldValue( const SvxFieldItem& rField, sal_uInt16 nPara, sal_uInt16 nPos, Color*& rpTxtColor, Color*& rpFldColor )
195 : : {
196 : 2415 : return pOwner->CalcFieldValue( rField, nPara, nPos, rpTxtColor, rpFldColor );
197 : : }
198 : :
199 : 565435 : void OutlinerEditEng::SetParaAttribs( sal_uInt16 nPara, const SfxItemSet& rSet )
200 : : {
201 : 565435 : Paragraph* pPara = pOwner->pParaList->GetParagraph( nPara );
202 [ + - ]: 565435 : if( pPara )
203 : : {
204 [ + - ][ + + ]: 565435 : if ( !IsInUndo() && IsUndoEnabled() )
[ + + ]
205 : 429587 : pOwner->UndoActionStart( OLUNDO_ATTR );
206 : :
207 : 565435 : EditEngine::SetParaAttribs( (sal_uInt16)nPara, rSet );
208 : :
209 : 565435 : pOwner->ImplCheckNumBulletItem( (sal_uInt16)nPara );
210 : : // #i100014#
211 : : // It is not a good idea to substract 1 from a count and cast the result
212 : : // to USHORT without check, if the count is 0.
213 : 565435 : pOwner->ImplCheckParagraphs( (sal_uInt16)nPara, (sal_uInt16) (pOwner->pParaList->GetParagraphCount()) );
214 : :
215 [ + + ][ + + ]: 565435 : if ( !IsInUndo() && IsUndoEnabled() )
[ + - ]
216 : 429587 : pOwner->UndoActionEnd( OLUNDO_ATTR );
217 : : }
218 : 565435 : }
219 : :
220 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|