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 10cdf0e10cSrcweir * 11190118d0SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 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. 19cdf0e10cSrcweir * 20190118d0SAndrew Rist *************************************************************/ 21190118d0SAndrew Rist 22190118d0SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_editeng.hxx" 26cdf0e10cSrcweir #include <vcl/svapp.hxx> 27cdf0e10cSrcweir #include <com/sun/star/style/LineSpacing.hpp> 28cdf0e10cSrcweir #include <com/sun/star/text/ControlCharacter.hpp> 29cdf0e10cSrcweir #include <com/sun/star/text/ControlCharacter.hpp> 30cdf0e10cSrcweir #include <com/sun/star/text/XTextField.hdl> 31cdf0e10cSrcweir #include <vos/mutex.hxx> 32cdf0e10cSrcweir #include <svl/itemset.hxx> 33cdf0e10cSrcweir #include <svl/itempool.hxx> 34cdf0e10cSrcweir #include <svl/intitem.hxx> 35cdf0e10cSrcweir #include <svl/eitem.hxx> 36cdf0e10cSrcweir #include <rtl/uuid.h> 37cdf0e10cSrcweir #include <rtl/memory.h> 38cdf0e10cSrcweir 39cdf0e10cSrcweir #include <editeng/fontitem.hxx> 40cdf0e10cSrcweir #include <editeng/tstpitem.hxx> 41cdf0e10cSrcweir #include <editeng/unoprnms.hxx> 42cdf0e10cSrcweir #include <editeng/unotext.hxx> 43cdf0e10cSrcweir #include <editeng/unoedsrc.hxx> 44cdf0e10cSrcweir #include <editeng/unonrule.hxx> 45cdf0e10cSrcweir #include <editeng/unofdesc.hxx> 46cdf0e10cSrcweir #include <editeng/unofield.hxx> 47cdf0e10cSrcweir #include <editeng/flditem.hxx> 48cdf0e10cSrcweir #include <editeng/numitem.hxx> 49cdf0e10cSrcweir #include <editeng/editeng.hxx> 50cdf0e10cSrcweir #include <editeng/outliner.hxx> 51cdf0e10cSrcweir #include <editeng/unoipset.hxx> 52cdf0e10cSrcweir #include <comphelper/serviceinfohelper.hxx> 53cdf0e10cSrcweir 54cdf0e10cSrcweir using namespace ::rtl; 55cdf0e10cSrcweir using namespace ::vos; 56cdf0e10cSrcweir using namespace ::cppu; 57cdf0e10cSrcweir using namespace ::com::sun::star; 58cdf0e10cSrcweir 59cdf0e10cSrcweir #define QUERYINT( xint ) \ 60cdf0e10cSrcweir if( rType == ::getCppuType((const uno::Reference< xint >*)0) ) \ 61cdf0e10cSrcweir return uno::makeAny(uno::Reference< xint >(this)) 62cdf0e10cSrcweir 63cdf0e10cSrcweir const SvxItemPropertySet* ImplGetSvxUnoOutlinerTextCursorSvxPropertySet() 64cdf0e10cSrcweir { 65cdf0e10cSrcweir static SvxItemPropertySet aTextCursorSvxPropertySet( ImplGetSvxUnoOutlinerTextCursorPropertyMap(), EditEngine::GetGlobalItemPool() ); 66cdf0e10cSrcweir return &aTextCursorSvxPropertySet; 67cdf0e10cSrcweir } 68cdf0e10cSrcweir 69cdf0e10cSrcweir const SfxItemPropertyMapEntry* ImplGetSvxTextPortionPropertyMap() 70cdf0e10cSrcweir { 71cdf0e10cSrcweir // Propertymap fuer einen Outliner Text 72cdf0e10cSrcweir static const SfxItemPropertyMapEntry aSvxTextPortionPropertyMap[] = 73cdf0e10cSrcweir { 74cdf0e10cSrcweir SVX_UNOEDIT_CHAR_PROPERTIES, 75cdf0e10cSrcweir SVX_UNOEDIT_FONT_PROPERTIES, 76cdf0e10cSrcweir SVX_UNOEDIT_OUTLINER_PROPERTIES, 77cdf0e10cSrcweir SVX_UNOEDIT_PARA_PROPERTIES, 78cdf0e10cSrcweir {MAP_CHAR_LEN("TextField"), EE_FEATURE_FIELD, &::getCppuType((const uno::Reference< text::XTextField >*)0), beans::PropertyAttribute::READONLY, 0 }, 79cdf0e10cSrcweir {MAP_CHAR_LEN("TextPortionType"), WID_PORTIONTYPE, &::getCppuType((const ::rtl::OUString*)0), beans::PropertyAttribute::READONLY, 0 }, 80cdf0e10cSrcweir {MAP_CHAR_LEN("TextUserDefinedAttributes"), EE_CHAR_XMLATTRIBS, &::getCppuType((const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >*)0) , 0, 0}, 81cdf0e10cSrcweir {MAP_CHAR_LEN("ParaUserDefinedAttributes"), EE_PARA_XMLATTRIBS, &::getCppuType((const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >*)0) , 0, 0}, 82cdf0e10cSrcweir {0,0,0,0,0,0} 83cdf0e10cSrcweir }; 84cdf0e10cSrcweir return aSvxTextPortionPropertyMap; 85cdf0e10cSrcweir } 86cdf0e10cSrcweir const SvxItemPropertySet* ImplGetSvxTextPortionSvxPropertySet() 87cdf0e10cSrcweir { 88cdf0e10cSrcweir static SvxItemPropertySet aSvxTextPortionPropertySet( ImplGetSvxTextPortionPropertyMap(), EditEngine::GetGlobalItemPool() ); 89cdf0e10cSrcweir return &aSvxTextPortionPropertySet; 90cdf0e10cSrcweir } 91cdf0e10cSrcweir 92cdf0e10cSrcweir const SfxItemPropertySet* ImplGetSvxTextPortionSfxPropertySet() 93cdf0e10cSrcweir { 94cdf0e10cSrcweir static SfxItemPropertySet aSvxTextPortionSfxPropertySet( ImplGetSvxTextPortionPropertyMap() ); 95cdf0e10cSrcweir return &aSvxTextPortionSfxPropertySet; 96cdf0e10cSrcweir } 97cdf0e10cSrcweir 98cdf0e10cSrcweir const SfxItemPropertyMapEntry* ImplGetSvxUnoOutlinerTextCursorPropertyMap() 99cdf0e10cSrcweir { 100cdf0e10cSrcweir // Propertymap fuer einen Outliner Text 101cdf0e10cSrcweir static const SfxItemPropertyMapEntry aSvxUnoOutlinerTextCursorPropertyMap[] = 102cdf0e10cSrcweir { 103cdf0e10cSrcweir SVX_UNOEDIT_CHAR_PROPERTIES, 104cdf0e10cSrcweir SVX_UNOEDIT_FONT_PROPERTIES, 105cdf0e10cSrcweir SVX_UNOEDIT_OUTLINER_PROPERTIES, 106cdf0e10cSrcweir SVX_UNOEDIT_PARA_PROPERTIES, 107cdf0e10cSrcweir {MAP_CHAR_LEN("TextUserDefinedAttributes"), EE_CHAR_XMLATTRIBS, &::getCppuType((const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >*)0) , 0, 0}, 108cdf0e10cSrcweir {MAP_CHAR_LEN("ParaUserDefinedAttributes"), EE_PARA_XMLATTRIBS, &::getCppuType((const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >*)0) , 0, 0}, 109cdf0e10cSrcweir {0,0,0,0,0,0} 110cdf0e10cSrcweir }; 111cdf0e10cSrcweir 112cdf0e10cSrcweir return aSvxUnoOutlinerTextCursorPropertyMap; 113cdf0e10cSrcweir } 114cdf0e10cSrcweir const SfxItemPropertySet* ImplGetSvxUnoOutlinerTextCursorSfxPropertySet() 115cdf0e10cSrcweir { 116cdf0e10cSrcweir static SfxItemPropertySet aTextCursorSfxPropertySet( ImplGetSvxUnoOutlinerTextCursorPropertyMap() ); 117cdf0e10cSrcweir return &aTextCursorSfxPropertySet; 118cdf0e10cSrcweir } 119cdf0e10cSrcweir 120cdf0e10cSrcweir // ==================================================================== 121cdf0e10cSrcweir // helper fuer Item/Property Konvertierung 122cdf0e10cSrcweir // ==================================================================== 123cdf0e10cSrcweir 124cdf0e10cSrcweir void GetSelection( struct ESelection& rSel, SvxTextForwarder* pForwarder ) throw() 125cdf0e10cSrcweir { 126cdf0e10cSrcweir DBG_ASSERT( pForwarder, "I need a valid SvxTextForwarder!" ); 127cdf0e10cSrcweir if( pForwarder ) 128cdf0e10cSrcweir { 129c2eaa082SDamjan Jovanovic sal_Int32 nParaCount = pForwarder->GetParagraphCount(); 130cdf0e10cSrcweir if(nParaCount>0) 131cdf0e10cSrcweir nParaCount--; 132cdf0e10cSrcweir 133cdf0e10cSrcweir rSel = ESelection( 0,0, nParaCount, pForwarder->GetTextLen( nParaCount )); 134cdf0e10cSrcweir } 135cdf0e10cSrcweir } 136cdf0e10cSrcweir 137cdf0e10cSrcweir void CheckSelection( struct ESelection& rSel, SvxTextForwarder* pForwarder ) throw() 138cdf0e10cSrcweir { 139cdf0e10cSrcweir DBG_ASSERT( pForwarder, "I need a valid SvxTextForwarder!" ); 140cdf0e10cSrcweir if( pForwarder ) 141cdf0e10cSrcweir { 142cdf0e10cSrcweir if( rSel.nStartPara == 0xffff ) 143cdf0e10cSrcweir { 144cdf0e10cSrcweir ::GetSelection( rSel, pForwarder ); 145cdf0e10cSrcweir } 146cdf0e10cSrcweir else 147cdf0e10cSrcweir { 148cdf0e10cSrcweir ESelection aMaxSelection; 149cdf0e10cSrcweir GetSelection( aMaxSelection, pForwarder ); 150cdf0e10cSrcweir 151cdf0e10cSrcweir // check start position 152cdf0e10cSrcweir if( rSel.nStartPara < aMaxSelection.nStartPara ) 153cdf0e10cSrcweir { 154cdf0e10cSrcweir rSel.nStartPara = aMaxSelection.nStartPara; 155cdf0e10cSrcweir rSel.nStartPos = aMaxSelection.nStartPos; 156cdf0e10cSrcweir } 157cdf0e10cSrcweir else if( rSel.nStartPara > aMaxSelection.nEndPara ) 158cdf0e10cSrcweir { 159cdf0e10cSrcweir rSel.nStartPara = aMaxSelection.nEndPara; 160cdf0e10cSrcweir rSel.nStartPos = aMaxSelection.nEndPos; 161cdf0e10cSrcweir } 162cdf0e10cSrcweir else if( rSel.nStartPos > pForwarder->GetTextLen( rSel.nStartPara ) ) 163cdf0e10cSrcweir { 164cdf0e10cSrcweir rSel.nStartPos = pForwarder->GetTextLen( rSel.nStartPara ); 165cdf0e10cSrcweir } 166cdf0e10cSrcweir 167cdf0e10cSrcweir // check end position 168cdf0e10cSrcweir if( rSel.nEndPara < aMaxSelection.nStartPara ) 169cdf0e10cSrcweir { 170cdf0e10cSrcweir rSel.nEndPara = aMaxSelection.nStartPara; 171cdf0e10cSrcweir rSel.nEndPos = aMaxSelection.nStartPos; 172cdf0e10cSrcweir } 173cdf0e10cSrcweir else if( rSel.nEndPara > aMaxSelection.nEndPara ) 174cdf0e10cSrcweir { 175cdf0e10cSrcweir rSel.nEndPara = aMaxSelection.nEndPara; 176cdf0e10cSrcweir rSel.nEndPos = aMaxSelection.nEndPos; 177cdf0e10cSrcweir } 178cdf0e10cSrcweir else if( rSel.nEndPos > pForwarder->GetTextLen( rSel.nEndPara ) ) 179cdf0e10cSrcweir { 180cdf0e10cSrcweir rSel.nEndPos = pForwarder->GetTextLen( rSel.nEndPara ); 181cdf0e10cSrcweir } 182cdf0e10cSrcweir } 183cdf0e10cSrcweir } 184cdf0e10cSrcweir } 185cdf0e10cSrcweir 186cdf0e10cSrcweir // ==================================================================== 187cdf0e10cSrcweir // class SvxUnoTextRangeBase 188cdf0e10cSrcweir // ==================================================================== 189cdf0e10cSrcweir 190cdf0e10cSrcweir #ifdef DEBUG 191cdf0e10cSrcweir class check_me 192cdf0e10cSrcweir { 193cdf0e10cSrcweir public: 194cdf0e10cSrcweir check_me() : mnAllocNum(0) {}; 195cdf0e10cSrcweir ~check_me(); 196cdf0e10cSrcweir 197cdf0e10cSrcweir void add( SvxUnoTextRangeBase* pRange ); 198cdf0e10cSrcweir void remove( SvxUnoTextRangeBase* pRange ); 199cdf0e10cSrcweir 200cdf0e10cSrcweir std::list< std::pair< sal_uInt32, SvxUnoTextRangeBase* > > maRanges; 201cdf0e10cSrcweir sal_uInt32 mnAllocNum; 202cdf0e10cSrcweir }; 203cdf0e10cSrcweir 204cdf0e10cSrcweir void check_me::add( SvxUnoTextRangeBase* pRange ) 205cdf0e10cSrcweir { 206cdf0e10cSrcweir maRanges.push_back( std::pair< sal_uInt32, SvxUnoTextRangeBase* >( mnAllocNum++, pRange ) ); 207cdf0e10cSrcweir } 208cdf0e10cSrcweir 209cdf0e10cSrcweir void check_me::remove( SvxUnoTextRangeBase* pRange ) 210cdf0e10cSrcweir { 211cdf0e10cSrcweir std::list< std::pair< sal_uInt32, SvxUnoTextRangeBase* > >::iterator aIter; 212cdf0e10cSrcweir for( aIter = maRanges.begin(); aIter != maRanges.end(); aIter++ ) 213cdf0e10cSrcweir { 214cdf0e10cSrcweir if( pRange == (*aIter).second ) 215cdf0e10cSrcweir { 216cdf0e10cSrcweir maRanges.erase( aIter ); 217cdf0e10cSrcweir break; 218cdf0e10cSrcweir } 219cdf0e10cSrcweir } 220cdf0e10cSrcweir } 221cdf0e10cSrcweir 222cdf0e10cSrcweir check_me::~check_me() 223cdf0e10cSrcweir { 224cdf0e10cSrcweir if( !maRanges.empty() ) 225cdf0e10cSrcweir { 226cdf0e10cSrcweir DBG_ERROR("living text range detected!"); 227cdf0e10cSrcweir std::list< std::pair< sal_uInt32, SvxUnoTextRangeBase* > >::iterator aIter; 228cdf0e10cSrcweir for( aIter = maRanges.begin(); aIter != maRanges.end(); aIter++ ) 229cdf0e10cSrcweir { 230cdf0e10cSrcweir sal_Int32 nAllocNum; 231cdf0e10cSrcweir SvxUnoTextRangeBase* pRange; 232cdf0e10cSrcweir nAllocNum = (*aIter).first; 233cdf0e10cSrcweir pRange = (*aIter).second; 234cdf0e10cSrcweir } 235cdf0e10cSrcweir } 236cdf0e10cSrcweir } 237cdf0e10cSrcweir 238cdf0e10cSrcweir static check_me gNumRanges; 239cdf0e10cSrcweir #endif 240cdf0e10cSrcweir 241cdf0e10cSrcweir UNO3_GETIMPLEMENTATION_IMPL( SvxUnoTextRangeBase ); 242cdf0e10cSrcweir 243cdf0e10cSrcweir SvxUnoTextRangeBase::SvxUnoTextRangeBase( const SvxItemPropertySet* _pSet ) throw() 244cdf0e10cSrcweir : mpEditSource(NULL) , mpPropSet(_pSet) 245cdf0e10cSrcweir { 246cdf0e10cSrcweir #ifdef DEBUG 247cdf0e10cSrcweir gNumRanges.add(this); 248cdf0e10cSrcweir #endif 249cdf0e10cSrcweir } 250cdf0e10cSrcweir 251cdf0e10cSrcweir SvxUnoTextRangeBase::SvxUnoTextRangeBase( const SvxEditSource* pSource, const SvxItemPropertySet* _pSet ) throw() 252cdf0e10cSrcweir : mpPropSet(_pSet) 253cdf0e10cSrcweir { 254cdf0e10cSrcweir OGuard aGuard( Application::GetSolarMutex() ); 255cdf0e10cSrcweir 256cdf0e10cSrcweir DBG_ASSERT(pSource,"SvxUnoTextRangeBase: I need a valid SvxEditSource!"); 257cdf0e10cSrcweir 258cdf0e10cSrcweir mpEditSource = pSource->Clone(); 259cdf0e10cSrcweir if (mpEditSource != NULL) 260cdf0e10cSrcweir { 261cdf0e10cSrcweir ESelection aSelection; 262cdf0e10cSrcweir ::GetSelection( aSelection, mpEditSource->GetTextForwarder() ); 263cdf0e10cSrcweir SetSelection( aSelection ); 264cdf0e10cSrcweir 265cdf0e10cSrcweir mpEditSource->addRange( this ); 266cdf0e10cSrcweir } 267cdf0e10cSrcweir #ifdef DEBUG 268cdf0e10cSrcweir gNumRanges.add(this); 269cdf0e10cSrcweir #endif 270cdf0e10cSrcweir } 271cdf0e10cSrcweir 272cdf0e10cSrcweir SvxUnoTextRangeBase::SvxUnoTextRangeBase( const SvxUnoTextRangeBase& rRange ) throw() 273cdf0e10cSrcweir : text::XTextRange() 274cdf0e10cSrcweir , beans::XPropertySet() 275cdf0e10cSrcweir , beans::XMultiPropertySet() 276cdf0e10cSrcweir , beans::XMultiPropertyStates() 277cdf0e10cSrcweir , beans::XPropertyState() 278cdf0e10cSrcweir , lang::XServiceInfo() 279cdf0e10cSrcweir , text::XTextRangeCompare() 280cdf0e10cSrcweir , lang::XUnoTunnel() 281cdf0e10cSrcweir , mpPropSet(rRange.getPropertySet()) 282cdf0e10cSrcweir { 283cdf0e10cSrcweir OGuard aGuard( Application::GetSolarMutex() ); 284cdf0e10cSrcweir 285cdf0e10cSrcweir mpEditSource = rRange.mpEditSource ? rRange.mpEditSource->Clone() : NULL; 286cdf0e10cSrcweir 287cdf0e10cSrcweir SvxTextForwarder* pForwarder = mpEditSource ? mpEditSource->GetTextForwarder() : NULL; 288cdf0e10cSrcweir if( pForwarder ) 289cdf0e10cSrcweir { 290cdf0e10cSrcweir maSelection = rRange.maSelection; 291cdf0e10cSrcweir CheckSelection( maSelection, pForwarder ); 292cdf0e10cSrcweir } 293cdf0e10cSrcweir 294cdf0e10cSrcweir if( mpEditSource ) 295cdf0e10cSrcweir mpEditSource->addRange( this ); 296cdf0e10cSrcweir 297cdf0e10cSrcweir #ifdef DEBUG 298cdf0e10cSrcweir gNumRanges.add(this); 299cdf0e10cSrcweir #endif 300cdf0e10cSrcweir } 301cdf0e10cSrcweir 302cdf0e10cSrcweir SvxUnoTextRangeBase::~SvxUnoTextRangeBase() throw() 303cdf0e10cSrcweir { 304cdf0e10cSrcweir #ifdef DEBUG 305cdf0e10cSrcweir gNumRanges.remove(this); 306cdf0e10cSrcweir #endif 307cdf0e10cSrcweir 308cdf0e10cSrcweir if( mpEditSource ) 309cdf0e10cSrcweir mpEditSource->removeRange( this ); 310cdf0e10cSrcweir 311cdf0e10cSrcweir delete mpEditSource; 312cdf0e10cSrcweir } 313cdf0e10cSrcweir 314cdf0e10cSrcweir void SvxUnoTextRangeBase::SetEditSource( SvxEditSource* pSource ) throw() 315cdf0e10cSrcweir { 316cdf0e10cSrcweir DBG_ASSERT(pSource,"SvxUnoTextRangeBase: I need a valid SvxEditSource!"); 317cdf0e10cSrcweir DBG_ASSERT(mpEditSource==NULL,"SvxUnoTextRangeBase::SetEditSource called while SvxEditSource already set" ); 318cdf0e10cSrcweir 319cdf0e10cSrcweir mpEditSource = pSource; 320cdf0e10cSrcweir 321cdf0e10cSrcweir maSelection.nStartPara = 0xffff; 322cdf0e10cSrcweir 323cdf0e10cSrcweir if( mpEditSource ) 324cdf0e10cSrcweir mpEditSource->addRange( this ); 325cdf0e10cSrcweir } 326cdf0e10cSrcweir 327cdf0e10cSrcweir /** puts a field item with a copy of the given FieldData into the itemset 328cdf0e10cSrcweir corresponding with this range */ 329cdf0e10cSrcweir void SvxUnoTextRangeBase::attachField( const SvxFieldData* pData ) throw() 330cdf0e10cSrcweir { 331cdf0e10cSrcweir OGuard aGuard( Application::GetSolarMutex() ); 332cdf0e10cSrcweir 333cdf0e10cSrcweir if( pData ) 334cdf0e10cSrcweir { 335cdf0e10cSrcweir SvxTextForwarder* pForwarder = mpEditSource ? mpEditSource->GetTextForwarder() : NULL; 336cdf0e10cSrcweir if( pForwarder ) 337cdf0e10cSrcweir { 338cdf0e10cSrcweir SvxFieldItem aField( *pData, EE_FEATURE_FIELD ); 339cdf0e10cSrcweir pForwarder->QuickInsertField( aField, maSelection ); 340cdf0e10cSrcweir } 341cdf0e10cSrcweir } 342cdf0e10cSrcweir } 343cdf0e10cSrcweir 344cdf0e10cSrcweir void SvxUnoTextRangeBase::SetSelection( const ESelection& rSelection ) throw() 345cdf0e10cSrcweir { 346cdf0e10cSrcweir OGuard aGuard( Application::GetSolarMutex() ); 347cdf0e10cSrcweir 348cdf0e10cSrcweir maSelection = rSelection; 349cdf0e10cSrcweir if (mpEditSource != NULL) 350cdf0e10cSrcweir CheckSelection( maSelection, mpEditSource->GetTextForwarder() ); 351cdf0e10cSrcweir } 352cdf0e10cSrcweir 353cdf0e10cSrcweir // Interface XTextRange ( XText ) 354cdf0e10cSrcweir 355cdf0e10cSrcweir uno::Reference< text::XTextRange > SAL_CALL SvxUnoTextRangeBase::getStart(void) 356cdf0e10cSrcweir throw( uno::RuntimeException ) 357cdf0e10cSrcweir { 358cdf0e10cSrcweir OGuard aGuard( Application::GetSolarMutex() ); 359cdf0e10cSrcweir 360cdf0e10cSrcweir uno::Reference< text::XTextRange > xRange; 361cdf0e10cSrcweir 362cdf0e10cSrcweir SvxTextForwarder* pForwarder = mpEditSource ? mpEditSource->GetTextForwarder() : NULL; 363cdf0e10cSrcweir if( pForwarder ) 364cdf0e10cSrcweir { 365cdf0e10cSrcweir 366cdf0e10cSrcweir CheckSelection( maSelection, pForwarder ); 367cdf0e10cSrcweir 368cdf0e10cSrcweir SvxUnoTextBase* pText = SvxUnoTextBase::getImplementation( getText() ); 369cdf0e10cSrcweir 370cdf0e10cSrcweir if(pText == NULL) 371cdf0e10cSrcweir throw uno::RuntimeException(); 372cdf0e10cSrcweir 373cdf0e10cSrcweir SvxUnoTextRange* pRange = new SvxUnoTextRange( *pText ); 374cdf0e10cSrcweir xRange = pRange; 375cdf0e10cSrcweir 376cdf0e10cSrcweir ESelection aNewSel = maSelection; 377cdf0e10cSrcweir aNewSel.nEndPara = aNewSel.nStartPara; 378cdf0e10cSrcweir aNewSel.nEndPos = aNewSel.nStartPos; 379cdf0e10cSrcweir pRange->SetSelection( aNewSel ); 380cdf0e10cSrcweir } 381cdf0e10cSrcweir 382cdf0e10cSrcweir return xRange; 383cdf0e10cSrcweir } 384cdf0e10cSrcweir 385cdf0e10cSrcweir uno::Reference< text::XTextRange > SAL_CALL SvxUnoTextRangeBase::getEnd(void) 386cdf0e10cSrcweir throw( uno::RuntimeException ) 387cdf0e10cSrcweir { 388cdf0e10cSrcweir OGuard aGuard( Application::GetSolarMutex() ); 389cdf0e10cSrcweir 390cdf0e10cSrcweir uno::Reference< text::XTextRange > xRet; 391cdf0e10cSrcweir 392cdf0e10cSrcweir SvxTextForwarder* pForwarder = mpEditSource ? mpEditSource->GetTextForwarder() : NULL; 393cdf0e10cSrcweir if( pForwarder ) 394cdf0e10cSrcweir { 395cdf0e10cSrcweir CheckSelection( maSelection, pForwarder ); 396cdf0e10cSrcweir 397cdf0e10cSrcweir SvxUnoTextBase* pText = SvxUnoTextBase::getImplementation( getText() ); 398cdf0e10cSrcweir 399cdf0e10cSrcweir if(pText == NULL) 400cdf0e10cSrcweir throw uno::RuntimeException(); 401cdf0e10cSrcweir 402cdf0e10cSrcweir SvxUnoTextRange* pNew = new SvxUnoTextRange( *pText ); 403cdf0e10cSrcweir xRet = pNew; 404cdf0e10cSrcweir 405cdf0e10cSrcweir ESelection aNewSel = maSelection; 406cdf0e10cSrcweir aNewSel.nStartPara = aNewSel.nEndPara; 407cdf0e10cSrcweir aNewSel.nStartPos = aNewSel.nEndPos; 408cdf0e10cSrcweir pNew->SetSelection( aNewSel ); 409cdf0e10cSrcweir } 410cdf0e10cSrcweir return xRet; 411cdf0e10cSrcweir } 412cdf0e10cSrcweir 413cdf0e10cSrcweir OUString SAL_CALL SvxUnoTextRangeBase::getString(void) 414cdf0e10cSrcweir throw( uno::RuntimeException ) 415cdf0e10cSrcweir { 416cdf0e10cSrcweir OGuard aGuard( Application::GetSolarMutex() ); 417cdf0e10cSrcweir 418cdf0e10cSrcweir SvxTextForwarder* pForwarder = mpEditSource ? mpEditSource->GetTextForwarder() : NULL; 419cdf0e10cSrcweir if( pForwarder ) 420cdf0e10cSrcweir { 421cdf0e10cSrcweir CheckSelection( maSelection, pForwarder ); 422cdf0e10cSrcweir 423cdf0e10cSrcweir return pForwarder->GetText( maSelection ); 424cdf0e10cSrcweir } 425cdf0e10cSrcweir else 426cdf0e10cSrcweir { 427cdf0e10cSrcweir const OUString aEmpty; 428cdf0e10cSrcweir return aEmpty; 429cdf0e10cSrcweir } 430cdf0e10cSrcweir } 431cdf0e10cSrcweir 432cdf0e10cSrcweir void SAL_CALL SvxUnoTextRangeBase::setString(const OUString& aString) 433cdf0e10cSrcweir throw( uno::RuntimeException ) 434cdf0e10cSrcweir { 435cdf0e10cSrcweir OGuard aGuard( Application::GetSolarMutex() ); 436cdf0e10cSrcweir 437cdf0e10cSrcweir SvxTextForwarder* pForwarder = mpEditSource ? mpEditSource->GetTextForwarder() : NULL; 438cdf0e10cSrcweir if( pForwarder ) 439cdf0e10cSrcweir { 440cdf0e10cSrcweir CheckSelection( maSelection, pForwarder ); 441cdf0e10cSrcweir 442cdf0e10cSrcweir String aConverted( aString ); 443cdf0e10cSrcweir aConverted.ConvertLineEnd( LINEEND_LF ); // Zeilenenden nur einfach zaehlen 444cdf0e10cSrcweir 445cdf0e10cSrcweir pForwarder->QuickInsertText( aConverted, maSelection ); 446cdf0e10cSrcweir mpEditSource->UpdateData(); 447cdf0e10cSrcweir 448cdf0e10cSrcweir // Selektion anpassen 449cdf0e10cSrcweir //! Wenn die EditEngine bei QuickInsertText die Selektion zurueckgeben wuerde, 450cdf0e10cSrcweir //! waer's einfacher... 451cdf0e10cSrcweir CollapseToStart(); 452cdf0e10cSrcweir 453cdf0e10cSrcweir sal_uInt16 nLen = aConverted.Len(); 454cdf0e10cSrcweir if (nLen) 455cdf0e10cSrcweir GoRight( nLen, sal_True ); 456cdf0e10cSrcweir } 457cdf0e10cSrcweir } 458cdf0e10cSrcweir 459cdf0e10cSrcweir // Interface beans::XPropertySet 460cdf0e10cSrcweir uno::Reference< beans::XPropertySetInfo > SAL_CALL SvxUnoTextRangeBase::getPropertySetInfo(void) 461cdf0e10cSrcweir throw( uno::RuntimeException ) 462cdf0e10cSrcweir { 463cdf0e10cSrcweir return mpPropSet->getPropertySetInfo(); 464cdf0e10cSrcweir } 465cdf0e10cSrcweir 466cdf0e10cSrcweir void SAL_CALL SvxUnoTextRangeBase::setPropertyValue(const OUString& PropertyName, const uno::Any& aValue) 467cdf0e10cSrcweir throw( beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException ) 468cdf0e10cSrcweir { 469cdf0e10cSrcweir _setPropertyValue( PropertyName, aValue, -1 ); 470cdf0e10cSrcweir } 471cdf0e10cSrcweir 472cdf0e10cSrcweir void SAL_CALL SvxUnoTextRangeBase::_setPropertyValue( const OUString& PropertyName, const uno::Any& aValue, sal_Int32 nPara ) 473cdf0e10cSrcweir throw( beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException ) 474cdf0e10cSrcweir { 475cdf0e10cSrcweir OGuard aGuard( Application::GetSolarMutex() ); 476cdf0e10cSrcweir 477cdf0e10cSrcweir SvxTextForwarder* pForwarder = mpEditSource ? mpEditSource->GetTextForwarder() : NULL; 478cdf0e10cSrcweir if( pForwarder ) 479cdf0e10cSrcweir { 480cdf0e10cSrcweir 481cdf0e10cSrcweir CheckSelection( maSelection, pForwarder ); 482cdf0e10cSrcweir 483cdf0e10cSrcweir const SfxItemPropertySimpleEntry* pMap = mpPropSet->getPropertyMapEntry(PropertyName ); 484cdf0e10cSrcweir if ( pMap ) 485cdf0e10cSrcweir { 486cdf0e10cSrcweir ESelection aSel( GetSelection() ); 487cdf0e10cSrcweir sal_Bool bParaAttrib = (pMap->nWID >= EE_PARA_START) && ( pMap->nWID <= EE_PARA_END ); 488cdf0e10cSrcweir 489cdf0e10cSrcweir if( nPara == -1 && !bParaAttrib ) 490cdf0e10cSrcweir { 491cdf0e10cSrcweir SfxItemSet aOldSet( pForwarder->GetAttribs( aSel ) ); 492cdf0e10cSrcweir // we have a selection and no para attribute 493cdf0e10cSrcweir SfxItemSet aNewSet( *aOldSet.GetPool(), aOldSet.GetRanges() ); 494cdf0e10cSrcweir 495cdf0e10cSrcweir setPropertyValue( pMap, aValue, maSelection, aOldSet, aNewSet ); 496cdf0e10cSrcweir 497cdf0e10cSrcweir 498cdf0e10cSrcweir pForwarder->QuickSetAttribs( aNewSet, GetSelection() ); 499cdf0e10cSrcweir } 500cdf0e10cSrcweir else 501cdf0e10cSrcweir { 502cdf0e10cSrcweir sal_Int32 nEndPara; 503cdf0e10cSrcweir 504cdf0e10cSrcweir if( nPara == -1 ) 505cdf0e10cSrcweir { 506cdf0e10cSrcweir nPara = aSel.nStartPara; 507cdf0e10cSrcweir nEndPara = aSel.nEndPara; 508cdf0e10cSrcweir } 509cdf0e10cSrcweir else 510cdf0e10cSrcweir { 511cdf0e10cSrcweir // only one paragraph 512cdf0e10cSrcweir nEndPara = nPara; 513cdf0e10cSrcweir } 514cdf0e10cSrcweir 515cdf0e10cSrcweir while( nPara <= nEndPara ) 516cdf0e10cSrcweir { 517cdf0e10cSrcweir // we have a paragraph 5189ec87cd3SDamjan Jovanovic SfxItemSet aSet( pForwarder->GetParaAttribs( nPara ) ); 519cdf0e10cSrcweir setPropertyValue( pMap, aValue, maSelection, aSet, aSet ); 52036a46462SDamjan Jovanovic pForwarder->SetParaAttribs( nPara, aSet ); 521cdf0e10cSrcweir nPara++; 522cdf0e10cSrcweir } 523cdf0e10cSrcweir } 524cdf0e10cSrcweir 525cdf0e10cSrcweir GetEditSource()->UpdateData(); 526cdf0e10cSrcweir return; 527cdf0e10cSrcweir } 528cdf0e10cSrcweir } 529cdf0e10cSrcweir 530cdf0e10cSrcweir throw beans::UnknownPropertyException(); 531cdf0e10cSrcweir } 532cdf0e10cSrcweir 533cdf0e10cSrcweir void SvxUnoTextRangeBase::setPropertyValue( const SfxItemPropertySimpleEntry* pMap, const uno::Any& rValue, const ESelection& rSelection, const SfxItemSet& rOldSet, SfxItemSet& rNewSet ) throw( beans::UnknownPropertyException, lang::IllegalArgumentException ) 534cdf0e10cSrcweir { 535cdf0e10cSrcweir if(!SetPropertyValueHelper( rOldSet, pMap, rValue, rNewSet, &rSelection, GetEditSource() )) 536cdf0e10cSrcweir { 537cdf0e10cSrcweir // Fuer Teile von zusammengesetzten Items mit mehreren Properties (z.B. Hintergrund) 538cdf0e10cSrcweir // muss vorher das alte Item aus dem Dokument geholt werden 539cdf0e10cSrcweir rNewSet.Put(rOldSet.Get(pMap->nWID)); // altes Item in neuen Set 540cdf0e10cSrcweir mpPropSet->setPropertyValue(pMap, rValue, rNewSet, false ); 541cdf0e10cSrcweir } 542cdf0e10cSrcweir } 543cdf0e10cSrcweir 544cdf0e10cSrcweir sal_Bool SvxUnoTextRangeBase::SetPropertyValueHelper( const SfxItemSet&, const SfxItemPropertySimpleEntry* pMap, const uno::Any& aValue, SfxItemSet& rNewSet, const ESelection* pSelection /* = NULL */, SvxEditSource* pEditSource /* = NULL*/ ) throw( uno::RuntimeException ) 545cdf0e10cSrcweir { 546cdf0e10cSrcweir switch( pMap->nWID ) 547cdf0e10cSrcweir { 548cdf0e10cSrcweir case WID_FONTDESC: 549cdf0e10cSrcweir { 550cdf0e10cSrcweir awt::FontDescriptor aDesc; 551cdf0e10cSrcweir if(aValue >>= aDesc) 552cdf0e10cSrcweir { 553cdf0e10cSrcweir SvxUnoFontDescriptor::FillItemSet( aDesc, rNewSet ); 554cdf0e10cSrcweir return sal_True; 555cdf0e10cSrcweir } 556cdf0e10cSrcweir } 557cdf0e10cSrcweir break; 558cdf0e10cSrcweir 559cdf0e10cSrcweir case EE_PARA_NUMBULLET: 560cdf0e10cSrcweir { 561cdf0e10cSrcweir uno::Reference< container::XIndexReplace > xRule; 562cdf0e10cSrcweir if( !aValue.hasValue() || ((aValue >>= xRule) && !xRule.is()) ) 563cdf0e10cSrcweir return sal_True; 564cdf0e10cSrcweir 565cdf0e10cSrcweir return sal_False; 566cdf0e10cSrcweir } 567cdf0e10cSrcweir 568cdf0e10cSrcweir case WID_NUMLEVEL: 569cdf0e10cSrcweir { 570cdf0e10cSrcweir SvxTextForwarder* pForwarder = pEditSource? pEditSource->GetTextForwarder() : NULL; 571cdf0e10cSrcweir if(pForwarder && pSelection) 572cdf0e10cSrcweir { 573cdf0e10cSrcweir sal_Int16 nLevel = sal_Int16(); 574cdf0e10cSrcweir if( aValue >>= nLevel ) 575cdf0e10cSrcweir { 576cdf0e10cSrcweir // #101004# Call interface method instead of unsafe cast 577cdf0e10cSrcweir if(! pForwarder->SetDepth( pSelection->nStartPara, nLevel ) ) 578cdf0e10cSrcweir throw lang::IllegalArgumentException(); 579cdf0e10cSrcweir 580cdf0e10cSrcweir return sal_True; 581cdf0e10cSrcweir } 582cdf0e10cSrcweir } 583cdf0e10cSrcweir } 584cdf0e10cSrcweir break; 585cdf0e10cSrcweir case WID_NUMBERINGSTARTVALUE: 586cdf0e10cSrcweir { 587cdf0e10cSrcweir SvxTextForwarder* pForwarder = pEditSource? pEditSource->GetTextForwarder() : NULL; 588cdf0e10cSrcweir if(pForwarder && pSelection) 589cdf0e10cSrcweir { 590cdf0e10cSrcweir sal_Int16 nStartValue = -1; 591cdf0e10cSrcweir if( aValue >>= nStartValue ) 592cdf0e10cSrcweir { 593cdf0e10cSrcweir pForwarder->SetNumberingStartValue( pSelection->nStartPara, nStartValue ); 594cdf0e10cSrcweir return sal_True; 595cdf0e10cSrcweir } 596cdf0e10cSrcweir } 597cdf0e10cSrcweir } 598cdf0e10cSrcweir break; 599cdf0e10cSrcweir case WID_PARAISNUMBERINGRESTART: 600cdf0e10cSrcweir { 601cdf0e10cSrcweir SvxTextForwarder* pForwarder = pEditSource? pEditSource->GetTextForwarder() : NULL; 602cdf0e10cSrcweir if(pForwarder && pSelection) 603cdf0e10cSrcweir { 604cdf0e10cSrcweir sal_Bool bParaIsNumberingRestart = sal_False; 605cdf0e10cSrcweir if( aValue >>= bParaIsNumberingRestart ) 606cdf0e10cSrcweir { 607cdf0e10cSrcweir pForwarder->SetParaIsNumberingRestart( pSelection->nStartPara, bParaIsNumberingRestart ); 608cdf0e10cSrcweir return sal_True; 609cdf0e10cSrcweir } 610cdf0e10cSrcweir } 611cdf0e10cSrcweir } 612cdf0e10cSrcweir break; 613cdf0e10cSrcweir case EE_PARA_BULLETSTATE: 614cdf0e10cSrcweir { 615cdf0e10cSrcweir sal_Bool bBullet = sal_True; 616cdf0e10cSrcweir if( aValue >>= bBullet ) 617cdf0e10cSrcweir { 618cdf0e10cSrcweir SfxBoolItem aItem( EE_PARA_BULLETSTATE, bBullet ); 619cdf0e10cSrcweir rNewSet.Put(aItem); 620cdf0e10cSrcweir return sal_True; 621cdf0e10cSrcweir } 622cdf0e10cSrcweir } 623cdf0e10cSrcweir break; 624cdf0e10cSrcweir 625cdf0e10cSrcweir default: 626cdf0e10cSrcweir return sal_False; 627cdf0e10cSrcweir } 628cdf0e10cSrcweir 629cdf0e10cSrcweir throw lang::IllegalArgumentException(); 630cdf0e10cSrcweir } 631cdf0e10cSrcweir 632cdf0e10cSrcweir uno::Any SAL_CALL SvxUnoTextRangeBase::getPropertyValue(const OUString& PropertyName) 633cdf0e10cSrcweir throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException ) 634cdf0e10cSrcweir { 635cdf0e10cSrcweir return _getPropertyValue( PropertyName, -1 ); 636cdf0e10cSrcweir } 637cdf0e10cSrcweir 638cdf0e10cSrcweir uno::Any SAL_CALL SvxUnoTextRangeBase::_getPropertyValue(const OUString& PropertyName, sal_Int32 nPara ) 639cdf0e10cSrcweir throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException ) 640cdf0e10cSrcweir { 641cdf0e10cSrcweir OGuard aGuard( Application::GetSolarMutex() ); 642cdf0e10cSrcweir 643cdf0e10cSrcweir uno::Any aAny; 644cdf0e10cSrcweir 645cdf0e10cSrcweir SvxTextForwarder* pForwarder = mpEditSource ? mpEditSource->GetTextForwarder() : NULL; 646cdf0e10cSrcweir if( pForwarder ) 647cdf0e10cSrcweir { 648cdf0e10cSrcweir const SfxItemPropertySimpleEntry* pMap = mpPropSet->getPropertyMapEntry(PropertyName ); 649cdf0e10cSrcweir if( pMap ) 650cdf0e10cSrcweir { 651cdf0e10cSrcweir SfxItemSet* pAttribs = NULL; 652cdf0e10cSrcweir if( nPara != -1 ) 6539ec87cd3SDamjan Jovanovic pAttribs = pForwarder->GetParaAttribs( nPara ).Clone(); 654cdf0e10cSrcweir else 655cdf0e10cSrcweir pAttribs = pForwarder->GetAttribs( GetSelection() ).Clone(); 656cdf0e10cSrcweir 657cdf0e10cSrcweir // Dontcare durch Default ersetzen, damit man immer eine Reflection hat 658cdf0e10cSrcweir pAttribs->ClearInvalidItems(); 659cdf0e10cSrcweir 660cdf0e10cSrcweir getPropertyValue( pMap, aAny, *pAttribs ); 661cdf0e10cSrcweir 662cdf0e10cSrcweir delete pAttribs; 663cdf0e10cSrcweir return aAny; 664cdf0e10cSrcweir } 665cdf0e10cSrcweir } 666cdf0e10cSrcweir 667cdf0e10cSrcweir throw beans::UnknownPropertyException(); 668cdf0e10cSrcweir } 669cdf0e10cSrcweir 670cdf0e10cSrcweir void SvxUnoTextRangeBase::getPropertyValue( const SfxItemPropertySimpleEntry* pMap, uno::Any& rAny, const SfxItemSet& rSet ) throw( beans::UnknownPropertyException ) 671cdf0e10cSrcweir { 672cdf0e10cSrcweir switch( pMap->nWID ) 673cdf0e10cSrcweir { 674cdf0e10cSrcweir case EE_FEATURE_FIELD: 675cdf0e10cSrcweir if ( rSet.GetItemState( EE_FEATURE_FIELD, sal_False ) == SFX_ITEM_SET ) 676cdf0e10cSrcweir { 677cdf0e10cSrcweir SvxFieldItem* pItem = (SvxFieldItem*)rSet.GetItem( EE_FEATURE_FIELD ); 678cdf0e10cSrcweir const SvxFieldData* pData = pItem->GetField(); 679cdf0e10cSrcweir uno::Reference< text::XTextRange > xAnchor( this ); 680cdf0e10cSrcweir 681cdf0e10cSrcweir // get presentation string for field 682cdf0e10cSrcweir Color* pTColor = NULL; 683cdf0e10cSrcweir Color* pFColor = NULL; 684cdf0e10cSrcweir 685cdf0e10cSrcweir SvxTextForwarder* pForwarder = mpEditSource->GetTextForwarder(); 686cdf0e10cSrcweir OUString aPresentation( pForwarder->CalcFieldValue( SvxFieldItem(*pData, EE_FEATURE_FIELD), maSelection.nStartPara, maSelection.nStartPos, pTColor, pFColor ) ); 687cdf0e10cSrcweir 688cdf0e10cSrcweir delete pTColor; 689cdf0e10cSrcweir delete pFColor; 690cdf0e10cSrcweir 691cdf0e10cSrcweir uno::Reference< text::XTextField > xField( new SvxUnoTextField( xAnchor, aPresentation, pData ) ); 692cdf0e10cSrcweir rAny <<= xField; 693cdf0e10cSrcweir } 694cdf0e10cSrcweir break; 695cdf0e10cSrcweir 696cdf0e10cSrcweir case WID_PORTIONTYPE: 697cdf0e10cSrcweir if ( rSet.GetItemState( EE_FEATURE_FIELD, sal_False ) == SFX_ITEM_SET ) 698cdf0e10cSrcweir { 699cdf0e10cSrcweir OUString aType( RTL_CONSTASCII_USTRINGPARAM("TextField") ); 700cdf0e10cSrcweir rAny <<= aType; 701cdf0e10cSrcweir } 702cdf0e10cSrcweir else 703cdf0e10cSrcweir { 704cdf0e10cSrcweir OUString aType( RTL_CONSTASCII_USTRINGPARAM("Text") ); 705cdf0e10cSrcweir rAny <<= aType; 706cdf0e10cSrcweir } 707cdf0e10cSrcweir break; 708cdf0e10cSrcweir 709cdf0e10cSrcweir default: 710cdf0e10cSrcweir if(!GetPropertyValueHelper( *((SfxItemSet*)(&rSet)), pMap, rAny, &maSelection, GetEditSource() )) 711cdf0e10cSrcweir rAny = mpPropSet->getPropertyValue(pMap, rSet, true, false ); 712cdf0e10cSrcweir } 713cdf0e10cSrcweir } 714cdf0e10cSrcweir 715cdf0e10cSrcweir sal_Bool SvxUnoTextRangeBase::GetPropertyValueHelper( SfxItemSet& rSet, const SfxItemPropertySimpleEntry* pMap, uno::Any& aAny, const ESelection* pSelection /* = NULL */, SvxEditSource* pEditSource /* = NULL */ ) 716cdf0e10cSrcweir throw( uno::RuntimeException ) 717cdf0e10cSrcweir { 718cdf0e10cSrcweir switch( pMap->nWID ) 719cdf0e10cSrcweir { 720cdf0e10cSrcweir case WID_FONTDESC: 721cdf0e10cSrcweir { 722cdf0e10cSrcweir awt::FontDescriptor aDesc; 723cdf0e10cSrcweir SvxUnoFontDescriptor::FillFromItemSet( rSet, aDesc ); 724cdf0e10cSrcweir aAny <<= aDesc; 725cdf0e10cSrcweir } 726cdf0e10cSrcweir break; 727cdf0e10cSrcweir 728cdf0e10cSrcweir case EE_PARA_NUMBULLET: 729cdf0e10cSrcweir { 730cdf0e10cSrcweir if((rSet.GetItemState( EE_PARA_NUMBULLET, sal_True ) & (SFX_ITEM_SET|SFX_ITEM_DEFAULT)) == 0) 731cdf0e10cSrcweir throw uno::RuntimeException(); 732cdf0e10cSrcweir 733cdf0e10cSrcweir SvxNumBulletItem* pBulletItem = (SvxNumBulletItem*)rSet.GetItem( EE_PARA_NUMBULLET, sal_True ); 734cdf0e10cSrcweir 735cdf0e10cSrcweir if( pBulletItem == NULL ) 736cdf0e10cSrcweir throw uno::RuntimeException(); 737cdf0e10cSrcweir 738cdf0e10cSrcweir aAny <<= SvxCreateNumRule( pBulletItem->GetNumRule() ); 739cdf0e10cSrcweir } 740cdf0e10cSrcweir break; 741cdf0e10cSrcweir 742cdf0e10cSrcweir case WID_NUMLEVEL: 743cdf0e10cSrcweir { 744cdf0e10cSrcweir SvxTextForwarder* pForwarder = pEditSource? pEditSource->GetTextForwarder() : NULL; 745cdf0e10cSrcweir if(pForwarder && pSelection) 746cdf0e10cSrcweir { 747cdf0e10cSrcweir sal_Int16 nLevel = pForwarder->GetDepth( pSelection->nStartPara ); 748cdf0e10cSrcweir if( nLevel >= 0 ) 749cdf0e10cSrcweir aAny <<= nLevel; 750cdf0e10cSrcweir } 751cdf0e10cSrcweir } 752cdf0e10cSrcweir break; 753cdf0e10cSrcweir case WID_NUMBERINGSTARTVALUE: 754cdf0e10cSrcweir { 755cdf0e10cSrcweir SvxTextForwarder* pForwarder = pEditSource? pEditSource->GetTextForwarder() : NULL; 756cdf0e10cSrcweir if(pForwarder && pSelection) 757cdf0e10cSrcweir aAny <<= pForwarder->GetNumberingStartValue( pSelection->nStartPara ); 758cdf0e10cSrcweir } 759cdf0e10cSrcweir break; 760cdf0e10cSrcweir case WID_PARAISNUMBERINGRESTART: 761cdf0e10cSrcweir { 762cdf0e10cSrcweir SvxTextForwarder* pForwarder = pEditSource? pEditSource->GetTextForwarder() : NULL; 763cdf0e10cSrcweir if(pForwarder && pSelection) 764cdf0e10cSrcweir aAny <<= pForwarder->IsParaIsNumberingRestart( pSelection->nStartPara ); 765cdf0e10cSrcweir } 766cdf0e10cSrcweir break; 767cdf0e10cSrcweir 768cdf0e10cSrcweir case EE_PARA_BULLETSTATE: 769cdf0e10cSrcweir { 770cdf0e10cSrcweir sal_Bool bState = sal_False; 771cdf0e10cSrcweir if( rSet.GetItemState( EE_PARA_BULLETSTATE, sal_True ) & (SFX_ITEM_SET|SFX_ITEM_DEFAULT)) 772cdf0e10cSrcweir { 773cdf0e10cSrcweir SfxBoolItem* pItem = (SfxBoolItem*)rSet.GetItem( EE_PARA_BULLETSTATE, sal_True ); 774cdf0e10cSrcweir bState = pItem->GetValue() ? sal_True : sal_False; 775cdf0e10cSrcweir } 776cdf0e10cSrcweir 777cdf0e10cSrcweir aAny <<= bState; 778cdf0e10cSrcweir } 779cdf0e10cSrcweir break; 780cdf0e10cSrcweir default: 781cdf0e10cSrcweir 782cdf0e10cSrcweir return sal_False; 783cdf0e10cSrcweir } 784cdf0e10cSrcweir 785cdf0e10cSrcweir return sal_True; 786cdf0e10cSrcweir } 787cdf0e10cSrcweir 788cdf0e10cSrcweir // wird (noch) nicht unterstuetzt 789cdf0e10cSrcweir void SAL_CALL SvxUnoTextRangeBase::addPropertyChangeListener( const OUString& , const uno::Reference< beans::XPropertyChangeListener >& ) throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) {} 790cdf0e10cSrcweir void SAL_CALL SvxUnoTextRangeBase::removePropertyChangeListener( const OUString& , const uno::Reference< beans::XPropertyChangeListener >& ) throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) {} 791cdf0e10cSrcweir void SAL_CALL SvxUnoTextRangeBase::addVetoableChangeListener( const OUString& , const uno::Reference< beans::XVetoableChangeListener >& ) throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) {} 792cdf0e10cSrcweir void SAL_CALL SvxUnoTextRangeBase::removeVetoableChangeListener( const OUString& , const uno::Reference< beans::XVetoableChangeListener >& ) throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) {} 793cdf0e10cSrcweir 794cdf0e10cSrcweir // XMultiPropertySet 795cdf0e10cSrcweir 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) 796cdf0e10cSrcweir { 797cdf0e10cSrcweir _setPropertyValues( aPropertyNames, aValues, -1 ); 798cdf0e10cSrcweir } 799cdf0e10cSrcweir 800cdf0e10cSrcweir 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) 801cdf0e10cSrcweir { 802cdf0e10cSrcweir OGuard aGuard( Application::GetSolarMutex() ); 803cdf0e10cSrcweir 804cdf0e10cSrcweir SvxTextForwarder* pForwarder = mpEditSource ? mpEditSource->GetTextForwarder() : NULL; 805cdf0e10cSrcweir if( pForwarder ) 806cdf0e10cSrcweir { 807cdf0e10cSrcweir CheckSelection( maSelection, pForwarder ); 808cdf0e10cSrcweir 809cdf0e10cSrcweir ESelection aSel( GetSelection() ); 810cdf0e10cSrcweir 811cdf0e10cSrcweir const OUString* pPropertyNames = aPropertyNames.getConstArray(); 812cdf0e10cSrcweir const uno::Any* pValues = aValues.getConstArray(); 813cdf0e10cSrcweir sal_Int32 nCount = aPropertyNames.getLength(); 814cdf0e10cSrcweir 815cdf0e10cSrcweir sal_Int32 nEndPara = nPara; 816cdf0e10cSrcweir sal_Int32 nTempPara = nPara; 817cdf0e10cSrcweir 818cdf0e10cSrcweir if( nTempPara == -1 ) 819cdf0e10cSrcweir { 820cdf0e10cSrcweir nTempPara = aSel.nStartPara; 821cdf0e10cSrcweir nEndPara = aSel.nEndPara; 822cdf0e10cSrcweir } 823cdf0e10cSrcweir 824cdf0e10cSrcweir SfxItemSet* pOldAttrSet = NULL; 825cdf0e10cSrcweir SfxItemSet* pNewAttrSet = NULL; 826cdf0e10cSrcweir 827cdf0e10cSrcweir SfxItemSet* pOldParaSet = NULL; 828cdf0e10cSrcweir SfxItemSet* pNewParaSet = NULL; 829cdf0e10cSrcweir 830cdf0e10cSrcweir for( ; nCount; nCount--, pPropertyNames++, pValues++ ) 831cdf0e10cSrcweir { 832cdf0e10cSrcweir const SfxItemPropertySimpleEntry* pMap = mpPropSet->getPropertyMapEntry( *pPropertyNames ); 833cdf0e10cSrcweir 834cdf0e10cSrcweir if( pMap ) 835cdf0e10cSrcweir { 836cdf0e10cSrcweir sal_Bool bParaAttrib = (pMap->nWID >= EE_PARA_START) && ( pMap->nWID <= EE_PARA_END ); 837cdf0e10cSrcweir 838cdf0e10cSrcweir if( (nPara == -1) && !bParaAttrib ) 839cdf0e10cSrcweir { 840cdf0e10cSrcweir if( NULL == pNewAttrSet ) 841cdf0e10cSrcweir { 842cdf0e10cSrcweir const SfxItemSet aSet( pForwarder->GetAttribs( aSel ) ); 843cdf0e10cSrcweir pOldAttrSet = new SfxItemSet( aSet ); 844cdf0e10cSrcweir pNewAttrSet = new SfxItemSet( *pOldAttrSet->GetPool(), pOldAttrSet->GetRanges() ); 845cdf0e10cSrcweir } 846cdf0e10cSrcweir 847cdf0e10cSrcweir setPropertyValue( pMap, *pValues, GetSelection(), *pOldAttrSet, *pNewAttrSet ); 848cdf0e10cSrcweir 849cdf0e10cSrcweir if( pMap->nWID >= EE_ITEMS_START && pMap->nWID <= EE_ITEMS_END ) 850cdf0e10cSrcweir { 851cdf0e10cSrcweir const SfxPoolItem* pItem; 852cdf0e10cSrcweir if( pNewAttrSet->GetItemState( pMap->nWID, sal_True, &pItem ) == SFX_ITEM_SET ) 853cdf0e10cSrcweir { 854cdf0e10cSrcweir pOldAttrSet->Put( *pItem ); 855cdf0e10cSrcweir } 856cdf0e10cSrcweir } 857cdf0e10cSrcweir } 858cdf0e10cSrcweir else 859cdf0e10cSrcweir { 860cdf0e10cSrcweir if( NULL == pNewParaSet ) 861cdf0e10cSrcweir { 8629ec87cd3SDamjan Jovanovic const SfxItemSet aSet( pForwarder->GetParaAttribs( nTempPara ) ); 863cdf0e10cSrcweir pOldParaSet = new SfxItemSet( aSet ); 864cdf0e10cSrcweir pNewParaSet = new SfxItemSet( *pOldParaSet->GetPool(), pOldParaSet->GetRanges() ); 865cdf0e10cSrcweir } 866cdf0e10cSrcweir 867cdf0e10cSrcweir setPropertyValue( pMap, *pValues, GetSelection(), *pOldParaSet, *pNewParaSet ); 868cdf0e10cSrcweir 869cdf0e10cSrcweir if( pMap->nWID >= EE_ITEMS_START && pMap->nWID <= EE_ITEMS_END ) 870cdf0e10cSrcweir { 871cdf0e10cSrcweir const SfxPoolItem* pItem; 872cdf0e10cSrcweir if( pNewParaSet->GetItemState( pMap->nWID, sal_True, &pItem ) == SFX_ITEM_SET ) 873cdf0e10cSrcweir { 874cdf0e10cSrcweir pOldParaSet->Put( *pItem ); 875cdf0e10cSrcweir } 876cdf0e10cSrcweir } 877cdf0e10cSrcweir 878cdf0e10cSrcweir } 879cdf0e10cSrcweir } 880cdf0e10cSrcweir } 881cdf0e10cSrcweir 882cdf0e10cSrcweir sal_Bool bNeedsUpdate = sal_False; 883cdf0e10cSrcweir 884cdf0e10cSrcweir if( pNewParaSet ) 885cdf0e10cSrcweir { 886cdf0e10cSrcweir if( pNewParaSet->Count() ) 887cdf0e10cSrcweir { 888cdf0e10cSrcweir while( nTempPara <= nEndPara ) 889cdf0e10cSrcweir { 8909ec87cd3SDamjan Jovanovic SfxItemSet aSet( pForwarder->GetParaAttribs( nTempPara ) ); 891cdf0e10cSrcweir aSet.Put( *pNewParaSet ); 89236a46462SDamjan Jovanovic pForwarder->SetParaAttribs( nTempPara, aSet ); 893cdf0e10cSrcweir nTempPara++; 894cdf0e10cSrcweir } 895cdf0e10cSrcweir bNeedsUpdate = sal_True; 896cdf0e10cSrcweir } 897cdf0e10cSrcweir 898cdf0e10cSrcweir delete pNewParaSet; 899cdf0e10cSrcweir delete pOldParaSet; 900cdf0e10cSrcweir } 901cdf0e10cSrcweir 902cdf0e10cSrcweir if( pNewAttrSet ) 903cdf0e10cSrcweir { 904cdf0e10cSrcweir if( pNewAttrSet->Count() ) 905cdf0e10cSrcweir { 906cdf0e10cSrcweir pForwarder->QuickSetAttribs( *pNewAttrSet, GetSelection() ); 907cdf0e10cSrcweir bNeedsUpdate = sal_True; 908cdf0e10cSrcweir } 909cdf0e10cSrcweir delete pNewAttrSet; 910cdf0e10cSrcweir delete pOldAttrSet; 911cdf0e10cSrcweir 912cdf0e10cSrcweir } 913cdf0e10cSrcweir 914cdf0e10cSrcweir if( bNeedsUpdate ) 915cdf0e10cSrcweir GetEditSource()->UpdateData(); 916cdf0e10cSrcweir } 917cdf0e10cSrcweir } 918cdf0e10cSrcweir 919cdf0e10cSrcweir uno::Sequence< uno::Any > SAL_CALL SvxUnoTextRangeBase::getPropertyValues( const uno::Sequence< ::rtl::OUString >& aPropertyNames ) throw (uno::RuntimeException) 920cdf0e10cSrcweir { 921cdf0e10cSrcweir return _getPropertyValues( aPropertyNames, -1 ); 922cdf0e10cSrcweir } 923cdf0e10cSrcweir 924cdf0e10cSrcweir uno::Sequence< uno::Any > SAL_CALL SvxUnoTextRangeBase::_getPropertyValues( const uno::Sequence< ::rtl::OUString >& aPropertyNames, sal_Int32 nPara ) throw (uno::RuntimeException) 925cdf0e10cSrcweir { 926cdf0e10cSrcweir OGuard aGuard( Application::GetSolarMutex() ); 927cdf0e10cSrcweir 928cdf0e10cSrcweir sal_Int32 nCount = aPropertyNames.getLength(); 929cdf0e10cSrcweir 930cdf0e10cSrcweir 931cdf0e10cSrcweir uno::Sequence< uno::Any > aValues( nCount ); 932cdf0e10cSrcweir 933cdf0e10cSrcweir SvxTextForwarder* pForwarder = mpEditSource ? mpEditSource->GetTextForwarder() : NULL; 934cdf0e10cSrcweir if( pForwarder ) 935cdf0e10cSrcweir { 936cdf0e10cSrcweir SfxItemSet* pAttribs = NULL; 937cdf0e10cSrcweir if( nPara != -1 ) 9389ec87cd3SDamjan Jovanovic pAttribs = pForwarder->GetParaAttribs( nPara ).Clone(); 939cdf0e10cSrcweir else 940cdf0e10cSrcweir pAttribs = pForwarder->GetAttribs( GetSelection() ).Clone(); 941cdf0e10cSrcweir 942cdf0e10cSrcweir pAttribs->ClearInvalidItems(); 943cdf0e10cSrcweir 944cdf0e10cSrcweir const OUString* pPropertyNames = aPropertyNames.getConstArray(); 945cdf0e10cSrcweir uno::Any* pValues = aValues.getArray(); 946cdf0e10cSrcweir 947cdf0e10cSrcweir for( ; nCount; nCount--, pPropertyNames++, pValues++ ) 948cdf0e10cSrcweir { 949cdf0e10cSrcweir const SfxItemPropertySimpleEntry* pMap = mpPropSet->getPropertyMapEntry( *pPropertyNames ); 950cdf0e10cSrcweir if( pMap ) 951cdf0e10cSrcweir { 952cdf0e10cSrcweir getPropertyValue( pMap, *pValues, *pAttribs ); 953cdf0e10cSrcweir } 954cdf0e10cSrcweir } 955cdf0e10cSrcweir 956cdf0e10cSrcweir delete pAttribs; 957cdf0e10cSrcweir 958cdf0e10cSrcweir } 959cdf0e10cSrcweir 960cdf0e10cSrcweir return aValues; 961cdf0e10cSrcweir } 962cdf0e10cSrcweir 963cdf0e10cSrcweir void SAL_CALL SvxUnoTextRangeBase::addPropertiesChangeListener( const uno::Sequence< ::rtl::OUString >& , const uno::Reference< beans::XPropertiesChangeListener >& ) throw (uno::RuntimeException) 964cdf0e10cSrcweir { 965cdf0e10cSrcweir } 966cdf0e10cSrcweir 967cdf0e10cSrcweir void SAL_CALL SvxUnoTextRangeBase::removePropertiesChangeListener( const uno::Reference< beans::XPropertiesChangeListener >& ) throw (uno::RuntimeException) 968cdf0e10cSrcweir { 969cdf0e10cSrcweir } 970cdf0e10cSrcweir 971cdf0e10cSrcweir void SAL_CALL SvxUnoTextRangeBase::firePropertiesChangeEvent( const uno::Sequence< ::rtl::OUString >& , const uno::Reference< beans::XPropertiesChangeListener >& ) throw (uno::RuntimeException) 972cdf0e10cSrcweir { 973cdf0e10cSrcweir } 974cdf0e10cSrcweir 975cdf0e10cSrcweir // beans::XPropertyState 976cdf0e10cSrcweir beans::PropertyState SAL_CALL SvxUnoTextRangeBase::getPropertyState( const OUString& PropertyName ) 977cdf0e10cSrcweir throw(beans::UnknownPropertyException, uno::RuntimeException) 978cdf0e10cSrcweir { 979cdf0e10cSrcweir return _getPropertyState( PropertyName, -1 ); 980cdf0e10cSrcweir } 981cdf0e10cSrcweir 982cdf0e10cSrcweir static sal_uInt16 aSvxUnoFontDescriptorWhichMap[] = { EE_CHAR_FONTINFO, EE_CHAR_FONTHEIGHT, EE_CHAR_ITALIC, 983cdf0e10cSrcweir EE_CHAR_UNDERLINE, EE_CHAR_WEIGHT, EE_CHAR_STRIKEOUT, 984cdf0e10cSrcweir EE_CHAR_WLM, 0 }; 985cdf0e10cSrcweir 986cdf0e10cSrcweir beans::PropertyState SAL_CALL SvxUnoTextRangeBase::_getPropertyState(const SfxItemPropertySimpleEntry* pMap, sal_Int32 nPara) 987cdf0e10cSrcweir throw( beans::UnknownPropertyException, uno::RuntimeException ) 988cdf0e10cSrcweir { 989cdf0e10cSrcweir if ( pMap ) 990cdf0e10cSrcweir { 991cdf0e10cSrcweir SvxTextForwarder* pForwarder = mpEditSource ? mpEditSource->GetTextForwarder() : NULL; 992cdf0e10cSrcweir if( pForwarder ) 993cdf0e10cSrcweir { 994cdf0e10cSrcweir SfxItemState eItemState = SFX_ITEM_UNKNOWN; 995cdf0e10cSrcweir sal_uInt16 nWID = 0; 996cdf0e10cSrcweir 997cdf0e10cSrcweir switch( pMap->nWID ) 998cdf0e10cSrcweir { 999cdf0e10cSrcweir case WID_FONTDESC: 1000cdf0e10cSrcweir { 1001cdf0e10cSrcweir sal_uInt16* pWhichId = aSvxUnoFontDescriptorWhichMap; 1002cdf0e10cSrcweir SfxItemState eTempItemState; 1003cdf0e10cSrcweir while( *pWhichId ) 1004cdf0e10cSrcweir { 1005cdf0e10cSrcweir if(nPara != -1) 1006cdf0e10cSrcweir eTempItemState = pForwarder->GetItemState( (sal_uInt16)nPara, *pWhichId ); 1007cdf0e10cSrcweir else 1008cdf0e10cSrcweir eTempItemState = pForwarder->GetItemState( GetSelection(), *pWhichId ); 1009cdf0e10cSrcweir 1010cdf0e10cSrcweir switch( eTempItemState ) 1011cdf0e10cSrcweir { 1012cdf0e10cSrcweir case SFX_ITEM_DISABLED: 1013cdf0e10cSrcweir case SFX_ITEM_DONTCARE: 1014cdf0e10cSrcweir eItemState = SFX_ITEM_DONTCARE; 1015cdf0e10cSrcweir break; 1016cdf0e10cSrcweir 1017cdf0e10cSrcweir case SFX_ITEM_DEFAULT: 1018cdf0e10cSrcweir if( eItemState != SFX_ITEM_DEFAULT ) 1019cdf0e10cSrcweir { 1020cdf0e10cSrcweir if( eItemState == SFX_ITEM_UNKNOWN ) 1021cdf0e10cSrcweir eItemState = SFX_ITEM_DEFAULT; 1022cdf0e10cSrcweir } 1023cdf0e10cSrcweir break; 1024cdf0e10cSrcweir 1025cdf0e10cSrcweir case SFX_ITEM_READONLY: 1026cdf0e10cSrcweir case SFX_ITEM_SET: 1027cdf0e10cSrcweir if( eItemState != SFX_ITEM_SET ) 1028cdf0e10cSrcweir { 1029cdf0e10cSrcweir if( eItemState == SFX_ITEM_UNKNOWN ) 1030cdf0e10cSrcweir eItemState = SFX_ITEM_SET; 1031cdf0e10cSrcweir } 1032cdf0e10cSrcweir break; 1033cdf0e10cSrcweir default: 1034cdf0e10cSrcweir throw beans::UnknownPropertyException(); 1035cdf0e10cSrcweir } 1036cdf0e10cSrcweir 1037cdf0e10cSrcweir pWhichId++; 1038cdf0e10cSrcweir } 1039cdf0e10cSrcweir } 1040cdf0e10cSrcweir break; 1041cdf0e10cSrcweir 1042cdf0e10cSrcweir case WID_NUMLEVEL: 1043cdf0e10cSrcweir case WID_NUMBERINGSTARTVALUE: 1044cdf0e10cSrcweir case WID_PARAISNUMBERINGRESTART: 1045cdf0e10cSrcweir eItemState = SFX_ITEM_SET; 1046cdf0e10cSrcweir break; 1047cdf0e10cSrcweir 1048cdf0e10cSrcweir default: 1049cdf0e10cSrcweir nWID = pMap->nWID; 1050cdf0e10cSrcweir } 1051cdf0e10cSrcweir 1052cdf0e10cSrcweir if( nWID != 0 ) 1053cdf0e10cSrcweir { 1054cdf0e10cSrcweir if( nPara != -1 ) 1055cdf0e10cSrcweir eItemState = pForwarder->GetItemState( (sal_uInt16)nPara, nWID ); 1056cdf0e10cSrcweir else 1057cdf0e10cSrcweir eItemState = pForwarder->GetItemState( GetSelection(), nWID ); 1058cdf0e10cSrcweir } 1059cdf0e10cSrcweir 1060cdf0e10cSrcweir switch( eItemState ) 1061cdf0e10cSrcweir { 1062cdf0e10cSrcweir case SFX_ITEM_DONTCARE: 1063cdf0e10cSrcweir case SFX_ITEM_DISABLED: 1064cdf0e10cSrcweir return beans::PropertyState_AMBIGUOUS_VALUE; 1065cdf0e10cSrcweir case SFX_ITEM_READONLY: 1066cdf0e10cSrcweir case SFX_ITEM_SET: 1067cdf0e10cSrcweir return beans::PropertyState_DIRECT_VALUE; 1068cdf0e10cSrcweir case SFX_ITEM_DEFAULT: 1069cdf0e10cSrcweir return beans::PropertyState_DEFAULT_VALUE; 1070cdf0e10cSrcweir // case SFX_ITEM_UNKNOWN: 1071cdf0e10cSrcweir } 1072cdf0e10cSrcweir } 1073cdf0e10cSrcweir } 1074cdf0e10cSrcweir throw beans::UnknownPropertyException(); 1075cdf0e10cSrcweir } 1076cdf0e10cSrcweir 1077cdf0e10cSrcweir beans::PropertyState SAL_CALL SvxUnoTextRangeBase::_getPropertyState(const OUString& PropertyName, sal_Int32 nPara /* = -1 */) 1078cdf0e10cSrcweir throw( beans::UnknownPropertyException, uno::RuntimeException ) 1079cdf0e10cSrcweir { 1080cdf0e10cSrcweir OGuard aGuard( Application::GetSolarMutex() ); 1081cdf0e10cSrcweir 1082cdf0e10cSrcweir return _getPropertyState( mpPropSet->getPropertyMapEntry( PropertyName ), nPara); 1083cdf0e10cSrcweir } 1084cdf0e10cSrcweir 1085cdf0e10cSrcweir uno::Sequence< beans::PropertyState > SAL_CALL SvxUnoTextRangeBase::getPropertyStates( const uno::Sequence< OUString >& aPropertyName ) 1086cdf0e10cSrcweir throw(beans::UnknownPropertyException, uno::RuntimeException) 1087cdf0e10cSrcweir { 1088cdf0e10cSrcweir return _getPropertyStates( aPropertyName, -1 ); 1089cdf0e10cSrcweir } 1090cdf0e10cSrcweir 1091cdf0e10cSrcweir uno::Sequence< beans::PropertyState > SvxUnoTextRangeBase::_getPropertyStates(const uno::Sequence< OUString >& PropertyName, sal_Int32 nPara /* = -1 */) 1092cdf0e10cSrcweir throw( beans::UnknownPropertyException, uno::RuntimeException ) 1093cdf0e10cSrcweir { 1094cdf0e10cSrcweir const sal_Int32 nCount = PropertyName.getLength(); 1095cdf0e10cSrcweir const OUString* pNames = PropertyName.getConstArray(); 1096cdf0e10cSrcweir 1097cdf0e10cSrcweir uno::Sequence< beans::PropertyState > aRet( nCount ); 1098cdf0e10cSrcweir beans::PropertyState* pState = aRet.getArray(); 1099cdf0e10cSrcweir 1100cdf0e10cSrcweir SvxTextForwarder* pForwarder = mpEditSource ? mpEditSource->GetTextForwarder() : NULL; 1101cdf0e10cSrcweir if( pForwarder ) 1102cdf0e10cSrcweir { 1103cdf0e10cSrcweir SfxItemSet* pSet = NULL; 1104cdf0e10cSrcweir if( nPara != -1 ) 1105cdf0e10cSrcweir { 11069ec87cd3SDamjan Jovanovic pSet = new SfxItemSet( pForwarder->GetParaAttribs( nPara ) ); 1107cdf0e10cSrcweir } 1108cdf0e10cSrcweir else 1109cdf0e10cSrcweir { 1110cdf0e10cSrcweir ESelection aSel( GetSelection() ); 1111cdf0e10cSrcweir CheckSelection( aSel, pForwarder ); 1112cdf0e10cSrcweir pSet = new SfxItemSet( pForwarder->GetAttribs( aSel, EditEngineAttribs_OnlyHard ) ); 1113cdf0e10cSrcweir } 1114cdf0e10cSrcweir 1115cdf0e10cSrcweir sal_Bool bUnknownPropertyFound = sal_False; 1116cdf0e10cSrcweir for( sal_Int32 nIdx = 0; nIdx < nCount; nIdx++ ) 1117cdf0e10cSrcweir { 1118cdf0e10cSrcweir const SfxItemPropertySimpleEntry* pMap = mpPropSet->getPropertyMapEntry( *pNames++ ); 1119cdf0e10cSrcweir if( NULL == pMap ) 1120cdf0e10cSrcweir { 1121cdf0e10cSrcweir bUnknownPropertyFound = sal_True; 1122cdf0e10cSrcweir break; 1123cdf0e10cSrcweir } 1124cdf0e10cSrcweir bUnknownPropertyFound = !_getOnePropertyStates(pSet, pMap, *pState++); 1125cdf0e10cSrcweir } 1126cdf0e10cSrcweir 1127cdf0e10cSrcweir delete pSet; 1128cdf0e10cSrcweir 1129cdf0e10cSrcweir if( bUnknownPropertyFound ) 1130cdf0e10cSrcweir throw beans::UnknownPropertyException(); 1131cdf0e10cSrcweir } 1132cdf0e10cSrcweir 1133cdf0e10cSrcweir return aRet; 1134cdf0e10cSrcweir } 1135cdf0e10cSrcweir 1136cdf0e10cSrcweir sal_Bool SvxUnoTextRangeBase::_getOnePropertyStates(const SfxItemSet* pSet, const SfxItemPropertySimpleEntry* pMap, beans::PropertyState& rState) 1137cdf0e10cSrcweir { 1138cdf0e10cSrcweir sal_Bool bUnknownPropertyFound = sal_False; 1139cdf0e10cSrcweir if(pSet && pMap) 1140cdf0e10cSrcweir { 1141cdf0e10cSrcweir SfxItemState eItemState = SFX_ITEM_UNKNOWN; 1142cdf0e10cSrcweir sal_uInt16 nWID = 0; 1143cdf0e10cSrcweir 1144cdf0e10cSrcweir switch( pMap->nWID ) 1145cdf0e10cSrcweir { 1146cdf0e10cSrcweir case WID_FONTDESC: 1147cdf0e10cSrcweir { 1148cdf0e10cSrcweir sal_uInt16* pWhichId = aSvxUnoFontDescriptorWhichMap; 1149cdf0e10cSrcweir SfxItemState eTempItemState; 1150cdf0e10cSrcweir while( *pWhichId ) 1151cdf0e10cSrcweir { 1152cdf0e10cSrcweir eTempItemState = pSet->GetItemState( *pWhichId ); 1153cdf0e10cSrcweir 1154cdf0e10cSrcweir switch( eTempItemState ) 1155cdf0e10cSrcweir { 1156cdf0e10cSrcweir case SFX_ITEM_DISABLED: 1157cdf0e10cSrcweir case SFX_ITEM_DONTCARE: 1158cdf0e10cSrcweir eItemState = SFX_ITEM_DONTCARE; 1159cdf0e10cSrcweir break; 1160cdf0e10cSrcweir 1161cdf0e10cSrcweir case SFX_ITEM_DEFAULT: 1162cdf0e10cSrcweir if( eItemState != SFX_ITEM_DEFAULT ) 1163cdf0e10cSrcweir { 1164cdf0e10cSrcweir if( eItemState == SFX_ITEM_UNKNOWN ) 1165cdf0e10cSrcweir eItemState = SFX_ITEM_DEFAULT; 1166cdf0e10cSrcweir } 1167cdf0e10cSrcweir break; 1168cdf0e10cSrcweir 1169cdf0e10cSrcweir case SFX_ITEM_READONLY: 1170cdf0e10cSrcweir case SFX_ITEM_SET: 1171cdf0e10cSrcweir if( eItemState != SFX_ITEM_SET ) 1172cdf0e10cSrcweir { 1173cdf0e10cSrcweir if( eItemState == SFX_ITEM_UNKNOWN ) 1174cdf0e10cSrcweir eItemState = SFX_ITEM_SET; 1175cdf0e10cSrcweir } 1176cdf0e10cSrcweir break; 1177cdf0e10cSrcweir default: 1178cdf0e10cSrcweir bUnknownPropertyFound = sal_True; 1179cdf0e10cSrcweir break; 1180cdf0e10cSrcweir } 1181cdf0e10cSrcweir 1182cdf0e10cSrcweir pWhichId++; 1183cdf0e10cSrcweir } 1184cdf0e10cSrcweir } 1185cdf0e10cSrcweir break; 1186cdf0e10cSrcweir 1187cdf0e10cSrcweir case WID_NUMLEVEL: 1188cdf0e10cSrcweir case WID_NUMBERINGSTARTVALUE: 1189cdf0e10cSrcweir case WID_PARAISNUMBERINGRESTART: 1190cdf0e10cSrcweir eItemState = SFX_ITEM_SET; 1191cdf0e10cSrcweir break; 1192cdf0e10cSrcweir 1193cdf0e10cSrcweir default: 1194cdf0e10cSrcweir nWID = pMap->nWID; 1195cdf0e10cSrcweir } 1196cdf0e10cSrcweir 1197cdf0e10cSrcweir if( bUnknownPropertyFound ) 1198cdf0e10cSrcweir return !bUnknownPropertyFound; 1199cdf0e10cSrcweir 1200cdf0e10cSrcweir if( nWID != 0 ) 1201cdf0e10cSrcweir eItemState = pSet->GetItemState( nWID, sal_False ); 1202cdf0e10cSrcweir 1203cdf0e10cSrcweir switch( eItemState ) 1204cdf0e10cSrcweir { 1205cdf0e10cSrcweir case SFX_ITEM_READONLY: 1206cdf0e10cSrcweir case SFX_ITEM_SET: 1207cdf0e10cSrcweir rState = beans::PropertyState_DIRECT_VALUE; 1208cdf0e10cSrcweir break; 1209cdf0e10cSrcweir case SFX_ITEM_DEFAULT: 1210cdf0e10cSrcweir rState = beans::PropertyState_DEFAULT_VALUE; 1211cdf0e10cSrcweir break; 1212cdf0e10cSrcweir // case SFX_ITEM_UNKNOWN: 1213cdf0e10cSrcweir // case SFX_ITEM_DONTCARE: 1214cdf0e10cSrcweir // case SFX_ITEM_DISABLED: 1215cdf0e10cSrcweir default: 1216cdf0e10cSrcweir rState = beans::PropertyState_AMBIGUOUS_VALUE; 1217cdf0e10cSrcweir } 1218cdf0e10cSrcweir } 1219cdf0e10cSrcweir return !bUnknownPropertyFound; 1220cdf0e10cSrcweir } 1221cdf0e10cSrcweir 1222cdf0e10cSrcweir void SAL_CALL SvxUnoTextRangeBase::setPropertyToDefault( const OUString& PropertyName ) 1223cdf0e10cSrcweir throw(beans::UnknownPropertyException, uno::RuntimeException) 1224cdf0e10cSrcweir { 1225cdf0e10cSrcweir _setPropertyToDefault( PropertyName, -1 ); 1226cdf0e10cSrcweir } 1227cdf0e10cSrcweir 1228cdf0e10cSrcweir void SvxUnoTextRangeBase::_setPropertyToDefault(const OUString& PropertyName, sal_Int32 nPara /* = -1 */) 1229cdf0e10cSrcweir throw( beans::UnknownPropertyException, uno::RuntimeException ) 1230cdf0e10cSrcweir { 1231cdf0e10cSrcweir OGuard aGuard( Application::GetSolarMutex() ); 1232cdf0e10cSrcweir 1233cdf0e10cSrcweir SvxTextForwarder* pForwarder = mpEditSource ? mpEditSource->GetTextForwarder() : NULL; 1234cdf0e10cSrcweir 1235cdf0e10cSrcweir if( pForwarder ) 1236cdf0e10cSrcweir { 1237cdf0e10cSrcweir const SfxItemPropertySimpleEntry* pMap = mpPropSet->getPropertyMapEntry( PropertyName ); 1238cdf0e10cSrcweir if ( pMap ) 1239cdf0e10cSrcweir { 1240cdf0e10cSrcweir CheckSelection( maSelection, mpEditSource->GetTextForwarder() ); 1241cdf0e10cSrcweir _setPropertyToDefault( pForwarder, pMap, nPara ); 1242cdf0e10cSrcweir return; 1243cdf0e10cSrcweir } 1244cdf0e10cSrcweir } 1245cdf0e10cSrcweir 1246cdf0e10cSrcweir throw beans::UnknownPropertyException(); 1247cdf0e10cSrcweir } 1248cdf0e10cSrcweir 1249cdf0e10cSrcweir void SvxUnoTextRangeBase::_setPropertyToDefault(SvxTextForwarder* pForwarder, const SfxItemPropertySimpleEntry* pMap, sal_Int32 nPara ) 1250cdf0e10cSrcweir throw( beans::UnknownPropertyException, uno::RuntimeException ) 1251cdf0e10cSrcweir { 1252cdf0e10cSrcweir do 1253cdf0e10cSrcweir { 1254cdf0e10cSrcweir SfxItemSet aSet( *pForwarder->GetPool(), sal_True ); 1255cdf0e10cSrcweir 1256cdf0e10cSrcweir if( pMap->nWID == WID_FONTDESC ) 1257cdf0e10cSrcweir { 1258cdf0e10cSrcweir SvxUnoFontDescriptor::setPropertyToDefault( aSet ); 1259cdf0e10cSrcweir } 1260cdf0e10cSrcweir else if( pMap->nWID == WID_NUMLEVEL ) 1261cdf0e10cSrcweir { 1262cdf0e10cSrcweir // #101004# Call interface method instead of unsafe cast 1263cdf0e10cSrcweir pForwarder->SetDepth( maSelection.nStartPara, -1 ); 1264cdf0e10cSrcweir return; 1265cdf0e10cSrcweir } 1266cdf0e10cSrcweir else if( pMap->nWID == WID_NUMBERINGSTARTVALUE ) 1267cdf0e10cSrcweir { 1268cdf0e10cSrcweir pForwarder->SetNumberingStartValue( maSelection.nStartPara, -1 ); 1269cdf0e10cSrcweir } 1270cdf0e10cSrcweir else if( pMap->nWID == WID_PARAISNUMBERINGRESTART ) 1271cdf0e10cSrcweir { 1272cdf0e10cSrcweir pForwarder->SetParaIsNumberingRestart( maSelection.nStartPara, sal_False ); 1273cdf0e10cSrcweir } 1274cdf0e10cSrcweir else 1275cdf0e10cSrcweir { 1276cdf0e10cSrcweir aSet.InvalidateItem( pMap->nWID ); 1277cdf0e10cSrcweir } 1278cdf0e10cSrcweir 1279cdf0e10cSrcweir if(nPara != -1) 128036a46462SDamjan Jovanovic pForwarder->SetParaAttribs( nPara, aSet ); 1281cdf0e10cSrcweir else 1282cdf0e10cSrcweir pForwarder->QuickSetAttribs( aSet, GetSelection() ); 1283cdf0e10cSrcweir 1284cdf0e10cSrcweir GetEditSource()->UpdateData(); 1285cdf0e10cSrcweir 1286cdf0e10cSrcweir return; 1287cdf0e10cSrcweir } 1288cdf0e10cSrcweir while(0); 1289cdf0e10cSrcweir } 1290cdf0e10cSrcweir 1291cdf0e10cSrcweir uno::Any SAL_CALL SvxUnoTextRangeBase::getPropertyDefault( const OUString& aPropertyName ) 1292cdf0e10cSrcweir throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) 1293cdf0e10cSrcweir { 1294cdf0e10cSrcweir OGuard aGuard( Application::GetSolarMutex() ); 1295cdf0e10cSrcweir 1296cdf0e10cSrcweir SvxTextForwarder* pForwarder = mpEditSource ? mpEditSource->GetTextForwarder() : NULL; 1297cdf0e10cSrcweir if( pForwarder ) 1298cdf0e10cSrcweir { 1299cdf0e10cSrcweir const SfxItemPropertySimpleEntry* pMap = mpPropSet->getPropertyMapEntry( aPropertyName ); 1300cdf0e10cSrcweir if( pMap ) 1301cdf0e10cSrcweir { 1302cdf0e10cSrcweir SfxItemPool* pPool = pForwarder->GetPool(); 1303cdf0e10cSrcweir 1304cdf0e10cSrcweir switch( pMap->nWID ) 1305cdf0e10cSrcweir { 1306cdf0e10cSrcweir case WID_FONTDESC: 1307cdf0e10cSrcweir return SvxUnoFontDescriptor::getPropertyDefault( pPool ); 1308cdf0e10cSrcweir 1309cdf0e10cSrcweir case WID_NUMLEVEL: 1310cdf0e10cSrcweir { 1311cdf0e10cSrcweir uno::Any aAny; 1312cdf0e10cSrcweir return aAny; 1313cdf0e10cSrcweir } 1314cdf0e10cSrcweir 1315cdf0e10cSrcweir case WID_NUMBERINGSTARTVALUE: 1316cdf0e10cSrcweir return uno::Any( (sal_Int16)-1 ); 1317cdf0e10cSrcweir 1318cdf0e10cSrcweir case WID_PARAISNUMBERINGRESTART: 1319cdf0e10cSrcweir return uno::Any( (sal_Bool)sal_False ); 1320cdf0e10cSrcweir 1321cdf0e10cSrcweir default: 1322cdf0e10cSrcweir { 1323cdf0e10cSrcweir // Default aus ItemPool holen 1324cdf0e10cSrcweir if(pPool->IsWhich(pMap->nWID)) 1325cdf0e10cSrcweir { 1326cdf0e10cSrcweir SfxItemSet aSet( *pPool, pMap->nWID, pMap->nWID); 1327cdf0e10cSrcweir aSet.Put(pPool->GetDefaultItem(pMap->nWID)); 1328cdf0e10cSrcweir return mpPropSet->getPropertyValue(pMap, aSet, true, false ); 1329cdf0e10cSrcweir } 1330cdf0e10cSrcweir } 1331cdf0e10cSrcweir } 1332cdf0e10cSrcweir } 1333cdf0e10cSrcweir } 1334cdf0e10cSrcweir throw beans::UnknownPropertyException(); 1335cdf0e10cSrcweir } 1336cdf0e10cSrcweir 1337cdf0e10cSrcweir // beans::XMultiPropertyStates 1338cdf0e10cSrcweir void SAL_CALL SvxUnoTextRangeBase::setAllPropertiesToDefault( ) throw (uno::RuntimeException) 1339cdf0e10cSrcweir { 1340cdf0e10cSrcweir OGuard aGuard( Application::GetSolarMutex() ); 1341cdf0e10cSrcweir 1342cdf0e10cSrcweir SvxTextForwarder* pForwarder = mpEditSource ? mpEditSource->GetTextForwarder() : NULL; 1343cdf0e10cSrcweir 1344cdf0e10cSrcweir if( pForwarder ) 1345cdf0e10cSrcweir { 1346cdf0e10cSrcweir PropertyEntryVector_t aEntries = mpPropSet->getPropertyMap()->getPropertyEntries(); 1347cdf0e10cSrcweir PropertyEntryVector_t::const_iterator aIt = aEntries.begin(); 1348cdf0e10cSrcweir while( aIt != aEntries.end() ) 1349cdf0e10cSrcweir { 1350cdf0e10cSrcweir _setPropertyToDefault( pForwarder, &(*aIt), -1 ); 1351cdf0e10cSrcweir ++aIt; 1352cdf0e10cSrcweir } 1353cdf0e10cSrcweir } 1354cdf0e10cSrcweir } 1355cdf0e10cSrcweir 1356cdf0e10cSrcweir void SAL_CALL SvxUnoTextRangeBase::setPropertiesToDefault( const uno::Sequence< OUString >& aPropertyNames ) throw (beans::UnknownPropertyException, uno::RuntimeException) 1357cdf0e10cSrcweir { 1358cdf0e10cSrcweir sal_Int32 nCount = aPropertyNames.getLength(); 1359cdf0e10cSrcweir for( const OUString* pName = aPropertyNames.getConstArray(); nCount; pName++, nCount-- ) 1360cdf0e10cSrcweir { 1361cdf0e10cSrcweir setPropertyToDefault( *pName ); 1362cdf0e10cSrcweir } 1363cdf0e10cSrcweir } 1364cdf0e10cSrcweir 1365cdf0e10cSrcweir uno::Sequence< uno::Any > SAL_CALL SvxUnoTextRangeBase::getPropertyDefaults( const uno::Sequence< OUString >& aPropertyNames ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) 1366cdf0e10cSrcweir { 1367cdf0e10cSrcweir sal_Int32 nCount = aPropertyNames.getLength(); 1368cdf0e10cSrcweir uno::Sequence< uno::Any > ret( nCount ); 1369cdf0e10cSrcweir uno::Any* pDefaults = ret.getArray(); 1370cdf0e10cSrcweir 1371cdf0e10cSrcweir for( const OUString* pName = aPropertyNames.getConstArray(); nCount; pName++, nCount--, pDefaults++ ) 1372cdf0e10cSrcweir { 1373cdf0e10cSrcweir *pDefaults = getPropertyDefault( *pName ); 1374cdf0e10cSrcweir } 1375cdf0e10cSrcweir 1376cdf0e10cSrcweir return ret; 1377cdf0e10cSrcweir } 1378cdf0e10cSrcweir 1379cdf0e10cSrcweir // internal 1380cdf0e10cSrcweir void SvxUnoTextRangeBase::CollapseToStart(void) throw() 1381cdf0e10cSrcweir { 1382cdf0e10cSrcweir CheckSelection( maSelection, mpEditSource->GetTextForwarder() ); 1383cdf0e10cSrcweir 1384cdf0e10cSrcweir maSelection.nEndPara = maSelection.nStartPara; 1385cdf0e10cSrcweir maSelection.nEndPos = maSelection.nStartPos; 1386cdf0e10cSrcweir } 1387cdf0e10cSrcweir 1388cdf0e10cSrcweir void SvxUnoTextRangeBase::CollapseToEnd(void) throw() 1389cdf0e10cSrcweir { 1390cdf0e10cSrcweir CheckSelection( maSelection, mpEditSource->GetTextForwarder() ); 1391cdf0e10cSrcweir 1392cdf0e10cSrcweir maSelection.nStartPara = maSelection.nEndPara; 1393cdf0e10cSrcweir maSelection.nStartPos = maSelection.nEndPos; 1394cdf0e10cSrcweir } 1395cdf0e10cSrcweir 1396cdf0e10cSrcweir sal_Bool SvxUnoTextRangeBase::IsCollapsed(void) throw() 1397cdf0e10cSrcweir { 1398cdf0e10cSrcweir CheckSelection( maSelection, mpEditSource->GetTextForwarder() ); 1399cdf0e10cSrcweir 1400cdf0e10cSrcweir return ( maSelection.nStartPara == maSelection.nEndPara && 1401cdf0e10cSrcweir maSelection.nStartPos == maSelection.nEndPos ); 1402cdf0e10cSrcweir } 1403cdf0e10cSrcweir 1404cdf0e10cSrcweir sal_Bool SvxUnoTextRangeBase::GoLeft(sal_Int16 nCount, sal_Bool Expand) throw() 1405cdf0e10cSrcweir { 1406cdf0e10cSrcweir CheckSelection( maSelection, mpEditSource->GetTextForwarder() ); 1407cdf0e10cSrcweir 1408cdf0e10cSrcweir // #75098# use end position, as in Writer (start is anchor, end is cursor) 1409cdf0e10cSrcweir sal_uInt16 nNewPos = maSelection.nEndPos; 14108ee1071cSDamjan Jovanovic sal_uInt32 nNewPar = maSelection.nEndPara; 1411cdf0e10cSrcweir 1412cdf0e10cSrcweir sal_Bool bOk = sal_True; 1413cdf0e10cSrcweir SvxTextForwarder* pForwarder = NULL; 1414cdf0e10cSrcweir while ( nCount > nNewPos && bOk ) 1415cdf0e10cSrcweir { 1416cdf0e10cSrcweir if ( nNewPar == 0 ) 1417cdf0e10cSrcweir bOk = sal_False; 1418cdf0e10cSrcweir else 1419cdf0e10cSrcweir { 1420cdf0e10cSrcweir if ( !pForwarder ) 1421cdf0e10cSrcweir pForwarder = mpEditSource->GetTextForwarder(); // erst hier, wenn's noetig ist... 1422cdf0e10cSrcweir 1423cdf0e10cSrcweir --nNewPar; 1424cdf0e10cSrcweir nCount -= nNewPos + 1; 1425cdf0e10cSrcweir nNewPos = pForwarder->GetTextLen( nNewPar ); 1426cdf0e10cSrcweir } 1427cdf0e10cSrcweir } 1428cdf0e10cSrcweir 1429cdf0e10cSrcweir if ( bOk ) 1430cdf0e10cSrcweir { 1431cdf0e10cSrcweir nNewPos = nNewPos - nCount; 1432cdf0e10cSrcweir maSelection.nStartPara = nNewPar; 1433cdf0e10cSrcweir maSelection.nStartPos = nNewPos; 1434cdf0e10cSrcweir } 1435cdf0e10cSrcweir 1436cdf0e10cSrcweir if (!Expand) 1437cdf0e10cSrcweir CollapseToStart(); 1438cdf0e10cSrcweir 1439cdf0e10cSrcweir return bOk; 1440cdf0e10cSrcweir } 1441cdf0e10cSrcweir 1442cdf0e10cSrcweir sal_Bool SvxUnoTextRangeBase::GoRight(sal_Int16 nCount, sal_Bool Expand) throw() 1443cdf0e10cSrcweir { 1444cdf0e10cSrcweir SvxTextForwarder* pForwarder = mpEditSource ? mpEditSource->GetTextForwarder() : NULL; 1445cdf0e10cSrcweir if( pForwarder ) 1446cdf0e10cSrcweir { 1447cdf0e10cSrcweir CheckSelection( maSelection, pForwarder ); 1448cdf0e10cSrcweir 1449cdf0e10cSrcweir 1450cdf0e10cSrcweir sal_uInt16 nNewPos = maSelection.nEndPos + nCount; //! Ueberlauf ??? 14518ee1071cSDamjan Jovanovic sal_uInt32 nNewPar = maSelection.nEndPara; 1452cdf0e10cSrcweir 1453cdf0e10cSrcweir sal_Bool bOk = sal_True; 1454c2eaa082SDamjan Jovanovic sal_uInt32 nParCount = pForwarder->GetParagraphCount(); 1455cdf0e10cSrcweir sal_uInt16 nThisLen = pForwarder->GetTextLen( nNewPar ); 1456cdf0e10cSrcweir while ( nNewPos > nThisLen && bOk ) 1457cdf0e10cSrcweir { 1458cdf0e10cSrcweir if ( nNewPar + 1 >= nParCount ) 1459cdf0e10cSrcweir bOk = sal_False; 1460cdf0e10cSrcweir else 1461cdf0e10cSrcweir { 1462cdf0e10cSrcweir nNewPos -= nThisLen+1; 1463cdf0e10cSrcweir ++nNewPar; 1464cdf0e10cSrcweir nThisLen = pForwarder->GetTextLen( nNewPar ); 1465cdf0e10cSrcweir } 1466cdf0e10cSrcweir } 1467cdf0e10cSrcweir 1468cdf0e10cSrcweir if (bOk) 1469cdf0e10cSrcweir { 1470cdf0e10cSrcweir maSelection.nEndPara = nNewPar; 1471cdf0e10cSrcweir maSelection.nEndPos = nNewPos; 1472cdf0e10cSrcweir } 1473cdf0e10cSrcweir 1474cdf0e10cSrcweir if (!Expand) 1475cdf0e10cSrcweir CollapseToEnd(); 1476cdf0e10cSrcweir 1477cdf0e10cSrcweir return bOk; 1478cdf0e10cSrcweir } 1479cdf0e10cSrcweir return sal_False; 1480cdf0e10cSrcweir } 1481cdf0e10cSrcweir 1482cdf0e10cSrcweir void SvxUnoTextRangeBase::GotoStart(sal_Bool Expand) throw() 1483cdf0e10cSrcweir { 1484cdf0e10cSrcweir maSelection.nStartPara = 0; 1485cdf0e10cSrcweir maSelection.nStartPos = 0; 1486cdf0e10cSrcweir 1487cdf0e10cSrcweir if (!Expand) 1488cdf0e10cSrcweir CollapseToStart(); 1489cdf0e10cSrcweir } 1490cdf0e10cSrcweir 1491cdf0e10cSrcweir void SvxUnoTextRangeBase::GotoEnd(sal_Bool Expand) throw() 1492cdf0e10cSrcweir { 1493cdf0e10cSrcweir CheckSelection( maSelection, mpEditSource->GetTextForwarder() ); 1494cdf0e10cSrcweir 1495cdf0e10cSrcweir SvxTextForwarder* pForwarder = mpEditSource ? mpEditSource->GetTextForwarder() : NULL; 1496cdf0e10cSrcweir if( pForwarder ) 1497cdf0e10cSrcweir { 1498cdf0e10cSrcweir 1499c2eaa082SDamjan Jovanovic sal_uInt32 nPar = pForwarder->GetParagraphCount(); 1500cdf0e10cSrcweir if (nPar) 1501cdf0e10cSrcweir --nPar; 1502cdf0e10cSrcweir 1503cdf0e10cSrcweir maSelection.nEndPara = nPar; 1504cdf0e10cSrcweir maSelection.nEndPos = pForwarder->GetTextLen( nPar ); 1505cdf0e10cSrcweir 1506cdf0e10cSrcweir if (!Expand) 1507cdf0e10cSrcweir CollapseToEnd(); 1508cdf0e10cSrcweir } 1509cdf0e10cSrcweir } 1510cdf0e10cSrcweir 1511cdf0e10cSrcweir // lang::XServiceInfo 1512cdf0e10cSrcweir sal_Bool SAL_CALL SvxUnoTextRangeBase::supportsService( const OUString& ServiceName ) 1513cdf0e10cSrcweir throw(uno::RuntimeException) 1514cdf0e10cSrcweir { 1515cdf0e10cSrcweir return comphelper::ServiceInfoHelper::supportsService( ServiceName, getSupportedServiceNames() ); 1516cdf0e10cSrcweir } 1517cdf0e10cSrcweir 1518cdf0e10cSrcweir uno::Sequence< OUString > SAL_CALL SvxUnoTextRangeBase::getSupportedServiceNames() 1519cdf0e10cSrcweir throw(uno::RuntimeException) 1520cdf0e10cSrcweir { 1521cdf0e10cSrcweir return getSupportedServiceNames_Static(); 1522cdf0e10cSrcweir } 1523cdf0e10cSrcweir 1524cdf0e10cSrcweir uno::Sequence< OUString > SAL_CALL SvxUnoTextRangeBase::getSupportedServiceNames_Static() 1525cdf0e10cSrcweir SAL_THROW(()) 1526cdf0e10cSrcweir { 1527cdf0e10cSrcweir uno::Sequence< OUString > aSeq; 1528cdf0e10cSrcweir comphelper::ServiceInfoHelper::addToSequence( aSeq, 3, "com.sun.star.style.CharacterProperties", 1529cdf0e10cSrcweir "com.sun.star.style.CharacterPropertiesComplex", 1530cdf0e10cSrcweir "com.sun.star.style.CharacterPropertiesAsian"); 1531cdf0e10cSrcweir return aSeq; 1532cdf0e10cSrcweir } 1533cdf0e10cSrcweir 1534cdf0e10cSrcweir // XTextRangeCompare 1535cdf0e10cSrcweir sal_Int16 SAL_CALL SvxUnoTextRangeBase::compareRegionStarts( const uno::Reference< text::XTextRange >& xR1, const uno::Reference< text::XTextRange >& xR2 ) throw (lang::IllegalArgumentException, uno::RuntimeException) 1536cdf0e10cSrcweir { 1537cdf0e10cSrcweir SvxUnoTextRangeBase* pR1 = SvxUnoTextRangeBase::getImplementation( xR1 ); 1538cdf0e10cSrcweir SvxUnoTextRangeBase* pR2 = SvxUnoTextRangeBase::getImplementation( xR2 ); 1539cdf0e10cSrcweir 1540cdf0e10cSrcweir if( (pR1 == 0) || (pR2 == 0) ) 1541cdf0e10cSrcweir throw lang::IllegalArgumentException(); 1542cdf0e10cSrcweir 1543cdf0e10cSrcweir const ESelection& r1 = pR1->maSelection; 1544cdf0e10cSrcweir const ESelection& r2 = pR2->maSelection; 1545cdf0e10cSrcweir 1546cdf0e10cSrcweir if( r1.nStartPara == r2.nStartPara ) 1547cdf0e10cSrcweir { 1548cdf0e10cSrcweir if( r1.nStartPos == r2.nStartPos ) 1549cdf0e10cSrcweir return 0; 1550cdf0e10cSrcweir else 1551cdf0e10cSrcweir return r1.nStartPos < r2.nStartPos ? 1 : -1; 1552cdf0e10cSrcweir } 1553cdf0e10cSrcweir else 1554cdf0e10cSrcweir { 1555cdf0e10cSrcweir return r1.nStartPara < r2.nStartPara ? 1 : -1; 1556cdf0e10cSrcweir } 1557cdf0e10cSrcweir } 1558cdf0e10cSrcweir 1559cdf0e10cSrcweir sal_Int16 SAL_CALL SvxUnoTextRangeBase::compareRegionEnds( const uno::Reference< text::XTextRange >& xR1, const uno::Reference< text::XTextRange >& xR2 ) throw (lang::IllegalArgumentException, uno::RuntimeException) 1560cdf0e10cSrcweir { 1561cdf0e10cSrcweir SvxUnoTextRangeBase* pR1 = SvxUnoTextRangeBase::getImplementation( xR1 ); 1562cdf0e10cSrcweir SvxUnoTextRangeBase* pR2 = SvxUnoTextRangeBase::getImplementation( xR2 ); 1563cdf0e10cSrcweir 1564cdf0e10cSrcweir if( (pR1 == 0) || (pR2 == 0) ) 1565cdf0e10cSrcweir throw lang::IllegalArgumentException(); 1566cdf0e10cSrcweir 1567cdf0e10cSrcweir const ESelection& r1 = pR1->maSelection; 1568cdf0e10cSrcweir const ESelection& r2 = pR2->maSelection; 1569cdf0e10cSrcweir 1570cdf0e10cSrcweir if( r1.nEndPara == r2.nEndPara ) 1571cdf0e10cSrcweir { 1572cdf0e10cSrcweir if( r1.nEndPos == r2.nEndPos ) 1573cdf0e10cSrcweir return 0; 1574cdf0e10cSrcweir else 1575cdf0e10cSrcweir return r1.nEndPos < r2.nEndPos ? 1 : -1; 1576cdf0e10cSrcweir } 1577cdf0e10cSrcweir else 1578cdf0e10cSrcweir { 1579cdf0e10cSrcweir return r1.nEndPara < r2.nEndPara ? 1 : -1; 1580cdf0e10cSrcweir } 1581cdf0e10cSrcweir } 1582cdf0e10cSrcweir 1583cdf0e10cSrcweir // ==================================================================== 1584cdf0e10cSrcweir // class SvxUnoTextRange 1585cdf0e10cSrcweir // ==================================================================== 1586cdf0e10cSrcweir 1587cdf0e10cSrcweir uno::Sequence< uno::Type > SvxUnoTextRange::maTypeSequence; 1588cdf0e10cSrcweir 1589cdf0e10cSrcweir uno::Reference< uno::XInterface > SvxUnoTextRange_NewInstance() 1590cdf0e10cSrcweir { 1591cdf0e10cSrcweir SvxUnoText aText; 1592cdf0e10cSrcweir uno::Reference< text::XTextRange > xRange( new SvxUnoTextRange( aText ) ); 1593cdf0e10cSrcweir #if (_MSC_VER < 1300) 1594cdf0e10cSrcweir return xRange; 1595cdf0e10cSrcweir #else 1596cdf0e10cSrcweir return (uno::Reference< uno::XInterface >)xRange; 1597cdf0e10cSrcweir #endif 1598cdf0e10cSrcweir } 1599cdf0e10cSrcweir 1600cdf0e10cSrcweir SvxUnoTextRange::SvxUnoTextRange( const SvxUnoTextBase& rParent, sal_Bool bPortion /* = sal_False */ ) throw() 1601cdf0e10cSrcweir :SvxUnoTextRangeBase( rParent.GetEditSource(), bPortion ? ImplGetSvxTextPortionSvxPropertySet() : rParent.getPropertySet() ), 1602cdf0e10cSrcweir mbPortion( bPortion ) 1603cdf0e10cSrcweir { 1604cdf0e10cSrcweir xParentText = (text::XText*)&rParent; 1605cdf0e10cSrcweir } 1606cdf0e10cSrcweir 1607cdf0e10cSrcweir SvxUnoTextRange::~SvxUnoTextRange() throw() 1608cdf0e10cSrcweir { 1609cdf0e10cSrcweir } 1610cdf0e10cSrcweir 1611cdf0e10cSrcweir uno::Any SAL_CALL SvxUnoTextRange::queryAggregation( const uno::Type & rType ) 1612cdf0e10cSrcweir throw(uno::RuntimeException) 1613cdf0e10cSrcweir { 1614cdf0e10cSrcweir QUERYINT( text::XTextRange ); 1615cdf0e10cSrcweir else if( rType == ::getCppuType((const uno::Reference< beans::XMultiPropertyStates >*)0) ) 1616cdf0e10cSrcweir return uno::makeAny(uno::Reference< beans::XMultiPropertyStates >(this)); 1617cdf0e10cSrcweir else if( rType == ::getCppuType((const uno::Reference< beans::XPropertySet >*)0) ) 1618cdf0e10cSrcweir return uno::makeAny(uno::Reference< beans::XPropertySet >(this)); 1619cdf0e10cSrcweir else QUERYINT( beans::XPropertyState ); 1620cdf0e10cSrcweir else QUERYINT( text::XTextRangeCompare ); 1621cdf0e10cSrcweir else if( rType == ::getCppuType((const uno::Reference< beans::XMultiPropertySet >*)0) ) 1622cdf0e10cSrcweir return uno::makeAny(uno::Reference< beans::XMultiPropertySet >(this)); 1623cdf0e10cSrcweir else QUERYINT( lang::XServiceInfo ); 1624cdf0e10cSrcweir else QUERYINT( lang::XTypeProvider ); 1625cdf0e10cSrcweir else QUERYINT( lang::XUnoTunnel ); 1626cdf0e10cSrcweir else 1627cdf0e10cSrcweir return OWeakAggObject::queryAggregation( rType ); 1628cdf0e10cSrcweir } 1629cdf0e10cSrcweir 1630cdf0e10cSrcweir uno::Any SAL_CALL SvxUnoTextRange::queryInterface( const uno::Type & rType ) 1631cdf0e10cSrcweir throw(uno::RuntimeException) 1632cdf0e10cSrcweir { 1633cdf0e10cSrcweir return OWeakAggObject::queryInterface(rType); 1634cdf0e10cSrcweir } 1635cdf0e10cSrcweir 1636cdf0e10cSrcweir void SAL_CALL SvxUnoTextRange::acquire() 1637cdf0e10cSrcweir throw( ) 1638cdf0e10cSrcweir { 1639cdf0e10cSrcweir OWeakAggObject::acquire(); 1640cdf0e10cSrcweir } 1641cdf0e10cSrcweir 1642cdf0e10cSrcweir void SAL_CALL SvxUnoTextRange::release() 1643cdf0e10cSrcweir throw( ) 1644cdf0e10cSrcweir { 1645cdf0e10cSrcweir OWeakAggObject::release(); 1646cdf0e10cSrcweir } 1647cdf0e10cSrcweir 1648cdf0e10cSrcweir // XTypeProvider 1649cdf0e10cSrcweir 1650cdf0e10cSrcweir uno::Sequence< uno::Type > SAL_CALL SvxUnoTextRange::getTypes() 1651cdf0e10cSrcweir throw (uno::RuntimeException) 1652cdf0e10cSrcweir { 1653cdf0e10cSrcweir if( maTypeSequence.getLength() == 0 ) 1654cdf0e10cSrcweir { 1655cdf0e10cSrcweir maTypeSequence.realloc( 9 ); // !DANGER! keep this updated 1656cdf0e10cSrcweir uno::Type* pTypes = maTypeSequence.getArray(); 1657cdf0e10cSrcweir 1658cdf0e10cSrcweir *pTypes++ = ::getCppuType(( const uno::Reference< text::XTextRange >*)0); 1659cdf0e10cSrcweir *pTypes++ = ::getCppuType(( const uno::Reference< beans::XPropertySet >*)0); 1660cdf0e10cSrcweir *pTypes++ = ::getCppuType(( const uno::Reference< beans::XMultiPropertySet >*)0); 1661cdf0e10cSrcweir *pTypes++ = ::getCppuType(( const uno::Reference< beans::XMultiPropertyStates >*)0); 1662cdf0e10cSrcweir *pTypes++ = ::getCppuType(( const uno::Reference< beans::XPropertyState >*)0); 1663cdf0e10cSrcweir *pTypes++ = ::getCppuType(( const uno::Reference< lang::XServiceInfo >*)0); 1664cdf0e10cSrcweir *pTypes++ = ::getCppuType(( const uno::Reference< lang::XTypeProvider >*)0); 1665cdf0e10cSrcweir *pTypes++ = ::getCppuType(( const uno::Reference< lang::XUnoTunnel >*)0); 1666cdf0e10cSrcweir *pTypes++ = ::getCppuType(( const uno::Reference< text::XTextRangeCompare >*)0); 1667cdf0e10cSrcweir } 1668cdf0e10cSrcweir return maTypeSequence; 1669cdf0e10cSrcweir } 1670cdf0e10cSrcweir 1671cdf0e10cSrcweir uno::Sequence< sal_Int8 > SAL_CALL SvxUnoTextRange::getImplementationId() 1672cdf0e10cSrcweir throw (uno::RuntimeException) 1673cdf0e10cSrcweir { 1674cdf0e10cSrcweir static uno::Sequence< sal_Int8 > aId; 1675cdf0e10cSrcweir if( aId.getLength() == 0 ) 1676cdf0e10cSrcweir { 1677cdf0e10cSrcweir aId.realloc( 16 ); 1678cdf0e10cSrcweir rtl_createUuid( (sal_uInt8 *)aId.getArray(), 0, sal_True ); 1679cdf0e10cSrcweir } 1680cdf0e10cSrcweir return aId; 1681cdf0e10cSrcweir } 1682cdf0e10cSrcweir 1683cdf0e10cSrcweir // XTextRange 1684cdf0e10cSrcweir uno::Reference< text::XText > SAL_CALL SvxUnoTextRange::getText() 1685cdf0e10cSrcweir throw(uno::RuntimeException) 1686cdf0e10cSrcweir { 1687cdf0e10cSrcweir return xParentText; 1688cdf0e10cSrcweir } 1689cdf0e10cSrcweir 1690cdf0e10cSrcweir // lang::XServiceInfo 1691cdf0e10cSrcweir OUString SAL_CALL SvxUnoTextRange::getImplementationName() 1692cdf0e10cSrcweir throw(uno::RuntimeException) 1693cdf0e10cSrcweir { 1694cdf0e10cSrcweir return OUString(RTL_CONSTASCII_USTRINGPARAM("SvxUnoTextRange")); 1695cdf0e10cSrcweir } 1696cdf0e10cSrcweir 1697cdf0e10cSrcweir // ==================================================================== 1698cdf0e10cSrcweir // class SvxUnoText 1699cdf0e10cSrcweir // ==================================================================== 1700cdf0e10cSrcweir 1701cdf0e10cSrcweir // UNO3_GETIMPLEMENTATION2_IMPL( SvxUnoText, SvxUnoTextRangeBase ); 1702cdf0e10cSrcweir 1703cdf0e10cSrcweir uno::Sequence< uno::Type > SvxUnoTextBase::maTypeSequence; 1704cdf0e10cSrcweir 1705cdf0e10cSrcweir SvxUnoTextBase::SvxUnoTextBase() throw() 1706cdf0e10cSrcweir : SvxUnoTextRangeBase( NULL ) 1707cdf0e10cSrcweir { 1708cdf0e10cSrcweir 1709cdf0e10cSrcweir } 1710cdf0e10cSrcweir 1711cdf0e10cSrcweir SvxUnoTextBase::SvxUnoTextBase( const SvxItemPropertySet* _pSet ) throw() 1712cdf0e10cSrcweir : SvxUnoTextRangeBase( _pSet ) 1713cdf0e10cSrcweir { 1714cdf0e10cSrcweir } 1715cdf0e10cSrcweir 1716cdf0e10cSrcweir SvxUnoTextBase::SvxUnoTextBase( const SvxEditSource* pSource, const SvxItemPropertySet* _pSet ) throw() 1717cdf0e10cSrcweir : SvxUnoTextRangeBase( pSource, _pSet ) 1718cdf0e10cSrcweir { 1719cdf0e10cSrcweir ESelection aSelection; 1720cdf0e10cSrcweir ::GetSelection( aSelection, GetEditSource()->GetTextForwarder() ); 1721cdf0e10cSrcweir SetSelection( aSelection ); 1722cdf0e10cSrcweir } 1723cdf0e10cSrcweir 1724cdf0e10cSrcweir SvxUnoTextBase::SvxUnoTextBase( const SvxEditSource* pSource, const SvxItemPropertySet* _pSet, uno::Reference < text::XText > xParent ) throw() 1725cdf0e10cSrcweir : SvxUnoTextRangeBase( pSource, _pSet ) 1726cdf0e10cSrcweir { 1727cdf0e10cSrcweir xParentText = xParent; 1728cdf0e10cSrcweir ESelection aSelection; 1729cdf0e10cSrcweir ::GetSelection( aSelection, GetEditSource()->GetTextForwarder() ); 1730cdf0e10cSrcweir SetSelection( aSelection ); 1731cdf0e10cSrcweir } 1732cdf0e10cSrcweir 1733cdf0e10cSrcweir SvxUnoTextBase::SvxUnoTextBase( const SvxUnoTextBase& rText ) throw() 1734cdf0e10cSrcweir : SvxUnoTextRangeBase( rText ) 1735cdf0e10cSrcweir , text::XTextAppend() 1736cdf0e10cSrcweir , text::XTextCopy() 1737cdf0e10cSrcweir , container::XEnumerationAccess() 1738cdf0e10cSrcweir , text::XTextRangeMover() 1739cdf0e10cSrcweir , lang::XTypeProvider() 1740cdf0e10cSrcweir { 1741cdf0e10cSrcweir xParentText = rText.xParentText; 1742cdf0e10cSrcweir } 1743cdf0e10cSrcweir 1744cdf0e10cSrcweir SvxUnoTextBase::~SvxUnoTextBase() throw() 1745cdf0e10cSrcweir { 1746cdf0e10cSrcweir } 1747cdf0e10cSrcweir 1748cdf0e10cSrcweir // Internal 1749cdf0e10cSrcweir ESelection SvxUnoTextBase::InsertField( const SvxFieldItem& rField ) throw() 1750cdf0e10cSrcweir { 1751cdf0e10cSrcweir SvxTextForwarder* pForwarder = GetEditSource() ? GetEditSource()->GetTextForwarder() : NULL; 1752cdf0e10cSrcweir if( pForwarder ) 1753cdf0e10cSrcweir { 1754cdf0e10cSrcweir pForwarder->QuickInsertField( rField, GetSelection() ); 1755cdf0e10cSrcweir GetEditSource()->UpdateData(); 1756cdf0e10cSrcweir 1757cdf0e10cSrcweir // Selektion anpassen 1758cdf0e10cSrcweir //! Wenn die EditEngine bei QuickInsertText die Selektion zurueckgeben wuerde, 1759cdf0e10cSrcweir //! waer's einfacher... 1760cdf0e10cSrcweir 1761cdf0e10cSrcweir CollapseToStart(); 1762cdf0e10cSrcweir GoRight( 1, sal_True ); // Feld ist immer 1 Zeichen 1763cdf0e10cSrcweir } 1764cdf0e10cSrcweir 1765cdf0e10cSrcweir return GetSelection(); // Selektion mit dem Feld 1766cdf0e10cSrcweir } 1767cdf0e10cSrcweir 1768cdf0e10cSrcweir // XInterface 1769cdf0e10cSrcweir uno::Any SAL_CALL SvxUnoTextBase::queryAggregation( const uno::Type & rType ) 1770cdf0e10cSrcweir throw(uno::RuntimeException) 1771cdf0e10cSrcweir { 1772cdf0e10cSrcweir QUERYINT( text::XText ); 1773cdf0e10cSrcweir QUERYINT( text::XSimpleText ); 1774cdf0e10cSrcweir if( rType == ::getCppuType((const uno::Reference< text::XTextRange >*)0) ) 1775cdf0e10cSrcweir return uno::makeAny(uno::Reference< text::XTextRange >((text::XText*)(this))); 1776cdf0e10cSrcweir QUERYINT(container::XEnumerationAccess ); 1777cdf0e10cSrcweir QUERYINT( container::XElementAccess ); 1778cdf0e10cSrcweir QUERYINT( beans::XMultiPropertyStates ); 1779cdf0e10cSrcweir QUERYINT( beans::XPropertySet ); 1780cdf0e10cSrcweir QUERYINT( beans::XMultiPropertySet ); 1781cdf0e10cSrcweir QUERYINT( beans::XPropertyState ); 1782cdf0e10cSrcweir QUERYINT( text::XTextRangeCompare ); 1783cdf0e10cSrcweir QUERYINT( lang::XServiceInfo ); 1784cdf0e10cSrcweir QUERYINT( text::XTextRangeMover ); 1785cdf0e10cSrcweir QUERYINT( text::XTextCopy ); 1786cdf0e10cSrcweir QUERYINT( text::XTextAppend ); 1787cdf0e10cSrcweir QUERYINT( text::XParagraphAppend ); 1788cdf0e10cSrcweir QUERYINT( text::XTextPortionAppend ); 1789cdf0e10cSrcweir QUERYINT( lang::XTypeProvider ); 1790cdf0e10cSrcweir QUERYINT( lang::XUnoTunnel ); 1791cdf0e10cSrcweir 1792cdf0e10cSrcweir return uno::Any(); 1793cdf0e10cSrcweir } 1794cdf0e10cSrcweir 1795cdf0e10cSrcweir // XTypeProvider 1796cdf0e10cSrcweir 1797cdf0e10cSrcweir uno::Sequence< uno::Type > SAL_CALL SvxUnoTextBase::getStaticTypes() throw() 1798cdf0e10cSrcweir { 1799cdf0e10cSrcweir if( maTypeSequence.getLength() == 0 ) 1800cdf0e10cSrcweir { 1801cdf0e10cSrcweir maTypeSequence.realloc( 15 ); // !DANGER! keep this updated 1802cdf0e10cSrcweir uno::Type* pTypes = maTypeSequence.getArray(); 1803cdf0e10cSrcweir 1804cdf0e10cSrcweir *pTypes++ = ::getCppuType(( const uno::Reference< text::XText >*)0); 1805cdf0e10cSrcweir *pTypes++ = ::getCppuType(( const uno::Reference< container::XEnumerationAccess >*)0); 1806cdf0e10cSrcweir *pTypes++ = ::getCppuType(( const uno::Reference< beans::XPropertySet >*)0); 1807cdf0e10cSrcweir *pTypes++ = ::getCppuType(( const uno::Reference< beans::XMultiPropertySet >*)0); 1808cdf0e10cSrcweir *pTypes++ = ::getCppuType(( const uno::Reference< beans::XMultiPropertyStates >*)0); 1809cdf0e10cSrcweir *pTypes++ = ::getCppuType(( const uno::Reference< beans::XPropertyState >*)0); 1810cdf0e10cSrcweir *pTypes++ = ::getCppuType(( const uno::Reference< text::XTextRangeMover >*)0); 1811cdf0e10cSrcweir *pTypes++ = ::getCppuType(( const uno::Reference< text::XTextAppend >*)0); 1812cdf0e10cSrcweir *pTypes++ = ::getCppuType(( const uno::Reference< text::XTextCopy >*)0); 1813cdf0e10cSrcweir *pTypes++ = ::getCppuType(( const uno::Reference< text::XParagraphAppend >*)0); 1814cdf0e10cSrcweir *pTypes++ = ::getCppuType(( const uno::Reference< text::XTextPortionAppend >*)0); 1815cdf0e10cSrcweir *pTypes++ = ::getCppuType(( const uno::Reference< lang::XServiceInfo >*)0); 1816cdf0e10cSrcweir *pTypes++ = ::getCppuType(( const uno::Reference< lang::XTypeProvider >*)0); 1817cdf0e10cSrcweir *pTypes++ = ::getCppuType(( const uno::Reference< lang::XUnoTunnel >*)0); 1818cdf0e10cSrcweir *pTypes++ = ::getCppuType(( const uno::Reference< text::XTextRangeCompare >*)0); 1819cdf0e10cSrcweir } 1820cdf0e10cSrcweir return maTypeSequence; 1821cdf0e10cSrcweir } 1822cdf0e10cSrcweir 1823cdf0e10cSrcweir uno::Sequence< uno::Type > SAL_CALL SvxUnoTextBase::getTypes() 1824cdf0e10cSrcweir throw (uno::RuntimeException) 1825cdf0e10cSrcweir { 1826cdf0e10cSrcweir return getStaticTypes(); 1827cdf0e10cSrcweir } 1828cdf0e10cSrcweir 1829cdf0e10cSrcweir uno::Sequence< sal_Int8 > SAL_CALL SvxUnoTextBase::getImplementationId() 1830cdf0e10cSrcweir throw (uno::RuntimeException) 1831cdf0e10cSrcweir { 1832cdf0e10cSrcweir static uno::Sequence< sal_Int8 > aId; 1833cdf0e10cSrcweir if( aId.getLength() == 0 ) 1834cdf0e10cSrcweir { 1835cdf0e10cSrcweir aId.realloc( 16 ); 1836cdf0e10cSrcweir rtl_createUuid( (sal_uInt8 *)aId.getArray(), 0, sal_True ); 1837cdf0e10cSrcweir } 1838cdf0e10cSrcweir return aId; 1839cdf0e10cSrcweir } 1840cdf0e10cSrcweir 1841cdf0e10cSrcweir uno::Reference< text::XTextCursor > SvxUnoTextBase::createTextCursorBySelection( const ESelection& rSel ) 1842cdf0e10cSrcweir { 1843cdf0e10cSrcweir SvxUnoTextCursor* pCursor = new SvxUnoTextCursor( *this ); 1844cdf0e10cSrcweir uno::Reference< text::XTextCursor > xCursor( pCursor ); 1845cdf0e10cSrcweir pCursor->SetSelection( rSel ); 1846cdf0e10cSrcweir return xCursor; 1847cdf0e10cSrcweir } 1848cdf0e10cSrcweir 1849cdf0e10cSrcweir // XSimpleText 1850cdf0e10cSrcweir 1851cdf0e10cSrcweir uno::Reference< text::XTextCursor > SAL_CALL SvxUnoTextBase::createTextCursor() 1852cdf0e10cSrcweir throw(uno::RuntimeException) 1853cdf0e10cSrcweir { 1854cdf0e10cSrcweir OGuard aGuard( Application::GetSolarMutex() ); 1855cdf0e10cSrcweir return new SvxUnoTextCursor( *this ); 1856cdf0e10cSrcweir } 1857cdf0e10cSrcweir 1858cdf0e10cSrcweir uno::Reference< text::XTextCursor > SAL_CALL SvxUnoTextBase::createTextCursorByRange( const uno::Reference< text::XTextRange >& aTextPosition ) 1859cdf0e10cSrcweir throw(uno::RuntimeException) 1860cdf0e10cSrcweir { 1861cdf0e10cSrcweir OGuard aGuard( Application::GetSolarMutex() ); 1862cdf0e10cSrcweir 1863cdf0e10cSrcweir uno::Reference< text::XTextCursor > xCursor; 1864cdf0e10cSrcweir 1865cdf0e10cSrcweir if( aTextPosition.is() ) 1866cdf0e10cSrcweir { 1867cdf0e10cSrcweir SvxUnoTextRangeBase* pRange = SvxUnoTextRangeBase::getImplementation( aTextPosition ); 1868cdf0e10cSrcweir if(pRange) 1869cdf0e10cSrcweir xCursor = createTextCursorBySelection( pRange->GetSelection() ); 1870cdf0e10cSrcweir } 1871cdf0e10cSrcweir 1872cdf0e10cSrcweir return xCursor; 1873cdf0e10cSrcweir } 1874cdf0e10cSrcweir 1875cdf0e10cSrcweir void SAL_CALL SvxUnoTextBase::insertString( const uno::Reference< text::XTextRange >& xRange, const OUString& aString, sal_Bool bAbsorb ) 1876cdf0e10cSrcweir throw(uno::RuntimeException) 1877cdf0e10cSrcweir { 1878cdf0e10cSrcweir OGuard aGuard( Application::GetSolarMutex() ); 1879cdf0e10cSrcweir 1880cdf0e10cSrcweir if( !xRange.is() ) 1881cdf0e10cSrcweir return; 1882cdf0e10cSrcweir 1883cdf0e10cSrcweir ESelection aSelection; 1884cdf0e10cSrcweir ::GetSelection( aSelection, GetEditSource()->GetTextForwarder() ); 1885cdf0e10cSrcweir SetSelection( aSelection ); 1886cdf0e10cSrcweir 1887cdf0e10cSrcweir SvxUnoTextRangeBase* pRange = SvxUnoTextRange::getImplementation( xRange ); 1888cdf0e10cSrcweir if(pRange) 1889cdf0e10cSrcweir { 1890cdf0e10cSrcweir // setString am SvxUnoTextRangeBase statt selber QuickInsertText und UpdateData, 1891cdf0e10cSrcweir // damit die Selektion am SvxUnoTextRangeBase angepasst wird. 1892cdf0e10cSrcweir //! Eigentlich muessten alle Cursor-Objekte dieses Textes angepasst werden! 1893cdf0e10cSrcweir 1894cdf0e10cSrcweir if (!bAbsorb) // nicht ersetzen -> hinten anhaengen 1895cdf0e10cSrcweir pRange->CollapseToEnd(); 1896cdf0e10cSrcweir 1897cdf0e10cSrcweir pRange->setString( aString ); 1898cdf0e10cSrcweir 1899cdf0e10cSrcweir pRange->CollapseToEnd(); 1900cdf0e10cSrcweir } 1901cdf0e10cSrcweir } 1902cdf0e10cSrcweir 1903cdf0e10cSrcweir void SAL_CALL SvxUnoTextBase::insertControlCharacter( const uno::Reference< text::XTextRange >& xRange, sal_Int16 nControlCharacter, sal_Bool bAbsorb ) 1904cdf0e10cSrcweir throw(lang::IllegalArgumentException, uno::RuntimeException) 1905cdf0e10cSrcweir { 1906cdf0e10cSrcweir OGuard aGuard( Application::GetSolarMutex() ); 1907cdf0e10cSrcweir 1908cdf0e10cSrcweir SvxTextForwarder* pForwarder = GetEditSource() ? GetEditSource()->GetTextForwarder() : NULL; 1909cdf0e10cSrcweir 1910cdf0e10cSrcweir if( pForwarder ) 1911cdf0e10cSrcweir { 1912cdf0e10cSrcweir ESelection aSelection; 1913cdf0e10cSrcweir ::GetSelection( aSelection, pForwarder ); 1914cdf0e10cSrcweir SetSelection( aSelection ); 1915cdf0e10cSrcweir 1916cdf0e10cSrcweir switch( nControlCharacter ) 1917cdf0e10cSrcweir { 1918cdf0e10cSrcweir case text::ControlCharacter::PARAGRAPH_BREAK: 1919cdf0e10cSrcweir { 1920cdf0e10cSrcweir const String aText( (sal_Unicode)13 ); // '\r' geht auf'm Mac nicht 1921cdf0e10cSrcweir insertString( xRange, aText, bAbsorb ); 1922cdf0e10cSrcweir 1923cdf0e10cSrcweir return; 1924cdf0e10cSrcweir } 1925cdf0e10cSrcweir case text::ControlCharacter::LINE_BREAK: 1926cdf0e10cSrcweir { 1927cdf0e10cSrcweir SvxUnoTextRangeBase* pRange = SvxUnoTextRange::getImplementation( xRange ); 1928cdf0e10cSrcweir if(pRange) 1929cdf0e10cSrcweir { 1930cdf0e10cSrcweir ESelection aRange = pRange->GetSelection(); 1931cdf0e10cSrcweir 1932cdf0e10cSrcweir if( bAbsorb ) 1933cdf0e10cSrcweir { 1934cdf0e10cSrcweir const String aEmpty; 1935cdf0e10cSrcweir pForwarder->QuickInsertText( aEmpty, aRange ); 1936cdf0e10cSrcweir 1937cdf0e10cSrcweir aRange.nEndPos = aRange.nStartPos; 1938cdf0e10cSrcweir aRange.nEndPara = aRange.nStartPara; 1939cdf0e10cSrcweir } 1940cdf0e10cSrcweir else 1941cdf0e10cSrcweir { 1942cdf0e10cSrcweir aRange.nStartPos = aRange.nEndPos; 1943cdf0e10cSrcweir aRange.nStartPara = aRange.nStartPara; 1944cdf0e10cSrcweir } 1945cdf0e10cSrcweir 1946cdf0e10cSrcweir pForwarder->QuickInsertLineBreak( aRange ); 1947cdf0e10cSrcweir GetEditSource()->UpdateData(); 1948cdf0e10cSrcweir 1949cdf0e10cSrcweir aRange.nEndPos += 1; 1950cdf0e10cSrcweir if( !bAbsorb ) 1951cdf0e10cSrcweir aRange.nStartPos += 1; 1952cdf0e10cSrcweir 1953cdf0e10cSrcweir pRange->SetSelection( aRange ); 1954cdf0e10cSrcweir } 1955cdf0e10cSrcweir return; 1956cdf0e10cSrcweir } 1957cdf0e10cSrcweir case text::ControlCharacter::APPEND_PARAGRAPH: 1958cdf0e10cSrcweir { 1959cdf0e10cSrcweir SvxUnoTextRangeBase* pRange = SvxUnoTextRange::getImplementation( xRange ); 1960cdf0e10cSrcweir if(pRange) 1961cdf0e10cSrcweir { 1962cdf0e10cSrcweir ESelection aRange = pRange->GetSelection(); 1963cdf0e10cSrcweir // ESelection aOldSelection = aRange; 1964cdf0e10cSrcweir 1965cdf0e10cSrcweir aRange.nStartPos = pForwarder->GetTextLen( aRange.nStartPara ); 1966cdf0e10cSrcweir 1967cdf0e10cSrcweir aRange.nEndPara = aRange.nStartPara; 1968cdf0e10cSrcweir aRange.nEndPos = aRange.nStartPos; 1969cdf0e10cSrcweir 1970cdf0e10cSrcweir pRange->SetSelection( aRange ); 1971cdf0e10cSrcweir const String aText( (sal_Unicode)13 ); // '\r' geht auf'm Mac nicht 1972cdf0e10cSrcweir pRange->setString( aText ); 1973cdf0e10cSrcweir 1974cdf0e10cSrcweir aRange.nStartPos = 0; 1975cdf0e10cSrcweir aRange.nStartPara += 1; 1976cdf0e10cSrcweir aRange.nEndPos = 0; 1977cdf0e10cSrcweir aRange.nEndPara += 1; 1978cdf0e10cSrcweir 1979cdf0e10cSrcweir pRange->SetSelection( aRange ); 1980cdf0e10cSrcweir 1981cdf0e10cSrcweir return; 1982cdf0e10cSrcweir } 1983cdf0e10cSrcweir } 1984cdf0e10cSrcweir } 1985cdf0e10cSrcweir } 1986cdf0e10cSrcweir 1987cdf0e10cSrcweir throw lang::IllegalArgumentException(); 1988cdf0e10cSrcweir } 1989cdf0e10cSrcweir 1990cdf0e10cSrcweir // XText 1991cdf0e10cSrcweir void SAL_CALL SvxUnoTextBase::insertTextContent( const uno::Reference< text::XTextRange >& xRange, const uno::Reference< text::XTextContent >& xContent, sal_Bool bAbsorb ) 1992cdf0e10cSrcweir throw(lang::IllegalArgumentException, uno::RuntimeException) 1993cdf0e10cSrcweir { 1994cdf0e10cSrcweir OGuard aGuard( Application::GetSolarMutex() ); 1995cdf0e10cSrcweir 1996cdf0e10cSrcweir SvxTextForwarder* pForwarder = GetEditSource() ? GetEditSource()->GetTextForwarder() : NULL; 1997cdf0e10cSrcweir if( pForwarder ) 1998cdf0e10cSrcweir { 1999cdf0e10cSrcweir 2000cdf0e10cSrcweir SvxUnoTextRangeBase* pRange = SvxUnoTextRange::getImplementation( xRange ); 2001cdf0e10cSrcweir SvxUnoTextField* pField = SvxUnoTextField::getImplementation( xContent ); 2002cdf0e10cSrcweir 2003cdf0e10cSrcweir if( pRange == NULL || pField == NULL ) 2004cdf0e10cSrcweir throw lang::IllegalArgumentException(); 2005cdf0e10cSrcweir 2006cdf0e10cSrcweir ESelection aSelection = pRange->GetSelection(); 2007cdf0e10cSrcweir if( !bAbsorb ) 2008cdf0e10cSrcweir { 2009cdf0e10cSrcweir aSelection.nStartPara = aSelection.nEndPara; 2010cdf0e10cSrcweir aSelection.nStartPos = aSelection.nEndPos; 2011cdf0e10cSrcweir } 2012cdf0e10cSrcweir 2013cdf0e10cSrcweir SvxFieldData* pFieldData = pField->CreateFieldData(); 2014cdf0e10cSrcweir if( pFieldData == NULL ) 2015cdf0e10cSrcweir throw lang::IllegalArgumentException(); 2016cdf0e10cSrcweir 2017cdf0e10cSrcweir SvxFieldItem aField( *pFieldData, EE_FEATURE_FIELD ); 2018cdf0e10cSrcweir pForwarder->QuickInsertField( aField, aSelection ); 2019cdf0e10cSrcweir GetEditSource()->UpdateData(); 2020cdf0e10cSrcweir 2021cdf0e10cSrcweir pField->SetAnchor( uno::Reference< text::XTextRange >::query( (cppu::OWeakObject*)this ) ); 2022cdf0e10cSrcweir 2023cdf0e10cSrcweir aSelection.nEndPos += 1; 2024cdf0e10cSrcweir aSelection.nStartPos = aSelection.nEndPos; 2025cdf0e10cSrcweir //maSelection = aSelection; //??? 2026cdf0e10cSrcweir pRange->SetSelection( aSelection ); 2027cdf0e10cSrcweir 2028cdf0e10cSrcweir delete pFieldData; 2029cdf0e10cSrcweir } 2030cdf0e10cSrcweir } 2031cdf0e10cSrcweir 2032cdf0e10cSrcweir void SAL_CALL SvxUnoTextBase::removeTextContent( const uno::Reference< text::XTextContent >& ) throw(container::NoSuchElementException, uno::RuntimeException) 2033cdf0e10cSrcweir { 2034cdf0e10cSrcweir } 2035cdf0e10cSrcweir 2036cdf0e10cSrcweir // XTextRange 2037cdf0e10cSrcweir 2038cdf0e10cSrcweir uno::Reference< text::XText > SAL_CALL SvxUnoTextBase::getText() 2039cdf0e10cSrcweir throw(uno::RuntimeException) 2040cdf0e10cSrcweir { 2041cdf0e10cSrcweir OGuard aGuard( Application::GetSolarMutex() ); 2042cdf0e10cSrcweir 2043cdf0e10cSrcweir if (GetEditSource()) 2044cdf0e10cSrcweir { 2045cdf0e10cSrcweir ESelection aSelection; 2046cdf0e10cSrcweir ::GetSelection( aSelection, GetEditSource()->GetTextForwarder() ); 2047cdf0e10cSrcweir ((SvxUnoTextBase*)this)->SetSelection( aSelection ); 2048cdf0e10cSrcweir } 2049cdf0e10cSrcweir 2050cdf0e10cSrcweir return (text::XText*)this; 2051cdf0e10cSrcweir } 2052cdf0e10cSrcweir 2053cdf0e10cSrcweir uno::Reference< text::XTextRange > SAL_CALL SvxUnoTextBase::getStart() 2054cdf0e10cSrcweir throw(uno::RuntimeException) 2055cdf0e10cSrcweir { 2056cdf0e10cSrcweir return SvxUnoTextRangeBase::getStart(); 2057cdf0e10cSrcweir } 2058cdf0e10cSrcweir 2059cdf0e10cSrcweir uno::Reference< text::XTextRange > SAL_CALL SvxUnoTextBase::getEnd() 2060cdf0e10cSrcweir throw(uno::RuntimeException) 2061cdf0e10cSrcweir { 2062cdf0e10cSrcweir return SvxUnoTextRangeBase::getEnd(); 2063cdf0e10cSrcweir } 2064cdf0e10cSrcweir 2065cdf0e10cSrcweir OUString SAL_CALL SvxUnoTextBase::getString() throw( uno::RuntimeException ) 2066cdf0e10cSrcweir { 2067cdf0e10cSrcweir return SvxUnoTextRangeBase::getString(); 2068cdf0e10cSrcweir } 2069cdf0e10cSrcweir 2070cdf0e10cSrcweir void SAL_CALL SvxUnoTextBase::setString( const OUString& aString ) throw(uno::RuntimeException) 2071cdf0e10cSrcweir { 2072cdf0e10cSrcweir SvxUnoTextRangeBase::setString(aString); 2073cdf0e10cSrcweir } 2074cdf0e10cSrcweir 2075cdf0e10cSrcweir 2076cdf0e10cSrcweir // XEnumerationAccess 2077cdf0e10cSrcweir uno::Reference< container::XEnumeration > SAL_CALL SvxUnoTextBase::createEnumeration() 2078cdf0e10cSrcweir throw(uno::RuntimeException) 2079cdf0e10cSrcweir { 2080cdf0e10cSrcweir OGuard aGuard( Application::GetSolarMutex() ); 2081cdf0e10cSrcweir 2082cdf0e10cSrcweir ESelection aSelection; 2083cdf0e10cSrcweir ::GetSelection( aSelection, GetEditSource()->GetTextForwarder() ); 2084cdf0e10cSrcweir SetSelection( aSelection ); 2085cdf0e10cSrcweir 2086cdf0e10cSrcweir uno::Reference< container::XEnumeration > xEnum( (container::XEnumeration*) new SvxUnoTextContentEnumeration( *this ) ); 2087cdf0e10cSrcweir return xEnum; 2088cdf0e10cSrcweir } 2089cdf0e10cSrcweir 2090cdf0e10cSrcweir // XElementAccess ( container::XEnumerationAccess ) 2091cdf0e10cSrcweir uno::Type SAL_CALL SvxUnoTextBase::getElementType( ) throw(uno::RuntimeException) 2092cdf0e10cSrcweir { 2093cdf0e10cSrcweir return ::getCppuType((const uno::Reference< text::XTextRange >*)0 ); 2094cdf0e10cSrcweir } 2095cdf0e10cSrcweir 2096cdf0e10cSrcweir sal_Bool SAL_CALL SvxUnoTextBase::hasElements( ) throw(uno::RuntimeException) 2097cdf0e10cSrcweir { 2098cdf0e10cSrcweir OGuard aGuard( Application::GetSolarMutex() ); 2099cdf0e10cSrcweir 2100cdf0e10cSrcweir if(GetEditSource()) 2101cdf0e10cSrcweir { 2102cdf0e10cSrcweir SvxTextForwarder* pForwarder = GetEditSource()->GetTextForwarder(); 2103cdf0e10cSrcweir if(pForwarder) 2104cdf0e10cSrcweir return pForwarder->GetParagraphCount() != 0; 2105cdf0e10cSrcweir } 2106cdf0e10cSrcweir 2107cdf0e10cSrcweir return sal_False; 2108cdf0e10cSrcweir } 2109cdf0e10cSrcweir 2110cdf0e10cSrcweir // text::XTextRangeMover 2111cdf0e10cSrcweir void SAL_CALL SvxUnoTextBase::moveTextRange( const uno::Reference< text::XTextRange >&, sal_Int16 ) 2112cdf0e10cSrcweir throw(uno::RuntimeException) 2113cdf0e10cSrcweir { 2114cdf0e10cSrcweir } 2115cdf0e10cSrcweir 2116cdf0e10cSrcweir void SvxPropertyValuesToItemSet( 2117cdf0e10cSrcweir SfxItemSet &rItemSet, 2118cdf0e10cSrcweir const uno::Sequence< beans::PropertyValue > rPropertyVaules, 2119cdf0e10cSrcweir const SfxItemPropertySet *pPropSet, 2120cdf0e10cSrcweir SvxTextForwarder *pForwarder /*needed for WID_NUMLEVEL*/, 2121cdf0e10cSrcweir sal_uInt16 nPara /*needed for WID_NUMLEVEL*/) 2122cdf0e10cSrcweir throw(lang::IllegalArgumentException, beans::UnknownPropertyException, uno::RuntimeException) 2123cdf0e10cSrcweir { 2124cdf0e10cSrcweir sal_Int32 nProps = rPropertyVaules.getLength(); 2125cdf0e10cSrcweir const beans::PropertyValue *pProps = rPropertyVaules.getConstArray(); 2126cdf0e10cSrcweir for (sal_Int32 i = 0; i < nProps; ++i) 2127cdf0e10cSrcweir { 2128cdf0e10cSrcweir const SfxItemPropertySimpleEntry *pEntry = pPropSet->getPropertyMap()->getByName( pProps[i].Name ); 2129cdf0e10cSrcweir if (pEntry) 2130cdf0e10cSrcweir { 2131cdf0e10cSrcweir // Note: there is no need to take special care of the properties 2132cdf0e10cSrcweir // TextField (EE_FEATURE_FIELD) and 2133cdf0e10cSrcweir // TextPortionType (WID_PORTIONTYPE) 2134cdf0e10cSrcweir // since they are read-only and thus are already taken care of below. 2135cdf0e10cSrcweir 2136cdf0e10cSrcweir if (pEntry->nFlags & beans::PropertyAttribute::READONLY) 2137cdf0e10cSrcweir // should be PropertyVetoException which is not yet defined for the new import API's functions 2138cdf0e10cSrcweir throw uno::RuntimeException( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Property is read-only: " ) ) + pProps[i].Name, static_cast < cppu::OWeakObject * > ( 0 ) ); 2139cdf0e10cSrcweir //throw PropertyVetoException ( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Property is read-only: " ) ) + pProps[i].Name, static_cast < cppu::OWeakObject * > ( 0 ) ); 2140cdf0e10cSrcweir 2141cdf0e10cSrcweir if (pEntry->nWID == WID_FONTDESC) 2142cdf0e10cSrcweir { 2143cdf0e10cSrcweir awt::FontDescriptor aDesc; 2144cdf0e10cSrcweir if (pProps[i].Value >>= aDesc) 2145cdf0e10cSrcweir SvxUnoFontDescriptor::FillItemSet( aDesc, rItemSet ); 2146cdf0e10cSrcweir } 2147cdf0e10cSrcweir else if (pEntry->nWID == WID_NUMLEVEL) 2148cdf0e10cSrcweir { 2149cdf0e10cSrcweir if (pForwarder) 2150cdf0e10cSrcweir { 2151cdf0e10cSrcweir sal_Int16 nLevel = -1; 2152cdf0e10cSrcweir pProps[i].Value >>= nLevel; 2153cdf0e10cSrcweir 2154cdf0e10cSrcweir // #101004# Call interface method instead of unsafe cast 2155cdf0e10cSrcweir if (!pForwarder->SetDepth( nPara, nLevel )) 2156cdf0e10cSrcweir throw lang::IllegalArgumentException(); 2157cdf0e10cSrcweir } 2158cdf0e10cSrcweir } 2159cdf0e10cSrcweir else if (pEntry->nWID == WID_NUMBERINGSTARTVALUE ) 2160cdf0e10cSrcweir { 2161cdf0e10cSrcweir if( pForwarder ) 2162cdf0e10cSrcweir { 2163cdf0e10cSrcweir sal_Int16 nStartValue = -1; 2164cdf0e10cSrcweir if( !(pProps[i].Value >>= nStartValue) ) 2165cdf0e10cSrcweir throw lang::IllegalArgumentException(); 2166cdf0e10cSrcweir 2167cdf0e10cSrcweir pForwarder->SetNumberingStartValue( nPara, nStartValue ); 2168cdf0e10cSrcweir } 2169cdf0e10cSrcweir } 2170cdf0e10cSrcweir else if (pEntry->nWID == WID_PARAISNUMBERINGRESTART ) 2171cdf0e10cSrcweir { 2172cdf0e10cSrcweir if( pForwarder ) 2173cdf0e10cSrcweir { 2174cdf0e10cSrcweir sal_Bool bParaIsNumberingRestart = sal_False; 2175cdf0e10cSrcweir if( !(pProps[i].Value >>= bParaIsNumberingRestart) ) 2176cdf0e10cSrcweir throw lang::IllegalArgumentException(); 2177cdf0e10cSrcweir 2178cdf0e10cSrcweir pForwarder->SetParaIsNumberingRestart( nPara, bParaIsNumberingRestart ); 2179cdf0e10cSrcweir } 2180cdf0e10cSrcweir } 2181cdf0e10cSrcweir else 2182cdf0e10cSrcweir pPropSet->setPropertyValue( pProps[i].Name, pProps[i].Value, rItemSet ); 2183cdf0e10cSrcweir } 2184cdf0e10cSrcweir else 2185cdf0e10cSrcweir throw beans::UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + pProps[i].Name, static_cast < cppu::OWeakObject * > ( 0 ) ); 2186cdf0e10cSrcweir } 2187cdf0e10cSrcweir } 2188cdf0e10cSrcweir 2189cdf0e10cSrcweir // com::sun::star::text::XParagraphAppend (new import API) 2190cdf0e10cSrcweir uno::Reference< text::XTextRange > SAL_CALL SvxUnoTextBase::appendParagraph( 2191cdf0e10cSrcweir const uno::Sequence< beans::PropertyValue >& rCharAndParaProps ) 2192cdf0e10cSrcweir throw (lang::IllegalArgumentException, beans::UnknownPropertyException, uno::RuntimeException) 2193cdf0e10cSrcweir { 2194cdf0e10cSrcweir OGuard aGuard( Application::GetSolarMutex() ); 2195cdf0e10cSrcweir uno::Reference< text::XTextRange > xRet; 2196cdf0e10cSrcweir SvxEditSource *pEditSource = GetEditSource(); 2197cdf0e10cSrcweir SvxTextForwarder *pTextForwarder = pEditSource ? pEditSource->GetTextForwarder() : 0; 2198cdf0e10cSrcweir if (pTextForwarder) 2199cdf0e10cSrcweir { 2200c2eaa082SDamjan Jovanovic sal_uInt32 nParaCount = pTextForwarder->GetParagraphCount(); 2201cdf0e10cSrcweir DBG_ASSERT( nParaCount > 0, "paragraph count is 0 or negative" ); 2202cdf0e10cSrcweir pTextForwarder->AppendParagraph(); 2203cdf0e10cSrcweir 2204cdf0e10cSrcweir // set properties for new appended (now last) paragraph 2205cdf0e10cSrcweir ESelection aSel( nParaCount, 0, nParaCount, 0 ); 2206cdf0e10cSrcweir SfxItemSet aItemSet( *pTextForwarder->GetEmptyItemSetPtr() ); 2207cdf0e10cSrcweir SvxPropertyValuesToItemSet( aItemSet, rCharAndParaProps, 2208cdf0e10cSrcweir ImplGetSvxUnoOutlinerTextCursorSfxPropertySet(), 2209cdf0e10cSrcweir pTextForwarder, 2210cdf0e10cSrcweir nParaCount ); 2211cdf0e10cSrcweir pTextForwarder->QuickSetAttribs( aItemSet, aSel ); 2212cdf0e10cSrcweir pEditSource->UpdateData(); 2213cdf0e10cSrcweir SvxUnoTextRange* pRange = new SvxUnoTextRange( *this ); 2214cdf0e10cSrcweir xRet = pRange; 2215cdf0e10cSrcweir pRange->SetSelection( aSel ); 2216cdf0e10cSrcweir } 2217cdf0e10cSrcweir return xRet; 2218cdf0e10cSrcweir } 2219cdf0e10cSrcweir 2220cdf0e10cSrcweir uno::Reference< text::XTextRange > SAL_CALL SvxUnoTextBase::finishParagraph( 2221cdf0e10cSrcweir const uno::Sequence< beans::PropertyValue >& rCharAndParaProps ) 2222cdf0e10cSrcweir throw (lang::IllegalArgumentException, beans::UnknownPropertyException, uno::RuntimeException) 2223cdf0e10cSrcweir { 2224cdf0e10cSrcweir OGuard aGuard( Application::GetSolarMutex() ); 2225cdf0e10cSrcweir 2226cdf0e10cSrcweir uno::Reference< text::XTextRange > xRet; 2227cdf0e10cSrcweir SvxEditSource *pEditSource = GetEditSource(); 2228cdf0e10cSrcweir SvxTextForwarder *pTextForwarder = pEditSource ? pEditSource->GetTextForwarder() : 0; 2229cdf0e10cSrcweir if (pTextForwarder) 2230cdf0e10cSrcweir { 2231c2eaa082SDamjan Jovanovic sal_uInt32 nParaCount = pTextForwarder->GetParagraphCount(); 2232cdf0e10cSrcweir DBG_ASSERT( nParaCount > 0, "paragraph count is 0 or negative" ); 2233cdf0e10cSrcweir pTextForwarder->AppendParagraph(); 2234cdf0e10cSrcweir 2235cdf0e10cSrcweir // set properties for the previously last paragraph 2236cdf0e10cSrcweir sal_uInt16 nPara = nParaCount - 1; 2237cdf0e10cSrcweir ESelection aSel( nPara, 0, nPara, 0 ); 2238cdf0e10cSrcweir SfxItemSet aItemSet( *pTextForwarder->GetEmptyItemSetPtr() ); 2239cdf0e10cSrcweir SvxPropertyValuesToItemSet( aItemSet, rCharAndParaProps, 2240cdf0e10cSrcweir ImplGetSvxUnoOutlinerTextCursorSfxPropertySet(), pTextForwarder, nPara ); 2241cdf0e10cSrcweir pTextForwarder->QuickSetAttribs( aItemSet, aSel ); 2242cdf0e10cSrcweir pEditSource->UpdateData(); 2243cdf0e10cSrcweir SvxUnoTextRange* pRange = new SvxUnoTextRange( *this ); 2244cdf0e10cSrcweir xRet = pRange; 2245cdf0e10cSrcweir pRange->SetSelection( aSel ); 2246cdf0e10cSrcweir } 2247cdf0e10cSrcweir return xRet; 2248cdf0e10cSrcweir } 2249cdf0e10cSrcweir 2250cdf0e10cSrcweir // com::sun::star::text::XTextPortionAppend (new import API) 2251cdf0e10cSrcweir uno::Reference< text::XTextRange > SAL_CALL SvxUnoTextBase::appendTextPortion( 2252cdf0e10cSrcweir const ::rtl::OUString& rText, 2253cdf0e10cSrcweir const uno::Sequence< beans::PropertyValue >& rCharAndParaProps ) 2254cdf0e10cSrcweir throw (lang::IllegalArgumentException, beans::UnknownPropertyException, uno::RuntimeException) 2255cdf0e10cSrcweir { 2256cdf0e10cSrcweir OGuard aGuard( Application::GetSolarMutex() ); 2257cdf0e10cSrcweir 2258cdf0e10cSrcweir SvxEditSource *pEditSource = GetEditSource(); 2259cdf0e10cSrcweir SvxTextForwarder *pTextForwarder = pEditSource ? pEditSource->GetTextForwarder() : 0; 2260cdf0e10cSrcweir uno::Reference< text::XTextRange > xRet; 2261cdf0e10cSrcweir if (pTextForwarder) 2262cdf0e10cSrcweir { 2263c2eaa082SDamjan Jovanovic sal_uInt32 nParaCount = pTextForwarder->GetParagraphCount(); 2264cdf0e10cSrcweir DBG_ASSERT( nParaCount > 0, "paragraph count is 0 or negative" ); 2265c2eaa082SDamjan Jovanovic sal_uInt32 nPara = nParaCount - 1; 2266cdf0e10cSrcweir SfxItemSet aSet( pTextForwarder->GetParaAttribs( nPara ) ); 2267cdf0e10cSrcweir xub_StrLen nStart = pTextForwarder->AppendTextPortion( nPara, rText, aSet ); 2268cdf0e10cSrcweir pEditSource->UpdateData(); 2269cdf0e10cSrcweir xub_StrLen nEnd = pTextForwarder->GetTextLen( nPara ); 2270cdf0e10cSrcweir 2271cdf0e10cSrcweir // set properties for the new text portion 2272cdf0e10cSrcweir ESelection aSel( nPara, nStart, nPara, nEnd ); 2273cdf0e10cSrcweir pTextForwarder->RemoveAttribs( aSel, sal_False, 0 ); 2274cdf0e10cSrcweir pEditSource->UpdateData(); 2275cdf0e10cSrcweir 2276cdf0e10cSrcweir SfxItemSet aItemSet( *pTextForwarder->GetEmptyItemSetPtr() ); 2277cdf0e10cSrcweir SvxPropertyValuesToItemSet( aItemSet, rCharAndParaProps, 2278cdf0e10cSrcweir ImplGetSvxTextPortionSfxPropertySet(), pTextForwarder, nPara ); 2279cdf0e10cSrcweir pTextForwarder->QuickSetAttribs( aItemSet, aSel ); 2280cdf0e10cSrcweir SvxUnoTextRange* pRange = new SvxUnoTextRange( *this ); 2281cdf0e10cSrcweir xRet = pRange; 2282cdf0e10cSrcweir pRange->SetSelection( aSel ); 2283cdf0e10cSrcweir const beans::PropertyValue* pProps = rCharAndParaProps.getConstArray(); 2284cdf0e10cSrcweir for( sal_Int32 nProp = 0; nProp < rCharAndParaProps.getLength(); ++nProp ) 2285cdf0e10cSrcweir pRange->setPropertyValue( pProps[nProp].Name, pProps[nProp].Value ); 2286cdf0e10cSrcweir } 2287cdf0e10cSrcweir return xRet; 2288cdf0e10cSrcweir } 2289cdf0e10cSrcweir /*-- 25.03.2008 08:16:09--------------------------------------------------- 2290cdf0e10cSrcweir 2291cdf0e10cSrcweir -----------------------------------------------------------------------*/ 2292cdf0e10cSrcweir void SvxUnoTextBase::copyText( 2293cdf0e10cSrcweir const uno::Reference< text::XTextCopy >& xSource ) throw ( uno::RuntimeException ) 2294cdf0e10cSrcweir { 2295cdf0e10cSrcweir OGuard aGuard( Application::GetSolarMutex() ); 2296cdf0e10cSrcweir uno::Reference< lang::XUnoTunnel > xUT( xSource, uno::UNO_QUERY ); 2297cdf0e10cSrcweir SvxEditSource *pEditSource = GetEditSource(); 2298cdf0e10cSrcweir SvxTextForwarder *pTextForwarder = pEditSource ? pEditSource->GetTextForwarder() : 0; 2299cdf0e10cSrcweir if( !pTextForwarder ) 2300cdf0e10cSrcweir return; 2301cdf0e10cSrcweir if( xUT.is() ) 2302cdf0e10cSrcweir { 2303cdf0e10cSrcweir SvxUnoTextBase* pSource = reinterpret_cast<SvxUnoTextBase*>(sal::static_int_cast<sal_uIntPtr>( 2304cdf0e10cSrcweir xUT->getSomething( SvxUnoTextBase::getUnoTunnelId()))); 2305cdf0e10cSrcweir SvxEditSource *pSourceEditSource = pSource->GetEditSource(); 2306cdf0e10cSrcweir SvxTextForwarder *pSourceTextForwarder = pSourceEditSource ? pSourceEditSource->GetTextForwarder() : 0; 2307cdf0e10cSrcweir if( pSourceTextForwarder ) 2308cdf0e10cSrcweir { 2309cdf0e10cSrcweir pTextForwarder->CopyText( *pSourceTextForwarder ); 2310cdf0e10cSrcweir pEditSource->UpdateData(); 2311cdf0e10cSrcweir } 2312cdf0e10cSrcweir } 2313cdf0e10cSrcweir else 2314cdf0e10cSrcweir { 2315cdf0e10cSrcweir uno::Reference< text::XText > xSourceText( xSource, uno::UNO_QUERY ); 2316cdf0e10cSrcweir if( xSourceText.is() ) 2317cdf0e10cSrcweir { 2318cdf0e10cSrcweir setString( xSourceText->getString() ); 2319cdf0e10cSrcweir } 2320cdf0e10cSrcweir } 2321cdf0e10cSrcweir } 2322cdf0e10cSrcweir 2323cdf0e10cSrcweir // lang::XServiceInfo 2324cdf0e10cSrcweir OUString SAL_CALL SvxUnoTextBase::getImplementationName() 2325cdf0e10cSrcweir throw(uno::RuntimeException) 2326cdf0e10cSrcweir { 2327cdf0e10cSrcweir return OUString(RTL_CONSTASCII_USTRINGPARAM("SvxUnoTextBase")); 2328cdf0e10cSrcweir } 2329cdf0e10cSrcweir 2330cdf0e10cSrcweir uno::Sequence< OUString > SAL_CALL SvxUnoTextBase::getSupportedServiceNames( ) 2331cdf0e10cSrcweir throw(uno::RuntimeException) 2332cdf0e10cSrcweir { 2333cdf0e10cSrcweir return getSupportedServiceNames_Static(); 2334cdf0e10cSrcweir } 2335cdf0e10cSrcweir 2336cdf0e10cSrcweir uno::Sequence< OUString > SAL_CALL SvxUnoTextBase::getSupportedServiceNames_Static( ) 2337cdf0e10cSrcweir SAL_THROW(()) 2338cdf0e10cSrcweir { 2339cdf0e10cSrcweir uno::Sequence< OUString > aSeq( SvxUnoTextRangeBase::getSupportedServiceNames_Static() ); 2340cdf0e10cSrcweir comphelper::ServiceInfoHelper::addToSequence( aSeq, 1, "com.sun.star.text.Text" ); 2341cdf0e10cSrcweir return aSeq; 2342cdf0e10cSrcweir } 2343cdf0e10cSrcweir 2344cdf0e10cSrcweir const uno::Sequence< sal_Int8 > & SvxUnoTextBase::getUnoTunnelId() throw() 2345cdf0e10cSrcweir { 2346cdf0e10cSrcweir static uno::Sequence< sal_Int8 > * pSeq = 0; 2347cdf0e10cSrcweir if( !pSeq ) 2348cdf0e10cSrcweir { 2349cdf0e10cSrcweir ::osl::Guard< ::osl::Mutex > aGuard( ::osl::Mutex::getGlobalMutex() ); 2350cdf0e10cSrcweir if( !pSeq ) 2351cdf0e10cSrcweir { 2352cdf0e10cSrcweir static uno::Sequence< sal_Int8 > aSeq( 16 ); 2353cdf0e10cSrcweir rtl_createUuid( (sal_uInt8*)aSeq.getArray(), 0, sal_True ); 2354cdf0e10cSrcweir pSeq = &aSeq; 2355cdf0e10cSrcweir } 2356cdf0e10cSrcweir } 2357cdf0e10cSrcweir return *pSeq; 2358cdf0e10cSrcweir } 2359cdf0e10cSrcweir 2360cdf0e10cSrcweir SvxUnoTextBase* SvxUnoTextBase::getImplementation( const uno::Reference< uno::XInterface >& xInt ) 2361cdf0e10cSrcweir { 2362cdf0e10cSrcweir uno::Reference< lang::XUnoTunnel > xUT( xInt, uno::UNO_QUERY ); 2363cdf0e10cSrcweir if( xUT.is() ) 2364cdf0e10cSrcweir return reinterpret_cast<SvxUnoTextBase*>(sal::static_int_cast<sal_uIntPtr>(xUT->getSomething( SvxUnoTextBase::getUnoTunnelId()))); 2365cdf0e10cSrcweir else 2366cdf0e10cSrcweir return NULL; 2367cdf0e10cSrcweir } 2368cdf0e10cSrcweir 2369cdf0e10cSrcweir sal_Int64 SAL_CALL SvxUnoTextBase::getSomething( const uno::Sequence< sal_Int8 >& rId ) throw(uno::RuntimeException) \ 2370cdf0e10cSrcweir { 2371cdf0e10cSrcweir if( rId.getLength() == 16 && 0 == rtl_compareMemory( getUnoTunnelId().getConstArray(), 2372cdf0e10cSrcweir rId.getConstArray(), 16 ) ) 2373cdf0e10cSrcweir { 2374cdf0e10cSrcweir return sal::static_int_cast<sal_Int64>(reinterpret_cast<sal_uIntPtr>(this)); 2375cdf0e10cSrcweir } 2376cdf0e10cSrcweir else 2377cdf0e10cSrcweir { 2378cdf0e10cSrcweir return SvxUnoTextRangeBase::getSomething( rId ); 2379cdf0e10cSrcweir } 2380cdf0e10cSrcweir } 2381cdf0e10cSrcweir 2382cdf0e10cSrcweir // -------------------------------------------------------------------- 2383cdf0e10cSrcweir 2384cdf0e10cSrcweir SvxUnoText::SvxUnoText( ) throw() 2385cdf0e10cSrcweir { 2386cdf0e10cSrcweir } 2387cdf0e10cSrcweir 2388cdf0e10cSrcweir SvxUnoText::SvxUnoText( const SvxItemPropertySet* _pSet ) throw() 2389cdf0e10cSrcweir : SvxUnoTextBase( _pSet ) 2390cdf0e10cSrcweir { 2391cdf0e10cSrcweir } 2392cdf0e10cSrcweir 2393cdf0e10cSrcweir SvxUnoText::SvxUnoText( const SvxEditSource* pSource, const SvxItemPropertySet* _pSet, uno::Reference < text::XText > xParent ) throw() 2394cdf0e10cSrcweir : SvxUnoTextBase( pSource, _pSet, xParent ) 2395cdf0e10cSrcweir { 2396cdf0e10cSrcweir } 2397cdf0e10cSrcweir 2398cdf0e10cSrcweir SvxUnoText::SvxUnoText( const SvxUnoText& rText ) throw() 2399cdf0e10cSrcweir : SvxUnoTextBase( rText ) 2400cdf0e10cSrcweir , cppu::OWeakAggObject() 2401cdf0e10cSrcweir { 2402cdf0e10cSrcweir } 2403cdf0e10cSrcweir 2404cdf0e10cSrcweir SvxUnoText::~SvxUnoText() throw() 2405cdf0e10cSrcweir { 2406cdf0e10cSrcweir } 2407cdf0e10cSrcweir 2408cdf0e10cSrcweir uno::Sequence< uno::Type > SAL_CALL getStaticTypes() throw() 2409cdf0e10cSrcweir { 2410cdf0e10cSrcweir return SvxUnoTextBase::getStaticTypes(); 2411cdf0e10cSrcweir } 2412cdf0e10cSrcweir 2413cdf0e10cSrcweir // uno::XInterface 2414cdf0e10cSrcweir uno::Any SAL_CALL SvxUnoText::queryAggregation( const uno::Type & rType ) throw( uno::RuntimeException ) 2415cdf0e10cSrcweir { 2416cdf0e10cSrcweir uno::Any aAny( SvxUnoTextBase::queryAggregation( rType ) ); 2417cdf0e10cSrcweir if( !aAny.hasValue() ) 2418cdf0e10cSrcweir aAny = OWeakAggObject::queryAggregation( rType ); 2419cdf0e10cSrcweir 2420cdf0e10cSrcweir return aAny; 2421cdf0e10cSrcweir } 2422cdf0e10cSrcweir 2423cdf0e10cSrcweir uno::Any SAL_CALL SvxUnoText::queryInterface( const uno::Type & rType ) throw( uno::RuntimeException ) 2424cdf0e10cSrcweir { 2425cdf0e10cSrcweir return OWeakAggObject::queryInterface( rType ); 2426cdf0e10cSrcweir } 2427cdf0e10cSrcweir 2428cdf0e10cSrcweir void SAL_CALL SvxUnoText::acquire() throw( ) 2429cdf0e10cSrcweir { 2430cdf0e10cSrcweir OWeakAggObject::acquire(); 2431cdf0e10cSrcweir } 2432cdf0e10cSrcweir 2433cdf0e10cSrcweir void SAL_CALL SvxUnoText::release() throw( ) 2434cdf0e10cSrcweir { 2435cdf0e10cSrcweir OWeakAggObject::release(); 2436cdf0e10cSrcweir } 2437cdf0e10cSrcweir 2438cdf0e10cSrcweir // lang::XTypeProvider 2439cdf0e10cSrcweir uno::Sequence< uno::Type > SAL_CALL SvxUnoText::getTypes( ) throw( uno::RuntimeException ) 2440cdf0e10cSrcweir { 2441cdf0e10cSrcweir return SvxUnoTextBase::getTypes(); 2442cdf0e10cSrcweir } 2443cdf0e10cSrcweir 2444cdf0e10cSrcweir uno::Sequence< sal_Int8 > SAL_CALL SvxUnoText::getImplementationId( ) throw( uno::RuntimeException ) 2445cdf0e10cSrcweir { 2446cdf0e10cSrcweir static uno::Sequence< sal_Int8 > aId; 2447cdf0e10cSrcweir if( aId.getLength() == 0 ) 2448cdf0e10cSrcweir { 2449cdf0e10cSrcweir aId.realloc( 16 ); 2450cdf0e10cSrcweir rtl_createUuid( (sal_uInt8 *)aId.getArray(), 0, sal_True ); 2451cdf0e10cSrcweir } 2452cdf0e10cSrcweir return aId; 2453cdf0e10cSrcweir } 2454cdf0e10cSrcweir 2455cdf0e10cSrcweir SvxUnoText* SvxUnoText::getImplementation( const uno::Reference< uno::XInterface >& xInt ) 2456cdf0e10cSrcweir { 2457cdf0e10cSrcweir uno::Reference< lang::XUnoTunnel > xUT( xInt, uno::UNO_QUERY ); 2458cdf0e10cSrcweir if( xUT.is() ) 2459cdf0e10cSrcweir return reinterpret_cast<SvxUnoText*>(sal::static_int_cast<sal_uIntPtr>(xUT->getSomething( SvxUnoText::getUnoTunnelId()))); 2460cdf0e10cSrcweir else 2461cdf0e10cSrcweir return NULL; 2462cdf0e10cSrcweir } 2463cdf0e10cSrcweir 2464cdf0e10cSrcweir const uno::Sequence< sal_Int8 > & SvxUnoText::getUnoTunnelId() throw() 2465cdf0e10cSrcweir { 2466cdf0e10cSrcweir static uno::Sequence< sal_Int8 > * pSeq = 0; 2467cdf0e10cSrcweir if( !pSeq ) 2468cdf0e10cSrcweir { 2469cdf0e10cSrcweir ::osl::Guard< ::osl::Mutex > aGuard( ::osl::Mutex::getGlobalMutex() ); 2470cdf0e10cSrcweir if( !pSeq ) 2471cdf0e10cSrcweir { 2472cdf0e10cSrcweir static uno::Sequence< sal_Int8 > aSeq( 16 ); 2473cdf0e10cSrcweir rtl_createUuid( (sal_uInt8*)aSeq.getArray(), 0, sal_True ); 2474cdf0e10cSrcweir pSeq = &aSeq; 2475cdf0e10cSrcweir } 2476cdf0e10cSrcweir } 2477cdf0e10cSrcweir return *pSeq; 2478cdf0e10cSrcweir } 2479cdf0e10cSrcweir 2480cdf0e10cSrcweir sal_Int64 SAL_CALL SvxUnoText::getSomething( const uno::Sequence< sal_Int8 >& rId ) throw(uno::RuntimeException) \ 2481cdf0e10cSrcweir { 2482cdf0e10cSrcweir if( rId.getLength() == 16 && 0 == rtl_compareMemory( getUnoTunnelId().getConstArray(), 2483cdf0e10cSrcweir rId.getConstArray(), 16 ) ) 2484cdf0e10cSrcweir { 2485cdf0e10cSrcweir return sal::static_int_cast<sal_Int64>(reinterpret_cast<sal_uIntPtr>(this)); 2486cdf0e10cSrcweir } 2487cdf0e10cSrcweir else 2488cdf0e10cSrcweir { 2489cdf0e10cSrcweir return SvxUnoTextBase::getSomething( rId ); 2490cdf0e10cSrcweir } 2491cdf0e10cSrcweir } 2492cdf0e10cSrcweir 2493cdf0e10cSrcweir 2494cdf0e10cSrcweir // -------------------------------------------------------------------- 2495cdf0e10cSrcweir 2496cdf0e10cSrcweir SvxDummyTextSource::~SvxDummyTextSource() 2497cdf0e10cSrcweir { 2498cdf0e10cSrcweir }; 2499cdf0e10cSrcweir 2500cdf0e10cSrcweir SvxEditSource* SvxDummyTextSource::Clone() const 2501cdf0e10cSrcweir { 2502cdf0e10cSrcweir return new SvxDummyTextSource(); 2503cdf0e10cSrcweir } 2504cdf0e10cSrcweir 2505cdf0e10cSrcweir SvxTextForwarder* SvxDummyTextSource::GetTextForwarder() 2506cdf0e10cSrcweir { 2507cdf0e10cSrcweir return this; 2508cdf0e10cSrcweir } 2509cdf0e10cSrcweir 2510cdf0e10cSrcweir void SvxDummyTextSource::UpdateData() 2511cdf0e10cSrcweir { 2512cdf0e10cSrcweir } 2513cdf0e10cSrcweir 2514c2eaa082SDamjan Jovanovic sal_uInt32 SvxDummyTextSource::GetParagraphCount() const 2515cdf0e10cSrcweir { 2516cdf0e10cSrcweir return 0; 2517cdf0e10cSrcweir } 2518cdf0e10cSrcweir 25198ee1071cSDamjan Jovanovic sal_uInt16 SvxDummyTextSource::GetTextLen( sal_uInt32 ) const 2520cdf0e10cSrcweir { 2521cdf0e10cSrcweir return 0; 2522cdf0e10cSrcweir } 2523cdf0e10cSrcweir 2524cdf0e10cSrcweir String SvxDummyTextSource::GetText( const ESelection& ) const 2525cdf0e10cSrcweir { 2526cdf0e10cSrcweir return String(); 2527cdf0e10cSrcweir } 2528cdf0e10cSrcweir 2529cdf0e10cSrcweir SfxItemSet SvxDummyTextSource::GetAttribs( const ESelection&, sal_Bool ) const 2530cdf0e10cSrcweir { 2531cdf0e10cSrcweir // AW: Very dangerous: The former implementation used a SfxItemPool created on the 2532cdf0e10cSrcweir // fly which of course was deleted again ASAP. Thus, the returned SfxItemSet was using 2533cdf0e10cSrcweir // a deleted Pool by design. 2534cdf0e10cSrcweir return SfxItemSet(EditEngine::GetGlobalItemPool()); 2535cdf0e10cSrcweir } 2536cdf0e10cSrcweir 25379ec87cd3SDamjan Jovanovic SfxItemSet SvxDummyTextSource::GetParaAttribs( sal_uInt32 ) const 2538cdf0e10cSrcweir { 2539cdf0e10cSrcweir return GetAttribs(ESelection()); 2540cdf0e10cSrcweir } 2541cdf0e10cSrcweir 254236a46462SDamjan Jovanovic void SvxDummyTextSource::SetParaAttribs( sal_uInt32, const SfxItemSet& ) 2543cdf0e10cSrcweir { 2544cdf0e10cSrcweir } 2545cdf0e10cSrcweir 2546cdf0e10cSrcweir void SvxDummyTextSource::RemoveAttribs( const ESelection& , sal_Bool , sal_uInt16 ) 2547cdf0e10cSrcweir { 2548cdf0e10cSrcweir } 2549cdf0e10cSrcweir 2550*936080f7SDamjan Jovanovic void SvxDummyTextSource::GetPortions( sal_uInt32, SvUShorts& ) const 2551cdf0e10cSrcweir { 2552cdf0e10cSrcweir } 2553cdf0e10cSrcweir 2554cdf0e10cSrcweir sal_uInt16 SvxDummyTextSource::GetItemState( const ESelection&, sal_uInt16 ) const 2555cdf0e10cSrcweir { 2556cdf0e10cSrcweir return 0; 2557cdf0e10cSrcweir } 2558cdf0e10cSrcweir 2559cdf0e10cSrcweir sal_uInt16 SvxDummyTextSource::GetItemState( sal_uInt16, sal_uInt16 ) const 2560cdf0e10cSrcweir { 2561cdf0e10cSrcweir return 0; 2562cdf0e10cSrcweir } 2563cdf0e10cSrcweir 2564cdf0e10cSrcweir SfxItemPool* SvxDummyTextSource::GetPool() const 2565cdf0e10cSrcweir { 2566cdf0e10cSrcweir return NULL; 2567cdf0e10cSrcweir } 2568cdf0e10cSrcweir 2569cdf0e10cSrcweir void SvxDummyTextSource::QuickInsertText( const String&, const ESelection& ) 2570cdf0e10cSrcweir { 2571cdf0e10cSrcweir } 2572cdf0e10cSrcweir 2573cdf0e10cSrcweir void SvxDummyTextSource::QuickInsertField( const SvxFieldItem&, const ESelection& ) 2574cdf0e10cSrcweir { 2575cdf0e10cSrcweir } 2576cdf0e10cSrcweir 2577cdf0e10cSrcweir void SvxDummyTextSource::QuickSetAttribs( const SfxItemSet&, const ESelection& ) 2578cdf0e10cSrcweir { 2579cdf0e10cSrcweir } 2580cdf0e10cSrcweir 2581cdf0e10cSrcweir void SvxDummyTextSource::QuickInsertLineBreak( const ESelection& ) 2582cdf0e10cSrcweir { 2583cdf0e10cSrcweir }; 2584cdf0e10cSrcweir 25852cdd1ab0SDamjan Jovanovic XubString SvxDummyTextSource::CalcFieldValue( const SvxFieldItem&, sal_uInt32, sal_uInt16, Color*&, Color*& ) 2586cdf0e10cSrcweir { 2587cdf0e10cSrcweir return XubString(); 2588cdf0e10cSrcweir } 2589cdf0e10cSrcweir 2590cdf0e10cSrcweir void SvxDummyTextSource::FieldClicked( const SvxFieldItem&, sal_uInt16, xub_StrLen ) 2591cdf0e10cSrcweir { 2592cdf0e10cSrcweir } 2593cdf0e10cSrcweir 2594cdf0e10cSrcweir sal_Bool SvxDummyTextSource::IsValid() const 2595cdf0e10cSrcweir { 2596cdf0e10cSrcweir return sal_False; 2597cdf0e10cSrcweir } 2598cdf0e10cSrcweir 2599cdf0e10cSrcweir void SvxDummyTextSource::SetNotifyHdl( const Link& ) 2600cdf0e10cSrcweir { 2601cdf0e10cSrcweir } 2602cdf0e10cSrcweir 2603cdf0e10cSrcweir LanguageType SvxDummyTextSource::GetLanguage( sal_uInt16, sal_uInt16 ) const 2604cdf0e10cSrcweir { 2605cdf0e10cSrcweir return LANGUAGE_DONTKNOW; 2606cdf0e10cSrcweir } 2607cdf0e10cSrcweir 2608cdf0e10cSrcweir sal_uInt16 SvxDummyTextSource::GetFieldCount( sal_uInt16 ) const 2609cdf0e10cSrcweir { 2610cdf0e10cSrcweir return 0; 2611cdf0e10cSrcweir } 2612cdf0e10cSrcweir 2613cdf0e10cSrcweir EFieldInfo SvxDummyTextSource::GetFieldInfo( sal_uInt16, sal_uInt16 ) const 2614cdf0e10cSrcweir { 2615cdf0e10cSrcweir return EFieldInfo(); 2616cdf0e10cSrcweir } 2617cdf0e10cSrcweir 2618cdf0e10cSrcweir EBulletInfo SvxDummyTextSource::GetBulletInfo( sal_uInt16 ) const 2619cdf0e10cSrcweir { 2620cdf0e10cSrcweir return EBulletInfo(); 2621cdf0e10cSrcweir } 2622cdf0e10cSrcweir 2623cdf0e10cSrcweir Rectangle SvxDummyTextSource::GetCharBounds( sal_uInt16, sal_uInt16 ) const 2624cdf0e10cSrcweir { 2625cdf0e10cSrcweir return Rectangle(); 2626cdf0e10cSrcweir } 2627cdf0e10cSrcweir 2628cdf0e10cSrcweir Rectangle SvxDummyTextSource::GetParaBounds( sal_uInt16 ) const 2629cdf0e10cSrcweir { 2630cdf0e10cSrcweir return Rectangle(); 2631cdf0e10cSrcweir } 2632cdf0e10cSrcweir 2633cdf0e10cSrcweir MapMode SvxDummyTextSource::GetMapMode() const 2634cdf0e10cSrcweir { 2635cdf0e10cSrcweir return MapMode(); 2636cdf0e10cSrcweir } 2637cdf0e10cSrcweir 2638cdf0e10cSrcweir OutputDevice* SvxDummyTextSource::GetRefDevice() const 2639cdf0e10cSrcweir { 2640cdf0e10cSrcweir return NULL; 2641cdf0e10cSrcweir } 2642cdf0e10cSrcweir 2643cdf0e10cSrcweir sal_Bool SvxDummyTextSource::GetIndexAtPoint( const Point&, sal_uInt16&, sal_uInt16& ) const 2644cdf0e10cSrcweir { 2645cdf0e10cSrcweir return sal_False; 2646cdf0e10cSrcweir } 2647cdf0e10cSrcweir 2648cdf0e10cSrcweir sal_Bool SvxDummyTextSource::GetWordIndices( sal_uInt16, sal_uInt16, sal_uInt16&, sal_uInt16& ) const 2649cdf0e10cSrcweir { 2650cdf0e10cSrcweir return sal_False; 2651cdf0e10cSrcweir } 2652cdf0e10cSrcweir 26539d9bf804SDamjan Jovanovic sal_Bool SvxDummyTextSource::GetAttributeRun( sal_uInt16&, sal_uInt16&, sal_uInt32, sal_uInt16, sal_Bool ) const 2654cdf0e10cSrcweir { 2655cdf0e10cSrcweir return sal_False; 2656cdf0e10cSrcweir } 2657cdf0e10cSrcweir 2658cdf0e10cSrcweir sal_uInt16 SvxDummyTextSource::GetLineCount( sal_uInt16 ) const 2659cdf0e10cSrcweir { 2660cdf0e10cSrcweir return 0; 2661cdf0e10cSrcweir } 2662cdf0e10cSrcweir 2663cdf0e10cSrcweir sal_uInt16 SvxDummyTextSource::GetLineLen( sal_uInt16, sal_uInt16 ) const 2664cdf0e10cSrcweir { 2665cdf0e10cSrcweir return 0; 2666cdf0e10cSrcweir } 2667cdf0e10cSrcweir 2668cdf0e10cSrcweir void SvxDummyTextSource::GetLineBoundaries( /*out*/sal_uInt16 &rStart, /*out*/sal_uInt16 &rEnd, sal_uInt16 /*nParagraph*/, sal_uInt16 /*nLine*/ ) const 2669cdf0e10cSrcweir { 2670cdf0e10cSrcweir rStart = rEnd = 0; 2671cdf0e10cSrcweir } 2672cdf0e10cSrcweir 2673cdf0e10cSrcweir sal_uInt16 SvxDummyTextSource::GetLineNumberAtIndex( sal_uInt16 /*nPara*/, sal_uInt16 /*nIndex*/ ) const 2674cdf0e10cSrcweir { 2675cdf0e10cSrcweir return 0; 2676cdf0e10cSrcweir } 2677cdf0e10cSrcweir 2678cdf0e10cSrcweir sal_Bool SvxDummyTextSource::QuickFormatDoc( sal_Bool ) 2679cdf0e10cSrcweir { 2680cdf0e10cSrcweir return sal_False; 2681cdf0e10cSrcweir } 2682cdf0e10cSrcweir 2683cdf0e10cSrcweir sal_Int16 SvxDummyTextSource::GetDepth( sal_uInt16 ) const 2684cdf0e10cSrcweir { 2685cdf0e10cSrcweir return -1; 2686cdf0e10cSrcweir } 2687cdf0e10cSrcweir 2688cdf0e10cSrcweir sal_Bool SvxDummyTextSource::SetDepth( sal_uInt16, sal_Int16 nNewDepth ) 2689cdf0e10cSrcweir { 2690cdf0e10cSrcweir return nNewDepth == 0 ? sal_True : sal_False; 2691cdf0e10cSrcweir } 2692cdf0e10cSrcweir 2693cdf0e10cSrcweir sal_Bool SvxDummyTextSource::Delete( const ESelection& ) 2694cdf0e10cSrcweir { 2695cdf0e10cSrcweir return sal_False; 2696cdf0e10cSrcweir } 2697cdf0e10cSrcweir 2698cdf0e10cSrcweir sal_Bool SvxDummyTextSource::InsertText( const String&, const ESelection& ) 2699cdf0e10cSrcweir { 2700cdf0e10cSrcweir return sal_False; 2701cdf0e10cSrcweir } 2702cdf0e10cSrcweir 2703cdf0e10cSrcweir const SfxItemSet * SvxDummyTextSource::GetEmptyItemSetPtr() 2704cdf0e10cSrcweir { 2705cdf0e10cSrcweir return 0; 2706cdf0e10cSrcweir } 2707cdf0e10cSrcweir 2708cdf0e10cSrcweir void SvxDummyTextSource::AppendParagraph() 2709cdf0e10cSrcweir { 2710cdf0e10cSrcweir } 2711cdf0e10cSrcweir 2712cdf0e10cSrcweir xub_StrLen SvxDummyTextSource::AppendTextPortion( sal_uInt16, const String &, const SfxItemSet & ) 2713cdf0e10cSrcweir { 2714cdf0e10cSrcweir return 0; 2715cdf0e10cSrcweir } 2716cdf0e10cSrcweir 2717cdf0e10cSrcweir void SvxDummyTextSource::CopyText(const SvxTextForwarder& ) 2718cdf0e10cSrcweir { 2719cdf0e10cSrcweir } 2720cdf0e10cSrcweir 2721