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: drtxtob.cxx,v $
10 * $Revision: 1.34.128.1 $
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_sc.hxx"
36 //-------------------------------------------------------------------------
38 #include "scitems.hxx"
40 #include <svx/adjitem.hxx>
41 #include <svx/clipfmtitem.hxx>
42 #include <svx/cntritem.hxx>
43 #include <svx/crsditem.hxx>
44 #include <svx/editeng.hxx>
45 #include <svx/escpitem.hxx>
46 #include <svx/flditem.hxx>
47 #include <svx/fontitem.hxx>
48 #include <svx/frmdiritem.hxx>
49 #include <svx/hlnkitem.hxx>
50 #include <svx/lspcitem.hxx>
51 #include <svx/svdoutl.hxx>
52 #include <svx/outlobj.hxx>
53 #include <svx/postitem.hxx>
54 #include <svx/scripttypeitem.hxx>
55 #include <svx/shdditem.hxx>
56 #include <svx/srchitem.hxx>
57 #include <svx/udlnitem.hxx>
58 #include <svx/wghtitem.hxx>
59 #include <svx/writingmodeitem.hxx>
60 #include <sfx2/app.hxx>
61 #include <sfx2/dispatch.hxx>
62 #include <sfx2/objface.hxx>
63 #include <sfx2/objsh.hxx>
64 #include <sfx2/request.hxx>
65 #include <sfx2/viewfrm.hxx>
66 #include <svtools/cliplistener.hxx>
67 #include <svtools/transfer.hxx>
68 #include <svtools/whiter.hxx>
69 #include <svtools/languageoptions.hxx>
70 #include <vcl/msgbox.hxx>
72 #include <svx/svxdlg.hxx>
73 #include <svx/dialogs.hrc>
76 #include "globstr.hrc"
77 #include "drtxtob.hxx"
79 #include "viewdata.hxx"
80 #include "document.hxx"
81 #include "drawview.hxx"
82 #include "viewutil.hxx"
83 #include "scresid.hxx"
84 #include "tabvwsh.hxx"
86 #define ScDrawTextObjectBar
87 #include "scslots.hxx"
89 SFX_IMPL_INTERFACE( ScDrawTextObjectBar
, SfxShell
, ScResId(SCSTR_DRAWTEXTSHELL
) )
91 SFX_OBJECTBAR_REGISTRATION( SFX_OBJECTBAR_OBJECT
|SFX_VISIBILITY_STANDARD
|SFX_VISIBILITY_SERVER
,
92 ScResId(RID_TEXT_TOOLBOX
) );
93 SFX_POPUPMENU_REGISTRATION( ScResId(RID_POPUP_DRAWTEXT
) );
94 SFX_CHILDWINDOW_REGISTRATION( ScGetFontWorkId() );
97 TYPEINIT1( ScDrawTextObjectBar
, SfxShell
);
101 // abschalten der nicht erwuenschten Acceleratoren:
103 void ScDrawTextObjectBar::StateDisableItems( SfxItemSet
&rSet
)
105 SfxWhichIter
aIter(rSet
);
106 USHORT nWhich
= aIter
.FirstWhich();
110 rSet
.DisableItem( nWhich
);
111 nWhich
= aIter
.NextWhich();
115 ScDrawTextObjectBar::ScDrawTextObjectBar(ScViewData
* pData
) :
116 SfxShell(pData
->GetViewShell()),
119 bPastePossible(FALSE
)
121 SetPool( pViewData
->GetScDrawView()->GetDefaultAttr().GetPool() );
123 // UndoManager wird beim Umschalten in den Edit-Modus umgesetzt...
124 SfxUndoManager
* pMgr
= pViewData
->GetSfxDocShell()->GetUndoManager();
125 SetUndoManager( pMgr
);
126 if ( !pViewData
->GetDocument()->IsUndoEnabled() )
128 pMgr
->SetMaxUndoActionCount( 0 );
131 SetHelpId( HID_SCSHELL_DRTXTOB
);
132 SetName(String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("DrawText")));
135 __EXPORT
ScDrawTextObjectBar::~ScDrawTextObjectBar()
139 pClipEvtLstnr
->AddRemoveListener( pViewData
->GetActiveWin(), FALSE
);
141 // #122057# The listener may just now be waiting for the SolarMutex and call the link
142 // afterwards, in spite of RemoveListener. So the link has to be reset, too.
143 pClipEvtLstnr
->ClearCallbackLink();
145 pClipEvtLstnr
->release();
149 //========================================================================
153 //========================================================================
155 void __EXPORT
ScDrawTextObjectBar::Execute( SfxRequest
&rReq
)
157 ScDrawView
* pView
= pViewData
->GetScDrawView();
158 OutlinerView
* pOutView
= pView
->GetTextEditOutlinerView();
159 Outliner
* pOutliner
= pView
->GetTextEditOutliner();
161 if (!pOutView
|| !pOutliner
)
163 ExecuteGlobal( rReq
); // auf ganze Objekte
167 const SfxItemSet
* pReqArgs
= rReq
.GetArgs();
168 USHORT nSlot
= rReq
.GetSlot();
180 pOutView
->PasteSpecial();
183 case SID_CLIPBOARD_FORMAT_ITEMS
:
186 const SfxPoolItem
* pItem
;
188 pReqArgs
->GetItemState(nSlot
, TRUE
, &pItem
) == SFX_ITEM_SET
&&
189 pItem
->ISA(SfxUInt32Item
) )
191 nFormat
= ((const SfxUInt32Item
*)pItem
)->GetValue();
196 if (nFormat
== SOT_FORMAT_STRING
)
199 pOutView
->PasteSpecial();
204 case SID_PASTE_SPECIAL
:
205 ExecutePasteContents( rReq
);
210 ULONG nCount
= pOutliner
->GetParagraphCount();
211 ESelection
aSel( 0,0,(USHORT
)nCount
,0 );
212 pOutView
->SetSelection( aSel
);
218 const SvxFontItem
& rItem
= (const SvxFontItem
&)
219 pOutView
->GetAttribs().Get(EE_CHAR_FONTINFO
);
222 SvxFontItem
aNewItem( EE_CHAR_FONTINFO
);
224 const SfxItemSet
*pArgs
= rReq
.GetArgs();
225 const SfxPoolItem
* pItem
= 0;
227 pArgs
->GetItemState(GetPool().GetWhich(SID_CHARMAP
), FALSE
, &pItem
);
231 aString
= ((const SfxStringItem
*)pItem
)->GetValue();
232 const SfxPoolItem
* pFtItem
= NULL
;
233 pArgs
->GetItemState( GetPool().GetWhich(SID_ATTR_SPECIALCHAR
), FALSE
, &pFtItem
);
234 const SfxStringItem
* pFontItem
= PTR_CAST( SfxStringItem
, pFtItem
);
237 String
aFontName(pFontItem
->GetValue());
238 Font
aFont(aFontName
, Size(1,1)); // Size nur wg. CTOR
239 aNewItem
= SvxFontItem( aFont
.GetFamily(), aFont
.GetName(),
240 aFont
.GetStyleName(), aFont
.GetPitch(),
241 aFont
.GetCharSet(), ATTR_FONT
);
247 ScViewUtil::ExecuteCharMap( rItem
, *pViewData
->GetViewShell()->GetViewFrame(), aNewItem
, aString
);
251 SfxItemSet
aSet( pOutliner
->GetEmptyItemSet() );
252 aSet
.Put( aNewItem
);
253 // SetAttribs an der View selektiert ein Wort, wenn nichts selektiert ist
254 pOutView
->GetOutliner()->QuickSetAttribs( aSet
, pOutView
->GetSelection() );
255 pOutView
->InsertText(aString
);
258 Invalidate( SID_ATTR_CHAR_FONT
);
262 case SID_HYPERLINK_SETLINK
:
265 const SfxPoolItem
* pItem
;
266 if ( pReqArgs
->GetItemState( SID_HYPERLINK_SETLINK
, TRUE
, &pItem
) == SFX_ITEM_SET
)
268 const SvxHyperlinkItem
* pHyper
= (const SvxHyperlinkItem
*) pItem
;
269 const String
& rName
= pHyper
->GetName();
270 const String
& rURL
= pHyper
->GetURL();
271 const String
& rTarget
= pHyper
->GetTargetFrame();
272 SvxLinkInsertMode eMode
= pHyper
->GetInsertMode();
275 if ( pOutView
&& ( eMode
== HLINK_DEFAULT
|| eMode
== HLINK_FIELD
) )
277 const SvxFieldItem
* pFieldItem
= pOutView
->GetFieldAtSelection();
280 const SvxFieldData
* pField
= pFieldItem
->GetField();
281 if ( pField
&& pField
->ISA(SvxURLField
) )
283 // altes Feld selektieren
285 ESelection aSel
= pOutView
->GetSelection();
287 aSel
.nEndPara
= aSel
.nStartPara
;
288 aSel
.nEndPos
= aSel
.nStartPos
+ 1;
289 pOutView
->SetSelection( aSel
);
293 // neues Feld einfuegen
295 SvxURLField
aURLField( rURL
, rName
, SVXURLFORMAT_REPR
);
296 aURLField
.SetTargetFrame( rTarget
);
297 SvxFieldItem
aURLItem( aURLField
, EE_FEATURE_FIELD
);
298 pOutView
->InsertField( aURLItem
);
302 ESelection aSel
= pOutView
->GetSelection();
303 if ( aSel
.nStartPos
== aSel
.nEndPos
&& aSel
.nStartPos
> 0 )
305 // Cursor is behind the inserted field -> extend selection to the left
308 pOutView
->SetSelection( aSel
);
315 ExecuteGlobal( rReq
); // normal an der View
317 // InsertURL an der ViewShell schaltet bei "Text" die DrawShell ab !!!
322 case SID_OPEN_HYPERLINK
:
326 const SvxFieldItem
* pFieldItem
= pOutView
->GetFieldAtSelection();
329 const SvxFieldData
* pField
= pFieldItem
->GetField();
330 if( pField
&& pField
->ISA( SvxURLField
) )
332 const SvxURLField
* pURLField
= static_cast< const SvxURLField
* >( pField
);
333 ScGlobal::OpenURL( pURLField
->GetURL(), pURLField
->GetTargetFrame() );
340 case SID_ENABLE_HYPHENATION
:
341 case SID_TEXTDIRECTION_LEFT_TO_RIGHT
:
342 case SID_TEXTDIRECTION_TOP_TO_BOTTOM
:
346 pView
->CaptionTextDirection( rReq
.GetSlot()); // process Notes before we end the text edit.
347 ExecuteGlobal( rReq
);
348 pViewData
->GetDispatcher().Execute(pViewData
->GetView()->GetDrawFuncPtr()->GetSlotID(), SFX_CALLMODE_SLOT
| SFX_CALLMODE_RECORD
);
353 pView
->ScEndTextEdit(); // end text edit before switching direction
354 ExecuteGlobal( rReq
);
355 // restore consistent state between shells and functions:
356 pViewData
->GetDispatcher().Execute(SID_OBJECT_SELECT
, SFX_CALLMODE_SLOT
| SFX_CALLMODE_RECORD
);
361 // Hyphenation is handled above - text edit is ended
362 case SID_ENABLE_HYPHENATION
:
363 // force loading of hyphenator (object is skipped in repaint)
364 ((ScDrawLayer
*)pView
->GetModel())->UseHyphenator();
365 pOutliner
->SetHyphenator( LinguMgr::GetHyphenator() );
366 ExecuteGlobal( rReq
);
372 void __EXPORT
ScDrawTextObjectBar::GetState( SfxItemSet
& rSet
)
374 SfxViewFrame
* pViewFrm
= pViewData
->GetViewShell()->GetViewFrame();
375 BOOL bHasFontWork
= pViewFrm
->HasChildWindow(SID_FONTWORK
);
376 BOOL bDisableFontWork
= FALSE
;
380 // #i21255# notes now support rich text formatting (#i74140# but not fontwork)
381 bDisableFontWork
= TRUE
;
384 if ( bDisableFontWork
)
385 rSet
.DisableItem( SID_FONTWORK
);
387 rSet
.Put(SfxBoolItem(SID_FONTWORK
, bHasFontWork
));
389 if ( rSet
.GetItemState( SID_HYPERLINK_GETLINK
) != SFX_ITEM_UNKNOWN
)
391 SvxHyperlinkItem aHLinkItem
;
392 SdrView
* pView
= pViewData
->GetScDrawView();
393 OutlinerView
* pOutView
= pView
->GetTextEditOutlinerView();
397 const SvxFieldItem
* pFieldItem
= pOutView
->GetFieldAtSelection();
400 const SvxFieldData
* pField
= pFieldItem
->GetField();
401 if ( pField
&& pField
->ISA(SvxURLField
) )
403 const SvxURLField
* pURLField
= (const SvxURLField
*) pField
;
404 aHLinkItem
.SetName( pURLField
->GetRepresentation() );
405 aHLinkItem
.SetURL( pURLField
->GetURL() );
406 aHLinkItem
.SetTargetFrame( pURLField
->GetTargetFrame() );
412 // use selected text as name for urls
413 String sReturn
= pOutView
->GetSelected();
415 sReturn
.EraseTrailingChars();
416 aHLinkItem
.SetName(sReturn
);
419 rSet
.Put(aHLinkItem
);
422 if ( rSet
.GetItemState( SID_OPEN_HYPERLINK
) != SFX_ITEM_UNKNOWN
)
424 SdrView
* pView
= pViewData
->GetScDrawView();
425 OutlinerView
* pOutView
= pView
->GetTextEditOutlinerView();
426 bool bEnable
= false;
429 const SvxFieldItem
* pFieldItem
= pOutView
->GetFieldAtSelection();
432 const SvxFieldData
* pField
= pFieldItem
->GetField();
433 bEnable
= pField
&& pField
->ISA( SvxURLField
);
437 rSet
.DisableItem( SID_OPEN_HYPERLINK
);
440 if( rSet
.GetItemState( SID_TRANSLITERATE_HALFWIDTH
) != SFX_ITEM_UNKNOWN
)
441 ScViewUtil::HideDisabledSlot( rSet
, pViewFrm
->GetBindings(), SID_TRANSLITERATE_HALFWIDTH
);
442 if( rSet
.GetItemState( SID_TRANSLITERATE_FULLWIDTH
) != SFX_ITEM_UNKNOWN
)
443 ScViewUtil::HideDisabledSlot( rSet
, pViewFrm
->GetBindings(), SID_TRANSLITERATE_FULLWIDTH
);
444 if( rSet
.GetItemState( SID_TRANSLITERATE_HIRAGANA
) != SFX_ITEM_UNKNOWN
)
445 ScViewUtil::HideDisabledSlot( rSet
, pViewFrm
->GetBindings(), SID_TRANSLITERATE_HIRAGANA
);
446 if( rSet
.GetItemState( SID_TRANSLITERATE_KATAGANA
) != SFX_ITEM_UNKNOWN
)
447 ScViewUtil::HideDisabledSlot( rSet
, pViewFrm
->GetBindings(), SID_TRANSLITERATE_KATAGANA
);
449 if ( rSet
.GetItemState( SID_ENABLE_HYPHENATION
) != SFX_ITEM_UNKNOWN
)
451 SdrView
* pView
= pViewData
->GetScDrawView();
452 SfxItemSet
aAttrs( pView
->GetModel()->GetItemPool() );
453 pView
->GetAttributes( aAttrs
);
454 if( aAttrs
.GetItemState( EE_PARA_HYPHENATE
) >= SFX_ITEM_AVAILABLE
)
456 BOOL bValue
= ( (const SfxBoolItem
&) aAttrs
.Get( EE_PARA_HYPHENATE
) ).GetValue();
457 rSet
.Put( SfxBoolItem( SID_ENABLE_HYPHENATION
, bValue
) );
462 IMPL_LINK( ScDrawTextObjectBar
, ClipboardChanged
, TransferableDataHelper
*, pDataHelper
)
466 bPastePossible
= ( pDataHelper
->HasFormat( SOT_FORMAT_STRING
) || pDataHelper
->HasFormat( SOT_FORMAT_RTF
) );
468 SfxBindings
& rBindings
= pViewData
->GetBindings();
469 rBindings
.Invalidate( SID_PASTE
);
470 rBindings
.Invalidate( SID_PASTE_SPECIAL
);
471 rBindings
.Invalidate( SID_CLIPBOARD_FORMAT_ITEMS
);
476 void __EXPORT
ScDrawTextObjectBar::GetClipState( SfxItemSet
& rSet
)
478 SdrView
* pView
= pViewData
->GetScDrawView();
479 if ( !pView
->GetTextEditOutlinerView() )
481 GetGlobalClipState( rSet
);
485 if ( !pClipEvtLstnr
)
488 pClipEvtLstnr
= new TransferableClipboardListener( LINK( this, ScDrawTextObjectBar
, ClipboardChanged
) );
489 pClipEvtLstnr
->acquire();
490 Window
* pWin
= pViewData
->GetActiveWin();
491 pClipEvtLstnr
->AddRemoveListener( pWin
, TRUE
);
494 TransferableDataHelper
aDataHelper( TransferableDataHelper::CreateFromSystemClipboard( pViewData
->GetActiveWin() ) );
495 bPastePossible
= ( aDataHelper
.HasFormat( SOT_FORMAT_STRING
) || aDataHelper
.HasFormat( SOT_FORMAT_RTF
) );
498 SfxWhichIter
aIter( rSet
);
499 USHORT nWhich
= aIter
.FirstWhich();
505 case SID_PASTE_SPECIAL
:
506 if( !bPastePossible
)
507 rSet
.DisableItem( nWhich
);
509 case SID_CLIPBOARD_FORMAT_ITEMS
:
510 if ( bPastePossible
)
512 SvxClipboardFmtItem
aFormats( SID_CLIPBOARD_FORMAT_ITEMS
);
513 TransferableDataHelper
aDataHelper(
514 TransferableDataHelper::CreateFromSystemClipboard( pViewData
->GetActiveWin() ) );
516 if ( aDataHelper
.HasFormat( SOT_FORMAT_STRING
) )
517 aFormats
.AddClipbrdFormat( SOT_FORMAT_STRING
);
518 if ( aDataHelper
.HasFormat( SOT_FORMAT_RTF
) )
519 aFormats
.AddClipbrdFormat( SOT_FORMAT_RTF
);
521 rSet
.Put( aFormats
);
524 rSet
.DisableItem( nWhich
);
527 nWhich
= aIter
.NextWhich();
531 //========================================================================
535 //========================================================================
537 void __EXPORT
ScDrawTextObjectBar::ExecuteToggle( SfxRequest
&rReq
)
541 SdrView
* pView
= pViewData
->GetScDrawView();
543 USHORT nSlot
= rReq
.GetSlot();
545 SfxItemSet
aSet( pView
->GetDefaultAttr() );
547 SfxItemSet
aViewAttr(pView
->GetModel()->GetItemPool());
548 pView
->GetAttributes(aViewAttr
);
551 FontUnderline eOld
= ((const SvxUnderlineItem
&) aViewAttr
.
552 Get(EE_CHAR_UNDERLINE
)).GetLineStyle();
553 FontUnderline eNew
= eOld
;
556 case SID_ULINE_VAL_NONE
:
557 eNew
= UNDERLINE_NONE
;
559 case SID_ULINE_VAL_SINGLE
:
560 eNew
= ( eOld
== UNDERLINE_SINGLE
) ? UNDERLINE_NONE
: UNDERLINE_SINGLE
;
562 case SID_ULINE_VAL_DOUBLE
:
563 eNew
= ( eOld
== UNDERLINE_DOUBLE
) ? UNDERLINE_NONE
: UNDERLINE_DOUBLE
;
565 case SID_ULINE_VAL_DOTTED
:
566 eNew
= ( eOld
== UNDERLINE_DOTTED
) ? UNDERLINE_NONE
: UNDERLINE_DOTTED
;
571 aSet
.Put( SvxUnderlineItem( eNew
, EE_CHAR_UNDERLINE
) );
573 pView
->SetAttributes( aSet
);
575 pViewData
->GetScDrawView()->InvalidateDrawTextAttrs();
578 void lcl_RemoveFields( OutlinerView
& rOutView
)
580 //! Outliner should have RemoveFields with a selection
582 Outliner
* pOutliner
= rOutView
.GetOutliner();
583 if (!pOutliner
) return;
585 ESelection aOldSel
= rOutView
.GetSelection();
586 ESelection aSel
= aOldSel
;
588 xub_StrLen nNewEnd
= aSel
.nEndPos
;
590 BOOL bUpdate
= pOutliner
->GetUpdateMode();
591 BOOL bChanged
= FALSE
;
593 //! GetPortions and GetAttribs should be const!
594 EditEngine
& rEditEng
= (EditEngine
&)pOutliner
->GetEditEngine();
596 ULONG nParCount
= pOutliner
->GetParagraphCount();
597 for (ULONG nPar
=0; nPar
<nParCount
; nPar
++)
598 if ( nPar
>= aSel
.nStartPara
&& nPar
<= aSel
.nEndPara
)
601 rEditEng
.GetPortions( (USHORT
)nPar
, aPortions
);
602 //! GetPortions should use xub_StrLen instead of USHORT
604 for ( USHORT nPos
= aPortions
.Count(); nPos
; )
607 USHORT nEnd
= aPortions
.GetObject( nPos
);
608 USHORT nStart
= nPos
? aPortions
.GetObject( nPos
- 1 ) : 0;
609 // fields are single characters
610 if ( nEnd
== nStart
+1 &&
611 ( nPar
> aSel
.nStartPara
|| nStart
>= aSel
.nStartPos
) &&
612 ( nPar
< aSel
.nEndPara
|| nEnd
<= aSel
.nEndPos
) )
614 ESelection
aFieldSel( (USHORT
)nPar
, nStart
, (USHORT
)nPar
, nEnd
);
615 SfxItemSet aSet
= rEditEng
.GetAttribs( aFieldSel
);
616 if ( aSet
.GetItemState( EE_FEATURE_FIELD
) == SFX_ITEM_ON
)
621 pOutliner
->SetUpdateMode( FALSE
);
622 String aName
= ScGlobal::GetRscString( STR_UNDO_DELETECONTENTS
);
623 pOutliner
->GetUndoManager().EnterListAction( aName
, aName
);
627 String aFieldText
= rEditEng
.GetText( aFieldSel
);
628 pOutliner
->QuickInsertText( aFieldText
, aFieldSel
);
629 if ( nPar
== aSel
.nEndPara
)
631 nNewEnd
= sal::static_int_cast
<xub_StrLen
>( nNewEnd
+ aFieldText
.Len() );
639 if (bUpdate
&& bChanged
)
641 pOutliner
->GetUndoManager().LeaveListAction();
642 pOutliner
->SetUpdateMode( TRUE
);
645 if ( aOldSel
.IsEqual( aSel
) ) // aSel is adjusted
646 aOldSel
.nEndPos
= nNewEnd
;
648 aOldSel
.nStartPos
= nNewEnd
; // if aOldSel is backwards
649 rOutView
.SetSelection( aOldSel
);
652 void __EXPORT
ScDrawTextObjectBar::ExecuteAttr( SfxRequest
&rReq
)
654 SdrView
* pView
= pViewData
->GetScDrawView();
655 const SfxItemSet
* pArgs
= rReq
.GetArgs();
656 USHORT nSlot
= rReq
.GetSlot();
658 BOOL bArgsInReq
= ( pArgs
!= NULL
);
661 SfxItemSet
aEditAttr(pView
->GetModel()->GetItemPool());
662 pView
->GetAttributes(aEditAttr
);
663 SfxItemSet
aNewAttr( *aEditAttr
.GetPool(), aEditAttr
.GetRanges() );
668 case SID_TEXT_STANDARD
: // Harte Textattributierung loeschen
670 OutlinerView
* pOutView
= pView
->IsTextEdit() ?
671 pView
->GetTextEditOutlinerView() : NULL
;
673 pOutView
->Paint( Rectangle() );
675 SfxItemSet
aEmptyAttr( *aEditAttr
.GetPool(), EE_ITEMS_START
, EE_ITEMS_END
);
676 pView
->SetAttributes( aEmptyAttr
, TRUE
);
680 lcl_RemoveFields( *pOutView
);
681 pOutView
->ShowCursor();
684 rReq
.Done( aEmptyAttr
);
685 pViewData
->GetScDrawView()->InvalidateDrawTextAttrs();
686 bDone
= FALSE
; // bereits hier passiert
690 case SID_CHAR_DLG
: // Dialog-Button
691 case SID_ATTR_CHAR_FONT
: // Controller nicht angezeigt
692 case SID_ATTR_CHAR_FONTHEIGHT
:
693 bDone
= ExecuteCharDlg( aEditAttr
, aNewAttr
);
697 bDone
= ExecuteParaDlg( aEditAttr
, aNewAttr
);
700 case SID_ATTR_CHAR_WEIGHT
:
701 aNewAttr
.Put( (const SvxWeightItem
&)aEditAttr
.Get( EE_CHAR_WEIGHT
) );
704 case SID_ATTR_CHAR_POSTURE
:
705 aNewAttr
.Put( (const SvxPostureItem
&)aEditAttr
.Get( EE_CHAR_ITALIC
) );
708 case SID_ATTR_CHAR_UNDERLINE
:
709 aNewAttr
.Put( (const SvxUnderlineItem
&)aEditAttr
.Get( EE_CHAR_UNDERLINE
) );
712 case SID_ATTR_CHAR_OVERLINE
:
713 aNewAttr
.Put( (const SvxOverlineItem
&)aEditAttr
.Get( EE_CHAR_OVERLINE
) );
716 case SID_ATTR_CHAR_CONTOUR
:
717 aNewAttr
.Put( (const SvxContourItem
&)aEditAttr
.Get( EE_CHAR_OUTLINE
) );
720 case SID_ATTR_CHAR_SHADOWED
:
721 aNewAttr
.Put( (const SvxShadowedItem
&)aEditAttr
.Get( EE_CHAR_SHADOW
) );
724 case SID_ATTR_CHAR_STRIKEOUT
:
725 aNewAttr
.Put( (const SvxCrossedOutItem
&)aEditAttr
.Get( EE_CHAR_STRIKEOUT
) );
729 case SID_ALIGN_ANY_LEFT
:
730 aNewAttr
.Put( SvxAdjustItem( SVX_ADJUST_LEFT
, EE_PARA_JUST
) );
733 case SID_ALIGNCENTERHOR
:
734 case SID_ALIGN_ANY_HCENTER
:
735 aNewAttr
.Put( SvxAdjustItem( SVX_ADJUST_CENTER
, EE_PARA_JUST
) );
739 case SID_ALIGN_ANY_RIGHT
:
740 aNewAttr
.Put( SvxAdjustItem( SVX_ADJUST_RIGHT
, EE_PARA_JUST
) );
744 case SID_ALIGN_ANY_JUSTIFIED
:
745 aNewAttr
.Put( SvxAdjustItem( SVX_ADJUST_BLOCK
, EE_PARA_JUST
) );
748 case SID_ATTR_PARA_LINESPACE_10
:
750 SvxLineSpacingItem
aItem( SVX_LINESPACE_ONE_LINE
, EE_PARA_SBL
);
751 aItem
.SetPropLineSpace( 100 );
752 aNewAttr
.Put( aItem
);
756 case SID_ATTR_PARA_LINESPACE_15
:
758 SvxLineSpacingItem
aItem( SVX_LINESPACE_ONE_POINT_FIVE_LINES
, EE_PARA_SBL
);
759 aItem
.SetPropLineSpace( 150 );
760 aNewAttr
.Put( aItem
);
764 case SID_ATTR_PARA_LINESPACE_20
:
766 SvxLineSpacingItem
aItem( SVX_LINESPACE_TWO_LINES
, EE_PARA_SBL
);
767 aItem
.SetPropLineSpace( 200 );
768 aNewAttr
.Put( aItem
);
772 case SID_SET_SUPER_SCRIPT
:
774 SvxEscapementItem
aItem(EE_CHAR_ESCAPEMENT
);
775 SvxEscapement eEsc
= (SvxEscapement
) ( (const SvxEscapementItem
&)
776 aEditAttr
.Get( EE_CHAR_ESCAPEMENT
) ).GetEnumValue();
778 if( eEsc
== SVX_ESCAPEMENT_SUPERSCRIPT
)
779 aItem
.SetEscapement( SVX_ESCAPEMENT_OFF
);
781 aItem
.SetEscapement( SVX_ESCAPEMENT_SUPERSCRIPT
);
782 aNewAttr
.Put( aItem
);
785 case SID_SET_SUB_SCRIPT
:
787 SvxEscapementItem
aItem(EE_CHAR_ESCAPEMENT
);
788 SvxEscapement eEsc
= (SvxEscapement
) ( (const SvxEscapementItem
&)
789 aEditAttr
.Get( EE_CHAR_ESCAPEMENT
) ).GetEnumValue();
791 if( eEsc
== SVX_ESCAPEMENT_SUBSCRIPT
)
792 aItem
.SetEscapement( SVX_ESCAPEMENT_OFF
);
794 aItem
.SetEscapement( SVX_ESCAPEMENT_SUBSCRIPT
);
795 aNewAttr
.Put( aItem
);
799 case SID_DRAWTEXT_ATTR_DLG
:
801 SvxAbstractDialogFactory
* pFact
= SvxAbstractDialogFactory::Create();
802 SfxAbstractTabDialog
*pDlg
= pFact
->CreateTextTabDialog( pViewData
->GetDialogParent(), &aEditAttr
, RID_SVXDLG_TEXT
, pView
);
804 bDone
= ( RET_OK
== pDlg
->Execute() );
807 aNewAttr
.Put( *pDlg
->GetOutputItemSet() );
814 if ( bDone
) // wurden Attribute geaendert?
816 rReq
.Done( aNewAttr
);
817 pArgs
= rReq
.GetArgs();
824 ( nSlot
== SID_ATTR_CHAR_FONT
|| nSlot
== SID_ATTR_CHAR_FONTHEIGHT
||
825 nSlot
== SID_ATTR_CHAR_WEIGHT
|| nSlot
== SID_ATTR_CHAR_POSTURE
) )
827 // font items from toolbox controller have to be applied for the right script type
829 // #i78017 establish the same behaviour as in Writer
830 USHORT nScript
= SCRIPTTYPE_LATIN
| SCRIPTTYPE_ASIAN
| SCRIPTTYPE_COMPLEX
;
831 if (nSlot
== SID_ATTR_CHAR_FONT
)
832 nScript
= pView
->GetScriptType();
834 SfxItemPool
& rPool
= GetPool();
835 SvxScriptSetItem
aSetItem( nSlot
, rPool
);
836 USHORT nWhich
= rPool
.GetWhich( nSlot
);
837 aSetItem
.PutItemForScriptType( nScript
, pArgs
->Get( nWhich
) );
839 pView
->SetAttributes( aSetItem
.GetItemSet() );
845 pView
->SetAttributes( *pArgs
);
847 pViewData
->GetScDrawView()->InvalidateDrawTextAttrs();
851 void __EXPORT
ScDrawTextObjectBar::GetAttrState( SfxItemSet
& rDestSet
)
855 // issue 21255 - Notes now support rich text formatting.
858 SvtLanguageOptions aLangOpt
;
859 BOOL bDisableCTLFont
= !aLangOpt
.IsCTLFontEnabled();
860 BOOL bDisableVerticalText
= !aLangOpt
.IsVerticalTextEnabled();
862 SdrView
* pView
= pViewData
->GetScDrawView();
863 SfxItemSet
aAttrSet(pView
->GetModel()->GetItemPool());
864 pView
->GetAttributes(aAttrSet
);
868 rDestSet
.Put( aAttrSet
);
870 // choose font info according to selection script type
872 USHORT nScript
= pView
->GetScriptType();
874 // #i55929# input-language-dependent script type (depends on input language if nothing selected)
875 USHORT nInputScript
= nScript
;
876 OutlinerView
* pOutView
= pView
->GetTextEditOutlinerView();
877 if (pOutView
&& !pOutView
->GetSelection().HasRange())
879 LanguageType nInputLang
= pViewData
->GetActiveWin()->GetInputLanguage();
880 if (nInputLang
!= LANGUAGE_DONTKNOW
&& nInputLang
!= LANGUAGE_SYSTEM
)
881 nInputScript
= SvtLanguageOptions::GetScriptTypeOfLanguage( nInputLang
);
884 // #i55929# according to spec, nInputScript is used for font and font height only
885 if ( rDestSet
.GetItemState( EE_CHAR_FONTINFO
) != SFX_ITEM_UNKNOWN
)
886 ScViewUtil::PutItemScript( rDestSet
, aAttrSet
, EE_CHAR_FONTINFO
, nInputScript
);
887 if ( rDestSet
.GetItemState( EE_CHAR_FONTHEIGHT
) != SFX_ITEM_UNKNOWN
)
888 ScViewUtil::PutItemScript( rDestSet
, aAttrSet
, EE_CHAR_FONTHEIGHT
, nInputScript
);
889 if ( rDestSet
.GetItemState( EE_CHAR_WEIGHT
) != SFX_ITEM_UNKNOWN
)
890 ScViewUtil::PutItemScript( rDestSet
, aAttrSet
, EE_CHAR_WEIGHT
, nScript
);
891 if ( rDestSet
.GetItemState( EE_CHAR_ITALIC
) != SFX_ITEM_UNKNOWN
)
892 ScViewUtil::PutItemScript( rDestSet
, aAttrSet
, EE_CHAR_ITALIC
, nScript
);
896 SvxAdjust eAdj
= ((const SvxAdjustItem
&)aAttrSet
.Get(EE_PARA_JUST
)).GetAdjust();
899 case SVX_ADJUST_LEFT
:
900 rDestSet
.Put( SfxBoolItem( SID_ALIGNLEFT
, TRUE
) );
902 case SVX_ADJUST_CENTER
:
903 rDestSet
.Put( SfxBoolItem( SID_ALIGNCENTERHOR
, TRUE
) );
905 case SVX_ADJUST_RIGHT
:
906 rDestSet
.Put( SfxBoolItem( SID_ALIGNRIGHT
, TRUE
) );
908 case SVX_ADJUST_BLOCK
:
909 rDestSet
.Put( SfxBoolItem( SID_ALIGNBLOCK
, TRUE
) );
913 // added to avoid warnings
916 // pseudo slots for Format menu
917 rDestSet
.Put( SfxBoolItem( SID_ALIGN_ANY_LEFT
, eAdj
== SVX_ADJUST_LEFT
) );
918 rDestSet
.Put( SfxBoolItem( SID_ALIGN_ANY_HCENTER
, eAdj
== SVX_ADJUST_CENTER
) );
919 rDestSet
.Put( SfxBoolItem( SID_ALIGN_ANY_RIGHT
, eAdj
== SVX_ADJUST_RIGHT
) );
920 rDestSet
.Put( SfxBoolItem( SID_ALIGN_ANY_JUSTIFIED
, eAdj
== SVX_ADJUST_BLOCK
) );
924 USHORT nLineSpace
= (USHORT
)
925 ((const SvxLineSpacingItem
&)aAttrSet
.
926 Get( EE_PARA_SBL
)).GetPropLineSpace();
930 rDestSet
.Put( SfxBoolItem( SID_ATTR_PARA_LINESPACE_10
, TRUE
) );
933 rDestSet
.Put( SfxBoolItem( SID_ATTR_PARA_LINESPACE_15
, TRUE
) );
936 rDestSet
.Put( SfxBoolItem( SID_ATTR_PARA_LINESPACE_20
, TRUE
) );
940 // hoch-/tiefgestellt
942 SvxEscapement eEsc
= (SvxEscapement
) ( (const SvxEscapementItem
&)
943 aAttrSet
.Get( EE_CHAR_ESCAPEMENT
) ).GetEnumValue();
944 if( eEsc
== SVX_ESCAPEMENT_SUPERSCRIPT
)
945 rDestSet
.Put( SfxBoolItem( SID_SET_SUPER_SCRIPT
, TRUE
) );
946 else if( eEsc
== SVX_ESCAPEMENT_SUBSCRIPT
)
947 rDestSet
.Put( SfxBoolItem( SID_SET_SUB_SCRIPT
, TRUE
) );
951 SfxItemState eState
= aAttrSet
.GetItemState( EE_CHAR_UNDERLINE
, TRUE
);
952 if ( eState
== SFX_ITEM_DONTCARE
)
954 rDestSet
.InvalidateItem( SID_ULINE_VAL_NONE
);
955 rDestSet
.InvalidateItem( SID_ULINE_VAL_SINGLE
);
956 rDestSet
.InvalidateItem( SID_ULINE_VAL_DOUBLE
);
957 rDestSet
.InvalidateItem( SID_ULINE_VAL_DOTTED
);
961 FontUnderline eUnderline
= ((const SvxUnderlineItem
&)
962 aAttrSet
.Get(EE_CHAR_UNDERLINE
)).GetLineStyle();
963 USHORT nId
= SID_ULINE_VAL_NONE
;
966 case UNDERLINE_SINGLE
: nId
= SID_ULINE_VAL_SINGLE
; break;
967 case UNDERLINE_DOUBLE
: nId
= SID_ULINE_VAL_DOUBLE
; break;
968 case UNDERLINE_DOTTED
: nId
= SID_ULINE_VAL_DOTTED
; break;
972 rDestSet
.Put( SfxBoolItem( nId
, TRUE
) );
975 // horizontal / vertical
977 BOOL bLeftToRight
= TRUE
;
979 SdrOutliner
* pOutl
= pView
->GetTextEditOutliner();
982 if( pOutl
->IsVertical() )
983 bLeftToRight
= FALSE
;
986 bLeftToRight
= ( (const SvxWritingModeItem
&) aAttrSet
.Get( SDRATTR_TEXTDIRECTION
) ).GetValue() == com::sun::star::text::WritingMode_LR_TB
;
988 if ( bDisableVerticalText
)
990 rDestSet
.DisableItem( SID_TEXTDIRECTION_LEFT_TO_RIGHT
);
991 rDestSet
.DisableItem( SID_TEXTDIRECTION_TOP_TO_BOTTOM
);
995 rDestSet
.Put( SfxBoolItem( SID_TEXTDIRECTION_LEFT_TO_RIGHT
, bLeftToRight
) );
996 rDestSet
.Put( SfxBoolItem( SID_TEXTDIRECTION_TOP_TO_BOTTOM
, !bLeftToRight
) );
999 // left-to-right or right-to-left
1001 if ( !bLeftToRight
|| bDisableCTLFont
)
1003 // disabled if vertical
1004 rDestSet
.DisableItem( SID_ATTR_PARA_LEFT_TO_RIGHT
);
1005 rDestSet
.DisableItem( SID_ATTR_PARA_RIGHT_TO_LEFT
);
1007 else if ( aAttrSet
.GetItemState( EE_PARA_WRITINGDIR
) == SFX_ITEM_DONTCARE
)
1009 rDestSet
.InvalidateItem( SID_ATTR_PARA_LEFT_TO_RIGHT
);
1010 rDestSet
.InvalidateItem( SID_ATTR_PARA_RIGHT_TO_LEFT
);
1014 SvxFrameDirection eAttrDir
= (SvxFrameDirection
)((const SvxFrameDirectionItem
&)
1015 aAttrSet
.Get( EE_PARA_WRITINGDIR
)).GetValue();
1016 if ( eAttrDir
== FRMDIR_ENVIRONMENT
)
1018 // get "environment" direction from page style
1019 if ( pViewData
->GetDocument()->GetEditTextDirection( pViewData
->GetTabNo() ) == EE_HTEXTDIR_R2L
)
1020 eAttrDir
= FRMDIR_HORI_RIGHT_TOP
;
1022 eAttrDir
= FRMDIR_HORI_LEFT_TOP
;
1024 rDestSet
.Put( SfxBoolItem( SID_ATTR_PARA_LEFT_TO_RIGHT
, ( eAttrDir
== FRMDIR_HORI_LEFT_TOP
) ) );
1025 rDestSet
.Put( SfxBoolItem( SID_ATTR_PARA_RIGHT_TO_LEFT
, ( eAttrDir
== FRMDIR_HORI_RIGHT_TOP
) ) );
1029 void ScDrawTextObjectBar::ExecuteTrans( SfxRequest
& rReq
)
1031 sal_Int32 nType
= ScViewUtil::GetTransliterationType( rReq
.GetSlot() );
1034 ScDrawView
* pView
= pViewData
->GetScDrawView();
1035 OutlinerView
* pOutView
= pView
->GetTextEditOutlinerView();
1038 // change selected text in object
1039 pOutView
->TransliterateText( nType
);
1043 //! apply to whole objects?