1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: unotext.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_svx.hxx"
33 #include <vcl/svapp.hxx>
34 #include <com/sun/star/style/LineSpacing.hpp>
35 #include <com/sun/star/text/ControlCharacter.hpp>
36 #include <com/sun/star/text/ControlCharacter.hpp>
37 #ifndef _COM_SUN_STAR_TEXT_XTEXTFIELD_HDL_
38 #include <com/sun/star/text/XTextField.hdl>
40 #include <vos/mutex.hxx>
41 #include <svtools/itemset.hxx>
43 #include <svx/eeitem.hxx>
44 #include <svtools/itempool.hxx>
45 #include <fontitem.hxx>
46 #include <svx/tstpitem.hxx>
47 #include <svx/svdobj.hxx>
48 #include <svtools/intitem.hxx>
50 #include <svtools/eitem.hxx>
53 #include <rtl/memory.h>
55 #include <svx/unoshtxt.hxx>
56 #include <svx/unoprnms.hxx>
57 #include <svx/unotext.hxx>
58 #include <svx/unoedsrc.hxx>
59 #include <svx/unomid.hxx>
60 #include "unonrule.hxx"
61 #include "unofdesc.hxx"
63 #include <svx/unofield.hxx>
64 #include <svx/flditem.hxx>
65 #include <svx/unoshprp.hxx>
66 #include <svx/numitem.hxx>
67 #include <svx/editeng.hxx>
69 using namespace ::rtl
;
70 using namespace ::vos
;
71 using namespace ::cppu
;
72 using namespace ::com::sun::star
;
74 #define QUERYINT( xint ) \
75 if( rType == ::getCppuType((const uno::Reference< xint >*)0) ) \
76 return uno::makeAny(uno::Reference< xint >(this))
79 extern const SfxItemPropertySet
* ImplGetSvxUnoOutlinerTextCursorSfxPropertySet();
80 const SfxItemPropertyMapEntry
* ImplGetSvxTextPortionPropertyMap()
82 // Propertymap fuer einen Outliner Text
83 static const SfxItemPropertyMapEntry aSvxTextPortionPropertyMap
[] =
85 SVX_UNOEDIT_CHAR_PROPERTIES
,
86 SVX_UNOEDIT_FONT_PROPERTIES
,
87 SVX_UNOEDIT_OUTLINER_PROPERTIES
,
88 SVX_UNOEDIT_PARA_PROPERTIES
,
89 {MAP_CHAR_LEN("TextField"), EE_FEATURE_FIELD
, &::getCppuType((const uno::Reference
< text::XTextField
>*)0), beans::PropertyAttribute::READONLY
, 0 },
90 {MAP_CHAR_LEN("TextPortionType"), WID_PORTIONTYPE
, &::getCppuType((const ::rtl::OUString
*)0), beans::PropertyAttribute::READONLY
, 0 },
91 {MAP_CHAR_LEN("TextUserDefinedAttributes"), EE_CHAR_XMLATTRIBS
, &::getCppuType((const ::com::sun::star::uno::Reference
< ::com::sun::star::container::XNameContainer
>*)0) , 0, 0},
92 {MAP_CHAR_LEN("ParaUserDefinedAttributes"), EE_PARA_XMLATTRIBS
, &::getCppuType((const ::com::sun::star::uno::Reference
< ::com::sun::star::container::XNameContainer
>*)0) , 0, 0},
95 return aSvxTextPortionPropertyMap
;
97 const SvxItemPropertySet
* ImplGetSvxTextPortionSvxPropertySet()
99 static SvxItemPropertySet
aSvxTextPortionPropertySet( ImplGetSvxTextPortionPropertyMap() );
100 return &aSvxTextPortionPropertySet
;
103 const SfxItemPropertySet
* ImplGetSvxTextPortionSfxPropertySet()
105 static SfxItemPropertySet
aSvxTextPortionSfxPropertySet( ImplGetSvxTextPortionPropertyMap() );
106 return &aSvxTextPortionSfxPropertySet
;
109 // ====================================================================
110 // helper fuer Item/Property Konvertierung
111 // ====================================================================
113 void GetSelection( struct ESelection
& rSel
, SvxTextForwarder
* pForwarder
) throw()
115 DBG_ASSERT( pForwarder
, "I need a valid SvxTextForwarder!" );
118 sal_Int16 nParaCount
= pForwarder
->GetParagraphCount();
122 rSel
= ESelection( 0,0, nParaCount
, pForwarder
->GetTextLen( nParaCount
));
126 void CheckSelection( struct ESelection
& rSel
, SvxTextForwarder
* pForwarder
) throw()
128 DBG_ASSERT( pForwarder
, "I need a valid SvxTextForwarder!" );
131 if( rSel
.nStartPara
== 0xffff )
133 ::GetSelection( rSel
, pForwarder
);
137 ESelection aMaxSelection
;
138 GetSelection( aMaxSelection
, pForwarder
);
140 // check start position
141 if( rSel
.nStartPara
< aMaxSelection
.nStartPara
)
143 rSel
.nStartPara
= aMaxSelection
.nStartPara
;
144 rSel
.nStartPos
= aMaxSelection
.nStartPos
;
146 else if( rSel
.nStartPara
> aMaxSelection
.nEndPara
)
148 rSel
.nStartPara
= aMaxSelection
.nEndPara
;
149 rSel
.nStartPos
= aMaxSelection
.nEndPos
;
151 else if( rSel
.nStartPos
> pForwarder
->GetTextLen( rSel
.nStartPara
) )
153 rSel
.nStartPos
= pForwarder
->GetTextLen( rSel
.nStartPara
);
156 // check end position
157 if( rSel
.nEndPara
< aMaxSelection
.nStartPara
)
159 rSel
.nEndPara
= aMaxSelection
.nStartPara
;
160 rSel
.nEndPos
= aMaxSelection
.nStartPos
;
162 else if( rSel
.nEndPara
> aMaxSelection
.nEndPara
)
164 rSel
.nEndPara
= aMaxSelection
.nEndPara
;
165 rSel
.nEndPos
= aMaxSelection
.nEndPos
;
167 else if( rSel
.nEndPos
> pForwarder
->GetTextLen( rSel
.nEndPara
) )
169 rSel
.nEndPos
= pForwarder
->GetTextLen( rSel
.nEndPara
);
175 // ====================================================================
176 // class SvxUnoTextRangeBase
177 // ====================================================================
183 check_me() : mnAllocNum(0) {};
186 void add( SvxUnoTextRangeBase
* pRange
);
187 void remove( SvxUnoTextRangeBase
* pRange
);
189 std::list
< std::pair
< sal_uInt32
, SvxUnoTextRangeBase
* > > maRanges
;
190 sal_uInt32 mnAllocNum
;
193 void check_me::add( SvxUnoTextRangeBase
* pRange
)
195 maRanges
.push_back( std::pair
< sal_uInt32
, SvxUnoTextRangeBase
* >( mnAllocNum
++, pRange
) );
198 void check_me::remove( SvxUnoTextRangeBase
* pRange
)
200 std::list
< std::pair
< sal_uInt32
, SvxUnoTextRangeBase
* > >::iterator aIter
;
201 for( aIter
= maRanges
.begin(); aIter
!= maRanges
.end(); aIter
++ )
203 if( pRange
== (*aIter
).second
)
205 maRanges
.erase( aIter
);
211 check_me::~check_me()
213 if( !maRanges
.empty() )
215 DBG_ERROR("living text range detected!");
216 std::list
< std::pair
< sal_uInt32
, SvxUnoTextRangeBase
* > >::iterator aIter
;
217 for( aIter
= maRanges
.begin(); aIter
!= maRanges
.end(); aIter
++ )
220 SvxUnoTextRangeBase
* pRange
;
221 nAllocNum
= (*aIter
).first
;
222 pRange
= (*aIter
).second
;
227 static check_me gNumRanges
;
230 UNO3_GETIMPLEMENTATION_IMPL( SvxUnoTextRangeBase
);
232 SvxUnoTextRangeBase::SvxUnoTextRangeBase( const SvxItemPropertySet
* _pSet
) throw()
233 : mpEditSource(NULL
) , mpPropSet(_pSet
)
236 gNumRanges
.add(this);
240 SvxUnoTextRangeBase::SvxUnoTextRangeBase( const SvxEditSource
* pSource
, const SvxItemPropertySet
* _pSet
) throw()
243 OGuard
aGuard( Application::GetSolarMutex() );
245 DBG_ASSERT(pSource
,"SvxUnoTextRangeBase: I need a valid SvxEditSource!");
247 mpEditSource
= pSource
->Clone();
248 ESelection aSelection
;
249 ::GetSelection( aSelection
, mpEditSource
->GetTextForwarder() );
250 SetSelection( aSelection
);
253 mpEditSource
->addRange( this );
255 gNumRanges
.add(this);
259 SvxUnoTextRangeBase::SvxUnoTextRangeBase( const SvxUnoTextRangeBase
& rRange
) throw()
261 , beans::XPropertySet()
262 , beans::XMultiPropertySet()
263 , beans::XMultiPropertyStates()
264 , beans::XPropertyState()
265 , lang::XServiceInfo()
266 , text::XTextRangeCompare()
268 , mpPropSet(rRange
.getPropertySet())
270 OGuard
aGuard( Application::GetSolarMutex() );
272 mpEditSource
= rRange
.mpEditSource
? rRange
.mpEditSource
->Clone() : NULL
;
274 SvxTextForwarder
* pForwarder
= mpEditSource
? mpEditSource
->GetTextForwarder() : NULL
;
277 maSelection
= rRange
.maSelection
;
278 CheckSelection( maSelection
, pForwarder
);
282 mpEditSource
->addRange( this );
285 gNumRanges
.add(this);
289 SvxUnoTextRangeBase::~SvxUnoTextRangeBase() throw()
292 gNumRanges
.remove(this);
296 mpEditSource
->removeRange( this );
301 void SvxUnoTextRangeBase::SetEditSource( SvxEditSource
* pSource
) throw()
303 DBG_ASSERT(pSource
,"SvxUnoTextRangeBase: I need a valid SvxEditSource!");
304 DBG_ASSERT(mpEditSource
==NULL
,"SvxUnoTextRangeBase::SetEditSource called while SvxEditSource already set" );
306 mpEditSource
= pSource
;
308 maSelection
.nStartPara
= 0xffff;
311 mpEditSource
->addRange( this );
314 /** puts a field item with a copy of the given FieldData into the itemset
315 corresponding with this range */
316 void SvxUnoTextRangeBase::attachField( const SvxFieldData
* pData
) throw()
318 OGuard
aGuard( Application::GetSolarMutex() );
322 SvxTextForwarder
* pForwarder
= mpEditSource
? mpEditSource
->GetTextForwarder() : NULL
;
325 SvxFieldItem
aField( *pData
, EE_FEATURE_FIELD
);
326 pForwarder
->QuickInsertField( aField
, maSelection
);
331 void SvxUnoTextRangeBase::SetSelection( const ESelection
& rSelection
) throw()
333 OGuard
aGuard( Application::GetSolarMutex() );
335 maSelection
= rSelection
;
336 CheckSelection( maSelection
, mpEditSource
->GetTextForwarder() );
339 // Interface XTextRange ( XText )
341 uno::Reference
< text::XTextRange
> SAL_CALL
SvxUnoTextRangeBase::getStart(void)
342 throw( uno::RuntimeException
)
344 OGuard
aGuard( Application::GetSolarMutex() );
346 uno::Reference
< text::XTextRange
> xRange
;
348 SvxTextForwarder
* pForwarder
= mpEditSource
? mpEditSource
->GetTextForwarder() : NULL
;
352 CheckSelection( maSelection
, pForwarder
);
354 SvxUnoTextBase
* pText
= SvxUnoTextBase::getImplementation( getText() );
357 throw uno::RuntimeException();
359 SvxUnoTextRange
* pRange
= new SvxUnoTextRange( *pText
);
362 ESelection aNewSel
= maSelection
;
363 aNewSel
.nEndPara
= aNewSel
.nStartPara
;
364 aNewSel
.nEndPos
= aNewSel
.nStartPos
;
365 pRange
->SetSelection( aNewSel
);
371 uno::Reference
< text::XTextRange
> SAL_CALL
SvxUnoTextRangeBase::getEnd(void)
372 throw( uno::RuntimeException
)
374 OGuard
aGuard( Application::GetSolarMutex() );
376 uno::Reference
< text::XTextRange
> xRet
;
378 SvxTextForwarder
* pForwarder
= mpEditSource
? mpEditSource
->GetTextForwarder() : NULL
;
381 CheckSelection( maSelection
, pForwarder
);
383 SvxUnoTextBase
* pText
= SvxUnoTextBase::getImplementation( getText() );
386 throw uno::RuntimeException();
388 SvxUnoTextRange
* pNew
= new SvxUnoTextRange( *pText
);
391 ESelection aNewSel
= maSelection
;
392 aNewSel
.nStartPara
= aNewSel
.nEndPara
;
393 aNewSel
.nStartPos
= aNewSel
.nEndPos
;
394 pNew
->SetSelection( aNewSel
);
399 OUString SAL_CALL
SvxUnoTextRangeBase::getString(void)
400 throw( uno::RuntimeException
)
402 OGuard
aGuard( Application::GetSolarMutex() );
404 SvxTextForwarder
* pForwarder
= mpEditSource
? mpEditSource
->GetTextForwarder() : NULL
;
407 CheckSelection( maSelection
, pForwarder
);
409 return pForwarder
->GetText( maSelection
);
413 const OUString aEmpty
;
418 void SAL_CALL
SvxUnoTextRangeBase::setString(const OUString
& aString
)
419 throw( uno::RuntimeException
)
421 OGuard
aGuard( Application::GetSolarMutex() );
423 SvxTextForwarder
* pForwarder
= mpEditSource
? mpEditSource
->GetTextForwarder() : NULL
;
426 CheckSelection( maSelection
, pForwarder
);
428 String
aConverted( aString
);
429 aConverted
.ConvertLineEnd( LINEEND_LF
); // Zeilenenden nur einfach zaehlen
431 pForwarder
->QuickInsertText( aConverted
, maSelection
);
432 mpEditSource
->UpdateData();
434 // Selektion anpassen
435 //! Wenn die EditEngine bei QuickInsertText die Selektion zurueckgeben wuerde,
436 //! waer's einfacher...
439 sal_uInt16 nLen
= aConverted
.Len();
441 GoRight( nLen
, sal_True
);
445 // Interface beans::XPropertySet
446 uno::Reference
< beans::XPropertySetInfo
> SAL_CALL
SvxUnoTextRangeBase::getPropertySetInfo(void)
447 throw( uno::RuntimeException
)
449 return mpPropSet
->getPropertySetInfo();
452 void SAL_CALL
SvxUnoTextRangeBase::setPropertyValue(const OUString
& PropertyName
, const uno::Any
& aValue
)
453 throw( beans::UnknownPropertyException
, beans::PropertyVetoException
, lang::IllegalArgumentException
, lang::WrappedTargetException
, uno::RuntimeException
)
455 _setPropertyValue( PropertyName
, aValue
, -1 );
458 void SAL_CALL
SvxUnoTextRangeBase::_setPropertyValue( const OUString
& PropertyName
, const uno::Any
& aValue
, sal_Int32 nPara
)
459 throw( beans::UnknownPropertyException
, beans::PropertyVetoException
, lang::IllegalArgumentException
, lang::WrappedTargetException
, uno::RuntimeException
)
461 OGuard
aGuard( Application::GetSolarMutex() );
463 SvxTextForwarder
* pForwarder
= mpEditSource
? mpEditSource
->GetTextForwarder() : NULL
;
467 CheckSelection( maSelection
, pForwarder
);
469 const SfxItemPropertySimpleEntry
* pMap
= mpPropSet
->getPropertyMapEntry(PropertyName
);
472 ESelection
aSel( GetSelection() );
473 sal_Bool bParaAttrib
= (pMap
->nWID
>= EE_PARA_START
) && ( pMap
->nWID
<= EE_PARA_END
);
475 if( nPara
== -1 && !bParaAttrib
)
477 SfxItemSet
aOldSet( pForwarder
->GetAttribs( aSel
) );
478 // we have a selection and no para attribute
479 SfxItemSet
aNewSet( *aOldSet
.GetPool(), aOldSet
.GetRanges() );
481 setPropertyValue( pMap
, aValue
, maSelection
, aOldSet
, aNewSet
);
484 pForwarder
->QuickSetAttribs( aNewSet
, GetSelection() );
492 nPara
= aSel
.nStartPara
;
493 nEndPara
= aSel
.nEndPara
;
497 // only one paragraph
501 while( nPara
<= nEndPara
)
503 // we have a paragraph
504 SfxItemSet
aSet( pForwarder
->GetParaAttribs( (USHORT
)nPara
) );
505 setPropertyValue( pMap
, aValue
, maSelection
, aSet
, aSet
);
506 pForwarder
->SetParaAttribs( (USHORT
)nPara
, aSet
);
511 GetEditSource()->UpdateData();
516 throw beans::UnknownPropertyException();
519 void SvxUnoTextRangeBase::setPropertyValue( const SfxItemPropertySimpleEntry
* pMap
, const uno::Any
& rValue
, const ESelection
& rSelection
, const SfxItemSet
& rOldSet
, SfxItemSet
& rNewSet
) throw( beans::UnknownPropertyException
, lang::IllegalArgumentException
)
521 if(!SetPropertyValueHelper( rOldSet
, pMap
, rValue
, rNewSet
, &rSelection
, (SvxTextEditSource
*)GetEditSource() ))
523 // Fuer Teile von zusammengesetzten Items mit mehreren Properties (z.B. Hintergrund)
524 // muss vorher das alte Item aus dem Dokument geholt werden
525 rNewSet
.Put(rOldSet
.Get(pMap
->nWID
)); // altes Item in neuen Set
526 mpPropSet
->setPropertyValue(pMap
, rValue
, rNewSet
);
530 sal_Bool
SvxUnoTextRangeBase::SetPropertyValueHelper( const SfxItemSet
&, const SfxItemPropertySimpleEntry
* pMap
, const uno::Any
& aValue
, SfxItemSet
& rNewSet
, const ESelection
* pSelection
/* = NULL */, SvxTextEditSource
* pEditSource
/* = NULL*/ ) throw( uno::RuntimeException
)
536 awt::FontDescriptor aDesc
;
539 SvxUnoFontDescriptor::FillItemSet( aDesc
, rNewSet
);
545 case EE_PARA_NUMBULLET
:
547 uno::Reference
< container::XIndexReplace
> xRule
;
548 if( !aValue
.hasValue() || ((aValue
>>= xRule
) && !xRule
.is()) )
556 SvxTextForwarder
* pForwarder
= pEditSource
? pEditSource
->GetTextForwarder() : NULL
;
557 if(pForwarder
&& pSelection
)
559 sal_Int16 nLevel
= sal_Int16();
560 if( aValue
>>= nLevel
)
562 // #101004# Call interface method instead of unsafe cast
563 if(! pForwarder
->SetDepth( pSelection
->nStartPara
, nLevel
) )
564 throw lang::IllegalArgumentException();
571 case WID_NUMBERINGSTARTVALUE
:
573 SvxTextForwarder
* pForwarder
= pEditSource
? pEditSource
->GetTextForwarder() : NULL
;
574 if(pForwarder
&& pSelection
)
576 sal_Int16 nStartValue
= -1;
577 if( aValue
>>= nStartValue
)
579 pForwarder
->SetNumberingStartValue( pSelection
->nStartPara
, nStartValue
);
585 case WID_PARAISNUMBERINGRESTART
:
587 SvxTextForwarder
* pForwarder
= pEditSource
? pEditSource
->GetTextForwarder() : NULL
;
588 if(pForwarder
&& pSelection
)
590 sal_Bool bParaIsNumberingRestart
= sal_False
;
591 if( aValue
>>= bParaIsNumberingRestart
)
593 pForwarder
->SetParaIsNumberingRestart( pSelection
->nStartPara
, bParaIsNumberingRestart
);
599 case EE_PARA_BULLETSTATE
:
601 sal_Bool bBullet
= sal_True
;
602 if( aValue
>>= bBullet
)
604 SfxBoolItem
aItem( EE_PARA_BULLETSTATE
, bBullet
);
615 throw lang::IllegalArgumentException();
618 uno::Any SAL_CALL
SvxUnoTextRangeBase::getPropertyValue(const OUString
& PropertyName
)
619 throw( beans::UnknownPropertyException
, lang::WrappedTargetException
, uno::RuntimeException
)
621 return _getPropertyValue( PropertyName
, -1 );
624 uno::Any SAL_CALL
SvxUnoTextRangeBase::_getPropertyValue(const OUString
& PropertyName
, sal_Int32 nPara
)
625 throw( beans::UnknownPropertyException
, lang::WrappedTargetException
, uno::RuntimeException
)
627 OGuard
aGuard( Application::GetSolarMutex() );
631 SvxTextForwarder
* pForwarder
= mpEditSource
? mpEditSource
->GetTextForwarder() : NULL
;
634 const SfxItemPropertySimpleEntry
* pMap
= mpPropSet
->getPropertyMapEntry(PropertyName
);
637 SfxItemSet
* pAttribs
= NULL
;
639 pAttribs
= pForwarder
->GetParaAttribs( (USHORT
)nPara
).Clone();
641 pAttribs
= pForwarder
->GetAttribs( GetSelection() ).Clone();
643 // Dontcare durch Default ersetzen, damit man immer eine Reflection hat
644 pAttribs
->ClearInvalidItems();
646 getPropertyValue( pMap
, aAny
, *pAttribs
);
653 throw beans::UnknownPropertyException();
656 void SvxUnoTextRangeBase::getPropertyValue( const SfxItemPropertySimpleEntry
* pMap
, uno::Any
& rAny
, const SfxItemSet
& rSet
) throw( beans::UnknownPropertyException
)
660 case EE_FEATURE_FIELD
:
661 if ( rSet
.GetItemState( EE_FEATURE_FIELD
, sal_False
) == SFX_ITEM_SET
)
663 SvxFieldItem
* pItem
= (SvxFieldItem
*)rSet
.GetItem( EE_FEATURE_FIELD
);
664 const SvxFieldData
* pData
= pItem
->GetField();
665 uno::Reference
< text::XTextRange
> xAnchor( this );
667 // get presentation string for field
668 Color
* pTColor
= NULL
;
669 Color
* pFColor
= NULL
;
671 SvxTextForwarder
* pForwarder
= mpEditSource
->GetTextForwarder();
672 OUString
aPresentation( pForwarder
->CalcFieldValue( SvxFieldItem(*pData
, EE_FEATURE_FIELD
), maSelection
.nStartPara
, maSelection
.nStartPos
, pTColor
, pFColor
) );
677 uno::Reference
< text::XTextField
> xField( new SvxUnoTextField( xAnchor
, aPresentation
, pData
) );
682 case WID_PORTIONTYPE
:
683 if ( rSet
.GetItemState( EE_FEATURE_FIELD
, sal_False
) == SFX_ITEM_SET
)
685 OUString
aType( RTL_CONSTASCII_USTRINGPARAM("TextField") );
690 OUString
aType( RTL_CONSTASCII_USTRINGPARAM("Text") );
696 if(!GetPropertyValueHelper( *((SfxItemSet
*)(&rSet
)), pMap
, rAny
, &maSelection
, (SvxTextEditSource
*)GetEditSource() ))
697 rAny
= mpPropSet
->getPropertyValue(pMap
, rSet
);
701 sal_Bool
SvxUnoTextRangeBase::GetPropertyValueHelper( SfxItemSet
& rSet
, const SfxItemPropertySimpleEntry
* pMap
, uno::Any
& aAny
, const ESelection
* pSelection
/* = NULL */, SvxTextEditSource
* pEditSource
/* = NULL */ )
702 throw( uno::RuntimeException
)
708 awt::FontDescriptor aDesc
;
709 SvxUnoFontDescriptor::FillFromItemSet( rSet
, aDesc
);
714 case EE_PARA_NUMBULLET
:
716 if((rSet
.GetItemState( EE_PARA_NUMBULLET
, sal_True
) & (SFX_ITEM_SET
|SFX_ITEM_DEFAULT
)) == 0)
717 throw uno::RuntimeException();
719 SvxNumBulletItem
* pBulletItem
= (SvxNumBulletItem
*)rSet
.GetItem( EE_PARA_NUMBULLET
, sal_True
);
721 if( pBulletItem
== NULL
)
722 throw uno::RuntimeException();
724 aAny
<<= SvxCreateNumRule( pBulletItem
->GetNumRule() );
730 SvxTextForwarder
* pForwarder
= pEditSource
? pEditSource
->GetTextForwarder() : NULL
;
731 if(pForwarder
&& pSelection
)
733 sal_Int16 nLevel
= pForwarder
->GetDepth( pSelection
->nStartPara
);
739 case WID_NUMBERINGSTARTVALUE
:
741 SvxTextForwarder
* pForwarder
= pEditSource
? pEditSource
->GetTextForwarder() : NULL
;
742 if(pForwarder
&& pSelection
)
743 aAny
<<= pForwarder
->GetNumberingStartValue( pSelection
->nStartPara
);
746 case WID_PARAISNUMBERINGRESTART
:
748 SvxTextForwarder
* pForwarder
= pEditSource
? pEditSource
->GetTextForwarder() : NULL
;
749 if(pForwarder
&& pSelection
)
750 aAny
<<= pForwarder
->IsParaIsNumberingRestart( pSelection
->nStartPara
);
754 case EE_PARA_BULLETSTATE
:
756 sal_Bool bState
= sal_False
;
757 if( rSet
.GetItemState( EE_PARA_BULLETSTATE
, sal_True
) & (SFX_ITEM_SET
|SFX_ITEM_DEFAULT
))
759 SfxBoolItem
* pItem
= (SfxBoolItem
*)rSet
.GetItem( EE_PARA_BULLETSTATE
, sal_True
);
760 bState
= pItem
->GetValue() ? sal_True
: sal_False
;
774 // wird (noch) nicht unterstuetzt
775 void SAL_CALL
SvxUnoTextRangeBase::addPropertyChangeListener( const OUString
& , const uno::Reference
< beans::XPropertyChangeListener
>& ) throw(beans::UnknownPropertyException
, lang::WrappedTargetException
, uno::RuntimeException
) {}
776 void SAL_CALL
SvxUnoTextRangeBase::removePropertyChangeListener( const OUString
& , const uno::Reference
< beans::XPropertyChangeListener
>& ) throw(beans::UnknownPropertyException
, lang::WrappedTargetException
, uno::RuntimeException
) {}
777 void SAL_CALL
SvxUnoTextRangeBase::addVetoableChangeListener( const OUString
& , const uno::Reference
< beans::XVetoableChangeListener
>& ) throw(beans::UnknownPropertyException
, lang::WrappedTargetException
, uno::RuntimeException
) {}
778 void SAL_CALL
SvxUnoTextRangeBase::removeVetoableChangeListener( const OUString
& , const uno::Reference
< beans::XVetoableChangeListener
>& ) throw(beans::UnknownPropertyException
, lang::WrappedTargetException
, uno::RuntimeException
) {}
781 void SAL_CALL
SvxUnoTextRangeBase::setPropertyValues( const uno::Sequence
< ::rtl::OUString
>& aPropertyNames
, const uno::Sequence
< uno::Any
>& aValues
) throw (beans::PropertyVetoException
, lang::IllegalArgumentException
, lang::WrappedTargetException
, uno::RuntimeException
)
783 _setPropertyValues( aPropertyNames
, aValues
, -1 );
786 void SAL_CALL
SvxUnoTextRangeBase::_setPropertyValues( const uno::Sequence
< ::rtl::OUString
>& aPropertyNames
, const uno::Sequence
< uno::Any
>& aValues
, sal_Int32 nPara
) throw (beans::PropertyVetoException
, lang::IllegalArgumentException
, lang::WrappedTargetException
, uno::RuntimeException
)
788 OGuard
aGuard( Application::GetSolarMutex() );
790 SvxTextForwarder
* pForwarder
= mpEditSource
? mpEditSource
->GetTextForwarder() : NULL
;
793 CheckSelection( maSelection
, pForwarder
);
795 ESelection
aSel( GetSelection() );
797 const OUString
* pPropertyNames
= aPropertyNames
.getConstArray();
798 const uno::Any
* pValues
= aValues
.getConstArray();
799 sal_Int32 nCount
= aPropertyNames
.getLength();
801 sal_Int32 nEndPara
= nPara
;
802 sal_Int32 nTempPara
= nPara
;
804 if( nTempPara
== -1 )
806 nTempPara
= aSel
.nStartPara
;
807 nEndPara
= aSel
.nEndPara
;
810 SfxItemSet
* pOldAttrSet
= NULL
;
811 SfxItemSet
* pNewAttrSet
= NULL
;
813 SfxItemSet
* pOldParaSet
= NULL
;
814 SfxItemSet
* pNewParaSet
= NULL
;
816 for( ; nCount
; nCount
--, pPropertyNames
++, pValues
++ )
818 const SfxItemPropertySimpleEntry
* pMap
= mpPropSet
->getPropertyMapEntry( *pPropertyNames
);
822 sal_Bool bParaAttrib
= (pMap
->nWID
>= EE_PARA_START
) && ( pMap
->nWID
<= EE_PARA_END
);
824 if( (nPara
== -1) && !bParaAttrib
)
826 if( NULL
== pNewAttrSet
)
828 const SfxItemSet
aSet( pForwarder
->GetAttribs( aSel
) );
829 pOldAttrSet
= new SfxItemSet( aSet
);
830 pNewAttrSet
= new SfxItemSet( *pOldAttrSet
->GetPool(), pOldAttrSet
->GetRanges() );
833 setPropertyValue( pMap
, *pValues
, GetSelection(), *pOldAttrSet
, *pNewAttrSet
);
835 if( pMap
->nWID
>= EE_ITEMS_START
&& pMap
->nWID
<= EE_ITEMS_END
)
837 const SfxPoolItem
* pItem
;
838 if( pNewAttrSet
->GetItemState( pMap
->nWID
, sal_True
, &pItem
) == SFX_ITEM_SET
)
840 pOldAttrSet
->Put( *pItem
);
846 if( NULL
== pNewParaSet
)
848 const SfxItemSet
aSet( pForwarder
->GetParaAttribs( (USHORT
)nTempPara
) );
849 pOldParaSet
= new SfxItemSet( aSet
);
850 pNewParaSet
= new SfxItemSet( *pOldParaSet
->GetPool(), pOldParaSet
->GetRanges() );
853 setPropertyValue( pMap
, *pValues
, GetSelection(), *pOldParaSet
, *pNewParaSet
);
855 if( pMap
->nWID
>= EE_ITEMS_START
&& pMap
->nWID
<= EE_ITEMS_END
)
857 const SfxPoolItem
* pItem
;
858 if( pNewParaSet
->GetItemState( pMap
->nWID
, sal_True
, &pItem
) == SFX_ITEM_SET
)
860 pOldParaSet
->Put( *pItem
);
868 sal_Bool bNeedsUpdate
= sal_False
;
872 if( pNewParaSet
->Count() )
874 while( nTempPara
<= nEndPara
)
876 SfxItemSet
aSet( pForwarder
->GetParaAttribs( (USHORT
)nTempPara
) );
877 aSet
.Put( *pNewParaSet
);
878 pForwarder
->SetParaAttribs( (USHORT
)nTempPara
, aSet
);
881 bNeedsUpdate
= sal_True
;
890 if( pNewAttrSet
->Count() )
892 pForwarder
->QuickSetAttribs( *pNewAttrSet
, GetSelection() );
893 bNeedsUpdate
= sal_True
;
901 GetEditSource()->UpdateData();
905 uno::Sequence
< uno::Any
> SAL_CALL
SvxUnoTextRangeBase::getPropertyValues( const uno::Sequence
< ::rtl::OUString
>& aPropertyNames
) throw (uno::RuntimeException
)
907 return _getPropertyValues( aPropertyNames
, -1 );
910 uno::Sequence
< uno::Any
> SAL_CALL
SvxUnoTextRangeBase::_getPropertyValues( const uno::Sequence
< ::rtl::OUString
>& aPropertyNames
, sal_Int32 nPara
) throw (uno::RuntimeException
)
912 OGuard
aGuard( Application::GetSolarMutex() );
914 sal_Int32 nCount
= aPropertyNames
.getLength();
917 uno::Sequence
< uno::Any
> aValues( nCount
);
919 SvxTextForwarder
* pForwarder
= mpEditSource
? mpEditSource
->GetTextForwarder() : NULL
;
922 SfxItemSet
* pAttribs
= NULL
;
924 pAttribs
= pForwarder
->GetParaAttribs( (USHORT
)nPara
).Clone();
926 pAttribs
= pForwarder
->GetAttribs( GetSelection() ).Clone();
928 pAttribs
->ClearInvalidItems();
930 const OUString
* pPropertyNames
= aPropertyNames
.getConstArray();
931 uno::Any
* pValues
= aValues
.getArray();
933 for( ; nCount
; nCount
--, pPropertyNames
++, pValues
++ )
935 const SfxItemPropertySimpleEntry
* pMap
= mpPropSet
->getPropertyMapEntry( *pPropertyNames
);
938 getPropertyValue( pMap
, *pValues
, *pAttribs
);
949 void SAL_CALL
SvxUnoTextRangeBase::addPropertiesChangeListener( const uno::Sequence
< ::rtl::OUString
>& , const uno::Reference
< beans::XPropertiesChangeListener
>& ) throw (uno::RuntimeException
)
953 void SAL_CALL
SvxUnoTextRangeBase::removePropertiesChangeListener( const uno::Reference
< beans::XPropertiesChangeListener
>& ) throw (uno::RuntimeException
)
957 void SAL_CALL
SvxUnoTextRangeBase::firePropertiesChangeEvent( const uno::Sequence
< ::rtl::OUString
>& , const uno::Reference
< beans::XPropertiesChangeListener
>& ) throw (uno::RuntimeException
)
961 // beans::XPropertyState
962 beans::PropertyState SAL_CALL
SvxUnoTextRangeBase::getPropertyState( const OUString
& PropertyName
)
963 throw(beans::UnknownPropertyException
, uno::RuntimeException
)
965 return _getPropertyState( PropertyName
, -1 );
968 static sal_uInt16 aSvxUnoFontDescriptorWhichMap
[] = { EE_CHAR_FONTINFO
, EE_CHAR_FONTHEIGHT
, EE_CHAR_ITALIC
,
969 EE_CHAR_UNDERLINE
, EE_CHAR_WEIGHT
, EE_CHAR_STRIKEOUT
,
972 beans::PropertyState SAL_CALL
SvxUnoTextRangeBase::_getPropertyState(const SfxItemPropertySimpleEntry
* pMap
, sal_Int32 nPara
)
973 throw( beans::UnknownPropertyException
, uno::RuntimeException
)
977 SvxTextForwarder
* pForwarder
= mpEditSource
? mpEditSource
->GetTextForwarder() : NULL
;
980 SfxItemState eItemState
= SFX_ITEM_UNKNOWN
;
987 sal_uInt16
* pWhichId
= aSvxUnoFontDescriptorWhichMap
;
988 SfxItemState eTempItemState
;
992 eTempItemState
= pForwarder
->GetItemState( (USHORT
)nPara
, *pWhichId
);
994 eTempItemState
= pForwarder
->GetItemState( GetSelection(), *pWhichId
);
996 switch( eTempItemState
)
998 case SFX_ITEM_DISABLED
:
999 case SFX_ITEM_DONTCARE
:
1000 eItemState
= SFX_ITEM_DONTCARE
;
1003 case SFX_ITEM_DEFAULT
:
1004 if( eItemState
!= SFX_ITEM_DEFAULT
)
1006 if( eItemState
== SFX_ITEM_UNKNOWN
)
1007 eItemState
= SFX_ITEM_DEFAULT
;
1011 case SFX_ITEM_READONLY
:
1013 if( eItemState
!= SFX_ITEM_SET
)
1015 if( eItemState
== SFX_ITEM_UNKNOWN
)
1016 eItemState
= SFX_ITEM_SET
;
1020 throw beans::UnknownPropertyException();
1029 case WID_NUMBERINGSTARTVALUE
:
1030 case WID_PARAISNUMBERINGRESTART
:
1031 eItemState
= SFX_ITEM_SET
;
1041 eItemState
= pForwarder
->GetItemState( (USHORT
)nPara
, nWID
);
1043 eItemState
= pForwarder
->GetItemState( GetSelection(), nWID
);
1046 switch( eItemState
)
1048 case SFX_ITEM_DONTCARE
:
1049 case SFX_ITEM_DISABLED
:
1050 return beans::PropertyState_AMBIGUOUS_VALUE
;
1051 case SFX_ITEM_READONLY
:
1053 return beans::PropertyState_DIRECT_VALUE
;
1054 case SFX_ITEM_DEFAULT
:
1055 return beans::PropertyState_DEFAULT_VALUE
;
1056 // case SFX_ITEM_UNKNOWN:
1060 throw beans::UnknownPropertyException();
1063 beans::PropertyState SAL_CALL
SvxUnoTextRangeBase::_getPropertyState(const OUString
& PropertyName
, sal_Int32 nPara
/* = -1 */)
1064 throw( beans::UnknownPropertyException
, uno::RuntimeException
)
1066 OGuard
aGuard( Application::GetSolarMutex() );
1068 return _getPropertyState( mpPropSet
->getPropertyMapEntry( PropertyName
), nPara
);
1071 uno::Sequence
< beans::PropertyState
> SAL_CALL
SvxUnoTextRangeBase::getPropertyStates( const uno::Sequence
< OUString
>& aPropertyName
)
1072 throw(beans::UnknownPropertyException
, uno::RuntimeException
)
1074 return _getPropertyStates( aPropertyName
, -1 );
1077 uno::Sequence
< beans::PropertyState
> SvxUnoTextRangeBase::_getPropertyStates(const uno::Sequence
< OUString
>& PropertyName
, sal_Int32 nPara
/* = -1 */)
1078 throw( beans::UnknownPropertyException
, uno::RuntimeException
)
1080 const sal_Int32 nCount
= PropertyName
.getLength();
1081 const OUString
* pNames
= PropertyName
.getConstArray();
1083 uno::Sequence
< beans::PropertyState
> aRet( nCount
);
1084 beans::PropertyState
* pState
= aRet
.getArray();
1086 SvxTextForwarder
* pForwarder
= mpEditSource
? mpEditSource
->GetTextForwarder() : NULL
;
1089 SfxItemSet
* pSet
= NULL
;
1092 pSet
= new SfxItemSet( pForwarder
->GetParaAttribs( (USHORT
)nPara
) );
1096 ESelection
aSel( GetSelection() );
1097 CheckSelection( aSel
, pForwarder
);
1098 pSet
= new SfxItemSet( pForwarder
->GetAttribs( aSel
, EditEngineAttribs_OnlyHard
) );
1101 sal_Bool bUnknownPropertyFound
= sal_False
;
1102 for( sal_Int32 nIdx
= 0; nIdx
< nCount
; nIdx
++ )
1104 const SfxItemPropertySimpleEntry
* pMap
= mpPropSet
->getPropertyMapEntry( *pNames
++ );
1107 bUnknownPropertyFound
= sal_True
;
1110 bUnknownPropertyFound
= !_getOnePropertyStates(pSet
, pMap
, *pState
++);
1115 if( bUnknownPropertyFound
)
1116 throw beans::UnknownPropertyException();
1122 sal_Bool
SvxUnoTextRangeBase::_getOnePropertyStates(const SfxItemSet
* pSet
, const SfxItemPropertySimpleEntry
* pMap
, beans::PropertyState
& rState
)
1124 sal_Bool bUnknownPropertyFound
= sal_False
;
1127 SfxItemState eItemState
= SFX_ITEM_UNKNOWN
;
1128 sal_uInt16 nWID
= 0;
1130 switch( pMap
->nWID
)
1134 sal_uInt16
* pWhichId
= aSvxUnoFontDescriptorWhichMap
;
1135 SfxItemState eTempItemState
;
1138 eTempItemState
= pSet
->GetItemState( *pWhichId
);
1140 switch( eTempItemState
)
1142 case SFX_ITEM_DISABLED
:
1143 case SFX_ITEM_DONTCARE
:
1144 eItemState
= SFX_ITEM_DONTCARE
;
1147 case SFX_ITEM_DEFAULT
:
1148 if( eItemState
!= SFX_ITEM_DEFAULT
)
1150 if( eItemState
== SFX_ITEM_UNKNOWN
)
1151 eItemState
= SFX_ITEM_DEFAULT
;
1155 case SFX_ITEM_READONLY
:
1157 if( eItemState
!= SFX_ITEM_SET
)
1159 if( eItemState
== SFX_ITEM_UNKNOWN
)
1160 eItemState
= SFX_ITEM_SET
;
1164 bUnknownPropertyFound
= sal_True
;
1174 case WID_NUMBERINGSTARTVALUE
:
1175 case WID_PARAISNUMBERINGRESTART
:
1176 eItemState
= SFX_ITEM_SET
;
1183 if( bUnknownPropertyFound
)
1184 return !bUnknownPropertyFound
;
1187 eItemState
= pSet
->GetItemState( nWID
, sal_False
);
1189 switch( eItemState
)
1191 case SFX_ITEM_READONLY
:
1193 rState
= beans::PropertyState_DIRECT_VALUE
;
1195 case SFX_ITEM_DEFAULT
:
1196 rState
= beans::PropertyState_DEFAULT_VALUE
;
1198 // case SFX_ITEM_UNKNOWN:
1199 // case SFX_ITEM_DONTCARE:
1200 // case SFX_ITEM_DISABLED:
1202 rState
= beans::PropertyState_AMBIGUOUS_VALUE
;
1205 return !bUnknownPropertyFound
;
1208 void SAL_CALL
SvxUnoTextRangeBase::setPropertyToDefault( const OUString
& PropertyName
)
1209 throw(beans::UnknownPropertyException
, uno::RuntimeException
)
1211 _setPropertyToDefault( PropertyName
, -1 );
1214 void SvxUnoTextRangeBase::_setPropertyToDefault(const OUString
& PropertyName
, sal_Int32 nPara
/* = -1 */)
1215 throw( beans::UnknownPropertyException
, uno::RuntimeException
)
1217 OGuard
aGuard( Application::GetSolarMutex() );
1219 SvxTextForwarder
* pForwarder
= mpEditSource
? mpEditSource
->GetTextForwarder() : NULL
;
1223 const SfxItemPropertySimpleEntry
* pMap
= mpPropSet
->getPropertyMapEntry( PropertyName
);
1226 CheckSelection( maSelection
, mpEditSource
->GetTextForwarder() );
1227 _setPropertyToDefault( pForwarder
, pMap
, nPara
);
1232 throw beans::UnknownPropertyException();
1235 void SvxUnoTextRangeBase::_setPropertyToDefault(SvxTextForwarder
* pForwarder
, const SfxItemPropertySimpleEntry
* pMap
, sal_Int32 nPara
)
1236 throw( beans::UnknownPropertyException
, uno::RuntimeException
)
1240 SfxItemSet
aSet( *pForwarder
->GetPool(), TRUE
);
1242 if( pMap
->nWID
== WID_FONTDESC
)
1244 SvxUnoFontDescriptor::setPropertyToDefault( aSet
);
1246 else if( pMap
->nWID
== WID_NUMLEVEL
)
1248 // #101004# Call interface method instead of unsafe cast
1249 pForwarder
->SetDepth( maSelection
.nStartPara
, -1 );
1252 else if( pMap
->nWID
== WID_NUMBERINGSTARTVALUE
)
1254 pForwarder
->SetNumberingStartValue( maSelection
.nStartPara
, -1 );
1256 else if( pMap
->nWID
== WID_PARAISNUMBERINGRESTART
)
1258 pForwarder
->SetParaIsNumberingRestart( maSelection
.nStartPara
, sal_False
);
1262 aSet
.InvalidateItem( pMap
->nWID
);
1266 pForwarder
->SetParaAttribs( (USHORT
)nPara
, aSet
);
1268 pForwarder
->QuickSetAttribs( aSet
, GetSelection() );
1270 GetEditSource()->UpdateData();
1277 uno::Any SAL_CALL
SvxUnoTextRangeBase::getPropertyDefault( const OUString
& aPropertyName
)
1278 throw(beans::UnknownPropertyException
, lang::WrappedTargetException
, uno::RuntimeException
)
1280 OGuard
aGuard( Application::GetSolarMutex() );
1282 SvxTextForwarder
* pForwarder
= mpEditSource
? mpEditSource
->GetTextForwarder() : NULL
;
1285 const SfxItemPropertySimpleEntry
* pMap
= mpPropSet
->getPropertyMapEntry( aPropertyName
);
1288 SfxItemPool
* pPool
= pForwarder
->GetPool();
1290 switch( pMap
->nWID
)
1293 return SvxUnoFontDescriptor::getPropertyDefault( pPool
);
1301 case WID_NUMBERINGSTARTVALUE
:
1302 return uno::Any( (sal_Int16
)-1 );
1304 case WID_PARAISNUMBERINGRESTART
:
1305 return uno::Any( (sal_Bool
)sal_False
);
1309 // Default aus ItemPool holen
1310 if(pPool
->IsWhich(pMap
->nWID
))
1312 SfxItemSet
aSet( *pPool
, pMap
->nWID
, pMap
->nWID
);
1313 aSet
.Put(pPool
->GetDefaultItem(pMap
->nWID
));
1314 return mpPropSet
->getPropertyValue(pMap
, aSet
);
1320 throw beans::UnknownPropertyException();
1323 // beans::XMultiPropertyStates
1324 void SAL_CALL
SvxUnoTextRangeBase::setAllPropertiesToDefault( ) throw (uno::RuntimeException
)
1326 OGuard
aGuard( Application::GetSolarMutex() );
1328 SvxTextForwarder
* pForwarder
= mpEditSource
? mpEditSource
->GetTextForwarder() : NULL
;
1332 PropertyEntryVector_t aEntries
= mpPropSet
->getPropertyMap()->getPropertyEntries();
1333 PropertyEntryVector_t::const_iterator aIt
= aEntries
.begin();
1334 while( aIt
!= aEntries
.end() )
1336 _setPropertyToDefault( pForwarder
, &(*aIt
), -1 );
1342 void SAL_CALL
SvxUnoTextRangeBase::setPropertiesToDefault( const uno::Sequence
< OUString
>& aPropertyNames
) throw (beans::UnknownPropertyException
, uno::RuntimeException
)
1344 sal_Int32 nCount
= aPropertyNames
.getLength();
1345 for( const OUString
* pName
= aPropertyNames
.getConstArray(); nCount
; pName
++, nCount
-- )
1347 setPropertyToDefault( *pName
);
1351 uno::Sequence
< uno::Any
> SAL_CALL
SvxUnoTextRangeBase::getPropertyDefaults( const uno::Sequence
< OUString
>& aPropertyNames
) throw (beans::UnknownPropertyException
, lang::WrappedTargetException
, uno::RuntimeException
)
1353 sal_Int32 nCount
= aPropertyNames
.getLength();
1354 uno::Sequence
< uno::Any
> ret( nCount
);
1355 uno::Any
* pDefaults
= ret
.getArray();
1357 for( const OUString
* pName
= aPropertyNames
.getConstArray(); nCount
; pName
++, nCount
--, pDefaults
++ )
1359 *pDefaults
= getPropertyDefault( *pName
);
1366 void SvxUnoTextRangeBase::CollapseToStart(void) throw()
1368 CheckSelection( maSelection
, mpEditSource
->GetTextForwarder() );
1370 maSelection
.nEndPara
= maSelection
.nStartPara
;
1371 maSelection
.nEndPos
= maSelection
.nStartPos
;
1374 void SvxUnoTextRangeBase::CollapseToEnd(void) throw()
1376 CheckSelection( maSelection
, mpEditSource
->GetTextForwarder() );
1378 maSelection
.nStartPara
= maSelection
.nEndPara
;
1379 maSelection
.nStartPos
= maSelection
.nEndPos
;
1382 sal_Bool
SvxUnoTextRangeBase::IsCollapsed(void) throw()
1384 CheckSelection( maSelection
, mpEditSource
->GetTextForwarder() );
1386 return ( maSelection
.nStartPara
== maSelection
.nEndPara
&&
1387 maSelection
.nStartPos
== maSelection
.nEndPos
);
1390 sal_Bool
SvxUnoTextRangeBase::GoLeft(sal_Int16 nCount
, sal_Bool Expand
) throw()
1392 CheckSelection( maSelection
, mpEditSource
->GetTextForwarder() );
1394 // #75098# use end position, as in Writer (start is anchor, end is cursor)
1395 sal_uInt16 nNewPos
= maSelection
.nEndPos
;
1396 sal_uInt16 nNewPar
= maSelection
.nEndPara
;
1398 sal_Bool bOk
= sal_True
;
1399 SvxTextForwarder
* pForwarder
= NULL
;
1400 while ( nCount
> nNewPos
&& bOk
)
1407 pForwarder
= mpEditSource
->GetTextForwarder(); // erst hier, wenn's noetig ist...
1410 nCount
-= nNewPos
+ 1;
1411 nNewPos
= pForwarder
->GetTextLen( nNewPar
);
1417 nNewPos
= nNewPos
- nCount
;
1418 maSelection
.nStartPara
= nNewPar
;
1419 maSelection
.nStartPos
= nNewPos
;
1428 sal_Bool
SvxUnoTextRangeBase::GoRight(sal_Int16 nCount
, sal_Bool Expand
) throw()
1430 SvxTextForwarder
* pForwarder
= mpEditSource
? mpEditSource
->GetTextForwarder() : NULL
;
1433 CheckSelection( maSelection
, pForwarder
);
1436 sal_uInt16 nNewPos
= maSelection
.nEndPos
+ nCount
; //! Ueberlauf ???
1437 sal_uInt16 nNewPar
= maSelection
.nEndPara
;
1439 sal_Bool bOk
= sal_True
;
1440 sal_uInt16 nParCount
= pForwarder
->GetParagraphCount();
1441 sal_uInt16 nThisLen
= pForwarder
->GetTextLen( nNewPar
);
1442 while ( nNewPos
> nThisLen
&& bOk
)
1444 if ( nNewPar
+ 1 >= nParCount
)
1448 nNewPos
-= nThisLen
+1;
1450 nThisLen
= pForwarder
->GetTextLen( nNewPar
);
1456 maSelection
.nEndPara
= nNewPar
;
1457 maSelection
.nEndPos
= nNewPos
;
1468 void SvxUnoTextRangeBase::GotoStart(sal_Bool Expand
) throw()
1470 maSelection
.nStartPara
= 0;
1471 maSelection
.nStartPos
= 0;
1477 void SvxUnoTextRangeBase::GotoEnd(sal_Bool Expand
) throw()
1479 CheckSelection( maSelection
, mpEditSource
->GetTextForwarder() );
1481 SvxTextForwarder
* pForwarder
= mpEditSource
? mpEditSource
->GetTextForwarder() : NULL
;
1485 sal_uInt16 nPar
= pForwarder
->GetParagraphCount();
1489 maSelection
.nEndPara
= nPar
;
1490 maSelection
.nEndPos
= pForwarder
->GetTextLen( nPar
);
1497 // lang::XServiceInfo
1498 sal_Bool SAL_CALL
SvxUnoTextRangeBase::supportsService( const OUString
& ServiceName
)
1499 throw(uno::RuntimeException
)
1501 return SvxServiceInfoHelper::supportsService( ServiceName
, getSupportedServiceNames() );
1504 uno::Sequence
< OUString
> SAL_CALL
SvxUnoTextRangeBase::getSupportedServiceNames()
1505 throw(uno::RuntimeException
)
1507 return getSupportedServiceNames_Static();
1510 uno::Sequence
< OUString
> SAL_CALL
SvxUnoTextRangeBase::getSupportedServiceNames_Static()
1513 uno::Sequence
< OUString
> aSeq
;
1514 SvxServiceInfoHelper::addToSequence( aSeq
, 3, "com.sun.star.style.CharacterProperties",
1515 "com.sun.star.style.CharacterPropertiesComplex",
1516 "com.sun.star.style.CharacterPropertiesAsian");
1520 // XTextRangeCompare
1521 sal_Int16 SAL_CALL
SvxUnoTextRangeBase::compareRegionStarts( const uno::Reference
< text::XTextRange
>& xR1
, const uno::Reference
< text::XTextRange
>& xR2
) throw (lang::IllegalArgumentException
, uno::RuntimeException
)
1523 SvxUnoTextRangeBase
* pR1
= SvxUnoTextRangeBase::getImplementation( xR1
);
1524 SvxUnoTextRangeBase
* pR2
= SvxUnoTextRangeBase::getImplementation( xR2
);
1526 if( (pR1
== 0) || (pR2
== 0) )
1527 throw lang::IllegalArgumentException();
1529 const ESelection
& r1
= pR1
->maSelection
;
1530 const ESelection
& r2
= pR2
->maSelection
;
1532 if( r1
.nStartPara
== r2
.nStartPara
)
1534 if( r1
.nStartPos
== r2
.nStartPos
)
1537 return r1
.nStartPos
< r2
.nStartPos
? 1 : -1;
1541 return r1
.nStartPara
< r2
.nStartPara
? 1 : -1;
1545 sal_Int16 SAL_CALL
SvxUnoTextRangeBase::compareRegionEnds( const uno::Reference
< text::XTextRange
>& xR1
, const uno::Reference
< text::XTextRange
>& xR2
) throw (lang::IllegalArgumentException
, uno::RuntimeException
)
1547 SvxUnoTextRangeBase
* pR1
= SvxUnoTextRangeBase::getImplementation( xR1
);
1548 SvxUnoTextRangeBase
* pR2
= SvxUnoTextRangeBase::getImplementation( xR2
);
1550 if( (pR1
== 0) || (pR2
== 0) )
1551 throw lang::IllegalArgumentException();
1553 const ESelection
& r1
= pR1
->maSelection
;
1554 const ESelection
& r2
= pR2
->maSelection
;
1556 if( r1
.nEndPara
== r2
.nEndPara
)
1558 if( r1
.nEndPos
== r2
.nEndPos
)
1561 return r1
.nEndPos
< r2
.nEndPos
? 1 : -1;
1565 return r1
.nEndPara
< r2
.nEndPara
? 1 : -1;
1569 // ====================================================================
1570 // class SvxUnoTextRange
1571 // ====================================================================
1573 uno::Sequence
< uno::Type
> SvxUnoTextRange::maTypeSequence
;
1575 uno::Reference
< uno::XInterface
> SvxUnoTextRange_NewInstance()
1578 uno::Reference
< text::XTextRange
> xRange( new SvxUnoTextRange( aText
) );
1579 #if (_MSC_VER < 1300)
1582 return (uno::Reference
< uno::XInterface
>)xRange
;
1586 SvxUnoTextRange::SvxUnoTextRange( const SvxUnoTextBase
& rParent
, sal_Bool bPortion
/* = sal_False */ ) throw()
1587 :SvxUnoTextRangeBase( rParent
.GetEditSource(), bPortion
? ImplGetSvxTextPortionSvxPropertySet() : rParent
.getPropertySet() ),
1588 mbPortion( bPortion
)
1590 xParentText
= (text::XText
*)&rParent
;
1593 SvxUnoTextRange::~SvxUnoTextRange() throw()
1597 uno::Any SAL_CALL
SvxUnoTextRange::queryAggregation( const uno::Type
& rType
)
1598 throw(uno::RuntimeException
)
1600 QUERYINT( text::XTextRange
);
1601 else if( rType
== ::getCppuType((const uno::Reference
< beans::XMultiPropertyStates
>*)0) )
1602 return uno::makeAny(uno::Reference
< beans::XMultiPropertyStates
>(this));
1603 else if( rType
== ::getCppuType((const uno::Reference
< beans::XPropertySet
>*)0) )
1604 return uno::makeAny(uno::Reference
< beans::XPropertySet
>(this));
1605 else QUERYINT( beans::XPropertyState
);
1606 else QUERYINT( text::XTextRangeCompare
);
1607 else if( rType
== ::getCppuType((const uno::Reference
< beans::XMultiPropertySet
>*)0) )
1608 return uno::makeAny(uno::Reference
< beans::XMultiPropertySet
>(this));
1609 else QUERYINT( lang::XServiceInfo
);
1610 else QUERYINT( lang::XTypeProvider
);
1611 else QUERYINT( lang::XUnoTunnel
);
1613 return OWeakAggObject::queryAggregation( rType
);
1616 uno::Any SAL_CALL
SvxUnoTextRange::queryInterface( const uno::Type
& rType
)
1617 throw(uno::RuntimeException
)
1619 return OWeakAggObject::queryInterface(rType
);
1622 void SAL_CALL
SvxUnoTextRange::acquire()
1625 OWeakAggObject::acquire();
1628 void SAL_CALL
SvxUnoTextRange::release()
1631 OWeakAggObject::release();
1636 uno::Sequence
< uno::Type
> SAL_CALL
SvxUnoTextRange::getTypes()
1637 throw (uno::RuntimeException
)
1639 if( maTypeSequence
.getLength() == 0 )
1641 maTypeSequence
.realloc( 9 ); // !DANGER! keep this updated
1642 uno::Type
* pTypes
= maTypeSequence
.getArray();
1644 *pTypes
++ = ::getCppuType(( const uno::Reference
< text::XTextRange
>*)0);
1645 *pTypes
++ = ::getCppuType(( const uno::Reference
< beans::XPropertySet
>*)0);
1646 *pTypes
++ = ::getCppuType(( const uno::Reference
< beans::XMultiPropertySet
>*)0);
1647 *pTypes
++ = ::getCppuType(( const uno::Reference
< beans::XMultiPropertyStates
>*)0);
1648 *pTypes
++ = ::getCppuType(( const uno::Reference
< beans::XPropertyState
>*)0);
1649 *pTypes
++ = ::getCppuType(( const uno::Reference
< lang::XServiceInfo
>*)0);
1650 *pTypes
++ = ::getCppuType(( const uno::Reference
< lang::XTypeProvider
>*)0);
1651 *pTypes
++ = ::getCppuType(( const uno::Reference
< lang::XUnoTunnel
>*)0);
1652 *pTypes
++ = ::getCppuType(( const uno::Reference
< text::XTextRangeCompare
>*)0);
1654 return maTypeSequence
;
1657 uno::Sequence
< sal_Int8
> SAL_CALL
SvxUnoTextRange::getImplementationId()
1658 throw (uno::RuntimeException
)
1660 static uno::Sequence
< sal_Int8
> aId
;
1661 if( aId
.getLength() == 0 )
1664 rtl_createUuid( (sal_uInt8
*)aId
.getArray(), 0, sal_True
);
1670 uno::Reference
< text::XText
> SAL_CALL
SvxUnoTextRange::getText()
1671 throw(uno::RuntimeException
)
1676 // lang::XServiceInfo
1677 OUString SAL_CALL
SvxUnoTextRange::getImplementationName()
1678 throw(uno::RuntimeException
)
1680 return OUString(RTL_CONSTASCII_USTRINGPARAM("SvxUnoTextRange"));
1683 // ====================================================================
1685 // ====================================================================
1687 // UNO3_GETIMPLEMENTATION2_IMPL( SvxUnoText, SvxUnoTextRangeBase );
1689 uno::Sequence
< uno::Type
> SvxUnoTextBase::maTypeSequence
;
1691 SvxUnoTextBase::SvxUnoTextBase() throw()
1692 : SvxUnoTextRangeBase( NULL
)
1697 SvxUnoTextBase::SvxUnoTextBase( const SvxItemPropertySet
* _pSet
) throw()
1698 : SvxUnoTextRangeBase( _pSet
)
1702 SvxUnoTextBase::SvxUnoTextBase( const SvxEditSource
* pSource
, const SvxItemPropertySet
* _pSet
) throw()
1703 : SvxUnoTextRangeBase( pSource
, _pSet
)
1705 ESelection aSelection
;
1706 ::GetSelection( aSelection
, GetEditSource()->GetTextForwarder() );
1707 SetSelection( aSelection
);
1710 SvxUnoTextBase::SvxUnoTextBase( const SvxEditSource
* pSource
, const SvxItemPropertySet
* _pSet
, uno::Reference
< text::XText
> xParent
) throw()
1711 : SvxUnoTextRangeBase( pSource
, _pSet
)
1713 xParentText
= xParent
;
1714 ESelection aSelection
;
1715 ::GetSelection( aSelection
, GetEditSource()->GetTextForwarder() );
1716 SetSelection( aSelection
);
1719 SvxUnoTextBase::SvxUnoTextBase( const SvxUnoTextBase
& rText
) throw()
1720 : SvxUnoTextRangeBase( rText
)
1721 , text::XTextAppend()
1723 , container::XEnumerationAccess()
1724 , text::XTextRangeMover()
1725 , lang::XTypeProvider()
1727 xParentText
= rText
.xParentText
;
1730 SvxUnoTextBase::~SvxUnoTextBase() throw()
1735 ESelection
SvxUnoTextBase::InsertField( const SvxFieldItem
& rField
) throw()
1737 SvxTextForwarder
* pForwarder
= GetEditSource() ? GetEditSource()->GetTextForwarder() : NULL
;
1740 pForwarder
->QuickInsertField( rField
, GetSelection() );
1741 GetEditSource()->UpdateData();
1743 // Selektion anpassen
1744 //! Wenn die EditEngine bei QuickInsertText die Selektion zurueckgeben wuerde,
1745 //! waer's einfacher...
1748 GoRight( 1, sal_True
); // Feld ist immer 1 Zeichen
1751 return GetSelection(); // Selektion mit dem Feld
1755 uno::Any SAL_CALL
SvxUnoTextBase::queryAggregation( const uno::Type
& rType
)
1756 throw(uno::RuntimeException
)
1758 QUERYINT( text::XText
);
1759 QUERYINT( text::XSimpleText
);
1760 if( rType
== ::getCppuType((const uno::Reference
< text::XTextRange
>*)0) )
1761 return uno::makeAny(uno::Reference
< text::XTextRange
>((text::XText
*)(this)));
1762 QUERYINT(container::XEnumerationAccess
);
1763 QUERYINT( container::XElementAccess
);
1764 QUERYINT( beans::XMultiPropertyStates
);
1765 QUERYINT( beans::XPropertySet
);
1766 QUERYINT( beans::XMultiPropertySet
);
1767 QUERYINT( beans::XPropertyState
);
1768 QUERYINT( text::XTextRangeCompare
);
1769 QUERYINT( lang::XServiceInfo
);
1770 QUERYINT( text::XTextRangeMover
);
1771 QUERYINT( text::XTextCopy
);
1772 QUERYINT( text::XTextAppend
);
1773 QUERYINT( text::XParagraphAppend
);
1774 QUERYINT( text::XTextPortionAppend
);
1775 QUERYINT( lang::XTypeProvider
);
1776 QUERYINT( lang::XUnoTunnel
);
1783 uno::Sequence
< uno::Type
> SAL_CALL
SvxUnoTextBase::getStaticTypes() throw()
1785 if( maTypeSequence
.getLength() == 0 )
1787 maTypeSequence
.realloc( 15 ); // !DANGER! keep this updated
1788 uno::Type
* pTypes
= maTypeSequence
.getArray();
1790 *pTypes
++ = ::getCppuType(( const uno::Reference
< text::XText
>*)0);
1791 *pTypes
++ = ::getCppuType(( const uno::Reference
< container::XEnumerationAccess
>*)0);
1792 *pTypes
++ = ::getCppuType(( const uno::Reference
< beans::XPropertySet
>*)0);
1793 *pTypes
++ = ::getCppuType(( const uno::Reference
< beans::XMultiPropertySet
>*)0);
1794 *pTypes
++ = ::getCppuType(( const uno::Reference
< beans::XMultiPropertyStates
>*)0);
1795 *pTypes
++ = ::getCppuType(( const uno::Reference
< beans::XPropertyState
>*)0);
1796 *pTypes
++ = ::getCppuType(( const uno::Reference
< text::XTextRangeMover
>*)0);
1797 *pTypes
++ = ::getCppuType(( const uno::Reference
< text::XTextAppend
>*)0);
1798 *pTypes
++ = ::getCppuType(( const uno::Reference
< text::XTextCopy
>*)0);
1799 *pTypes
++ = ::getCppuType(( const uno::Reference
< text::XParagraphAppend
>*)0);
1800 *pTypes
++ = ::getCppuType(( const uno::Reference
< text::XTextPortionAppend
>*)0);
1801 *pTypes
++ = ::getCppuType(( const uno::Reference
< lang::XServiceInfo
>*)0);
1802 *pTypes
++ = ::getCppuType(( const uno::Reference
< lang::XTypeProvider
>*)0);
1803 *pTypes
++ = ::getCppuType(( const uno::Reference
< lang::XUnoTunnel
>*)0);
1804 *pTypes
++ = ::getCppuType(( const uno::Reference
< text::XTextRangeCompare
>*)0);
1806 return maTypeSequence
;
1809 uno::Sequence
< uno::Type
> SAL_CALL
SvxUnoTextBase::getTypes()
1810 throw (uno::RuntimeException
)
1812 return getStaticTypes();
1815 uno::Sequence
< sal_Int8
> SAL_CALL
SvxUnoTextBase::getImplementationId()
1816 throw (uno::RuntimeException
)
1818 static uno::Sequence
< sal_Int8
> aId
;
1819 if( aId
.getLength() == 0 )
1822 rtl_createUuid( (sal_uInt8
*)aId
.getArray(), 0, sal_True
);
1827 uno::Reference
< text::XTextCursor
> SvxUnoTextBase::createTextCursorBySelection( const ESelection
& rSel
)
1829 SvxUnoTextCursor
* pCursor
= new SvxUnoTextCursor( *this );
1830 uno::Reference
< text::XTextCursor
> xCursor( pCursor
);
1831 pCursor
->SetSelection( rSel
);
1837 uno::Reference
< text::XTextCursor
> SAL_CALL
SvxUnoTextBase::createTextCursor()
1838 throw(uno::RuntimeException
)
1840 OGuard
aGuard( Application::GetSolarMutex() );
1841 return new SvxUnoTextCursor( *this );
1844 uno::Reference
< text::XTextCursor
> SAL_CALL
SvxUnoTextBase::createTextCursorByRange( const uno::Reference
< text::XTextRange
>& aTextPosition
)
1845 throw(uno::RuntimeException
)
1847 OGuard
aGuard( Application::GetSolarMutex() );
1849 uno::Reference
< text::XTextCursor
> xCursor
;
1851 if( aTextPosition
.is() )
1853 SvxUnoTextRangeBase
* pRange
= SvxUnoTextRangeBase::getImplementation( aTextPosition
);
1855 xCursor
= createTextCursorBySelection( pRange
->GetSelection() );
1861 void SAL_CALL
SvxUnoTextBase::insertString( const uno::Reference
< text::XTextRange
>& xRange
, const OUString
& aString
, sal_Bool bAbsorb
)
1862 throw(uno::RuntimeException
)
1864 OGuard
aGuard( Application::GetSolarMutex() );
1869 ESelection aSelection
;
1870 ::GetSelection( aSelection
, GetEditSource()->GetTextForwarder() );
1871 SetSelection( aSelection
);
1873 SvxUnoTextRangeBase
* pRange
= SvxUnoTextRange::getImplementation( xRange
);
1876 // setString am SvxUnoTextRangeBase statt selber QuickInsertText und UpdateData,
1877 // damit die Selektion am SvxUnoTextRangeBase angepasst wird.
1878 //! Eigentlich muessten alle Cursor-Objekte dieses Textes angepasst werden!
1880 if (!bAbsorb
) // nicht ersetzen -> hinten anhaengen
1881 pRange
->CollapseToEnd();
1883 pRange
->setString( aString
);
1885 pRange
->CollapseToEnd();
1889 void SAL_CALL
SvxUnoTextBase::insertControlCharacter( const uno::Reference
< text::XTextRange
>& xRange
, sal_Int16 nControlCharacter
, sal_Bool bAbsorb
)
1890 throw(lang::IllegalArgumentException
, uno::RuntimeException
)
1892 OGuard
aGuard( Application::GetSolarMutex() );
1894 SvxTextForwarder
* pForwarder
= GetEditSource() ? GetEditSource()->GetTextForwarder() : NULL
;
1898 ESelection aSelection
;
1899 ::GetSelection( aSelection
, pForwarder
);
1900 SetSelection( aSelection
);
1902 switch( nControlCharacter
)
1904 case text::ControlCharacter::PARAGRAPH_BREAK
:
1906 const String
aText( (sal_Unicode
)13 ); // '\r' geht auf'm Mac nicht
1907 insertString( xRange
, aText
, bAbsorb
);
1911 case text::ControlCharacter::LINE_BREAK
:
1913 SvxUnoTextRangeBase
* pRange
= SvxUnoTextRange::getImplementation( xRange
);
1916 ESelection aRange
= pRange
->GetSelection();
1920 const String aEmpty
;
1921 pForwarder
->QuickInsertText( aEmpty
, aRange
);
1923 aRange
.nEndPos
= aRange
.nStartPos
;
1924 aRange
.nEndPara
= aRange
.nStartPara
;
1928 aRange
.nStartPos
= aRange
.nEndPos
;
1929 aRange
.nStartPara
= aRange
.nStartPara
;
1932 pForwarder
->QuickInsertLineBreak( aRange
);
1933 GetEditSource()->UpdateData();
1935 aRange
.nEndPos
+= 1;
1937 aRange
.nStartPos
+= 1;
1939 pRange
->SetSelection( aRange
);
1943 case text::ControlCharacter::APPEND_PARAGRAPH
:
1945 SvxUnoTextRangeBase
* pRange
= SvxUnoTextRange::getImplementation( xRange
);
1948 ESelection aRange
= pRange
->GetSelection();
1949 // ESelection aOldSelection = aRange;
1951 aRange
.nStartPos
= pForwarder
->GetTextLen( aRange
.nStartPara
);
1953 aRange
.nEndPara
= aRange
.nStartPara
;
1954 aRange
.nEndPos
= aRange
.nStartPos
;
1956 pRange
->SetSelection( aRange
);
1957 const String
aText( (sal_Unicode
)13 ); // '\r' geht auf'm Mac nicht
1958 pRange
->setString( aText
);
1960 aRange
.nStartPos
= 0;
1961 aRange
.nStartPara
+= 1;
1963 aRange
.nEndPara
+= 1;
1965 pRange
->SetSelection( aRange
);
1973 throw lang::IllegalArgumentException();
1977 void SAL_CALL
SvxUnoTextBase::insertTextContent( const uno::Reference
< text::XTextRange
>& xRange
, const uno::Reference
< text::XTextContent
>& xContent
, sal_Bool bAbsorb
)
1978 throw(lang::IllegalArgumentException
, uno::RuntimeException
)
1980 OGuard
aGuard( Application::GetSolarMutex() );
1982 SvxTextForwarder
* pForwarder
= GetEditSource() ? GetEditSource()->GetTextForwarder() : NULL
;
1986 SvxUnoTextRangeBase
* pRange
= SvxUnoTextRange::getImplementation( xRange
);
1987 SvxUnoTextField
* pField
= SvxUnoTextField::getImplementation( xContent
);
1989 if( pRange
== NULL
|| pField
== NULL
)
1990 throw lang::IllegalArgumentException();
1992 ESelection aSelection
= pRange
->GetSelection();
1995 aSelection
.nStartPara
= aSelection
.nEndPara
;
1996 aSelection
.nStartPos
= aSelection
.nEndPos
;
1999 SvxFieldData
* pFieldData
= pField
->CreateFieldData();
2000 if( pFieldData
== NULL
)
2001 throw lang::IllegalArgumentException();
2003 SvxFieldItem
aField( *pFieldData
, EE_FEATURE_FIELD
);
2004 pForwarder
->QuickInsertField( aField
, aSelection
);
2005 GetEditSource()->UpdateData();
2007 pField
->SetAnchor( uno::Reference
< text::XTextRange
>::query( (cppu::OWeakObject
*)this ) );
2009 aSelection
.nEndPos
+= 1;
2010 aSelection
.nStartPos
= aSelection
.nEndPos
;
2011 //maSelection = aSelection; //???
2012 pRange
->SetSelection( aSelection
);
2018 void SAL_CALL
SvxUnoTextBase::removeTextContent( const uno::Reference
< text::XTextContent
>& ) throw(container::NoSuchElementException
, uno::RuntimeException
)
2024 uno::Reference
< text::XText
> SAL_CALL
SvxUnoTextBase::getText()
2025 throw(uno::RuntimeException
)
2027 OGuard
aGuard( Application::GetSolarMutex() );
2029 if (GetEditSource())
2031 ESelection aSelection
;
2032 ::GetSelection( aSelection
, GetEditSource()->GetTextForwarder() );
2033 ((SvxUnoTextBase
*)this)->SetSelection( aSelection
);
2036 return (text::XText
*)this;
2039 uno::Reference
< text::XTextRange
> SAL_CALL
SvxUnoTextBase::getStart()
2040 throw(uno::RuntimeException
)
2042 return SvxUnoTextRangeBase::getStart();
2045 uno::Reference
< text::XTextRange
> SAL_CALL
SvxUnoTextBase::getEnd()
2046 throw(uno::RuntimeException
)
2048 return SvxUnoTextRangeBase::getEnd();
2051 OUString SAL_CALL
SvxUnoTextBase::getString() throw( uno::RuntimeException
)
2053 return SvxUnoTextRangeBase::getString();
2056 void SAL_CALL
SvxUnoTextBase::setString( const OUString
& aString
) throw(uno::RuntimeException
)
2058 SvxUnoTextRangeBase::setString(aString
);
2062 // XEnumerationAccess
2063 uno::Reference
< container::XEnumeration
> SAL_CALL
SvxUnoTextBase::createEnumeration()
2064 throw(uno::RuntimeException
)
2066 OGuard
aGuard( Application::GetSolarMutex() );
2068 ESelection aSelection
;
2069 ::GetSelection( aSelection
, GetEditSource()->GetTextForwarder() );
2070 SetSelection( aSelection
);
2072 uno::Reference
< container::XEnumeration
> xEnum( (container::XEnumeration
*) new SvxUnoTextContentEnumeration( *this ) );
2076 // XElementAccess ( container::XEnumerationAccess )
2077 uno::Type SAL_CALL
SvxUnoTextBase::getElementType( ) throw(uno::RuntimeException
)
2079 return ::getCppuType((const uno::Reference
< text::XTextRange
>*)0 );
2082 sal_Bool SAL_CALL
SvxUnoTextBase::hasElements( ) throw(uno::RuntimeException
)
2084 OGuard
aGuard( Application::GetSolarMutex() );
2088 SvxTextForwarder
* pForwarder
= GetEditSource()->GetTextForwarder();
2090 return pForwarder
->GetParagraphCount() != 0;
2096 // text::XTextRangeMover
2097 void SAL_CALL
SvxUnoTextBase::moveTextRange( const uno::Reference
< text::XTextRange
>&, sal_Int16
)
2098 throw(uno::RuntimeException
)
2102 void SvxPropertyValuesToItemSet(
2103 SfxItemSet
&rItemSet
,
2104 const uno::Sequence
< beans::PropertyValue
> rPropertyVaules
,
2105 const SfxItemPropertySet
*pPropSet
,
2106 SvxTextForwarder
*pForwarder
/*needed for WID_NUMLEVEL*/,
2107 USHORT nPara
/*needed for WID_NUMLEVEL*/)
2108 throw(lang::IllegalArgumentException
, beans::UnknownPropertyException
, uno::RuntimeException
)
2110 sal_Int32 nProps
= rPropertyVaules
.getLength();
2111 const beans::PropertyValue
*pProps
= rPropertyVaules
.getConstArray();
2112 for (sal_Int32 i
= 0; i
< nProps
; ++i
)
2114 const SfxItemPropertySimpleEntry
*pEntry
= pPropSet
->getPropertyMap()->getByName( pProps
[i
].Name
);
2117 // Note: there is no need to take special care of the properties
2118 // TextField (EE_FEATURE_FIELD) and
2119 // TextPortionType (WID_PORTIONTYPE)
2120 // since they are read-only and thus are already taken care of below.
2122 if (pEntry
->nFlags
& beans::PropertyAttribute::READONLY
)
2123 // should be PropertyVetoException which is not yet defined for the new import API's functions
2124 throw uno::RuntimeException( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Property is read-only: " ) ) + pProps
[i
].Name
, static_cast < cppu::OWeakObject
* > ( 0 ) );
2125 //throw PropertyVetoException ( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Property is read-only: " ) ) + pProps[i].Name, static_cast < cppu::OWeakObject * > ( 0 ) );
2127 if (pEntry
->nWID
== WID_FONTDESC
)
2129 awt::FontDescriptor aDesc
;
2130 if (pProps
[i
].Value
>>= aDesc
)
2131 SvxUnoFontDescriptor::FillItemSet( aDesc
, rItemSet
);
2133 else if (pEntry
->nWID
== WID_NUMLEVEL
)
2137 sal_Int16 nLevel
= -1;
2138 pProps
[i
].Value
>>= nLevel
;
2140 // #101004# Call interface method instead of unsafe cast
2141 if (!pForwarder
->SetDepth( nPara
, nLevel
))
2142 throw lang::IllegalArgumentException();
2145 else if (pEntry
->nWID
== WID_NUMBERINGSTARTVALUE
)
2149 sal_Int16 nStartValue
= -1;
2150 if( !(pProps
[i
].Value
>>= nStartValue
) )
2151 throw lang::IllegalArgumentException();
2153 pForwarder
->SetNumberingStartValue( nPara
, nStartValue
);
2156 else if (pEntry
->nWID
== WID_PARAISNUMBERINGRESTART
)
2160 sal_Bool bParaIsNumberingRestart
= sal_False
;
2161 if( !(pProps
[i
].Value
>>= bParaIsNumberingRestart
) )
2162 throw lang::IllegalArgumentException();
2164 pForwarder
->SetParaIsNumberingRestart( nPara
, bParaIsNumberingRestart
);
2168 pPropSet
->setPropertyValue( pProps
[i
].Name
, pProps
[i
].Value
, rItemSet
);
2171 throw beans::UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + pProps
[i
].Name
, static_cast < cppu::OWeakObject
* > ( 0 ) );
2175 // com::sun::star::text::XParagraphAppend (new import API)
2176 uno::Reference
< text::XTextRange
> SAL_CALL
SvxUnoTextBase::appendParagraph(
2177 const uno::Sequence
< beans::PropertyValue
>& rCharAndParaProps
)
2178 throw (lang::IllegalArgumentException
, beans::UnknownPropertyException
, uno::RuntimeException
)
2180 OGuard
aGuard( Application::GetSolarMutex() );
2181 uno::Reference
< text::XTextRange
> xRet
;
2182 SvxEditSource
*pEditSource
= GetEditSource();
2183 SvxTextForwarder
*pTextForwarder
= pEditSource
? pEditSource
->GetTextForwarder() : 0;
2186 USHORT nParaCount
= pTextForwarder
->GetParagraphCount();
2187 DBG_ASSERT( nParaCount
> 0, "paragraph count is 0 or negative" );
2188 pTextForwarder
->AppendParagraph();
2190 // set properties for new appended (now last) paragraph
2191 ESelection
aSel( nParaCount
, 0, nParaCount
, 0 );
2192 SfxItemSet
aItemSet( *pTextForwarder
->GetEmptyItemSetPtr() );
2193 SvxPropertyValuesToItemSet( aItemSet
, rCharAndParaProps
,
2194 ImplGetSvxUnoOutlinerTextCursorSfxPropertySet(),
2197 pTextForwarder
->QuickSetAttribs( aItemSet
, aSel
);
2198 pEditSource
->UpdateData();
2199 SvxUnoTextRange
* pRange
= new SvxUnoTextRange( *this );
2201 pRange
->SetSelection( aSel
);
2206 uno::Reference
< text::XTextRange
> SAL_CALL
SvxUnoTextBase::finishParagraph(
2207 const uno::Sequence
< beans::PropertyValue
>& rCharAndParaProps
)
2208 throw (lang::IllegalArgumentException
, beans::UnknownPropertyException
, uno::RuntimeException
)
2210 OGuard
aGuard( Application::GetSolarMutex() );
2212 uno::Reference
< text::XTextRange
> xRet
;
2213 SvxEditSource
*pEditSource
= GetEditSource();
2214 SvxTextForwarder
*pTextForwarder
= pEditSource
? pEditSource
->GetTextForwarder() : 0;
2217 USHORT nParaCount
= pTextForwarder
->GetParagraphCount();
2218 DBG_ASSERT( nParaCount
> 0, "paragraph count is 0 or negative" );
2219 pTextForwarder
->AppendParagraph();
2221 // set properties for the previously last paragraph
2222 USHORT nPara
= nParaCount
- 1;
2223 ESelection
aSel( nPara
, 0, nPara
, 0 );
2224 SfxItemSet
aItemSet( *pTextForwarder
->GetEmptyItemSetPtr() );
2225 SvxPropertyValuesToItemSet( aItemSet
, rCharAndParaProps
,
2226 ImplGetSvxUnoOutlinerTextCursorSfxPropertySet(), pTextForwarder
, nPara
);
2227 pTextForwarder
->QuickSetAttribs( aItemSet
, aSel
);
2228 pEditSource
->UpdateData();
2229 SvxUnoTextRange
* pRange
= new SvxUnoTextRange( *this );
2231 pRange
->SetSelection( aSel
);
2236 // com::sun::star::text::XTextPortionAppend (new import API)
2237 uno::Reference
< text::XTextRange
> SAL_CALL
SvxUnoTextBase::appendTextPortion(
2238 const ::rtl::OUString
& rText
,
2239 const uno::Sequence
< beans::PropertyValue
>& rCharAndParaProps
)
2240 throw (lang::IllegalArgumentException
, beans::UnknownPropertyException
, uno::RuntimeException
)
2242 OGuard
aGuard( Application::GetSolarMutex() );
2244 SvxEditSource
*pEditSource
= GetEditSource();
2245 SvxTextForwarder
*pTextForwarder
= pEditSource
? pEditSource
->GetTextForwarder() : 0;
2246 uno::Reference
< text::XTextRange
> xRet
;
2249 USHORT nParaCount
= pTextForwarder
->GetParagraphCount();
2250 DBG_ASSERT( nParaCount
> 0, "paragraph count is 0 or negative" );
2251 USHORT nPara
= nParaCount
- 1;
2252 SfxItemSet
aSet( pTextForwarder
->GetParaAttribs( nPara
) );
2253 xub_StrLen nStart
= pTextForwarder
->AppendTextPortion( nPara
, rText
, aSet
);
2254 pEditSource
->UpdateData();
2255 xub_StrLen nEnd
= pTextForwarder
->GetTextLen( nPara
);
2257 // set properties for the new text portion
2258 ESelection
aSel( nPara
, nStart
, nPara
, nEnd
);
2259 pTextForwarder
->RemoveAttribs( aSel
, sal_False
, 0 );
2260 pEditSource
->UpdateData();
2262 SfxItemSet
aItemSet( *pTextForwarder
->GetEmptyItemSetPtr() );
2263 SvxPropertyValuesToItemSet( aItemSet
, rCharAndParaProps
,
2264 ImplGetSvxTextPortionSfxPropertySet(), pTextForwarder
, nPara
);
2265 pTextForwarder
->QuickSetAttribs( aItemSet
, aSel
);
2266 SvxUnoTextRange
* pRange
= new SvxUnoTextRange( *this );
2268 pRange
->SetSelection( aSel
);
2269 const beans::PropertyValue
* pProps
= rCharAndParaProps
.getConstArray();
2270 for( sal_Int32 nProp
= 0; nProp
< rCharAndParaProps
.getLength(); ++nProp
)
2271 pRange
->setPropertyValue( pProps
[nProp
].Name
, pProps
[nProp
].Value
);
2275 /*-- 25.03.2008 08:16:09---------------------------------------------------
2277 -----------------------------------------------------------------------*/
2278 void SvxUnoTextBase::copyText(
2279 const uno::Reference
< text::XTextCopy
>& xSource
) throw ( uno::RuntimeException
)
2281 OGuard
aGuard( Application::GetSolarMutex() );
2282 uno::Reference
< lang::XUnoTunnel
> xUT( xSource
, uno::UNO_QUERY
);
2283 SvxEditSource
*pEditSource
= GetEditSource();
2284 SvxTextForwarder
*pTextForwarder
= pEditSource
? pEditSource
->GetTextForwarder() : 0;
2285 if( !pTextForwarder
)
2289 SvxUnoTextBase
* pSource
= reinterpret_cast<SvxUnoTextBase
*>(sal::static_int_cast
<sal_uIntPtr
>(
2290 xUT
->getSomething( SvxUnoTextBase::getUnoTunnelId())));
2291 SvxEditSource
*pSourceEditSource
= pSource
->GetEditSource();
2292 SvxTextForwarder
*pSourceTextForwarder
= pSourceEditSource
? pSourceEditSource
->GetTextForwarder() : 0;
2293 if( pSourceTextForwarder
)
2295 pTextForwarder
->CopyText( *pSourceTextForwarder
);
2296 pEditSource
->UpdateData();
2301 uno::Reference
< text::XText
> xSourceText( xSource
, uno::UNO_QUERY
);
2302 if( xSourceText
.is() )
2304 setString( xSourceText
->getString() );
2309 // lang::XServiceInfo
2310 OUString SAL_CALL
SvxUnoTextBase::getImplementationName()
2311 throw(uno::RuntimeException
)
2313 return OUString(RTL_CONSTASCII_USTRINGPARAM("SvxUnoTextBase"));
2316 uno::Sequence
< OUString
> SAL_CALL
SvxUnoTextBase::getSupportedServiceNames( )
2317 throw(uno::RuntimeException
)
2319 return getSupportedServiceNames_Static();
2322 uno::Sequence
< OUString
> SAL_CALL
SvxUnoTextBase::getSupportedServiceNames_Static( )
2325 uno::Sequence
< OUString
> aSeq( SvxUnoTextRangeBase::getSupportedServiceNames_Static() );
2326 SvxServiceInfoHelper::addToSequence( aSeq
, 1, "com.sun.star.text.Text" );
2330 const uno::Sequence
< sal_Int8
> & SvxUnoTextBase::getUnoTunnelId() throw()
2332 static uno::Sequence
< sal_Int8
> * pSeq
= 0;
2335 ::osl::Guard
< ::osl::Mutex
> aGuard( ::osl::Mutex::getGlobalMutex() );
2338 static uno::Sequence
< sal_Int8
> aSeq( 16 );
2339 rtl_createUuid( (sal_uInt8
*)aSeq
.getArray(), 0, sal_True
);
2346 SvxUnoTextBase
* SvxUnoTextBase::getImplementation( const uno::Reference
< uno::XInterface
>& xInt
)
2348 uno::Reference
< lang::XUnoTunnel
> xUT( xInt
, uno::UNO_QUERY
);
2350 return reinterpret_cast<SvxUnoTextBase
*>(sal::static_int_cast
<sal_uIntPtr
>(xUT
->getSomething( SvxUnoTextBase::getUnoTunnelId())));
2355 sal_Int64 SAL_CALL
SvxUnoTextBase::getSomething( const uno::Sequence
< sal_Int8
>& rId
) throw(uno::RuntimeException
) \
2357 if( rId
.getLength() == 16 && 0 == rtl_compareMemory( getUnoTunnelId().getConstArray(),
2358 rId
.getConstArray(), 16 ) )
2360 return sal::static_int_cast
<sal_Int64
>(reinterpret_cast<sal_uIntPtr
>(this));
2364 return SvxUnoTextRangeBase::getSomething( rId
);
2368 // --------------------------------------------------------------------
2370 SvxUnoText::SvxUnoText( ) throw()
2374 SvxUnoText::SvxUnoText( const SvxItemPropertySet
* _pSet
) throw()
2375 : SvxUnoTextBase( _pSet
)
2379 SvxUnoText::SvxUnoText( const SvxEditSource
* pSource
, const SvxItemPropertySet
* _pSet
, uno::Reference
< text::XText
> xParent
) throw()
2380 : SvxUnoTextBase( pSource
, _pSet
, xParent
)
2384 SvxUnoText::SvxUnoText( const SvxUnoText
& rText
) throw()
2385 : SvxUnoTextBase( rText
)
2386 , cppu::OWeakAggObject()
2390 SvxUnoText::~SvxUnoText() throw()
2394 uno::Sequence
< uno::Type
> SAL_CALL
getStaticTypes() throw()
2396 return SvxUnoTextBase::getStaticTypes();
2400 uno::Any SAL_CALL
SvxUnoText::queryAggregation( const uno::Type
& rType
) throw( uno::RuntimeException
)
2402 uno::Any
aAny( SvxUnoTextBase::queryAggregation( rType
) );
2403 if( !aAny
.hasValue() )
2404 aAny
= OWeakAggObject::queryAggregation( rType
);
2409 uno::Any SAL_CALL
SvxUnoText::queryInterface( const uno::Type
& rType
) throw( uno::RuntimeException
)
2411 return OWeakAggObject::queryInterface( rType
);
2414 void SAL_CALL
SvxUnoText::acquire() throw( )
2416 OWeakAggObject::acquire();
2419 void SAL_CALL
SvxUnoText::release() throw( )
2421 OWeakAggObject::release();
2424 // lang::XTypeProvider
2425 uno::Sequence
< uno::Type
> SAL_CALL
SvxUnoText::getTypes( ) throw( uno::RuntimeException
)
2427 return SvxUnoTextBase::getTypes();
2430 uno::Sequence
< sal_Int8
> SAL_CALL
SvxUnoText::getImplementationId( ) throw( uno::RuntimeException
)
2432 static uno::Sequence
< sal_Int8
> aId
;
2433 if( aId
.getLength() == 0 )
2436 rtl_createUuid( (sal_uInt8
*)aId
.getArray(), 0, sal_True
);
2441 SvxUnoText
* SvxUnoText::getImplementation( const uno::Reference
< uno::XInterface
>& xInt
)
2443 uno::Reference
< lang::XUnoTunnel
> xUT( xInt
, uno::UNO_QUERY
);
2445 return reinterpret_cast<SvxUnoText
*>(sal::static_int_cast
<sal_uIntPtr
>(xUT
->getSomething( SvxUnoText::getUnoTunnelId())));
2450 const uno::Sequence
< sal_Int8
> & SvxUnoText::getUnoTunnelId() throw()
2452 static uno::Sequence
< sal_Int8
> * pSeq
= 0;
2455 ::osl::Guard
< ::osl::Mutex
> aGuard( ::osl::Mutex::getGlobalMutex() );
2458 static uno::Sequence
< sal_Int8
> aSeq( 16 );
2459 rtl_createUuid( (sal_uInt8
*)aSeq
.getArray(), 0, sal_True
);
2466 sal_Int64 SAL_CALL
SvxUnoText::getSomething( const uno::Sequence
< sal_Int8
>& rId
) throw(uno::RuntimeException
) \
2468 if( rId
.getLength() == 16 && 0 == rtl_compareMemory( getUnoTunnelId().getConstArray(),
2469 rId
.getConstArray(), 16 ) )
2471 return sal::static_int_cast
<sal_Int64
>(reinterpret_cast<sal_uIntPtr
>(this));
2475 return SvxUnoTextBase::getSomething( rId
);
2480 // --------------------------------------------------------------------
2482 SvxDummyTextSource::~SvxDummyTextSource()
2486 SvxEditSource
* SvxDummyTextSource::Clone() const
2488 return new SvxDummyTextSource();
2491 SvxTextForwarder
* SvxDummyTextSource::GetTextForwarder()
2496 void SvxDummyTextSource::UpdateData()
2500 sal_uInt16
SvxDummyTextSource::GetParagraphCount() const
2505 sal_uInt16
SvxDummyTextSource::GetTextLen( sal_uInt16
) const
2510 String
SvxDummyTextSource::GetText( const ESelection
& ) const
2515 SfxItemSet
SvxDummyTextSource::GetAttribs( const ESelection
&, BOOL
) const
2517 // AW: Very dangerous: The former implementation used a SfxItemPool created on the
2518 // fly which of course was deleted again ASAP. Thus, the returned SfxItemSet was using
2519 // a deleted Pool by design.
2520 return SfxItemSet(SdrObject::GetGlobalDrawObjectItemPool());
2523 SfxItemSet
SvxDummyTextSource::GetParaAttribs( sal_uInt16
) const
2525 return GetAttribs(ESelection());
2528 void SvxDummyTextSource::SetParaAttribs( sal_uInt16
, const SfxItemSet
& )
2532 void SvxDummyTextSource::RemoveAttribs( const ESelection
& , sal_Bool
, sal_uInt16
)
2536 void SvxDummyTextSource::GetPortions( sal_uInt16
, SvUShorts
& ) const
2540 sal_uInt16
SvxDummyTextSource::GetItemState( const ESelection
&, sal_uInt16
) const
2545 sal_uInt16
SvxDummyTextSource::GetItemState( sal_uInt16
, sal_uInt16
) const
2550 SfxItemPool
* SvxDummyTextSource::GetPool() const
2555 void SvxDummyTextSource::QuickInsertText( const String
&, const ESelection
& )
2559 void SvxDummyTextSource::QuickInsertField( const SvxFieldItem
&, const ESelection
& )
2563 void SvxDummyTextSource::QuickSetAttribs( const SfxItemSet
&, const ESelection
& )
2567 void SvxDummyTextSource::QuickInsertLineBreak( const ESelection
& )
2571 XubString
SvxDummyTextSource::CalcFieldValue( const SvxFieldItem
&, sal_uInt16
, sal_uInt16
, Color
*&, Color
*& )
2576 sal_Bool
SvxDummyTextSource::IsValid() const
2581 void SvxDummyTextSource::SetNotifyHdl( const Link
& )
2585 LanguageType
SvxDummyTextSource::GetLanguage( USHORT
, USHORT
) const
2587 return LANGUAGE_DONTKNOW
;
2590 USHORT
SvxDummyTextSource::GetFieldCount( USHORT
) const
2595 EFieldInfo
SvxDummyTextSource::GetFieldInfo( USHORT
, USHORT
) const
2597 return EFieldInfo();
2600 EBulletInfo
SvxDummyTextSource::GetBulletInfo( USHORT
) const
2602 return EBulletInfo();
2605 Rectangle
SvxDummyTextSource::GetCharBounds( USHORT
, USHORT
) const
2610 Rectangle
SvxDummyTextSource::GetParaBounds( USHORT
) const
2615 MapMode
SvxDummyTextSource::GetMapMode() const
2620 OutputDevice
* SvxDummyTextSource::GetRefDevice() const
2625 sal_Bool
SvxDummyTextSource::GetIndexAtPoint( const Point
&, USHORT
&, USHORT
& ) const
2630 sal_Bool
SvxDummyTextSource::GetWordIndices( USHORT
, USHORT
, USHORT
&, USHORT
& ) const
2635 sal_Bool
SvxDummyTextSource::GetAttributeRun( USHORT
&, USHORT
&, USHORT
, USHORT
) const
2640 USHORT
SvxDummyTextSource::GetLineCount( USHORT
) const
2645 USHORT
SvxDummyTextSource::GetLineLen( USHORT
, USHORT
) const
2650 void SvxDummyTextSource::GetLineBoundaries( /*out*/USHORT
&rStart
, /*out*/USHORT
&rEnd
, USHORT
/*nParagraph*/, USHORT
/*nLine*/ ) const
2655 USHORT
SvxDummyTextSource::GetLineNumberAtIndex( USHORT
/*nPara*/, USHORT
/*nIndex*/ ) const
2660 sal_Bool
SvxDummyTextSource::QuickFormatDoc( BOOL
)
2665 sal_Int16
SvxDummyTextSource::GetDepth( USHORT
) const
2670 sal_Bool
SvxDummyTextSource::SetDepth( USHORT
, sal_Int16 nNewDepth
)
2672 return nNewDepth
== 0 ? sal_True
: sal_False
;
2675 sal_Bool
SvxDummyTextSource::Delete( const ESelection
& )
2680 sal_Bool
SvxDummyTextSource::InsertText( const String
&, const ESelection
& )
2685 const SfxItemSet
* SvxDummyTextSource::GetEmptyItemSetPtr()
2690 void SvxDummyTextSource::AppendParagraph()
2694 xub_StrLen
SvxDummyTextSource::AppendTextPortion( USHORT
, const String
&, const SfxItemSet
& )
2699 void SvxDummyTextSource::CopyText(const SvxTextForwarder
& )