1190118d0SAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3190118d0SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4190118d0SAndrew Rist * or more contributor license agreements. See the NOTICE file
5190118d0SAndrew Rist * distributed with this work for additional information
6190118d0SAndrew Rist * regarding copyright ownership. The ASF licenses this file
7190118d0SAndrew Rist * to you under the Apache License, Version 2.0 (the
8190118d0SAndrew Rist * "License"); you may not use this file except in compliance
9190118d0SAndrew Rist * with the License. You may obtain a copy of the License at
10190118d0SAndrew Rist *
11190118d0SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12190118d0SAndrew Rist *
13190118d0SAndrew Rist * Unless required by applicable law or agreed to in writing,
14190118d0SAndrew Rist * software distributed under the License is distributed on an
15190118d0SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16190118d0SAndrew Rist * KIND, either express or implied. See the License for the
17190118d0SAndrew Rist * specific language governing permissions and limitations
18190118d0SAndrew Rist * under the License.
19190118d0SAndrew Rist *
20190118d0SAndrew Rist *************************************************************/
21190118d0SAndrew Rist
22190118d0SAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_editeng.hxx"
26cdf0e10cSrcweir
27cdf0e10cSrcweir #include <algorithm>
28cdf0e10cSrcweir #include <svl/style.hxx>
29cdf0e10cSrcweir #include <com/sun/star/i18n/WordType.hpp>
30cdf0e10cSrcweir
31cdf0e10cSrcweir #include <svl/itemset.hxx>
32cdf0e10cSrcweir #include <editeng/editeng.hxx>
33cdf0e10cSrcweir #include <editeng/editdata.hxx>
34cdf0e10cSrcweir #include <editeng/outliner.hxx>
35cdf0e10cSrcweir #include <editeng/unoedhlp.hxx>
36cdf0e10cSrcweir #include <svl/poolitem.hxx>
37cdf0e10cSrcweir #include <vcl/wrkwin.hxx>
38cdf0e10cSrcweir #include <editeng/eeitem.hxx>
39cdf0e10cSrcweir
40cdf0e10cSrcweir #include <editeng/unoforou.hxx>
41cdf0e10cSrcweir #include <editeng/unofored.hxx>
42cdf0e10cSrcweir #include <editeng/outlobj.hxx>
43cdf0e10cSrcweir
44cdf0e10cSrcweir using namespace ::com::sun::star;
45cdf0e10cSrcweir
46cdf0e10cSrcweir //------------------------------------------------------------------------
47cdf0e10cSrcweir
SvxOutlinerForwarder(Outliner & rOutl,sal_Bool bOutlText)48cdf0e10cSrcweir SvxOutlinerForwarder::SvxOutlinerForwarder( Outliner& rOutl, sal_Bool bOutlText /* = sal_False */ ) :
49cdf0e10cSrcweir rOutliner( rOutl ),
50cdf0e10cSrcweir bOutlinerText( bOutlText ),
51cdf0e10cSrcweir mpAttribsCache( NULL ),
52cdf0e10cSrcweir mpParaAttribsCache( NULL ),
53cdf0e10cSrcweir mnParaAttribsCache( 0 )
54cdf0e10cSrcweir {
55cdf0e10cSrcweir }
56cdf0e10cSrcweir
~SvxOutlinerForwarder()57cdf0e10cSrcweir SvxOutlinerForwarder::~SvxOutlinerForwarder()
58cdf0e10cSrcweir {
59cdf0e10cSrcweir flushCache();
60cdf0e10cSrcweir }
61cdf0e10cSrcweir
GetParagraphCount() const62cdf0e10cSrcweir sal_uInt16 SvxOutlinerForwarder::GetParagraphCount() const
63cdf0e10cSrcweir {
64cdf0e10cSrcweir return (sal_uInt16)rOutliner.GetParagraphCount();
65cdf0e10cSrcweir }
66cdf0e10cSrcweir
GetTextLen(sal_uInt16 nParagraph) const67cdf0e10cSrcweir sal_uInt16 SvxOutlinerForwarder::GetTextLen( sal_uInt16 nParagraph ) const
68cdf0e10cSrcweir {
69cdf0e10cSrcweir return rOutliner.GetEditEngine().GetTextLen( nParagraph );
70cdf0e10cSrcweir }
71cdf0e10cSrcweir
GetText(const ESelection & rSel) const72cdf0e10cSrcweir String SvxOutlinerForwarder::GetText( const ESelection& rSel ) const
73cdf0e10cSrcweir {
74cdf0e10cSrcweir //! GetText(ESelection) sollte es wohl auch mal am Outliner geben
75cdf0e10cSrcweir // solange den Hack fuer die EditEngine uebernehmen:
76cdf0e10cSrcweir EditEngine* pEditEngine = (EditEngine*)&rOutliner.GetEditEngine();
77cdf0e10cSrcweir return pEditEngine->GetText( rSel, LINEEND_LF );
78cdf0e10cSrcweir }
79cdf0e10cSrcweir
ImplOutlinerForwarderGetAttribs(const ESelection & rSel,sal_Bool bOnlyHardAttrib,EditEngine & rEditEngine)80cdf0e10cSrcweir static SfxItemSet ImplOutlinerForwarderGetAttribs( const ESelection& rSel, sal_Bool bOnlyHardAttrib, EditEngine& rEditEngine )
81cdf0e10cSrcweir {
82cdf0e10cSrcweir if( rSel.nStartPara == rSel.nEndPara )
83cdf0e10cSrcweir {
84cdf0e10cSrcweir sal_uInt8 nFlags = 0;
85cdf0e10cSrcweir
86cdf0e10cSrcweir switch( bOnlyHardAttrib )
87cdf0e10cSrcweir {
88cdf0e10cSrcweir case EditEngineAttribs_All:
89cdf0e10cSrcweir nFlags = GETATTRIBS_ALL;
90cdf0e10cSrcweir break;
91cdf0e10cSrcweir case EditEngineAttribs_HardAndPara:
92cdf0e10cSrcweir nFlags = GETATTRIBS_PARAATTRIBS|GETATTRIBS_CHARATTRIBS;
93cdf0e10cSrcweir break;
94cdf0e10cSrcweir case EditEngineAttribs_OnlyHard:
95cdf0e10cSrcweir nFlags = GETATTRIBS_CHARATTRIBS;
96cdf0e10cSrcweir break;
97cdf0e10cSrcweir default:
98cdf0e10cSrcweir DBG_ERROR("unknown flags for SvxOutlinerForwarder::GetAttribs");
99cdf0e10cSrcweir }
100cdf0e10cSrcweir return rEditEngine.GetAttribs( rSel.nStartPara, rSel.nStartPos, rSel.nEndPos, nFlags );
101cdf0e10cSrcweir }
102cdf0e10cSrcweir else
103cdf0e10cSrcweir {
104cdf0e10cSrcweir return rEditEngine.GetAttribs( rSel, bOnlyHardAttrib );
105cdf0e10cSrcweir }
106cdf0e10cSrcweir }
107cdf0e10cSrcweir
GetAttribs(const ESelection & rSel,sal_Bool bOnlyHardAttrib) const108cdf0e10cSrcweir SfxItemSet SvxOutlinerForwarder::GetAttribs( const ESelection& rSel, sal_Bool bOnlyHardAttrib ) const
109cdf0e10cSrcweir {
110cdf0e10cSrcweir if( mpAttribsCache && ( 0 == bOnlyHardAttrib ) )
111cdf0e10cSrcweir {
112cdf0e10cSrcweir // have we the correct set in cache?
113cdf0e10cSrcweir if( ((SvxOutlinerForwarder*)this)->maAttribCacheSelection.IsEqual(rSel) )
114cdf0e10cSrcweir {
115cdf0e10cSrcweir // yes! just return the cache
116cdf0e10cSrcweir return *mpAttribsCache;
117cdf0e10cSrcweir }
118cdf0e10cSrcweir else
119cdf0e10cSrcweir {
120cdf0e10cSrcweir // no, we need delete the old cache
121cdf0e10cSrcweir delete mpAttribsCache;
122cdf0e10cSrcweir mpAttribsCache = NULL;
123cdf0e10cSrcweir }
124cdf0e10cSrcweir }
125cdf0e10cSrcweir
126cdf0e10cSrcweir //! gibt's das nicht am Outliner ???
127cdf0e10cSrcweir //! und warum ist GetAttribs an der EditEngine nicht const?
128cdf0e10cSrcweir EditEngine& rEditEngine = (EditEngine&)rOutliner.GetEditEngine();
129cdf0e10cSrcweir
130cdf0e10cSrcweir SfxItemSet aSet( ImplOutlinerForwarderGetAttribs( rSel, bOnlyHardAttrib, rEditEngine ) );
131cdf0e10cSrcweir
132cdf0e10cSrcweir if( 0 == bOnlyHardAttrib )
133cdf0e10cSrcweir {
134cdf0e10cSrcweir mpAttribsCache = new SfxItemSet( aSet );
135cdf0e10cSrcweir maAttribCacheSelection = rSel;
136cdf0e10cSrcweir }
137cdf0e10cSrcweir
138cdf0e10cSrcweir SfxStyleSheet* pStyle = rEditEngine.GetStyleSheet( rSel.nStartPara );
139cdf0e10cSrcweir if( pStyle )
140cdf0e10cSrcweir aSet.SetParent( &(pStyle->GetItemSet() ) );
141cdf0e10cSrcweir
142cdf0e10cSrcweir return aSet;
143cdf0e10cSrcweir }
144cdf0e10cSrcweir
GetParaAttribs(sal_uInt16 nPara) const145cdf0e10cSrcweir SfxItemSet SvxOutlinerForwarder::GetParaAttribs( sal_uInt16 nPara ) const
146cdf0e10cSrcweir {
147cdf0e10cSrcweir if( mpParaAttribsCache )
148cdf0e10cSrcweir {
149cdf0e10cSrcweir // have we the correct set in cache?
150cdf0e10cSrcweir if( nPara == mnParaAttribsCache )
151cdf0e10cSrcweir {
152cdf0e10cSrcweir // yes! just return the cache
153cdf0e10cSrcweir return *mpParaAttribsCache;
154cdf0e10cSrcweir }
155cdf0e10cSrcweir else
156cdf0e10cSrcweir {
157cdf0e10cSrcweir // no, we need delete the old cache
158cdf0e10cSrcweir delete mpParaAttribsCache;
159cdf0e10cSrcweir mpParaAttribsCache = NULL;
160cdf0e10cSrcweir }
161cdf0e10cSrcweir }
162cdf0e10cSrcweir
163cdf0e10cSrcweir mpParaAttribsCache = new SfxItemSet( rOutliner.GetParaAttribs( nPara ) );
164cdf0e10cSrcweir mnParaAttribsCache = nPara;
165cdf0e10cSrcweir
166cdf0e10cSrcweir EditEngine& rEditEngine = (EditEngine&)rOutliner.GetEditEngine();
167cdf0e10cSrcweir
168cdf0e10cSrcweir SfxStyleSheet* pStyle = rEditEngine.GetStyleSheet( nPara );
169cdf0e10cSrcweir if( pStyle )
170cdf0e10cSrcweir mpParaAttribsCache->SetParent( &(pStyle->GetItemSet() ) );
171cdf0e10cSrcweir
172cdf0e10cSrcweir return *mpParaAttribsCache;
173cdf0e10cSrcweir }
174cdf0e10cSrcweir
SetParaAttribs(sal_uInt16 nPara,const SfxItemSet & rSet)175cdf0e10cSrcweir void SvxOutlinerForwarder::SetParaAttribs( sal_uInt16 nPara, const SfxItemSet& rSet )
176cdf0e10cSrcweir {
177cdf0e10cSrcweir flushCache();
178cdf0e10cSrcweir
179cdf0e10cSrcweir const SfxItemSet* pOldParent = rSet.GetParent();
180cdf0e10cSrcweir if( pOldParent )
181cdf0e10cSrcweir ((SfxItemSet*)&rSet)->SetParent( NULL );
182cdf0e10cSrcweir
183cdf0e10cSrcweir rOutliner.SetParaAttribs( nPara, rSet );
184cdf0e10cSrcweir
185cdf0e10cSrcweir if( pOldParent )
186cdf0e10cSrcweir ((SfxItemSet*)&rSet)->SetParent( pOldParent );
187cdf0e10cSrcweir }
188cdf0e10cSrcweir
RemoveAttribs(const ESelection & rSelection,sal_Bool bRemoveParaAttribs,sal_uInt16 nWhich)189cdf0e10cSrcweir void SvxOutlinerForwarder::RemoveAttribs( const ESelection& rSelection, sal_Bool bRemoveParaAttribs, sal_uInt16 nWhich )
190cdf0e10cSrcweir {
191cdf0e10cSrcweir rOutliner.RemoveAttribs( rSelection, bRemoveParaAttribs, nWhich );
192cdf0e10cSrcweir }
193cdf0e10cSrcweir
GetPool() const194cdf0e10cSrcweir SfxItemPool* SvxOutlinerForwarder::GetPool() const
195cdf0e10cSrcweir {
196cdf0e10cSrcweir return rOutliner.GetEmptyItemSet().GetPool();
197cdf0e10cSrcweir }
198cdf0e10cSrcweir
GetPortions(sal_uInt16 nPara,SvUShorts & rList) const199cdf0e10cSrcweir void SvxOutlinerForwarder::GetPortions( sal_uInt16 nPara, SvUShorts& rList ) const
200cdf0e10cSrcweir {
201cdf0e10cSrcweir ((EditEngine&)rOutliner.GetEditEngine()).GetPortions( nPara, rList );
202cdf0e10cSrcweir }
203cdf0e10cSrcweir
QuickInsertText(const String & rText,const ESelection & rSel)204cdf0e10cSrcweir void SvxOutlinerForwarder::QuickInsertText( const String& rText, const ESelection& rSel )
205cdf0e10cSrcweir {
206cdf0e10cSrcweir flushCache();
207cdf0e10cSrcweir if( rText.Len() == 0 )
208cdf0e10cSrcweir {
209cdf0e10cSrcweir rOutliner.QuickDelete( rSel );
210cdf0e10cSrcweir }
211cdf0e10cSrcweir else
212cdf0e10cSrcweir {
213cdf0e10cSrcweir rOutliner.QuickInsertText( rText, rSel );
214cdf0e10cSrcweir }
215cdf0e10cSrcweir }
216cdf0e10cSrcweir
QuickInsertLineBreak(const ESelection & rSel)217cdf0e10cSrcweir void SvxOutlinerForwarder::QuickInsertLineBreak( const ESelection& rSel )
218cdf0e10cSrcweir {
219cdf0e10cSrcweir flushCache();
220cdf0e10cSrcweir rOutliner.QuickInsertLineBreak( rSel );
221cdf0e10cSrcweir }
222cdf0e10cSrcweir
QuickInsertField(const SvxFieldItem & rFld,const ESelection & rSel)223cdf0e10cSrcweir void SvxOutlinerForwarder::QuickInsertField( const SvxFieldItem& rFld, const ESelection& rSel )
224cdf0e10cSrcweir {
225cdf0e10cSrcweir flushCache();
226cdf0e10cSrcweir rOutliner.QuickInsertField( rFld, rSel );
227cdf0e10cSrcweir }
228cdf0e10cSrcweir
QuickSetAttribs(const SfxItemSet & rSet,const ESelection & rSel)229cdf0e10cSrcweir void SvxOutlinerForwarder::QuickSetAttribs( const SfxItemSet& rSet, const ESelection& rSel )
230cdf0e10cSrcweir {
231cdf0e10cSrcweir flushCache();
232cdf0e10cSrcweir rOutliner.QuickSetAttribs( rSet, rSel );
233cdf0e10cSrcweir }
234cdf0e10cSrcweir
CalcFieldValue(const SvxFieldItem & rField,sal_uInt16 nPara,sal_uInt16 nPos,Color * & rpTxtColor,Color * & rpFldColor)235cdf0e10cSrcweir XubString SvxOutlinerForwarder::CalcFieldValue( const SvxFieldItem& rField, sal_uInt16 nPara, sal_uInt16 nPos, Color*& rpTxtColor, Color*& rpFldColor )
236cdf0e10cSrcweir {
237cdf0e10cSrcweir return rOutliner.CalcFieldValue( rField, nPara, nPos, rpTxtColor, rpFldColor );
238cdf0e10cSrcweir }
239cdf0e10cSrcweir
FieldClicked(const SvxFieldItem & rField,sal_uInt16 nPara,xub_StrLen nPos)240cdf0e10cSrcweir void SvxOutlinerForwarder::FieldClicked( const SvxFieldItem& rField, sal_uInt16 nPara, xub_StrLen nPos )
241cdf0e10cSrcweir {
242cdf0e10cSrcweir rOutliner.FieldClicked( rField, nPara, nPos );
243cdf0e10cSrcweir }
244cdf0e10cSrcweir
IsValid() const245cdf0e10cSrcweir sal_Bool SvxOutlinerForwarder::IsValid() const
246cdf0e10cSrcweir {
247cdf0e10cSrcweir // cannot reliably query outliner state
248cdf0e10cSrcweir // while in the middle of an update
249cdf0e10cSrcweir return rOutliner.GetUpdateMode();
250cdf0e10cSrcweir }
251cdf0e10cSrcweir
252cdf0e10cSrcweir extern sal_uInt16 GetSvxEditEngineItemState( EditEngine& rEditEngine, const ESelection& rSel, sal_uInt16 nWhich );
253cdf0e10cSrcweir
GetItemState(const ESelection & rSel,sal_uInt16 nWhich) const254cdf0e10cSrcweir sal_uInt16 SvxOutlinerForwarder::GetItemState( const ESelection& rSel, sal_uInt16 nWhich ) const
255cdf0e10cSrcweir {
256cdf0e10cSrcweir return GetSvxEditEngineItemState( (EditEngine&)rOutliner.GetEditEngine(), rSel, nWhich );
257cdf0e10cSrcweir }
258cdf0e10cSrcweir
GetItemState(sal_uInt16 nPara,sal_uInt16 nWhich) const259cdf0e10cSrcweir sal_uInt16 SvxOutlinerForwarder::GetItemState( sal_uInt16 nPara, sal_uInt16 nWhich ) const
260cdf0e10cSrcweir {
261cdf0e10cSrcweir const SfxItemSet& rSet = rOutliner.GetParaAttribs( nPara );
262cdf0e10cSrcweir return rSet.GetItemState( nWhich );
263cdf0e10cSrcweir }
264cdf0e10cSrcweir
265cdf0e10cSrcweir
flushCache()266cdf0e10cSrcweir void SvxOutlinerForwarder::flushCache()
267cdf0e10cSrcweir {
268cdf0e10cSrcweir if( mpAttribsCache )
269cdf0e10cSrcweir {
270cdf0e10cSrcweir delete mpAttribsCache;
271cdf0e10cSrcweir mpAttribsCache = NULL;
272cdf0e10cSrcweir }
273cdf0e10cSrcweir
274cdf0e10cSrcweir if( mpParaAttribsCache )
275cdf0e10cSrcweir {
276cdf0e10cSrcweir delete mpParaAttribsCache;
277cdf0e10cSrcweir mpParaAttribsCache = NULL;
278cdf0e10cSrcweir }
279cdf0e10cSrcweir }
280cdf0e10cSrcweir
GetLanguage(sal_uInt16 nPara,sal_uInt16 nIndex) const281cdf0e10cSrcweir LanguageType SvxOutlinerForwarder::GetLanguage( sal_uInt16 nPara, sal_uInt16 nIndex ) const
282cdf0e10cSrcweir {
283cdf0e10cSrcweir return rOutliner.GetLanguage(nPara, nIndex);
284cdf0e10cSrcweir }
285cdf0e10cSrcweir
GetFieldCount(sal_uInt16 nPara) const286cdf0e10cSrcweir sal_uInt16 SvxOutlinerForwarder::GetFieldCount( sal_uInt16 nPara ) const
287cdf0e10cSrcweir {
288cdf0e10cSrcweir return rOutliner.GetEditEngine().GetFieldCount(nPara);
289cdf0e10cSrcweir }
290cdf0e10cSrcweir
GetFieldInfo(sal_uInt16 nPara,sal_uInt16 nField) const291cdf0e10cSrcweir EFieldInfo SvxOutlinerForwarder::GetFieldInfo( sal_uInt16 nPara, sal_uInt16 nField ) const
292cdf0e10cSrcweir {
293cdf0e10cSrcweir return rOutliner.GetEditEngine().GetFieldInfo( nPara, nField );
294cdf0e10cSrcweir }
295cdf0e10cSrcweir
GetBulletInfo(sal_uInt16 nPara) const296cdf0e10cSrcweir EBulletInfo SvxOutlinerForwarder::GetBulletInfo( sal_uInt16 nPara ) const
297cdf0e10cSrcweir {
298cdf0e10cSrcweir return rOutliner.GetBulletInfo( nPara );
299cdf0e10cSrcweir }
300cdf0e10cSrcweir
GetCharBounds(sal_uInt16 nPara,sal_uInt16 nIndex) const301cdf0e10cSrcweir Rectangle SvxOutlinerForwarder::GetCharBounds( sal_uInt16 nPara, sal_uInt16 nIndex ) const
302cdf0e10cSrcweir {
303cdf0e10cSrcweir // #101701#
304cdf0e10cSrcweir // EditEngine's 'internal' methods like GetCharacterBounds()
305cdf0e10cSrcweir // don't rotate for vertical text.
306cdf0e10cSrcweir Size aSize( rOutliner.CalcTextSize() );
307cdf0e10cSrcweir ::std::swap( aSize.Width(), aSize.Height() );
308cdf0e10cSrcweir bool bIsVertical( rOutliner.IsVertical() == sal_True );
309cdf0e10cSrcweir
310cdf0e10cSrcweir // #108900# Handle virtual position one-past-the end of the string
311cdf0e10cSrcweir if( nIndex >= GetTextLen(nPara) )
312cdf0e10cSrcweir {
313cdf0e10cSrcweir Rectangle aLast;
314cdf0e10cSrcweir
315cdf0e10cSrcweir if( nIndex )
316cdf0e10cSrcweir {
317cdf0e10cSrcweir // use last character, if possible
318cdf0e10cSrcweir aLast = rOutliner.GetEditEngine().GetCharacterBounds( EPosition(nPara, nIndex-1) );
319cdf0e10cSrcweir
320cdf0e10cSrcweir // move at end of this last character, make one pixel wide
321cdf0e10cSrcweir aLast.Move( aLast.Right() - aLast.Left(), 0 );
322cdf0e10cSrcweir aLast.SetSize( Size(1, aLast.GetHeight()) );
323cdf0e10cSrcweir
324cdf0e10cSrcweir // take care for CTL
325cdf0e10cSrcweir aLast = SvxEditSourceHelper::EEToUserSpace( aLast, aSize, bIsVertical );
326cdf0e10cSrcweir }
327cdf0e10cSrcweir else
328cdf0e10cSrcweir {
329cdf0e10cSrcweir // #109864# Bounds must lie within the paragraph
330cdf0e10cSrcweir aLast = GetParaBounds( nPara );
331cdf0e10cSrcweir
332cdf0e10cSrcweir // #109151# Don't use paragraph height, but line height
333cdf0e10cSrcweir // instead. aLast is already CTL-correct
334cdf0e10cSrcweir if( bIsVertical)
335cdf0e10cSrcweir aLast.SetSize( Size( rOutliner.GetLineHeight(nPara,0), 1 ) );
336cdf0e10cSrcweir else
337cdf0e10cSrcweir aLast.SetSize( Size( 1, rOutliner.GetLineHeight(nPara,0) ) );
338cdf0e10cSrcweir }
339cdf0e10cSrcweir
340cdf0e10cSrcweir return aLast;
341cdf0e10cSrcweir }
342cdf0e10cSrcweir else
343cdf0e10cSrcweir {
344cdf0e10cSrcweir return SvxEditSourceHelper::EEToUserSpace( rOutliner.GetEditEngine().GetCharacterBounds( EPosition(nPara, nIndex) ),
345cdf0e10cSrcweir aSize, bIsVertical );
346cdf0e10cSrcweir }
347cdf0e10cSrcweir }
348cdf0e10cSrcweir
GetParaBounds(sal_uInt16 nPara) const349cdf0e10cSrcweir Rectangle SvxOutlinerForwarder::GetParaBounds( sal_uInt16 nPara ) const
350cdf0e10cSrcweir {
351cdf0e10cSrcweir Point aPnt = rOutliner.GetDocPosTopLeft( nPara );
352cdf0e10cSrcweir Size aSize = rOutliner.CalcTextSize();
353cdf0e10cSrcweir
354cdf0e10cSrcweir if( rOutliner.IsVertical() )
355cdf0e10cSrcweir {
356cdf0e10cSrcweir // #101701#
357cdf0e10cSrcweir // Hargl. Outliner's 'external' methods return the rotated
358cdf0e10cSrcweir // dimensions, 'internal' methods like GetTextHeight( n )
359cdf0e10cSrcweir // don't rotate.
360cdf0e10cSrcweir sal_uLong nWidth = rOutliner.GetTextHeight( nPara );
361cdf0e10cSrcweir
362cdf0e10cSrcweir return Rectangle( aSize.Width() - aPnt.Y() - nWidth, 0, aSize.Width() - aPnt.Y(), aSize.Height() );
363cdf0e10cSrcweir }
364cdf0e10cSrcweir else
365cdf0e10cSrcweir {
366cdf0e10cSrcweir sal_uLong nHeight = rOutliner.GetTextHeight( nPara );
367cdf0e10cSrcweir
368cdf0e10cSrcweir return Rectangle( 0, aPnt.Y(), aSize.Width(), aPnt.Y() + nHeight );
369cdf0e10cSrcweir }
370cdf0e10cSrcweir }
371cdf0e10cSrcweir
GetMapMode() const372cdf0e10cSrcweir MapMode SvxOutlinerForwarder::GetMapMode() const
373cdf0e10cSrcweir {
374cdf0e10cSrcweir return rOutliner.GetRefMapMode();
375cdf0e10cSrcweir }
376cdf0e10cSrcweir
GetRefDevice() const377cdf0e10cSrcweir OutputDevice* SvxOutlinerForwarder::GetRefDevice() const
378cdf0e10cSrcweir {
379cdf0e10cSrcweir return rOutliner.GetRefDevice();
380cdf0e10cSrcweir }
381cdf0e10cSrcweir
GetIndexAtPoint(const Point & rPos,sal_uInt16 & nPara,sal_uInt16 & nIndex) const382cdf0e10cSrcweir sal_Bool SvxOutlinerForwarder::GetIndexAtPoint( const Point& rPos, sal_uInt16& nPara, sal_uInt16& nIndex ) const
383cdf0e10cSrcweir {
384cdf0e10cSrcweir // #101701#
385cdf0e10cSrcweir Size aSize( rOutliner.CalcTextSize() );
386cdf0e10cSrcweir ::std::swap( aSize.Width(), aSize.Height() );
387cdf0e10cSrcweir Point aEEPos( SvxEditSourceHelper::UserSpaceToEE( rPos,
388cdf0e10cSrcweir aSize,
389cdf0e10cSrcweir rOutliner.IsVertical() == sal_True ));
390cdf0e10cSrcweir
391cdf0e10cSrcweir EPosition aDocPos = rOutliner.GetEditEngine().FindDocPosition( aEEPos );
392cdf0e10cSrcweir
393cdf0e10cSrcweir nPara = aDocPos.nPara;
394cdf0e10cSrcweir nIndex = aDocPos.nIndex;
395cdf0e10cSrcweir
396cdf0e10cSrcweir return sal_True;
397cdf0e10cSrcweir }
398cdf0e10cSrcweir
GetWordIndices(sal_uInt16 nPara,sal_uInt16 nIndex,sal_uInt16 & nStart,sal_uInt16 & nEnd) const399cdf0e10cSrcweir sal_Bool SvxOutlinerForwarder::GetWordIndices( sal_uInt16 nPara, sal_uInt16 nIndex, sal_uInt16& nStart, sal_uInt16& nEnd ) const
400cdf0e10cSrcweir {
401cdf0e10cSrcweir ESelection aRes = rOutliner.GetEditEngine().GetWord( ESelection(nPara, nIndex, nPara, nIndex), com::sun::star::i18n::WordType::DICTIONARY_WORD );
402cdf0e10cSrcweir
403cdf0e10cSrcweir if( aRes.nStartPara == nPara &&
404cdf0e10cSrcweir aRes.nStartPara == aRes.nEndPara )
405cdf0e10cSrcweir {
406cdf0e10cSrcweir nStart = aRes.nStartPos;
407cdf0e10cSrcweir nEnd = aRes.nEndPos;
408cdf0e10cSrcweir
409cdf0e10cSrcweir return sal_True;
410cdf0e10cSrcweir }
411cdf0e10cSrcweir
412cdf0e10cSrcweir return sal_False;
413cdf0e10cSrcweir }
GetAttributeRun(sal_uInt16 & nStartIndex,sal_uInt16 & nEndIndex,sal_uInt16 nPara,sal_uInt16 nIndex,sal_Bool bInCell) const414*9b8096d0SSteve Yin sal_Bool SvxOutlinerForwarder::GetAttributeRun( sal_uInt16& nStartIndex, sal_uInt16& nEndIndex, sal_uInt16 nPara, sal_uInt16 nIndex, sal_Bool bInCell ) const
415cdf0e10cSrcweir {
416*9b8096d0SSteve Yin return SvxEditSourceHelper::GetAttributeRun( nStartIndex, nEndIndex, rOutliner.GetEditEngine(), nPara, nIndex, bInCell );
417cdf0e10cSrcweir }
418cdf0e10cSrcweir
GetLineCount(sal_uInt16 nPara) const419cdf0e10cSrcweir sal_uInt16 SvxOutlinerForwarder::GetLineCount( sal_uInt16 nPara ) const
420cdf0e10cSrcweir {
421cdf0e10cSrcweir return static_cast < sal_uInt16 >( rOutliner.GetLineCount(nPara) );
422cdf0e10cSrcweir }
423cdf0e10cSrcweir
GetLineLen(sal_uInt16 nPara,sal_uInt16 nLine) const424cdf0e10cSrcweir sal_uInt16 SvxOutlinerForwarder::GetLineLen( sal_uInt16 nPara, sal_uInt16 nLine ) const
425cdf0e10cSrcweir {
426cdf0e10cSrcweir return rOutliner.GetLineLen(nPara, nLine);
427cdf0e10cSrcweir }
428cdf0e10cSrcweir
GetLineBoundaries(sal_uInt16 & rStart,sal_uInt16 & rEnd,sal_uInt16 nPara,sal_uInt16 nLine) const429cdf0e10cSrcweir void SvxOutlinerForwarder::GetLineBoundaries( /*out*/sal_uInt16 &rStart, /*out*/sal_uInt16 &rEnd, sal_uInt16 nPara, sal_uInt16 nLine ) const
430cdf0e10cSrcweir {
431cdf0e10cSrcweir return rOutliner.GetEditEngine().GetLineBoundaries( rStart, rEnd, nPara, nLine );
432cdf0e10cSrcweir }
433cdf0e10cSrcweir
GetLineNumberAtIndex(sal_uInt16 nPara,sal_uInt16 nIndex) const434cdf0e10cSrcweir sal_uInt16 SvxOutlinerForwarder::GetLineNumberAtIndex( sal_uInt16 nPara, sal_uInt16 nIndex ) const
435cdf0e10cSrcweir {
436cdf0e10cSrcweir return rOutliner.GetEditEngine().GetLineNumberAtIndex( nPara, nIndex );
437cdf0e10cSrcweir }
438cdf0e10cSrcweir
QuickFormatDoc(sal_Bool)439cdf0e10cSrcweir sal_Bool SvxOutlinerForwarder::QuickFormatDoc( sal_Bool )
440cdf0e10cSrcweir {
441cdf0e10cSrcweir rOutliner.QuickFormatDoc();
442cdf0e10cSrcweir
443cdf0e10cSrcweir return sal_True;
444cdf0e10cSrcweir }
445cdf0e10cSrcweir
Delete(const ESelection & rSelection)446cdf0e10cSrcweir sal_Bool SvxOutlinerForwarder::Delete( const ESelection& rSelection )
447cdf0e10cSrcweir {
448cdf0e10cSrcweir flushCache();
449cdf0e10cSrcweir rOutliner.QuickDelete( rSelection );
450cdf0e10cSrcweir rOutliner.QuickFormatDoc();
451cdf0e10cSrcweir
452cdf0e10cSrcweir return sal_True;
453cdf0e10cSrcweir }
454cdf0e10cSrcweir
InsertText(const String & rStr,const ESelection & rSelection)455cdf0e10cSrcweir sal_Bool SvxOutlinerForwarder::InsertText( const String& rStr, const ESelection& rSelection )
456cdf0e10cSrcweir {
457cdf0e10cSrcweir flushCache();
458cdf0e10cSrcweir rOutliner.QuickInsertText( rStr, rSelection );
459cdf0e10cSrcweir rOutliner.QuickFormatDoc();
460cdf0e10cSrcweir
461cdf0e10cSrcweir return sal_True;
462cdf0e10cSrcweir }
463cdf0e10cSrcweir
GetDepth(sal_uInt16 nPara) const464cdf0e10cSrcweir sal_Int16 SvxOutlinerForwarder::GetDepth( sal_uInt16 nPara ) const
465cdf0e10cSrcweir {
466cdf0e10cSrcweir DBG_ASSERT( nPara < GetParagraphCount(), "SvxOutlinerForwarder::GetDepth: Invalid paragraph index");
467cdf0e10cSrcweir
468cdf0e10cSrcweir Paragraph* pPara = rOutliner.GetParagraph( nPara );
469cdf0e10cSrcweir
470cdf0e10cSrcweir sal_Int16 nLevel = -1;
471cdf0e10cSrcweir
472cdf0e10cSrcweir if( pPara )
473cdf0e10cSrcweir nLevel = rOutliner.GetDepth( nPara );
474cdf0e10cSrcweir
475cdf0e10cSrcweir return nLevel;
476cdf0e10cSrcweir }
477cdf0e10cSrcweir
SetDepth(sal_uInt16 nPara,sal_Int16 nNewDepth)478cdf0e10cSrcweir sal_Bool SvxOutlinerForwarder::SetDepth( sal_uInt16 nPara, sal_Int16 nNewDepth )
479cdf0e10cSrcweir {
480cdf0e10cSrcweir DBG_ASSERT( nPara < GetParagraphCount(), "SvxOutlinerForwarder::SetDepth: Invalid paragraph index");
481cdf0e10cSrcweir
482cdf0e10cSrcweir if( (nNewDepth >= -1) && (nNewDepth <= 9) && (nPara < GetParagraphCount()) )
483cdf0e10cSrcweir {
484cdf0e10cSrcweir Paragraph* pPara = rOutliner.GetParagraph( nPara );
485cdf0e10cSrcweir if( pPara )
486cdf0e10cSrcweir {
487cdf0e10cSrcweir rOutliner.SetDepth( pPara, nNewDepth );
488cdf0e10cSrcweir
489cdf0e10cSrcweir // const bool bOutlinerText = pSdrObject && (pSdrObject->GetObjInventor() == SdrInventor) && (pSdrObject->GetObjIdentifier() == OBJ_OUTLINETEXT);
490cdf0e10cSrcweir if( bOutlinerText )
491cdf0e10cSrcweir rOutliner.SetLevelDependendStyleSheet( nPara );
492cdf0e10cSrcweir
493cdf0e10cSrcweir return sal_True;
494cdf0e10cSrcweir }
495cdf0e10cSrcweir }
496cdf0e10cSrcweir
497cdf0e10cSrcweir return sal_False;
498cdf0e10cSrcweir }
499cdf0e10cSrcweir
GetNumberingStartValue(sal_uInt16 nPara)500cdf0e10cSrcweir sal_Int16 SvxOutlinerForwarder::GetNumberingStartValue( sal_uInt16 nPara )
501cdf0e10cSrcweir {
502cdf0e10cSrcweir if( nPara < GetParagraphCount() )
503cdf0e10cSrcweir {
504cdf0e10cSrcweir return rOutliner.GetNumberingStartValue( nPara );
505cdf0e10cSrcweir }
506cdf0e10cSrcweir else
507cdf0e10cSrcweir {
508cdf0e10cSrcweir DBG_ERROR( "SvxOutlinerForwarder::GetNumberingStartValue)(), Invalid paragraph index");
509cdf0e10cSrcweir return -1;
510cdf0e10cSrcweir }
511cdf0e10cSrcweir }
512cdf0e10cSrcweir
SetNumberingStartValue(sal_uInt16 nPara,sal_Int16 nNumberingStartValue)513cdf0e10cSrcweir void SvxOutlinerForwarder::SetNumberingStartValue( sal_uInt16 nPara, sal_Int16 nNumberingStartValue )
514cdf0e10cSrcweir {
515cdf0e10cSrcweir if( nPara < GetParagraphCount() )
516cdf0e10cSrcweir {
517cdf0e10cSrcweir rOutliner.SetNumberingStartValue( nPara, nNumberingStartValue );
518cdf0e10cSrcweir }
519cdf0e10cSrcweir else
520cdf0e10cSrcweir {
521cdf0e10cSrcweir DBG_ERROR( "SvxOutlinerForwarder::SetNumberingStartValue)(), Invalid paragraph index");
522cdf0e10cSrcweir }
523cdf0e10cSrcweir }
524cdf0e10cSrcweir
IsParaIsNumberingRestart(sal_uInt16 nPara)525cdf0e10cSrcweir sal_Bool SvxOutlinerForwarder::IsParaIsNumberingRestart( sal_uInt16 nPara )
526cdf0e10cSrcweir {
527cdf0e10cSrcweir if( nPara < GetParagraphCount() )
528cdf0e10cSrcweir {
529cdf0e10cSrcweir return rOutliner.IsParaIsNumberingRestart( nPara );
530cdf0e10cSrcweir }
531cdf0e10cSrcweir else
532cdf0e10cSrcweir {
533cdf0e10cSrcweir DBG_ERROR( "SvxOutlinerForwarder::IsParaIsNumberingRestart)(), Invalid paragraph index");
534cdf0e10cSrcweir return sal_False;
535cdf0e10cSrcweir }
536cdf0e10cSrcweir }
537cdf0e10cSrcweir
SetParaIsNumberingRestart(sal_uInt16 nPara,sal_Bool bParaIsNumberingRestart)538cdf0e10cSrcweir void SvxOutlinerForwarder::SetParaIsNumberingRestart( sal_uInt16 nPara, sal_Bool bParaIsNumberingRestart )
539cdf0e10cSrcweir {
540cdf0e10cSrcweir if( nPara < GetParagraphCount() )
541cdf0e10cSrcweir {
542cdf0e10cSrcweir rOutliner.SetParaIsNumberingRestart( nPara, bParaIsNumberingRestart );
543cdf0e10cSrcweir }
544cdf0e10cSrcweir else
545cdf0e10cSrcweir {
546cdf0e10cSrcweir DBG_ERROR( "SvxOutlinerForwarder::SetParaIsNumberingRestart)(), Invalid paragraph index");
547cdf0e10cSrcweir }
548cdf0e10cSrcweir }
549cdf0e10cSrcweir
GetEmptyItemSetPtr()550cdf0e10cSrcweir const SfxItemSet * SvxOutlinerForwarder::GetEmptyItemSetPtr()
551cdf0e10cSrcweir {
552cdf0e10cSrcweir EditEngine& rEditEngine = const_cast< EditEngine& >( rOutliner.GetEditEngine() );
553cdf0e10cSrcweir return &rEditEngine.GetEmptyItemSet();
554cdf0e10cSrcweir }
555cdf0e10cSrcweir
AppendParagraph()556cdf0e10cSrcweir void SvxOutlinerForwarder::AppendParagraph()
557cdf0e10cSrcweir {
558cdf0e10cSrcweir EditEngine& rEditEngine = const_cast< EditEngine& >( rOutliner.GetEditEngine() );
559cdf0e10cSrcweir rEditEngine.InsertParagraph( rEditEngine.GetParagraphCount(), String::EmptyString() );
560cdf0e10cSrcweir }
561cdf0e10cSrcweir
AppendTextPortion(sal_uInt16 nPara,const String & rText,const SfxItemSet &)562cdf0e10cSrcweir xub_StrLen SvxOutlinerForwarder::AppendTextPortion( sal_uInt16 nPara, const String &rText, const SfxItemSet & /*rSet*/ )
563cdf0e10cSrcweir {
564cdf0e10cSrcweir xub_StrLen nLen = 0;
565cdf0e10cSrcweir
566cdf0e10cSrcweir EditEngine& rEditEngine = const_cast< EditEngine& >( rOutliner.GetEditEngine() );
567cdf0e10cSrcweir sal_uInt16 nParaCount = rEditEngine.GetParagraphCount();
568cdf0e10cSrcweir DBG_ASSERT( nPara < nParaCount, "paragraph index out of bounds" );
569cdf0e10cSrcweir if (/*0 <= nPara && */nPara < nParaCount)
570cdf0e10cSrcweir {
571cdf0e10cSrcweir nLen = rEditEngine.GetTextLen( nPara );
572cdf0e10cSrcweir rEditEngine.QuickInsertText( rText, ESelection( nPara, nLen, nPara, nLen ) );
573cdf0e10cSrcweir }
574cdf0e10cSrcweir
575cdf0e10cSrcweir return nLen;
576cdf0e10cSrcweir }
577cdf0e10cSrcweir
CopyText(const SvxTextForwarder & rSource)578cdf0e10cSrcweir void SvxOutlinerForwarder::CopyText(const SvxTextForwarder& rSource)
579cdf0e10cSrcweir {
580cdf0e10cSrcweir const SvxOutlinerForwarder* pSourceForwarder = dynamic_cast< const SvxOutlinerForwarder* >( &rSource );
581cdf0e10cSrcweir if( !pSourceForwarder )
582cdf0e10cSrcweir return;
583cdf0e10cSrcweir OutlinerParaObject* pNewOutlinerParaObject = pSourceForwarder->rOutliner.CreateParaObject();
584cdf0e10cSrcweir rOutliner.SetText( *pNewOutlinerParaObject );
585cdf0e10cSrcweir delete pNewOutlinerParaObject;
586cdf0e10cSrcweir }
587cdf0e10cSrcweir
588cdf0e10cSrcweir //------------------------------------------------------------------------
589cdf0e10cSrcweir
590cdf0e10cSrcweir
GetNumberingStartValue(sal_uInt16)591cdf0e10cSrcweir sal_Int16 SvxTextForwarder::GetNumberingStartValue( sal_uInt16 )
592cdf0e10cSrcweir {
593cdf0e10cSrcweir return -1;
594cdf0e10cSrcweir }
595cdf0e10cSrcweir
SetNumberingStartValue(sal_uInt16,sal_Int16)596cdf0e10cSrcweir void SvxTextForwarder::SetNumberingStartValue( sal_uInt16, sal_Int16 )
597cdf0e10cSrcweir {
598cdf0e10cSrcweir }
599cdf0e10cSrcweir
IsParaIsNumberingRestart(sal_uInt16)600cdf0e10cSrcweir sal_Bool SvxTextForwarder::IsParaIsNumberingRestart( sal_uInt16 )
601cdf0e10cSrcweir {
602cdf0e10cSrcweir return sal_False;
603cdf0e10cSrcweir }
604cdf0e10cSrcweir
SetParaIsNumberingRestart(sal_uInt16,sal_Bool)605cdf0e10cSrcweir void SvxTextForwarder::SetParaIsNumberingRestart( sal_uInt16, sal_Bool )
606cdf0e10cSrcweir {
607cdf0e10cSrcweir }
608cdf0e10cSrcweir
609cdf0e10cSrcweir //------------------------------------------------------------------------
610cdf0e10cSrcweir
611