1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: unoport.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sw.hxx"
36 #include <vos/mutex.hxx>
37 #include <vcl/svapp.hxx>
38 #include <svtools/itemprop.hxx>
39 #include <unocrsrhelper.hxx>
40 #include <unoport.hxx>
43 #include <unoprnms.hxx>
51 #include <fmtflcnt.hxx>
53 #include <com/sun/star/beans/PropertyAttribute.hpp>
54 #include <com/sun/star/beans/SetPropertyTolerantFailed.hpp>
55 #include <com/sun/star/beans/GetPropertyTolerantResult.hpp>
56 #include <com/sun/star/beans/TolerantPropertySetResultType.hpp>
58 using namespace ::com::sun::star
;
59 using ::rtl::OUString
;
62 /******************************************************************
64 ******************************************************************/
66 /*-- 11.12.98 09:56:52---------------------------------------------------
68 -----------------------------------------------------------------------*/
69 SwFmtFld
* SwXTextPortion::GetFldFmt(sal_Bool bInit
)
72 // initial wird es immer gesucht, danach nur noch, wenn es bereits existierte
73 SwUnoCrsr
* pUnoCrsr
= GetCrsr();
74 if(pUnoCrsr
&& (bInit
|| pFmtFld
))
76 SwTxtNode
*pNode
= pUnoCrsr
->GetPoint()->nNode
.GetNode().GetTxtNode();
77 SwTxtFld
*pTxtFld
= 0;
79 pTxtFld
= pNode
->GetTxtFld( pUnoCrsr
->Start()->nContent
);
81 pFmtFld
= pRet
= (SwFmtFld
*)&pTxtFld
->GetFld();
85 /*-- 11.12.98 09:56:55---------------------------------------------------
87 -----------------------------------------------------------------------*/
88 SwXTextPortion::SwXTextPortion(const SwUnoCrsr
* pPortionCrsr
,
89 uno::Reference
< text::XText
> const& rParent
,
90 SwTextPortionType eType
) :
91 aLstnrCntnr( (text::XTextRange
*)this),
92 m_pPropSet(aSwMapProvider
.GetPropertySet(
93 (PORTION_REDLINE_START
== eType
||
94 PORTION_REDLINE_END
== eType
) ?
95 PROPERTY_MAP_REDLINE_PORTION
: PROPERTY_MAP_TEXTPORTION_EXTENSIONS
)),
102 aFrameDepend(this, 0),
108 SwUnoCrsr
* pUnoCrsr
= pPortionCrsr
->GetDoc()->CreateUnoCrsr(*pPortionCrsr
->GetPoint());
109 if(pPortionCrsr
->HasMark())
112 *pUnoCrsr
->GetMark() = *pPortionCrsr
->GetMark();
116 if(ePortionType
== PORTION_FIELD
)
118 // else if(ePortionType == PORTION_FRAME)
121 /* -----------------24.03.99 16:30-------------------
123 * --------------------------------------------------*/
124 SwXTextPortion::SwXTextPortion(const SwUnoCrsr
* pPortionCrsr
,
125 uno::Reference
< text::XText
> const& rParent
,
127 aLstnrCntnr( (text::XTextRange
*)this),
128 m_pPropSet(aSwMapProvider
.GetPropertySet(PROPERTY_MAP_TEXTPORTION_EXTENSIONS
)),
129 xParentText(rParent
),
135 aFrameDepend(this, &rFmt
),
137 ePortionType(PORTION_FRAME
),
141 SwUnoCrsr
* pUnoCrsr
= pPortionCrsr
->GetDoc()->CreateUnoCrsr(*pPortionCrsr
->GetPoint());
142 if(pPortionCrsr
->HasMark())
145 *pUnoCrsr
->GetMark() = *pPortionCrsr
->GetMark();
150 /*-- 11.12.98 09:56:55---------------------------------------------------
152 -----------------------------------------------------------------------*/
153 SwXTextPortion::~SwXTextPortion()
155 vos::OGuard
aGuard(Application::GetSolarMutex());
156 SwUnoCrsr
* pUnoCrsr
= GetCrsr();
163 /*-- 11.12.98 09:56:56---------------------------------------------------
165 -----------------------------------------------------------------------*/
166 uno::Reference
< text::XText
> SwXTextPortion::getText(void) throw( uno::RuntimeException
)
170 /*-- 11.12.98 09:56:56---------------------------------------------------
172 -----------------------------------------------------------------------*/
173 uno::Reference
< text::XTextRange
> SwXTextPortion::getStart(void) throw( uno::RuntimeException
)
175 vos::OGuard
aGuard(Application::GetSolarMutex());
176 uno::Reference
< text::XTextRange
> xRet
;
177 SwUnoCrsr
* pUnoCrsr
= ((SwXTextPortion
*)this)->GetCrsr();
180 SwPaM
aPam(*pUnoCrsr
->Start());
181 uno::Reference
< text::XText
> xParent
= getText();
182 xRet
= new SwXTextRange(aPam
, xParent
);
185 throw uno::RuntimeException();
188 /*-- 11.12.98 09:56:57---------------------------------------------------
190 -----------------------------------------------------------------------*/
191 uno::Reference
< text::XTextRange
> SwXTextPortion::getEnd(void) throw( uno::RuntimeException
)
193 vos::OGuard
aGuard(Application::GetSolarMutex());
194 uno::Reference
< text::XTextRange
> xRet
;
195 SwUnoCrsr
* pUnoCrsr
= ((SwXTextPortion
*)this)->GetCrsr();
198 SwPaM
aPam(*pUnoCrsr
->End());
199 uno::Reference
< text::XText
> xParent
= getText();
200 xRet
= new SwXTextRange(aPam
, xParent
);
203 throw uno::RuntimeException();
206 /*-- 11.12.98 09:56:57---------------------------------------------------
208 -----------------------------------------------------------------------*/
209 OUString
SwXTextPortion::getString(void) throw( uno::RuntimeException
)
211 vos::OGuard
aGuard(Application::GetSolarMutex());
213 SwUnoCrsr
* pUnoCrsr
= ((SwXTextPortion
*)this)->GetCrsr();
216 //TextPortions liegen immer innerhalb eines Absatzes
217 SwTxtNode
* pTxtNd
= pUnoCrsr
->GetNode()->GetTxtNode();
220 xub_StrLen nStt
= pUnoCrsr
->Start()->nContent
.GetIndex();
221 aTxt
= pTxtNd
->GetExpandTxt( nStt
,
222 pUnoCrsr
->End()->nContent
.GetIndex() - nStt
);
226 throw uno::RuntimeException();
229 /*-- 11.12.98 09:56:57---------------------------------------------------
231 -----------------------------------------------------------------------*/
232 void SwXTextPortion::setString(const OUString
& aString
) throw( uno::RuntimeException
)
234 vos::OGuard
aGuard(Application::GetSolarMutex());
235 SwUnoCrsr
* pUnoCrsr
= GetCrsr();
237 SwXTextCursor::SetString(*pUnoCrsr
, aString
);
239 throw uno::RuntimeException();
241 /*-- 11.12.98 09:56:57---------------------------------------------------
243 -----------------------------------------------------------------------*/
244 uno::Reference
< beans::XPropertySetInfo
> SwXTextPortion::getPropertySetInfo(void) throw( uno::RuntimeException
)
246 //! PropertySetInfo for text portion extensions
247 static uno::Reference
< beans::XPropertySetInfo
>
248 xTxtPorExtRef
= aSwMapProvider
.GetPropertySet(
249 PROPERTY_MAP_TEXTPORTION_EXTENSIONS
)->getPropertySetInfo();
250 //! PropertySetInfo for redline portions
251 static uno::Reference
< beans::XPropertySetInfo
>
252 xRedlPorRef
= aSwMapProvider
.GetPropertySet(
253 PROPERTY_MAP_REDLINE_PORTION
)->getPropertySetInfo();
255 return (PORTION_REDLINE_START
== ePortionType
||
256 PORTION_REDLINE_END
== ePortionType
) ? xRedlPorRef
: xTxtPorExtRef
;
258 /*-- 11.12.98 09:56:57---------------------------------------------------
260 -----------------------------------------------------------------------*/
261 void SwXTextPortion::setPropertyValue(const OUString
& rPropertyName
,
262 const uno::Any
& aValue
)
263 throw( beans::UnknownPropertyException
,
264 beans::PropertyVetoException
, lang::IllegalArgumentException
, lang::WrappedTargetException
, uno::RuntimeException
)
266 vos::OGuard
aGuard(Application::GetSolarMutex());
267 SwUnoCrsr
* pUnoCrsr
= ((SwXTextPortion
*)this)->GetCrsr();
270 SwXTextCursor::SetPropertyValue(*pUnoCrsr
, *m_pPropSet
, rPropertyName
, aValue
);
273 throw uno::RuntimeException();
275 /*-- 04.11.03 09:56:58---------------------------------------------------
277 -----------------------------------------------------------------------*/
278 void SwXTextPortion::GetPropertyValue(
280 const SfxItemPropertySimpleEntry
& rEntry
,
284 DBG_ASSERT( pUnoCrsr
, "UNO cursor missing" );
291 case FN_UNO_TEXT_PORTION_TYPE
:
294 switch (ePortionType
)
296 case PORTION_TEXT
: pRet
= "Text";break;
297 case PORTION_FIELD
: pRet
= "TextField";break;
298 case PORTION_FRAME
: pRet
= "Frame";break;
299 case PORTION_FOOTNOTE
: pRet
= "Footnote";break;
300 case PORTION_CONTROL_CHAR
: pRet
= "ControlCharacter";break;
301 case PORTION_REFMARK_START
:
302 case PORTION_REFMARK_END
: pRet
= SW_PROP_NAME_STR(UNO_NAME_REFERENCE_MARK
);break;
303 case PORTION_TOXMARK_START
:
304 case PORTION_TOXMARK_END
: pRet
= SW_PROP_NAME_STR(UNO_NAME_DOCUMENT_INDEX_MARK
);break;
305 case PORTION_BOOKMARK_START
:
306 case PORTION_BOOKMARK_END
: pRet
= SW_PROP_NAME_STR(UNO_NAME_BOOKMARK
);break;
307 case PORTION_REDLINE_START
:
308 case PORTION_REDLINE_END
: pRet
= "Redline";break;
309 case PORTION_RUBY_START
:
310 case PORTION_RUBY_END
: pRet
= "Ruby";break;
311 case PORTION_SOFT_PAGEBREAK
:pRet
= "SoftPageBreak";break;
312 case PORTION_FIELD_START
:pRet
= "TextFieldStart";break;
313 case PORTION_FIELD_END
:pRet
= "TextFieldEnd";break;
314 case PORTION_FIELD_START_END
:pRet
= "TextFieldStartEnd";break;
325 case FN_UNO_CONTROL_CHARACTER
:
327 if(PORTION_CONTROL_CHAR
== ePortionType
)
328 rVal
<<= (sal_Int16
) nControlChar
;
331 case FN_UNO_DOCUMENT_INDEX_MARK
:
334 case FN_UNO_REFERENCE_MARK
:
337 case FN_UNO_BOOKMARK
:
340 case FN_UNO_FOOTNOTE
:
343 case FN_UNO_IS_COLLAPSED
:
346 switch (ePortionType
)
348 case PORTION_REFMARK_START
:
349 case PORTION_BOOKMARK_START
:
350 case PORTION_TOXMARK_START
:
351 case PORTION_REFMARK_END
:
352 case PORTION_TOXMARK_END
:
353 case PORTION_BOOKMARK_END
:
354 case PORTION_REDLINE_START
:
355 case PORTION_REDLINE_END
:
356 case PORTION_RUBY_START
:
357 case PORTION_RUBY_END
:
358 case PORTION_FIELD_START
:
359 case PORTION_FIELD_END
:
360 rVal
.setValue(&bIsCollapsed
, ::getBooleanCppuType());
367 case FN_UNO_IS_START
:
369 BOOL bStart
= TRUE
, bPut
= TRUE
;
370 switch (ePortionType
)
372 case PORTION_REFMARK_START
:
373 case PORTION_BOOKMARK_START
:
374 case PORTION_TOXMARK_START
:
375 case PORTION_REDLINE_START
:
376 case PORTION_RUBY_START
:
377 case PORTION_FIELD_START
:
380 case PORTION_REFMARK_END
:
381 case PORTION_TOXMARK_END
:
382 case PORTION_BOOKMARK_END
:
383 case PORTION_REDLINE_END
:
384 case PORTION_RUBY_END
:
385 case PORTION_FIELD_END
:
392 rVal
.setValue(&bStart
, ::getBooleanCppuType());
395 case RES_TXTATR_CJK_RUBY
:
397 uno::Any
* pToSet
= 0;
398 switch(rEntry
.nMemberId
)
400 case MID_RUBY_TEXT
: pToSet
= pRubyText
; break;
401 case MID_RUBY_ADJUST
: pToSet
= pRubyAdjust
; break;
402 case MID_RUBY_CHARSTYLE
:pToSet
= pRubyStyle
; break;
403 case MID_RUBY_ABOVE
: pToSet
= pRubyIsAbove
; break;
410 beans::PropertyState eTemp
;
411 BOOL bDone
= SwUnoCursorHelper::getCrsrPropertyValue(
412 rEntry
, *pUnoCrsr
, &(rVal
), eTemp
);
417 pSet
= new SfxItemSet(pUnoCrsr
->GetDoc()->GetAttrPool(),
418 RES_CHRATR_BEGIN
, RES_FRMATR_END
- 1,
419 RES_UNKNOWNATR_CONTAINER
, RES_UNKNOWNATR_CONTAINER
,
420 RES_TXTATR_UNKNOWN_CONTAINER
, RES_TXTATR_UNKNOWN_CONTAINER
,
422 SwXTextCursor::GetCrsrAttr(*pUnoCrsr
, *pSet
);
424 m_pPropSet
->getPropertyValue(rEntry
, *pSet
, rVal
);
431 uno::Sequence
< uno::Any
> SAL_CALL
SwXTextPortion::GetPropertyValues_Impl(
432 const uno::Sequence
< OUString
>& rPropertyNames
)
433 throw( beans::UnknownPropertyException
, lang::WrappedTargetException
, uno::RuntimeException
)
435 sal_Int32 nLength
= rPropertyNames
.getLength();
436 const OUString
*pPropertyNames
= rPropertyNames
.getConstArray();
437 uno::Sequence
< uno::Any
> aValues(rPropertyNames
.getLength());
438 uno::Any
*pValues
= aValues
.getArray();
439 SwUnoCrsr
* pUnoCrsr
= ((SwXTextPortion
*)this)->GetCrsr();
442 SfxItemSet
*pSet
= 0;
443 // get startting pount fo the look-up, either the provided one or else
444 // from the beginning of the map
445 const SfxItemPropertyMap
* pMap
= m_pPropSet
->getPropertyMap();
446 for(sal_Int32 nProp
= 0; nProp
< nLength
; nProp
++)
448 const SfxItemPropertySimpleEntry
* pEntry
= pMap
->getByName(pPropertyNames
[nProp
]);
451 GetPropertyValue( pValues
[nProp
], *pEntry
, pUnoCrsr
, pSet
);
454 throw beans::UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + pPropertyNames
[nProp
], static_cast < cppu::OWeakObject
* > ( this ) );
459 throw uno::RuntimeException();
462 /*-- 11.12.98 09:56:58---------------------------------------------------
464 -----------------------------------------------------------------------*/
465 uno::Any
SwXTextPortion::getPropertyValue(
466 const OUString
& rPropertyName
)
467 throw( beans::UnknownPropertyException
, lang::WrappedTargetException
, uno::RuntimeException
)
469 vos::OGuard
aGuard(Application::GetSolarMutex());
470 uno::Sequence
< ::rtl::OUString
> aPropertyNames(1);
471 aPropertyNames
.getArray()[0] = rPropertyName
;
472 return GetPropertyValues_Impl(aPropertyNames
).getConstArray()[0];
474 /* -----------------------------02.04.01 11:44--------------------------------
476 ---------------------------------------------------------------------------*/
477 void SAL_CALL
SwXTextPortion::SetPropertyValues_Impl(
478 const uno::Sequence
< OUString
>& rPropertyNames
,
479 const uno::Sequence
< uno::Any
>& rValues
)
480 throw( beans::UnknownPropertyException
, beans::PropertyVetoException
, lang::IllegalArgumentException
,
481 lang::WrappedTargetException
, uno::RuntimeException
)
483 SwUnoCrsr
* pUnoCrsr
= ((SwXTextPortion
*)this)->GetCrsr();
486 const OUString
* pPropertyNames
= rPropertyNames
.getConstArray();
487 const uno::Any
* pValues
= rValues
.getConstArray();
488 const SfxItemPropertyMap
* pMap
= m_pPropSet
->getPropertyMap();
489 for(sal_Int32 nProp
= 0; nProp
< rPropertyNames
.getLength(); nProp
++)
491 const SfxItemPropertySimpleEntry
* pEntry
= pMap
->getByName(pPropertyNames
[nProp
]);
493 throw beans::UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + pPropertyNames
[nProp
], static_cast < cppu::OWeakObject
* > ( this ) );
494 if ( pEntry
->nFlags
& beans::PropertyAttribute::READONLY
)
495 throw beans::PropertyVetoException ( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Property is read-only: " ) ) + pPropertyNames
[nProp
], static_cast < cppu::OWeakObject
* > ( this ) );
497 SwXTextCursor::SetPropertyValue( *pUnoCrsr
, *m_pPropSet
, pPropertyNames
[nProp
], pValues
[nProp
]);
501 throw uno::RuntimeException();
504 void SwXTextPortion::setPropertyValues(
505 const uno::Sequence
< OUString
>& rPropertyNames
,
506 const uno::Sequence
< uno::Any
>& rValues
)
507 throw(beans::PropertyVetoException
, lang::IllegalArgumentException
,
508 lang::WrappedTargetException
, uno::RuntimeException
)
510 vos::OGuard
aGuard(Application::GetSolarMutex());
512 // workaround for bad designed API
515 SetPropertyValues_Impl( rPropertyNames
, rValues
);
517 catch (beans::UnknownPropertyException
&rException
)
519 // wrap the original (here not allowed) exception in
520 // a lang::WrappedTargetException that gets thrown instead.
521 lang::WrappedTargetException aWExc
;
522 aWExc
.TargetException
<<= rException
;
526 /* -----------------------------02.04.01 11:44--------------------------------
528 ---------------------------------------------------------------------------*/
529 uno::Sequence
< uno::Any
> SwXTextPortion::getPropertyValues(
530 const uno::Sequence
< OUString
>& rPropertyNames
)
531 throw(uno::RuntimeException
)
533 vos::OGuard
aGuard(Application::GetSolarMutex());
534 uno::Sequence
< uno::Any
> aValues
;
536 // workaround for bad designed API
539 aValues
= GetPropertyValues_Impl( rPropertyNames
);
541 catch (beans::UnknownPropertyException
&)
543 throw uno::RuntimeException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property exception caught" ) ), static_cast < cppu::OWeakObject
* > ( this ) );
545 catch (lang::WrappedTargetException
&)
547 throw uno::RuntimeException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "WrappedTargetException caught" ) ), static_cast < cppu::OWeakObject
* > ( this ) );
552 /* -----------------------------29.09.03 11:44--------------------------------
554 ---------------------------------------------------------------------------*/
556 /* disabled for #i46921# */
558 uno::Sequence
< beans::SetPropertyTolerantFailed
> SAL_CALL
SwXTextPortion::setPropertyValuesTolerant(
559 const uno::Sequence
< OUString
>& rPropertyNames
,
560 const uno::Sequence
< uno::Any
>& rValues
)
561 throw (lang::IllegalArgumentException
, uno::RuntimeException
)
563 vos::OGuard
aGuard(Application::GetSolarMutex());
565 if (rPropertyNames
.getLength() != rValues
.getLength())
566 throw lang::IllegalArgumentException();
567 SwUnoCrsr
* pUnoCrsr
= ((SwXTextPortion
*)this)->GetCrsr();
569 throw uno::RuntimeException();
571 sal_Int32 nProps
= rPropertyNames
.getLength();
572 const OUString
*pProp
= rPropertyNames
.getConstArray();
574 //sal_Int32 nVals = rValues.getLength();
575 const uno::Any
*pValue
= rValues
.getConstArray();
577 sal_Int32 nFailed
= 0;
578 uno::Sequence
< beans::SetPropertyTolerantFailed
> aFailed( nProps
);
579 beans::SetPropertyTolerantFailed
*pFailed
= aFailed
.getArray();
581 const SfxItemPropertyMap
* pPropMap
= m_pPropSet
->getPropertyMap();
584 for (sal_Int32 i
= 0; i
< nProps
; ++i
)
588 pFailed
[ nFailed
].Name
= pProp
[i
];
590 const SfxItemPropertySimpleEntry
* pEntry
= pPropMap
->getByName( pProp
[i
] );
592 pFailed
[ nFailed
++ ].Result
= beans::TolerantPropertySetResultType::UNKNOWN_PROPERTY
;
595 // set property value
596 // (compare to SwXTextPortion::setPropertyValues)
597 if (pEntry
->nFlags
& beans::PropertyAttribute::READONLY
)
598 pFailed
[ nFailed
++ ].Result
= beans::TolerantPropertySetResultType::PROPERTY_VETO
;
601 SwXTextCursor::SetPropertyValue(
602 *pUnoCrsr
, *m_pPropSet
, pProp
[i
], pValue
[i
] );
606 catch (beans::UnknownPropertyException
&)
608 // should not occur because property was searched for before
609 DBG_ERROR( "unexpected exception catched" );
610 pFailed
[ nFailed
++ ].Result
= beans::TolerantPropertySetResultType::UNKNOWN_PROPERTY
;
612 catch (lang::IllegalArgumentException
&)
614 pFailed
[ nFailed
++ ].Result
= beans::TolerantPropertySetResultType::ILLEGAL_ARGUMENT
;
616 catch (beans::PropertyVetoException
&)
618 pFailed
[ nFailed
++ ].Result
= beans::TolerantPropertySetResultType::PROPERTY_VETO
;
620 catch (lang::WrappedTargetException
&)
622 pFailed
[ nFailed
++ ].Result
= beans::TolerantPropertySetResultType::WRAPPED_TARGET
;
626 aFailed
.realloc( nFailed
);
631 uno::Sequence
< beans::GetPropertyTolerantResult
> SAL_CALL
SwXTextPortion::getPropertyValuesTolerant(
632 const uno::Sequence
< OUString
>& rPropertyNames
)
633 throw (uno::RuntimeException
)
635 vos::OGuard
aGuard( Application::GetSolarMutex() );
637 uno::Sequence
< beans::GetDirectPropertyTolerantResult
> aTmpRes(
638 GetPropertyValuesTolerant_Impl( rPropertyNames
, sal_False
) );
639 const beans::GetDirectPropertyTolerantResult
*pTmpRes
= aTmpRes
.getConstArray();
641 // copy temporary result to final result type
642 sal_Int32 nLen
= aTmpRes
.getLength();
643 uno::Sequence
< beans::GetPropertyTolerantResult
> aRes( nLen
);
644 beans::GetPropertyTolerantResult
*pRes
= aRes
.getArray();
645 for (sal_Int32 i
= 0; i
< nLen
; i
++)
646 *pRes
++ = *pTmpRes
++;
651 uno::Sequence
< beans::GetDirectPropertyTolerantResult
> SAL_CALL
SwXTextPortion::getDirectPropertyValuesTolerant(
652 const uno::Sequence
< OUString
>& rPropertyNames
)
653 throw (uno::RuntimeException
)
655 vos::OGuard
aGuard( Application::GetSolarMutex() );
656 return GetPropertyValuesTolerant_Impl( rPropertyNames
, sal_True
);
660 uno::Sequence
< beans::GetDirectPropertyTolerantResult
> SAL_CALL
SwXTextPortion::GetPropertyValuesTolerant_Impl(
661 const uno::Sequence
< OUString
>& rPropertyNames
,
662 sal_Bool bDirectValuesOnly
)
663 throw (uno::RuntimeException
)
665 vos::OGuard
aGuard(Application::GetSolarMutex());
667 SwUnoCrsr
* pUnoCrsr
= ((SwXTextPortion
*)this)->GetCrsr();
669 throw uno::RuntimeException();
671 sal_Int32 nProps
= rPropertyNames
.getLength();
672 const OUString
*pProp
= rPropertyNames
.getConstArray();
674 SfxItemSet
*pSet
= 0;
676 const SfxItemPropertyMap
* pPropMap
= m_pPropSet
->getPropertyMap();
678 uno::Sequence
< beans::PropertyState
> aPropertyStates
= SwXTextCursor::GetPropertyStates(
679 *pUnoCrsr
, *m_pPropSet
,
681 SW_PROPERTY_STATE_CALLER_SWX_TEXT_PORTION_TOLERANT
);
682 const beans::PropertyState
* pPropertyStates
= aPropertyStates
.getConstArray();
684 std::vector
< beans::GetDirectPropertyTolerantResult
> aResultVector
;
685 for (sal_Int32 i
= 0; i
< nProps
; ++i
)
687 beans::GetDirectPropertyTolerantResult aResult
;
690 aResult
.Name
= pProp
[i
];
691 if(pPropertyStates
[i
] == beans::PropertyState_MAKE_FIXED_SIZE
) // property unknown?
693 if( bDirectValuesOnly
)
696 aResult
.Result
= beans::TolerantPropertySetResultType::UNKNOWN_PROPERTY
;
700 const SfxItemPropertySimpleEntry
* pEntry
= pPropMap
->getByName( pProp
[i
] );
701 aResult
.State
= pPropertyStates
[i
];
703 aResult
.Result
= beans::TolerantPropertySetResultType::UNKNOWN_FAILURE
;
704 //#i104499# ruby portion attributes need special handling:
705 if( pEntry
->nWID
== RES_TXTATR_CJK_RUBY
&&
706 ePortionType
== PORTION_RUBY_START
)
707 aResult
.State
= beans::PropertyState_DIRECT_VALUE
;
708 if (!bDirectValuesOnly
|| beans::PropertyState_DIRECT_VALUE
== aResult
.State
)
710 // get property value
711 // (compare to SwXTextPortion::getPropertyValue(s))
712 GetPropertyValue( aResult
.Value
, *pEntry
, pUnoCrsr
, pSet
);
713 aResult
.Result
= beans::TolerantPropertySetResultType::SUCCESS
;
714 aResultVector
.push_back( aResult
);
716 // this assertion should never occur!
717 DBG_ASSERT( !aResultVector
.size() || aResult
.Result
!= beans::TolerantPropertySetResultType::UNKNOWN_FAILURE
,
718 "unknown failure while retrieving property" );
722 catch (beans::UnknownPropertyException
&)
724 // should not occur because property was searched for before
725 DBG_ERROR( "unexpected exception catched" );
726 aResult
.Result
= beans::TolerantPropertySetResultType::UNKNOWN_PROPERTY
;
728 catch (lang::IllegalArgumentException
&)
730 aResult
.Result
= beans::TolerantPropertySetResultType::ILLEGAL_ARGUMENT
;
732 catch (beans::PropertyVetoException
&)
734 aResult
.Result
= beans::TolerantPropertySetResultType::PROPERTY_VETO
;
736 catch (lang::WrappedTargetException
&)
738 aResult
.Result
= beans::TolerantPropertySetResultType::WRAPPED_TARGET
;
743 uno::Sequence
< beans::GetDirectPropertyTolerantResult
> aResult( aResultVector
.size() );
744 std::vector
< beans::GetDirectPropertyTolerantResult
>::const_iterator aIt
= aResultVector
.begin();
745 beans::GetDirectPropertyTolerantResult
*pResult
= aResult
.getArray();
746 for( sal_Int32 nResult
= 0; nResult
< aResult
.getLength(); ++nResult
)
748 pResult
[nResult
] = *aIt
;
756 /* -----------------------------02.04.01 11:44--------------------------------
758 ---------------------------------------------------------------------------*/
759 void SwXTextPortion::addPropertiesChangeListener(
760 const uno::Sequence
< OUString
>& /*aPropertyNames*/,
761 const uno::Reference
< beans::XPropertiesChangeListener
>& /*xListener*/ )
762 throw(uno::RuntimeException
)
764 /* -----------------------------02.04.01 11:44--------------------------------
766 ---------------------------------------------------------------------------*/
767 void SwXTextPortion::removePropertiesChangeListener(
768 const uno::Reference
< beans::XPropertiesChangeListener
>& /*xListener*/ )
769 throw(uno::RuntimeException
)
771 /* -----------------------------02.04.01 11:44--------------------------------
773 ---------------------------------------------------------------------------*/
774 void SwXTextPortion::firePropertiesChangeEvent(
775 const uno::Sequence
< OUString
>& /*aPropertyNames*/,
776 const uno::Reference
< beans::XPropertiesChangeListener
>& /*xListener*/ )
777 throw(uno::RuntimeException
)
779 /*-- 11.12.98 09:56:58---------------------------------------------------
781 -----------------------------------------------------------------------*/
782 void SwXTextPortion::addPropertyChangeListener(
783 const OUString
& /*PropertyName*/,
784 const uno::Reference
< beans::XPropertyChangeListener
> & /*xListener*/)
785 throw( beans::UnknownPropertyException
, lang::WrappedTargetException
, uno::RuntimeException
)
787 DBG_WARNING("not implemented");
789 /*-- 11.12.98 09:56:58---------------------------------------------------
791 -----------------------------------------------------------------------*/
792 void SwXTextPortion::removePropertyChangeListener(const OUString
& /*rPropertyName*/, const uno::Reference
< beans::XPropertyChangeListener
> & /*aListener*/) throw( beans::UnknownPropertyException
, lang::WrappedTargetException
, uno::RuntimeException
)
794 DBG_WARNING("not implemented");
796 /*-- 11.12.98 09:56:58---------------------------------------------------
798 -----------------------------------------------------------------------*/
799 void SwXTextPortion::addVetoableChangeListener(const OUString
& /*rPropertyName*/, const uno::Reference
< beans::XVetoableChangeListener
> & /*aListener*/) throw( beans::UnknownPropertyException
, lang::WrappedTargetException
, uno::RuntimeException
)
801 DBG_WARNING("not implemented");
803 /*-- 11.12.98 09:56:59---------------------------------------------------
805 -----------------------------------------------------------------------*/
806 void SwXTextPortion::removeVetoableChangeListener(const OUString
& /*rPropertyName*/, const uno::Reference
< beans::XVetoableChangeListener
> & /*aListener*/) throw( beans::UnknownPropertyException
, lang::WrappedTargetException
, uno::RuntimeException
)
808 DBG_WARNING("not implemented");
810 /*-- 08.03.99 09:41:43---------------------------------------------------
812 -----------------------------------------------------------------------*/
813 beans::PropertyState
SwXTextPortion::getPropertyState(const OUString
& rPropertyName
)
814 throw( beans::UnknownPropertyException
, uno::RuntimeException
)
816 vos::OGuard
aGuard(Application::GetSolarMutex());
817 beans::PropertyState eRet
= beans::PropertyState_DEFAULT_VALUE
;
818 SwUnoCrsr
* pUnoCrsr
= ((SwXTextPortion
*)this)->GetCrsr();
821 if(GetTextPortionType() == PORTION_RUBY_START
&&
822 !rPropertyName
.compareToAscii( RTL_CONSTASCII_STRINGPARAM("Ruby") ))
823 eRet
= beans::PropertyState_DIRECT_VALUE
;
825 eRet
= SwXTextCursor::GetPropertyState(*pUnoCrsr
, *m_pPropSet
, rPropertyName
);
828 throw uno::RuntimeException();
831 /*-- 08.03.99 09:41:47---------------------------------------------------
833 -----------------------------------------------------------------------*/
834 uno::Sequence
< beans::PropertyState
> SwXTextPortion::getPropertyStates(
835 const uno::Sequence
< OUString
>& rPropertyNames
)
836 throw( beans::UnknownPropertyException
, uno::RuntimeException
)
838 vos::OGuard
aGuard(Application::GetSolarMutex());
839 SwUnoCrsr
* pUnoCrsr
= ((SwXTextPortion
*)this)->GetCrsr();
841 throw uno::RuntimeException();
842 uno::Sequence
< beans::PropertyState
> aRet
= SwXTextCursor::GetPropertyStates(*pUnoCrsr
, *m_pPropSet
, rPropertyNames
, SW_PROPERTY_STATE_CALLER_SWX_TEXT_PORTION
);
844 if(GetTextPortionType() == PORTION_RUBY_START
)
846 const OUString
* pNames
= rPropertyNames
.getConstArray();
847 beans::PropertyState
* pStates
= aRet
.getArray();
848 for(sal_Int32 nProp
= 0; nProp
< rPropertyNames
.getLength();nProp
++)
850 if(!pNames
[nProp
].compareToAscii( RTL_CONSTASCII_STRINGPARAM("Ruby") ))
851 pStates
[nProp
] = beans::PropertyState_DIRECT_VALUE
;
856 /*-- 08.03.99 09:41:47---------------------------------------------------
858 -----------------------------------------------------------------------*/
859 void SwXTextPortion::setPropertyToDefault(const OUString
& rPropertyName
)
860 throw( beans::UnknownPropertyException
, uno::RuntimeException
)
862 vos::OGuard
aGuard(Application::GetSolarMutex());
863 SwUnoCrsr
* pUnoCrsr
= GetCrsr();
866 SwXTextCursor::SetPropertyToDefault(*pUnoCrsr
, *m_pPropSet
, rPropertyName
);
869 throw uno::RuntimeException();
871 /*-- 08.03.99 09:41:48---------------------------------------------------
873 -----------------------------------------------------------------------*/
874 uno::Any
SwXTextPortion::getPropertyDefault(const OUString
& rPropertyName
)
875 throw( beans::UnknownPropertyException
, lang::WrappedTargetException
, uno::RuntimeException
)
878 SwUnoCrsr
* pUnoCrsr
= ((SwXTextPortion
*)this)->GetCrsr();
881 aRet
= SwXTextCursor::GetPropertyDefault(*pUnoCrsr
, *m_pPropSet
, rPropertyName
);
884 throw uno::RuntimeException();
887 /*-- 11.12.98 09:56:59---------------------------------------------------
889 -----------------------------------------------------------------------*/
890 OUString
SwXTextPortion::getPresentation(sal_Bool
/*bShowCommand*/) throw( uno::RuntimeException
)
892 vos::OGuard
aGuard(Application::GetSolarMutex());
893 SwUnoCrsr
* pUnoCrsr
= ((SwXTextPortion
*)this)->GetCrsr();
896 if(pUnoCrsr
&& 0 != (pFmt
= GetFldFmt()))
898 const SwField
* pField
= pFmt
->GetFld();
899 DBG_ERROR("bShowCommand auswerten!");
900 sRet
= pField
->Expand();
904 /*-- 11.12.98 09:56:59---------------------------------------------------
906 -----------------------------------------------------------------------*/
907 void SwXTextPortion::attach(const uno::Reference
< text::XTextRange
> & /*xTextRange*/)
908 throw( lang::IllegalArgumentException
, uno::RuntimeException
)
910 vos::OGuard
aGuard(Application::GetSolarMutex());
911 // SwXTextPortion cannot be created at the factory therefore
912 // they cannot be attached
913 throw uno::RuntimeException();
915 /*-- 11.12.98 09:57:00---------------------------------------------------
917 -----------------------------------------------------------------------*/
918 uno::Reference
< text::XTextRange
> SwXTextPortion::getAnchor(void) throw( uno::RuntimeException
)
920 vos::OGuard
aGuard(Application::GetSolarMutex());
921 uno::Reference
< text::XTextRange
> aRet
;
922 SwUnoCrsr
* pUnoCrsr
= ((SwXTextPortion
*)this)->GetCrsr();
924 aRet
= new SwXTextRange(*pUnoCrsr
, xParentText
);
926 throw uno::RuntimeException();
929 /*-- 11.12.98 09:57:00---------------------------------------------------
931 -----------------------------------------------------------------------*/
932 void SwXTextPortion::dispose(void) throw( uno::RuntimeException
)
934 vos::OGuard
aGuard(Application::GetSolarMutex());
935 SwUnoCrsr
* pUnoCrsr
= ((SwXTextPortion
*)this)->GetCrsr();
938 setString(aEmptyStr
);
939 pUnoCrsr
->Remove(this);
942 throw uno::RuntimeException();
944 /*-- 11.12.98 09:57:00---------------------------------------------------
946 -----------------------------------------------------------------------*/
947 void SwXTextPortion::addEventListener(const uno::Reference
< lang::XEventListener
> & aListener
) throw( uno::RuntimeException
)
949 vos::OGuard
aGuard(Application::GetSolarMutex());
950 if(!GetRegisteredIn())
951 throw uno::RuntimeException();
952 aLstnrCntnr
.AddListener(aListener
);
954 /*-- 11.12.98 09:57:01---------------------------------------------------
956 -----------------------------------------------------------------------*/
957 void SwXTextPortion::removeEventListener(const uno::Reference
< lang::XEventListener
> & aListener
) throw( uno::RuntimeException
)
959 vos::OGuard
aGuard(Application::GetSolarMutex());
960 if(!GetRegisteredIn() || !aLstnrCntnr
.RemoveListener(aListener
))
961 throw uno::RuntimeException();
963 /* -----------------24.03.99 13:30-------------------
965 * --------------------------------------------------*/
966 uno::Reference
< container::XEnumeration
> SwXTextPortion::createContentEnumeration(const OUString
& /*aServiceName*/)
967 throw( uno::RuntimeException
)
969 vos::OGuard
aGuard(Application::GetSolarMutex());
970 SwUnoCrsr
* pUnoCrsr
= GetCrsr();
972 throw uno::RuntimeException();
973 uno::Reference
< container::XEnumeration
> xRet
= new SwXParaFrameEnumeration(*pUnoCrsr
, PARAFRAME_PORTION_CHAR
, pFrameFmt
);
977 /* -----------------------------04.07.01 08:52--------------------------------
979 ---------------------------------------------------------------------------*/
980 const uno::Sequence
< sal_Int8
> & SwXTextPortion::getUnoTunnelId()
982 static uno::Sequence
< sal_Int8
> aSeq
= ::CreateUnoTunnelId();
985 /* -----------------------------04.07.01 08:52--------------------------------
987 ---------------------------------------------------------------------------*/
988 sal_Int64
SwXTextPortion::getSomething( const uno::Sequence
< sal_Int8
>& rId
)
989 throw(uno::RuntimeException
)
991 if( rId
.getLength() == 16
992 && 0 == rtl_compareMemory( getUnoTunnelId().getConstArray(),
993 rId
.getConstArray(), 16 ) )
995 return sal::static_int_cast
< sal_Int64
>( reinterpret_cast< sal_IntPtr
>(this) );
999 /* -----------------24.03.99 13:30-------------------
1001 * --------------------------------------------------*/
1002 uno::Sequence
< OUString
> SwXTextPortion::getAvailableServiceNames(void) throw( uno::RuntimeException
)
1004 vos::OGuard
aGuard(Application::GetSolarMutex());
1005 uno::Sequence
< OUString
> aRet(1);
1006 OUString
* pArray
= aRet
.getArray();
1007 pArray
[0] = C2U("com.sun.star.text.TextContent");
1010 /* -----------------25.03.99 10:30-------------------
1012 * --------------------------------------------------*/
1013 OUString
SwXTextPortion::getImplementationName(void) throw( uno::RuntimeException
)
1015 return C2U("SwXTextPortion");
1017 /* -----------------25.03.99 10:30-------------------
1019 * --------------------------------------------------*/
1020 sal_Bool
SwXTextPortion::supportsService(const OUString
& rServiceName
) throw( uno::RuntimeException
)
1022 vos::OGuard
aGuard(Application::GetSolarMutex());
1023 SwUnoCrsr
* pUnoCrsr
= GetCrsr();
1025 throw uno::RuntimeException();
1027 sal_Bool bRet
= sal_False
;
1028 if(!rServiceName
.compareToAscii("com.sun.star.text.TextPortion") ||
1029 !rServiceName
.compareToAscii("com.sun.star.style.CharacterProperties") ||
1030 !rServiceName
.compareToAscii("com.sun.star.style.CharacterPropertiesAsian") ||
1031 !rServiceName
.compareToAscii("com.sun.star.style.CharacterPropertiesComplex") ||
1032 !rServiceName
.compareToAscii("com.sun.star.style.ParagraphProperties") ||
1033 !rServiceName
.compareToAscii("com.sun.star.style.ParagraphPropertiesAsian") ||
1034 !rServiceName
.compareToAscii("com.sun.star.style.ParagraphPropertiesComplex"))
1036 else if(COMPARE_EQUAL
== rServiceName
.compareToAscii("com.sun.star.text.TextField"))
1037 bRet
= 0 != GetFldFmt();
1041 /* ---------------------------------------------------------------------------
1043 ---------------------------------------------------------------------------*/
1044 uno::Sequence
< OUString
> SwXTextPortion::getSupportedServiceNames(void)
1045 throw( uno::RuntimeException
)
1047 vos::OGuard
aGuard(Application::GetSolarMutex());
1048 SwUnoCrsr
* pUnoCrsr
= GetCrsr();
1050 throw uno::RuntimeException();
1051 sal_Bool bField
= 0 != GetFldFmt();
1052 sal_uInt16 nCount
= bField
? 8 : 7;
1053 uno::Sequence
< OUString
> aRet(nCount
);
1054 OUString
* pArray
= aRet
.getArray();
1055 pArray
[0] = C2U("com.sun.star.text.TextPortion");
1056 pArray
[1] = C2U("com.sun.star.style.CharacterProperties");
1057 pArray
[2] = C2U("com.sun.star.style.CharacterPropertiesAsian");
1058 pArray
[3] = C2U("com.sun.star.style.CharacterPropertiesComplex");
1059 pArray
[4] = C2U("com.sun.star.style.ParagraphProperties");
1060 pArray
[5] = C2U("com.sun.star.style.ParagraphPropertiesAsian");
1061 pArray
[6] = C2U("com.sun.star.style.ParagraphPropertiesComplex");
1063 pArray
[7] = C2U("com.sun.star.text.TextField");
1066 /*-- 11.12.98 09:57:01---------------------------------------------------
1068 -----------------------------------------------------------------------*/
1069 void SwXTextPortion::Modify( SfxPoolItem
*pOld
, SfxPoolItem
*pNew
)
1071 ClientModify(this, pOld
, pNew
);
1072 if(!aFrameDepend
.GetRegisteredIn())
1075 /* -----------------------------19.02.01 10:52--------------------------------
1077 ---------------------------------------------------------------------------*/
1078 SwXRubyPortion::SwXRubyPortion(const SwUnoCrsr
* pPortionCrsr
,
1080 uno::Reference
< text::XText
> const& rParent
,
1082 SwXTextPortion(pPortionCrsr
, rParent
, bEnd
? PORTION_RUBY_END
: PORTION_RUBY_START
)
1086 const SfxPoolItem
& rItem
= rAttr
.GetAttr();
1087 pRubyText
= new uno::Any
;
1088 pRubyStyle
= new uno::Any
;
1089 pRubyAdjust
= new uno::Any
;
1090 pRubyIsAbove
= new uno::Any
;
1091 rItem
.QueryValue(*pRubyText
, MID_RUBY_TEXT
);
1092 rItem
.QueryValue(*pRubyStyle
, MID_RUBY_CHARSTYLE
);
1093 rItem
.QueryValue(*pRubyAdjust
, MID_RUBY_ADJUST
);
1094 rItem
.QueryValue(*pRubyIsAbove
, MID_RUBY_ABOVE
);
1097 /* -----------------------------19.02.01 10:52--------------------------------
1099 ---------------------------------------------------------------------------*/
1100 SwXRubyPortion::~SwXRubyPortion()