dongquangang wrote:
> hi ,all
> I have a problem ! In the function SwTextShell::Execute(), I want to get the
> size of the first word in a paragraph,but i didn't find a function that
> could do it.Would you give me some sugeestion?
>
> Best regards!
>
>
Hi,
there is no such special function.
The following code might help you:
SwWrtShell& rSh = GetShell();
rSh.Push(); //push the current cursor on a stack
if( !rSh.IsSttOfPara()) // if not already at the start of the paragraph
rSh.SttPara( sal_False ); // goto start of para
rSh.NextWrd( sal_True ); //select current word if there is one
//depending on rSh.GetScriptType() returns SCRIPTTYPE_LATIN,
SCRIPTTYPE_ASIAN or SCRIPTTYPE_COMPLEX
//you have to set WHICH_ID to the right one for the returned script type
- can be RES_CHRATR_FONTSIZE, RES_CHRATR_CJK_FONTSIZE or
RES_CHRATR_CTL_FONTSIZE
SfxItemSet aSet( rSh.GetPool(), WHICH_ID);
rSh.GetAttr(aItemSet);
//the aItemSet contains the SvxFontHeightItem with the given WHICH_ID
only if the size is set to the same value for the complete word
const SfxPoolItem* pItem = 0;
SfxItemState eState = aItemSet.GetItemState( WHICH_ID, sal_True, &pItem);
if( SFX_ITEM_SET = eState )
{
//here you can cast pItem to const SvxFontHeightItem*
}
else if( SFX_ITEM_DEFAULT == eState )
//here you can cast the return of aItemSet.Get( WHICH_ID) to a const
SvxFontHeightItem&
rSh.Pop(sal_False); //restore cursor position
What do you want to take this value for?
HTH,
Oliver
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]