1b3f79822SAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3b3f79822SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4b3f79822SAndrew Rist * or more contributor license agreements. See the NOTICE file
5b3f79822SAndrew Rist * distributed with this work for additional information
6b3f79822SAndrew Rist * regarding copyright ownership. The ASF licenses this file
7b3f79822SAndrew Rist * to you under the Apache License, Version 2.0 (the
8b3f79822SAndrew Rist * "License"); you may not use this file except in compliance
9b3f79822SAndrew Rist * with the License. You may obtain a copy of the License at
10cdf0e10cSrcweir *
11b3f79822SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir *
13b3f79822SAndrew Rist * Unless required by applicable law or agreed to in writing,
14b3f79822SAndrew Rist * software distributed under the License is distributed on an
15b3f79822SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16b3f79822SAndrew Rist * KIND, either express or implied. See the License for the
17b3f79822SAndrew Rist * specific language governing permissions and limitations
18b3f79822SAndrew Rist * under the License.
19cdf0e10cSrcweir *
20b3f79822SAndrew Rist *************************************************************/
21b3f79822SAndrew Rist
22b3f79822SAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sc.hxx"
26cdf0e10cSrcweir
27cdf0e10cSrcweir
28cdf0e10cSrcweir
29cdf0e10cSrcweir //-------------------------------------------------------------------------
30cdf0e10cSrcweir
31cdf0e10cSrcweir #include <com/sun/star/linguistic2/XThesaurus.hpp>
32cdf0e10cSrcweir #include <com/sun/star/lang/Locale.hpp>
33cdf0e10cSrcweir
34cdf0e10cSrcweir #include "scitems.hxx"
35cdf0e10cSrcweir
36cdf0e10cSrcweir #include <editeng/adjitem.hxx>
37cdf0e10cSrcweir #include <svx/clipfmtitem.hxx>
38cdf0e10cSrcweir #include <editeng/cntritem.hxx>
39cdf0e10cSrcweir #include <editeng/crsditem.hxx>
40cdf0e10cSrcweir #include <editeng/editeng.hxx>
41cdf0e10cSrcweir #include <editeng/escpitem.hxx>
42cdf0e10cSrcweir #include <editeng/flditem.hxx>
43cdf0e10cSrcweir #include <editeng/fontitem.hxx>
44cdf0e10cSrcweir #include <editeng/frmdiritem.hxx>
45766ce4d0SZheng Fan #include <editeng/lrspitem.hxx>
46766ce4d0SZheng Fan #include <editeng/lspcitem.hxx>
47766ce4d0SZheng Fan #include <editeng/ulspitem.hxx>
48cdf0e10cSrcweir #include <svx/hlnkitem.hxx>
49cdf0e10cSrcweir #include <editeng/lspcitem.hxx>
50cdf0e10cSrcweir #include <svx/svdoutl.hxx>
51cdf0e10cSrcweir #include <editeng/unolingu.hxx>
52cdf0e10cSrcweir #include <editeng/outlobj.hxx>
53cdf0e10cSrcweir #include <editeng/postitem.hxx>
54cdf0e10cSrcweir #include <editeng/scripttypeitem.hxx>
55cdf0e10cSrcweir #include <editeng/shdditem.hxx>
56cdf0e10cSrcweir #include <svl/srchitem.hxx>
57cdf0e10cSrcweir #include <editeng/udlnitem.hxx>
58cdf0e10cSrcweir #include <editeng/wghtitem.hxx>
59cdf0e10cSrcweir #include <editeng/writingmodeitem.hxx>
60cdf0e10cSrcweir #include <sfx2/app.hxx>
61cdf0e10cSrcweir #include <sfx2/dispatch.hxx>
62cdf0e10cSrcweir #include <sfx2/objface.hxx>
63cdf0e10cSrcweir #include <sfx2/objsh.hxx>
64cdf0e10cSrcweir #include <sfx2/request.hxx>
65cdf0e10cSrcweir #include <sfx2/viewfrm.hxx>
66cdf0e10cSrcweir #include <svtools/cliplistener.hxx>
67cdf0e10cSrcweir #include <svtools/transfer.hxx>
68cdf0e10cSrcweir #include <svl/whiter.hxx>
69cdf0e10cSrcweir #include <svl/languageoptions.hxx>
70cdf0e10cSrcweir #include <vcl/msgbox.hxx>
71cdf0e10cSrcweir
72cdf0e10cSrcweir #include <svx/svxdlg.hxx>
73cdf0e10cSrcweir #include <svx/dialogs.hrc>
74f120fe41SAndre Fischer #include <sfx2/sidebar/EnumContext.hxx>
75cdf0e10cSrcweir
76cdf0e10cSrcweir #include "sc.hrc"
77cdf0e10cSrcweir #include "globstr.hrc"
78cdf0e10cSrcweir #include "scmod.hxx"
79cdf0e10cSrcweir #include "drtxtob.hxx"
80cdf0e10cSrcweir #include "fudraw.hxx"
81cdf0e10cSrcweir #include "viewdata.hxx"
82cdf0e10cSrcweir #include "document.hxx"
83cdf0e10cSrcweir #include "drawview.hxx"
84cdf0e10cSrcweir #include "viewutil.hxx"
85cdf0e10cSrcweir #include "scresid.hxx"
86cdf0e10cSrcweir #include "tabvwsh.hxx"
87cdf0e10cSrcweir
88cdf0e10cSrcweir #define ScDrawTextObjectBar
89cdf0e10cSrcweir #include "scslots.hxx"
90cdf0e10cSrcweir
91cdf0e10cSrcweir
92cdf0e10cSrcweir using namespace ::com::sun::star;
93cdf0e10cSrcweir
94cdf0e10cSrcweir
SFX_IMPL_INTERFACE(ScDrawTextObjectBar,SfxShell,ScResId (SCSTR_DRAWTEXTSHELL))95cdf0e10cSrcweir SFX_IMPL_INTERFACE( ScDrawTextObjectBar, SfxShell, ScResId(SCSTR_DRAWTEXTSHELL) )
96cdf0e10cSrcweir {
97cdf0e10cSrcweir SFX_OBJECTBAR_REGISTRATION( SFX_OBJECTBAR_OBJECT|SFX_VISIBILITY_STANDARD|SFX_VISIBILITY_SERVER,
98cdf0e10cSrcweir ScResId(RID_TEXT_TOOLBOX) );
99cdf0e10cSrcweir SFX_POPUPMENU_REGISTRATION( ScResId(RID_POPUP_DRAWTEXT) );
100cdf0e10cSrcweir SFX_CHILDWINDOW_REGISTRATION( ScGetFontWorkId() );
101cdf0e10cSrcweir }
102cdf0e10cSrcweir
103cdf0e10cSrcweir TYPEINIT1( ScDrawTextObjectBar, SfxShell );
104cdf0e10cSrcweir
105cdf0e10cSrcweir
106cdf0e10cSrcweir
107cdf0e10cSrcweir // abschalten der nicht erwuenschten Acceleratoren:
108cdf0e10cSrcweir
StateDisableItems(SfxItemSet & rSet)109cdf0e10cSrcweir void ScDrawTextObjectBar::StateDisableItems( SfxItemSet &rSet )
110cdf0e10cSrcweir {
111cdf0e10cSrcweir SfxWhichIter aIter(rSet);
112cdf0e10cSrcweir sal_uInt16 nWhich = aIter.FirstWhich();
113cdf0e10cSrcweir
114cdf0e10cSrcweir while (nWhich)
115cdf0e10cSrcweir {
116cdf0e10cSrcweir rSet.DisableItem( nWhich );
117cdf0e10cSrcweir nWhich = aIter.NextWhich();
118cdf0e10cSrcweir }
119cdf0e10cSrcweir }
120cdf0e10cSrcweir
ScDrawTextObjectBar(ScViewData * pData)121cdf0e10cSrcweir ScDrawTextObjectBar::ScDrawTextObjectBar(ScViewData* pData) :
122cdf0e10cSrcweir SfxShell(pData->GetViewShell()),
123cdf0e10cSrcweir pViewData(pData),
124cdf0e10cSrcweir pClipEvtLstnr(NULL),
125cdf0e10cSrcweir bPastePossible(sal_False)
126cdf0e10cSrcweir {
127cdf0e10cSrcweir SetPool( pViewData->GetScDrawView()->GetDefaultAttr().GetPool() );
128cdf0e10cSrcweir
129cdf0e10cSrcweir // UndoManager wird beim Umschalten in den Edit-Modus umgesetzt...
130cdf0e10cSrcweir ::svl::IUndoManager* pMgr = pViewData->GetSfxDocShell()->GetUndoManager();
131cdf0e10cSrcweir SetUndoManager( pMgr );
132cdf0e10cSrcweir if ( !pViewData->GetDocument()->IsUndoEnabled() )
133cdf0e10cSrcweir {
134cdf0e10cSrcweir pMgr->SetMaxUndoActionCount( 0 );
135cdf0e10cSrcweir }
136cdf0e10cSrcweir
137cdf0e10cSrcweir SetHelpId( HID_SCSHELL_DRTXTOB );
138cdf0e10cSrcweir SetName(String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("DrawText")));
139f120fe41SAndre Fischer SfxShell::SetContextName(sfx2::sidebar::EnumContext::GetContextName(sfx2::sidebar::EnumContext::Context_DrawText));
140cdf0e10cSrcweir }
141cdf0e10cSrcweir
~ScDrawTextObjectBar()142cdf0e10cSrcweir __EXPORT ScDrawTextObjectBar::~ScDrawTextObjectBar()
143cdf0e10cSrcweir {
144cdf0e10cSrcweir if ( pClipEvtLstnr )
145cdf0e10cSrcweir {
146cdf0e10cSrcweir pClipEvtLstnr->AddRemoveListener( pViewData->GetActiveWin(), sal_False );
147cdf0e10cSrcweir
148cdf0e10cSrcweir // #122057# The listener may just now be waiting for the SolarMutex and call the link
149cdf0e10cSrcweir // afterwards, in spite of RemoveListener. So the link has to be reset, too.
150cdf0e10cSrcweir pClipEvtLstnr->ClearCallbackLink();
151cdf0e10cSrcweir
152cdf0e10cSrcweir pClipEvtLstnr->release();
153cdf0e10cSrcweir }
154cdf0e10cSrcweir }
155cdf0e10cSrcweir
156cdf0e10cSrcweir //========================================================================
157cdf0e10cSrcweir //
158cdf0e10cSrcweir // Funktionen
159cdf0e10cSrcweir //
160cdf0e10cSrcweir //========================================================================
161cdf0e10cSrcweir
Execute(SfxRequest & rReq)162cdf0e10cSrcweir void __EXPORT ScDrawTextObjectBar::Execute( SfxRequest &rReq )
163cdf0e10cSrcweir {
164cdf0e10cSrcweir ScDrawView* pView = pViewData->GetScDrawView();
165cdf0e10cSrcweir OutlinerView* pOutView = pView->GetTextEditOutlinerView();
166cdf0e10cSrcweir Outliner* pOutliner = pView->GetTextEditOutliner();
167cdf0e10cSrcweir
168cdf0e10cSrcweir if (!pOutView || !pOutliner)
169cdf0e10cSrcweir {
170cdf0e10cSrcweir ExecuteGlobal( rReq ); // auf ganze Objekte
171cdf0e10cSrcweir return;
172cdf0e10cSrcweir }
173cdf0e10cSrcweir
174cdf0e10cSrcweir const SfxItemSet* pReqArgs = rReq.GetArgs();
175cdf0e10cSrcweir sal_uInt16 nSlot = rReq.GetSlot();
176cdf0e10cSrcweir switch ( nSlot )
177cdf0e10cSrcweir {
178cdf0e10cSrcweir case SID_COPY:
179cdf0e10cSrcweir pOutView->Copy();
180cdf0e10cSrcweir break;
181cdf0e10cSrcweir
182cdf0e10cSrcweir case SID_CUT:
183cdf0e10cSrcweir pOutView->Cut();
184cdf0e10cSrcweir break;
185cdf0e10cSrcweir
186cdf0e10cSrcweir case SID_PASTE:
187cdf0e10cSrcweir pOutView->PasteSpecial();
188cdf0e10cSrcweir break;
189cdf0e10cSrcweir
190cdf0e10cSrcweir case SID_CLIPBOARD_FORMAT_ITEMS:
191cdf0e10cSrcweir {
192cdf0e10cSrcweir sal_uLong nFormat = 0;
193cdf0e10cSrcweir const SfxPoolItem* pItem;
194cdf0e10cSrcweir if ( pReqArgs &&
195cdf0e10cSrcweir pReqArgs->GetItemState(nSlot, sal_True, &pItem) == SFX_ITEM_SET &&
196cdf0e10cSrcweir pItem->ISA(SfxUInt32Item) )
197cdf0e10cSrcweir {
198cdf0e10cSrcweir nFormat = ((const SfxUInt32Item*)pItem)->GetValue();
199cdf0e10cSrcweir }
200cdf0e10cSrcweir
201cdf0e10cSrcweir if ( nFormat )
202cdf0e10cSrcweir {
203cdf0e10cSrcweir if (nFormat == SOT_FORMAT_STRING)
204cdf0e10cSrcweir pOutView->Paste();
205cdf0e10cSrcweir else
206cdf0e10cSrcweir pOutView->PasteSpecial();
207cdf0e10cSrcweir }
208cdf0e10cSrcweir }
209cdf0e10cSrcweir break;
210cdf0e10cSrcweir
211cdf0e10cSrcweir case SID_PASTE_SPECIAL:
212cdf0e10cSrcweir ExecutePasteContents( rReq );
213cdf0e10cSrcweir break;
214cdf0e10cSrcweir
215cdf0e10cSrcweir case SID_SELECTALL:
216cdf0e10cSrcweir {
217cdf0e10cSrcweir sal_uLong nCount = pOutliner->GetParagraphCount();
218*c2eaa082SDamjan Jovanovic ESelection aSel( 0,0,nCount,0 );
219cdf0e10cSrcweir pOutView->SetSelection( aSel );
220cdf0e10cSrcweir }
221cdf0e10cSrcweir break;
222cdf0e10cSrcweir
223cdf0e10cSrcweir case SID_CHARMAP:
224cdf0e10cSrcweir {
225cdf0e10cSrcweir const SvxFontItem& rItem = (const SvxFontItem&)
226cdf0e10cSrcweir pOutView->GetAttribs().Get(EE_CHAR_FONTINFO);
227cdf0e10cSrcweir
228cdf0e10cSrcweir String aString;
229cdf0e10cSrcweir SvxFontItem aNewItem( EE_CHAR_FONTINFO );
230cdf0e10cSrcweir
231cdf0e10cSrcweir const SfxItemSet *pArgs = rReq.GetArgs();
232cdf0e10cSrcweir const SfxPoolItem* pItem = 0;
233cdf0e10cSrcweir if( pArgs )
234cdf0e10cSrcweir pArgs->GetItemState(GetPool().GetWhich(SID_CHARMAP), sal_False, &pItem);
235cdf0e10cSrcweir
236cdf0e10cSrcweir if ( pItem )
237cdf0e10cSrcweir {
238cdf0e10cSrcweir aString = ((const SfxStringItem*)pItem)->GetValue();
239cdf0e10cSrcweir const SfxPoolItem* pFtItem = NULL;
240cdf0e10cSrcweir pArgs->GetItemState( GetPool().GetWhich(SID_ATTR_SPECIALCHAR), sal_False, &pFtItem);
241cdf0e10cSrcweir const SfxStringItem* pFontItem = PTR_CAST( SfxStringItem, pFtItem );
242cdf0e10cSrcweir if ( pFontItem )
243cdf0e10cSrcweir {
244cdf0e10cSrcweir String aFontName(pFontItem->GetValue());
245cdf0e10cSrcweir Font aFont(aFontName, Size(1,1)); // Size nur wg. CTOR
246cdf0e10cSrcweir aNewItem = SvxFontItem( aFont.GetFamily(), aFont.GetName(),
247cdf0e10cSrcweir aFont.GetStyleName(), aFont.GetPitch(),
248cdf0e10cSrcweir aFont.GetCharSet(), ATTR_FONT );
249cdf0e10cSrcweir }
250cdf0e10cSrcweir else
251cdf0e10cSrcweir aNewItem = rItem;
252cdf0e10cSrcweir }
253cdf0e10cSrcweir else
254cdf0e10cSrcweir ScViewUtil::ExecuteCharMap( rItem, *pViewData->GetViewShell()->GetViewFrame(), aNewItem, aString );
255cdf0e10cSrcweir
256cdf0e10cSrcweir if ( aString.Len() )
257cdf0e10cSrcweir {
258cdf0e10cSrcweir SfxItemSet aSet( pOutliner->GetEmptyItemSet() );
259cdf0e10cSrcweir aSet.Put( aNewItem );
260cdf0e10cSrcweir // SetAttribs an der View selektiert ein Wort, wenn nichts selektiert ist
261cdf0e10cSrcweir pOutView->GetOutliner()->QuickSetAttribs( aSet, pOutView->GetSelection() );
262cdf0e10cSrcweir pOutView->InsertText(aString);
263cdf0e10cSrcweir }
264cdf0e10cSrcweir
265cdf0e10cSrcweir Invalidate( SID_ATTR_CHAR_FONT );
266cdf0e10cSrcweir }
267cdf0e10cSrcweir break;
268cdf0e10cSrcweir
269cdf0e10cSrcweir case SID_HYPERLINK_SETLINK:
270cdf0e10cSrcweir if( pReqArgs )
271cdf0e10cSrcweir {
272cdf0e10cSrcweir const SfxPoolItem* pItem;
273cdf0e10cSrcweir if ( pReqArgs->GetItemState( SID_HYPERLINK_SETLINK, sal_True, &pItem ) == SFX_ITEM_SET )
274cdf0e10cSrcweir {
275cdf0e10cSrcweir const SvxHyperlinkItem* pHyper = (const SvxHyperlinkItem*) pItem;
276cdf0e10cSrcweir const String& rName = pHyper->GetName();
277cdf0e10cSrcweir const String& rURL = pHyper->GetURL();
278cdf0e10cSrcweir const String& rTarget = pHyper->GetTargetFrame();
279cdf0e10cSrcweir SvxLinkInsertMode eMode = pHyper->GetInsertMode();
280cdf0e10cSrcweir
281cdf0e10cSrcweir sal_Bool bDone = sal_False;
282cdf0e10cSrcweir if ( pOutView && ( eMode == HLINK_DEFAULT || eMode == HLINK_FIELD ) )
283cdf0e10cSrcweir {
284cdf0e10cSrcweir const SvxFieldItem* pFieldItem = pOutView->GetFieldAtSelection();
285cdf0e10cSrcweir if (pFieldItem)
286cdf0e10cSrcweir {
287cdf0e10cSrcweir const SvxFieldData* pField = pFieldItem->GetField();
288cdf0e10cSrcweir if ( pField && pField->ISA(SvxURLField) )
289cdf0e10cSrcweir {
290cdf0e10cSrcweir // altes Feld selektieren
291cdf0e10cSrcweir
292cdf0e10cSrcweir ESelection aSel = pOutView->GetSelection();
293cdf0e10cSrcweir aSel.Adjust();
294cdf0e10cSrcweir aSel.nEndPara = aSel.nStartPara;
295cdf0e10cSrcweir aSel.nEndPos = aSel.nStartPos + 1;
296cdf0e10cSrcweir pOutView->SetSelection( aSel );
297cdf0e10cSrcweir }
298cdf0e10cSrcweir }
299cdf0e10cSrcweir
300cdf0e10cSrcweir // neues Feld einfuegen
301cdf0e10cSrcweir
302cdf0e10cSrcweir SvxURLField aURLField( rURL, rName, SVXURLFORMAT_REPR );
303cdf0e10cSrcweir aURLField.SetTargetFrame( rTarget );
304cdf0e10cSrcweir SvxFieldItem aURLItem( aURLField, EE_FEATURE_FIELD );
305cdf0e10cSrcweir pOutView->InsertField( aURLItem );
306cdf0e10cSrcweir
307cdf0e10cSrcweir // select new field
308cdf0e10cSrcweir
309cdf0e10cSrcweir ESelection aSel = pOutView->GetSelection();
310cdf0e10cSrcweir if ( aSel.nStartPos == aSel.nEndPos && aSel.nStartPos > 0 )
311cdf0e10cSrcweir {
312cdf0e10cSrcweir // Cursor is behind the inserted field -> extend selection to the left
313cdf0e10cSrcweir
314cdf0e10cSrcweir --aSel.nStartPos;
315cdf0e10cSrcweir pOutView->SetSelection( aSel );
316cdf0e10cSrcweir }
317cdf0e10cSrcweir
318cdf0e10cSrcweir bDone = sal_True;
319cdf0e10cSrcweir }
320cdf0e10cSrcweir
321cdf0e10cSrcweir if (!bDone)
322cdf0e10cSrcweir ExecuteGlobal( rReq ); // normal an der View
323cdf0e10cSrcweir
324cdf0e10cSrcweir // InsertURL an der ViewShell schaltet bei "Text" die DrawShell ab !!!
325cdf0e10cSrcweir }
326cdf0e10cSrcweir }
327cdf0e10cSrcweir break;
328cdf0e10cSrcweir
329cdf0e10cSrcweir case SID_OPEN_HYPERLINK:
330cdf0e10cSrcweir {
331cdf0e10cSrcweir if ( pOutView )
332cdf0e10cSrcweir {
333cdf0e10cSrcweir const SvxFieldItem* pFieldItem = pOutView->GetFieldAtSelection();
334cdf0e10cSrcweir if ( pFieldItem )
335cdf0e10cSrcweir {
336cdf0e10cSrcweir const SvxFieldData* pField = pFieldItem->GetField();
337cdf0e10cSrcweir if( pField && pField->ISA( SvxURLField ) )
338cdf0e10cSrcweir {
339cdf0e10cSrcweir const SvxURLField* pURLField = static_cast< const SvxURLField* >( pField );
340cdf0e10cSrcweir ScGlobal::OpenURL( pURLField->GetURL(), pURLField->GetTargetFrame() );
341cdf0e10cSrcweir }
342cdf0e10cSrcweir }
343cdf0e10cSrcweir }
344cdf0e10cSrcweir }
345cdf0e10cSrcweir break;
346cdf0e10cSrcweir
347cdf0e10cSrcweir case SID_ENABLE_HYPHENATION:
348cdf0e10cSrcweir case SID_TEXTDIRECTION_LEFT_TO_RIGHT:
349cdf0e10cSrcweir case SID_TEXTDIRECTION_TOP_TO_BOTTOM:
350cdf0e10cSrcweir #if 0 // DR
351cdf0e10cSrcweir if (IsNoteEdit())
352cdf0e10cSrcweir {
353cdf0e10cSrcweir pView->CaptionTextDirection( rReq.GetSlot()); // process Notes before we end the text edit.
354cdf0e10cSrcweir ExecuteGlobal( rReq );
355cdf0e10cSrcweir pViewData->GetDispatcher().Execute(pViewData->GetView()->GetDrawFuncPtr()->GetSlotID(), SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD);
356cdf0e10cSrcweir }
357cdf0e10cSrcweir else
358cdf0e10cSrcweir #endif
359cdf0e10cSrcweir {
360cdf0e10cSrcweir pView->ScEndTextEdit(); // end text edit before switching direction
361cdf0e10cSrcweir ExecuteGlobal( rReq );
362cdf0e10cSrcweir // restore consistent state between shells and functions:
363cdf0e10cSrcweir pViewData->GetDispatcher().Execute(SID_OBJECT_SELECT, SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD);
364cdf0e10cSrcweir }
365cdf0e10cSrcweir break;
366cdf0e10cSrcweir
367cdf0e10cSrcweir #if 0
368cdf0e10cSrcweir // Hyphenation is handled above - text edit is ended
369cdf0e10cSrcweir case SID_ENABLE_HYPHENATION:
370cdf0e10cSrcweir // force loading of hyphenator (object is skipped in repaint)
371cdf0e10cSrcweir ((ScDrawLayer*)pView->GetModel())->UseHyphenator();
372cdf0e10cSrcweir pOutliner->SetHyphenator( LinguMgr::GetHyphenator() );
373cdf0e10cSrcweir ExecuteGlobal( rReq );
374cdf0e10cSrcweir break;
375cdf0e10cSrcweir #endif
376cdf0e10cSrcweir
377cdf0e10cSrcweir case SID_THES:
378cdf0e10cSrcweir {
379cdf0e10cSrcweir String aReplaceText;
380cdf0e10cSrcweir SFX_REQUEST_ARG( rReq, pItem2, SfxStringItem, SID_THES, sal_False );
381cdf0e10cSrcweir if (pItem2)
382cdf0e10cSrcweir aReplaceText = pItem2->GetValue();
383cdf0e10cSrcweir if (aReplaceText.Len() > 0)
384cdf0e10cSrcweir ReplaceTextWithSynonym( pOutView->GetEditView(), aReplaceText );
385cdf0e10cSrcweir }
386cdf0e10cSrcweir break;
387cdf0e10cSrcweir
388cdf0e10cSrcweir case SID_THESAURUS:
389cdf0e10cSrcweir {
390cdf0e10cSrcweir pOutView->StartThesaurus();
391cdf0e10cSrcweir }
392cdf0e10cSrcweir break;
393cdf0e10cSrcweir
394cdf0e10cSrcweir }
395cdf0e10cSrcweir }
396cdf0e10cSrcweir
GetState(SfxItemSet & rSet)397cdf0e10cSrcweir void __EXPORT ScDrawTextObjectBar::GetState( SfxItemSet& rSet )
398cdf0e10cSrcweir {
399cdf0e10cSrcweir SfxViewFrame* pViewFrm = pViewData->GetViewShell()->GetViewFrame();
400cdf0e10cSrcweir sal_Bool bHasFontWork = pViewFrm->HasChildWindow(SID_FONTWORK);
401cdf0e10cSrcweir sal_Bool bDisableFontWork = sal_False;
402cdf0e10cSrcweir
403cdf0e10cSrcweir if (IsNoteEdit())
404cdf0e10cSrcweir {
405cdf0e10cSrcweir // #i21255# notes now support rich text formatting (#i74140# but not fontwork)
406cdf0e10cSrcweir bDisableFontWork = sal_True;
407cdf0e10cSrcweir }
408cdf0e10cSrcweir
409cdf0e10cSrcweir if ( bDisableFontWork )
410cdf0e10cSrcweir rSet.DisableItem( SID_FONTWORK );
411cdf0e10cSrcweir else
412cdf0e10cSrcweir rSet.Put(SfxBoolItem(SID_FONTWORK, bHasFontWork));
413cdf0e10cSrcweir
414cdf0e10cSrcweir if ( rSet.GetItemState( SID_HYPERLINK_GETLINK ) != SFX_ITEM_UNKNOWN )
415cdf0e10cSrcweir {
416cdf0e10cSrcweir SvxHyperlinkItem aHLinkItem;
417cdf0e10cSrcweir SdrView* pView = pViewData->GetScDrawView();
418cdf0e10cSrcweir OutlinerView* pOutView = pView->GetTextEditOutlinerView();
419cdf0e10cSrcweir if ( pOutView )
420cdf0e10cSrcweir {
421cdf0e10cSrcweir sal_Bool bField = sal_False;
422cdf0e10cSrcweir const SvxFieldItem* pFieldItem = pOutView->GetFieldAtSelection();
423cdf0e10cSrcweir if (pFieldItem)
424cdf0e10cSrcweir {
425cdf0e10cSrcweir const SvxFieldData* pField = pFieldItem->GetField();
426cdf0e10cSrcweir if ( pField && pField->ISA(SvxURLField) )
427cdf0e10cSrcweir {
428cdf0e10cSrcweir const SvxURLField* pURLField = (const SvxURLField*) pField;
429cdf0e10cSrcweir aHLinkItem.SetName( pURLField->GetRepresentation() );
430cdf0e10cSrcweir aHLinkItem.SetURL( pURLField->GetURL() );
431cdf0e10cSrcweir aHLinkItem.SetTargetFrame( pURLField->GetTargetFrame() );
432cdf0e10cSrcweir bField = sal_True;
433cdf0e10cSrcweir }
434cdf0e10cSrcweir }
435cdf0e10cSrcweir if (!bField)
436cdf0e10cSrcweir {
437cdf0e10cSrcweir // use selected text as name for urls
438cdf0e10cSrcweir String sReturn = pOutView->GetSelected();
439cdf0e10cSrcweir sReturn.Erase(255);
440cdf0e10cSrcweir sReturn.EraseTrailingChars();
441cdf0e10cSrcweir aHLinkItem.SetName(sReturn);
442cdf0e10cSrcweir }
443cdf0e10cSrcweir }
444cdf0e10cSrcweir rSet.Put(aHLinkItem);
445cdf0e10cSrcweir }
446cdf0e10cSrcweir
447cdf0e10cSrcweir if ( rSet.GetItemState( SID_OPEN_HYPERLINK ) != SFX_ITEM_UNKNOWN )
448cdf0e10cSrcweir {
449cdf0e10cSrcweir SdrView* pView = pViewData->GetScDrawView();
450cdf0e10cSrcweir OutlinerView* pOutView = pView->GetTextEditOutlinerView();
451cdf0e10cSrcweir bool bEnable = false;
452cdf0e10cSrcweir if ( pOutView )
453cdf0e10cSrcweir {
454cdf0e10cSrcweir const SvxFieldItem* pFieldItem = pOutView->GetFieldAtSelection();
455cdf0e10cSrcweir if ( pFieldItem )
456cdf0e10cSrcweir {
457cdf0e10cSrcweir const SvxFieldData* pField = pFieldItem->GetField();
458cdf0e10cSrcweir bEnable = pField && pField->ISA( SvxURLField );
459cdf0e10cSrcweir }
460cdf0e10cSrcweir }
461cdf0e10cSrcweir if( !bEnable )
462cdf0e10cSrcweir rSet.DisableItem( SID_OPEN_HYPERLINK );
463cdf0e10cSrcweir }
464cdf0e10cSrcweir
465cdf0e10cSrcweir if( rSet.GetItemState( SID_TRANSLITERATE_HALFWIDTH ) != SFX_ITEM_UNKNOWN )
466cdf0e10cSrcweir ScViewUtil::HideDisabledSlot( rSet, pViewFrm->GetBindings(), SID_TRANSLITERATE_HALFWIDTH );
467cdf0e10cSrcweir if( rSet.GetItemState( SID_TRANSLITERATE_FULLWIDTH ) != SFX_ITEM_UNKNOWN )
468cdf0e10cSrcweir ScViewUtil::HideDisabledSlot( rSet, pViewFrm->GetBindings(), SID_TRANSLITERATE_FULLWIDTH );
469cdf0e10cSrcweir if( rSet.GetItemState( SID_TRANSLITERATE_HIRAGANA ) != SFX_ITEM_UNKNOWN )
470cdf0e10cSrcweir ScViewUtil::HideDisabledSlot( rSet, pViewFrm->GetBindings(), SID_TRANSLITERATE_HIRAGANA );
471cdf0e10cSrcweir if( rSet.GetItemState( SID_TRANSLITERATE_KATAGANA ) != SFX_ITEM_UNKNOWN )
472cdf0e10cSrcweir ScViewUtil::HideDisabledSlot( rSet, pViewFrm->GetBindings(), SID_TRANSLITERATE_KATAGANA );
473cdf0e10cSrcweir
474cdf0e10cSrcweir if ( rSet.GetItemState( SID_ENABLE_HYPHENATION ) != SFX_ITEM_UNKNOWN )
475cdf0e10cSrcweir {
476cdf0e10cSrcweir SdrView* pView = pViewData->GetScDrawView();
477cdf0e10cSrcweir SfxItemSet aAttrs( pView->GetModel()->GetItemPool() );
478cdf0e10cSrcweir pView->GetAttributes( aAttrs );
479cdf0e10cSrcweir if( aAttrs.GetItemState( EE_PARA_HYPHENATE ) >= SFX_ITEM_AVAILABLE )
480cdf0e10cSrcweir {
481cdf0e10cSrcweir sal_Bool bValue = ( (const SfxBoolItem&) aAttrs.Get( EE_PARA_HYPHENATE ) ).GetValue();
482cdf0e10cSrcweir rSet.Put( SfxBoolItem( SID_ENABLE_HYPHENATION, bValue ) );
483cdf0e10cSrcweir }
484cdf0e10cSrcweir }
485cdf0e10cSrcweir
486cdf0e10cSrcweir if ( rSet.GetItemState( SID_THES ) != SFX_ITEM_UNKNOWN ||
487cdf0e10cSrcweir rSet.GetItemState( SID_THESAURUS ) != SFX_ITEM_UNKNOWN )
488cdf0e10cSrcweir {
489cdf0e10cSrcweir SdrView * pView = pViewData->GetScDrawView();
490cdf0e10cSrcweir OutlinerView* pOutView = pView->GetTextEditOutlinerView();
491cdf0e10cSrcweir
492cdf0e10cSrcweir String aStatusVal;
493cdf0e10cSrcweir LanguageType nLang = LANGUAGE_NONE;
494cdf0e10cSrcweir bool bIsLookUpWord = false;
495cdf0e10cSrcweir if ( pOutView )
496cdf0e10cSrcweir {
497cdf0e10cSrcweir EditView& rEditView = pOutView->GetEditView();
498cdf0e10cSrcweir bIsLookUpWord = GetStatusValueForThesaurusFromContext( aStatusVal, nLang, rEditView );
499cdf0e10cSrcweir }
500cdf0e10cSrcweir rSet.Put( SfxStringItem( SID_THES, aStatusVal ) );
501cdf0e10cSrcweir
502cdf0e10cSrcweir // disable thesaurus main menu and context menu entry if there is nothing to look up
503cdf0e10cSrcweir sal_Bool bCanDoThesaurus = ScModule::HasThesaurusLanguage( nLang );
504cdf0e10cSrcweir if (!bIsLookUpWord || !bCanDoThesaurus)
505cdf0e10cSrcweir rSet.DisableItem( SID_THES );
506cdf0e10cSrcweir if (!bCanDoThesaurus)
507cdf0e10cSrcweir rSet.DisableItem( SID_THESAURUS );
508cdf0e10cSrcweir }
509cdf0e10cSrcweir }
510cdf0e10cSrcweir
IMPL_LINK(ScDrawTextObjectBar,ClipboardChanged,TransferableDataHelper *,pDataHelper)511cdf0e10cSrcweir IMPL_LINK( ScDrawTextObjectBar, ClipboardChanged, TransferableDataHelper*, pDataHelper )
512cdf0e10cSrcweir {
513cdf0e10cSrcweir if ( pDataHelper )
514cdf0e10cSrcweir {
515cdf0e10cSrcweir bPastePossible = ( pDataHelper->HasFormat( SOT_FORMAT_STRING ) || pDataHelper->HasFormat( SOT_FORMAT_RTF ) );
516cdf0e10cSrcweir
517cdf0e10cSrcweir SfxBindings& rBindings = pViewData->GetBindings();
518cdf0e10cSrcweir rBindings.Invalidate( SID_PASTE );
519cdf0e10cSrcweir rBindings.Invalidate( SID_PASTE_SPECIAL );
520cdf0e10cSrcweir rBindings.Invalidate( SID_CLIPBOARD_FORMAT_ITEMS );
521cdf0e10cSrcweir }
522cdf0e10cSrcweir return 0;
523cdf0e10cSrcweir }
524cdf0e10cSrcweir
GetClipState(SfxItemSet & rSet)525cdf0e10cSrcweir void __EXPORT ScDrawTextObjectBar::GetClipState( SfxItemSet& rSet )
526cdf0e10cSrcweir {
527cdf0e10cSrcweir SdrView* pView = pViewData->GetScDrawView();
528cdf0e10cSrcweir if ( !pView->GetTextEditOutlinerView() )
529cdf0e10cSrcweir {
530cdf0e10cSrcweir GetGlobalClipState( rSet );
531cdf0e10cSrcweir return;
532cdf0e10cSrcweir }
533cdf0e10cSrcweir
534cdf0e10cSrcweir if ( !pClipEvtLstnr )
535cdf0e10cSrcweir {
536cdf0e10cSrcweir // create listener
537cdf0e10cSrcweir pClipEvtLstnr = new TransferableClipboardListener( LINK( this, ScDrawTextObjectBar, ClipboardChanged ) );
538cdf0e10cSrcweir pClipEvtLstnr->acquire();
539cdf0e10cSrcweir Window* pWin = pViewData->GetActiveWin();
540cdf0e10cSrcweir pClipEvtLstnr->AddRemoveListener( pWin, sal_True );
541cdf0e10cSrcweir
542cdf0e10cSrcweir // get initial state
543cdf0e10cSrcweir TransferableDataHelper aDataHelper( TransferableDataHelper::CreateFromSystemClipboard( pViewData->GetActiveWin() ) );
544cdf0e10cSrcweir bPastePossible = ( aDataHelper.HasFormat( SOT_FORMAT_STRING ) || aDataHelper.HasFormat( SOT_FORMAT_RTF ) );
545cdf0e10cSrcweir }
546cdf0e10cSrcweir
547cdf0e10cSrcweir SfxWhichIter aIter( rSet );
548cdf0e10cSrcweir sal_uInt16 nWhich = aIter.FirstWhich();
549cdf0e10cSrcweir while (nWhich)
550cdf0e10cSrcweir {
551cdf0e10cSrcweir switch (nWhich)
552cdf0e10cSrcweir {
553cdf0e10cSrcweir case SID_PASTE:
554cdf0e10cSrcweir case SID_PASTE_SPECIAL:
555cdf0e10cSrcweir if( !bPastePossible )
556cdf0e10cSrcweir rSet.DisableItem( nWhich );
557cdf0e10cSrcweir break;
558cdf0e10cSrcweir case SID_CLIPBOARD_FORMAT_ITEMS:
559cdf0e10cSrcweir if ( bPastePossible )
560cdf0e10cSrcweir {
561cdf0e10cSrcweir SvxClipboardFmtItem aFormats( SID_CLIPBOARD_FORMAT_ITEMS );
562cdf0e10cSrcweir TransferableDataHelper aDataHelper(
563cdf0e10cSrcweir TransferableDataHelper::CreateFromSystemClipboard( pViewData->GetActiveWin() ) );
564cdf0e10cSrcweir
565cdf0e10cSrcweir if ( aDataHelper.HasFormat( SOT_FORMAT_STRING ) )
566cdf0e10cSrcweir aFormats.AddClipbrdFormat( SOT_FORMAT_STRING );
567cdf0e10cSrcweir if ( aDataHelper.HasFormat( SOT_FORMAT_RTF ) )
568cdf0e10cSrcweir aFormats.AddClipbrdFormat( SOT_FORMAT_RTF );
569cdf0e10cSrcweir
570cdf0e10cSrcweir rSet.Put( aFormats );
571cdf0e10cSrcweir }
572cdf0e10cSrcweir else
573cdf0e10cSrcweir rSet.DisableItem( nWhich );
574cdf0e10cSrcweir break;
575cdf0e10cSrcweir }
576cdf0e10cSrcweir nWhich = aIter.NextWhich();
577cdf0e10cSrcweir }
578cdf0e10cSrcweir }
579cdf0e10cSrcweir
580cdf0e10cSrcweir //========================================================================
581cdf0e10cSrcweir //
582cdf0e10cSrcweir // Attribute
583cdf0e10cSrcweir //
584cdf0e10cSrcweir //========================================================================
585cdf0e10cSrcweir
ExecuteToggle(SfxRequest & rReq)586cdf0e10cSrcweir void __EXPORT ScDrawTextObjectBar::ExecuteToggle( SfxRequest &rReq )
587cdf0e10cSrcweir {
588cdf0e10cSrcweir // Unterstreichung
589cdf0e10cSrcweir
590cdf0e10cSrcweir SdrView* pView = pViewData->GetScDrawView();
591cdf0e10cSrcweir
592cdf0e10cSrcweir sal_uInt16 nSlot = rReq.GetSlot();
593cdf0e10cSrcweir
594cdf0e10cSrcweir SfxItemSet aSet( pView->GetDefaultAttr() );
595cdf0e10cSrcweir
596cdf0e10cSrcweir SfxItemSet aViewAttr(pView->GetModel()->GetItemPool());
597cdf0e10cSrcweir pView->GetAttributes(aViewAttr);
598cdf0e10cSrcweir
599cdf0e10cSrcweir // Unterstreichung
600cdf0e10cSrcweir FontUnderline eOld = ((const SvxUnderlineItem&) aViewAttr.
601cdf0e10cSrcweir Get(EE_CHAR_UNDERLINE)).GetLineStyle();
602cdf0e10cSrcweir FontUnderline eNew = eOld;
603cdf0e10cSrcweir switch (nSlot)
604cdf0e10cSrcweir {
605cdf0e10cSrcweir case SID_ULINE_VAL_NONE:
606cdf0e10cSrcweir eNew = UNDERLINE_NONE;
607cdf0e10cSrcweir break;
608cdf0e10cSrcweir case SID_ULINE_VAL_SINGLE:
609cdf0e10cSrcweir eNew = ( eOld == UNDERLINE_SINGLE ) ? UNDERLINE_NONE : UNDERLINE_SINGLE;
610cdf0e10cSrcweir break;
611cdf0e10cSrcweir case SID_ULINE_VAL_DOUBLE:
612cdf0e10cSrcweir eNew = ( eOld == UNDERLINE_DOUBLE ) ? UNDERLINE_NONE : UNDERLINE_DOUBLE;
613cdf0e10cSrcweir break;
614cdf0e10cSrcweir case SID_ULINE_VAL_DOTTED:
615cdf0e10cSrcweir eNew = ( eOld == UNDERLINE_DOTTED ) ? UNDERLINE_NONE : UNDERLINE_DOTTED;
616cdf0e10cSrcweir break;
617cdf0e10cSrcweir default:
618cdf0e10cSrcweir break;
619cdf0e10cSrcweir }
620cdf0e10cSrcweir aSet.Put( SvxUnderlineItem( eNew, EE_CHAR_UNDERLINE ) );
621cdf0e10cSrcweir
622cdf0e10cSrcweir pView->SetAttributes( aSet );
623cdf0e10cSrcweir rReq.Done();
624cdf0e10cSrcweir pViewData->GetScDrawView()->InvalidateDrawTextAttrs();
625cdf0e10cSrcweir }
626cdf0e10cSrcweir
lcl_RemoveFields(OutlinerView & rOutView)627cdf0e10cSrcweir void lcl_RemoveFields( OutlinerView& rOutView )
628cdf0e10cSrcweir {
629cdf0e10cSrcweir //! Outliner should have RemoveFields with a selection
630cdf0e10cSrcweir
631cdf0e10cSrcweir Outliner* pOutliner = rOutView.GetOutliner();
632cdf0e10cSrcweir if (!pOutliner) return;
633cdf0e10cSrcweir
634cdf0e10cSrcweir ESelection aOldSel = rOutView.GetSelection();
635cdf0e10cSrcweir ESelection aSel = aOldSel;
636cdf0e10cSrcweir aSel.Adjust();
637cdf0e10cSrcweir xub_StrLen nNewEnd = aSel.nEndPos;
638cdf0e10cSrcweir
639cdf0e10cSrcweir sal_Bool bUpdate = pOutliner->GetUpdateMode();
640cdf0e10cSrcweir sal_Bool bChanged = sal_False;
641cdf0e10cSrcweir
642cdf0e10cSrcweir //! GetPortions and GetAttribs should be const!
643cdf0e10cSrcweir EditEngine& rEditEng = (EditEngine&)pOutliner->GetEditEngine();
644cdf0e10cSrcweir
645cdf0e10cSrcweir sal_uLong nParCount = pOutliner->GetParagraphCount();
646cdf0e10cSrcweir for (sal_uLong nPar=0; nPar<nParCount; nPar++)
647cdf0e10cSrcweir if ( nPar >= aSel.nStartPara && nPar <= aSel.nEndPara )
648cdf0e10cSrcweir {
649cdf0e10cSrcweir SvUShorts aPortions;
650*c2eaa082SDamjan Jovanovic rEditEng.GetPortions( nPar, aPortions );
651766ce4d0SZheng Fan //! GetPortions should use xub_StrLen instead of sal_uInt16
652cdf0e10cSrcweir
653cdf0e10cSrcweir for ( sal_uInt16 nPos = aPortions.Count(); nPos; )
654cdf0e10cSrcweir {
655cdf0e10cSrcweir --nPos;
656cdf0e10cSrcweir sal_uInt16 nEnd = aPortions.GetObject( nPos );
657cdf0e10cSrcweir sal_uInt16 nStart = nPos ? aPortions.GetObject( nPos - 1 ) : 0;
658cdf0e10cSrcweir // fields are single characters
659cdf0e10cSrcweir if ( nEnd == nStart+1 &&
660cdf0e10cSrcweir ( nPar > aSel.nStartPara || nStart >= aSel.nStartPos ) &&
661cdf0e10cSrcweir ( nPar < aSel.nEndPara || nEnd <= aSel.nEndPos ) )
662cdf0e10cSrcweir {
663*c2eaa082SDamjan Jovanovic ESelection aFieldSel( nPar, nStart, nPar, nEnd );
664cdf0e10cSrcweir SfxItemSet aSet = rEditEng.GetAttribs( aFieldSel );
665cdf0e10cSrcweir if ( aSet.GetItemState( EE_FEATURE_FIELD ) == SFX_ITEM_ON )
666cdf0e10cSrcweir {
667cdf0e10cSrcweir if (!bChanged)
668cdf0e10cSrcweir {
669cdf0e10cSrcweir if (bUpdate)
670cdf0e10cSrcweir pOutliner->SetUpdateMode( sal_False );
671cdf0e10cSrcweir String aName = ScGlobal::GetRscString( STR_UNDO_DELETECONTENTS );
672cdf0e10cSrcweir pOutliner->GetUndoManager().EnterListAction( aName, aName );
673cdf0e10cSrcweir bChanged = sal_True;
674cdf0e10cSrcweir }
675cdf0e10cSrcweir
676cdf0e10cSrcweir String aFieldText = rEditEng.GetText( aFieldSel );
677cdf0e10cSrcweir pOutliner->QuickInsertText( aFieldText, aFieldSel );
678cdf0e10cSrcweir if ( nPar == aSel.nEndPara )
679cdf0e10cSrcweir {
680cdf0e10cSrcweir nNewEnd = sal::static_int_cast<xub_StrLen>( nNewEnd + aFieldText.Len() );
681cdf0e10cSrcweir --nNewEnd;
682cdf0e10cSrcweir }
683cdf0e10cSrcweir }
684cdf0e10cSrcweir }
685cdf0e10cSrcweir }
686cdf0e10cSrcweir }
687cdf0e10cSrcweir
688cdf0e10cSrcweir if (bUpdate && bChanged)
689cdf0e10cSrcweir {
690cdf0e10cSrcweir pOutliner->GetUndoManager().LeaveListAction();
691cdf0e10cSrcweir pOutliner->SetUpdateMode( sal_True );
692cdf0e10cSrcweir }
693cdf0e10cSrcweir
694cdf0e10cSrcweir if ( aOldSel.IsEqual( aSel ) ) // aSel is adjusted
695cdf0e10cSrcweir aOldSel.nEndPos = nNewEnd;
696cdf0e10cSrcweir else
697cdf0e10cSrcweir aOldSel.nStartPos = nNewEnd; // if aOldSel is backwards
698cdf0e10cSrcweir rOutView.SetSelection( aOldSel );
699cdf0e10cSrcweir }
700cdf0e10cSrcweir
ExecuteAttr(SfxRequest & rReq)701cdf0e10cSrcweir void __EXPORT ScDrawTextObjectBar::ExecuteAttr( SfxRequest &rReq )
702cdf0e10cSrcweir {
703cdf0e10cSrcweir SdrView* pView = pViewData->GetScDrawView();
704cdf0e10cSrcweir const SfxItemSet* pArgs = rReq.GetArgs();
705cdf0e10cSrcweir sal_uInt16 nSlot = rReq.GetSlot();
706cdf0e10cSrcweir
707cdf0e10cSrcweir sal_Bool bArgsInReq = ( pArgs != NULL );
708cdf0e10cSrcweir if ( !bArgsInReq )
709cdf0e10cSrcweir {
710cdf0e10cSrcweir SfxItemSet aEditAttr(pView->GetModel()->GetItemPool());
711cdf0e10cSrcweir pView->GetAttributes(aEditAttr);
712cdf0e10cSrcweir SfxItemSet aNewAttr( *aEditAttr.GetPool(), aEditAttr.GetRanges() );
713cdf0e10cSrcweir sal_Bool bDone = sal_True;
714cdf0e10cSrcweir
715cdf0e10cSrcweir switch ( nSlot )
716cdf0e10cSrcweir {
717cdf0e10cSrcweir case SID_TEXT_STANDARD: // Harte Textattributierung loeschen
718cdf0e10cSrcweir {
719cdf0e10cSrcweir OutlinerView* pOutView = pView->IsTextEdit() ?
720cdf0e10cSrcweir pView->GetTextEditOutlinerView() : NULL;
721cdf0e10cSrcweir if ( pOutView )
722cdf0e10cSrcweir pOutView->Paint( Rectangle() );
723cdf0e10cSrcweir
724cdf0e10cSrcweir SfxItemSet aEmptyAttr( *aEditAttr.GetPool(), EE_ITEMS_START, EE_ITEMS_END );
725cdf0e10cSrcweir pView->SetAttributes( aEmptyAttr, sal_True );
726cdf0e10cSrcweir
727cdf0e10cSrcweir if ( pOutView )
728cdf0e10cSrcweir {
729cdf0e10cSrcweir lcl_RemoveFields( *pOutView );
730cdf0e10cSrcweir pOutView->ShowCursor();
731cdf0e10cSrcweir }
732cdf0e10cSrcweir
733cdf0e10cSrcweir rReq.Done( aEmptyAttr );
734cdf0e10cSrcweir pViewData->GetScDrawView()->InvalidateDrawTextAttrs();
735cdf0e10cSrcweir bDone = sal_False; // bereits hier passiert
736cdf0e10cSrcweir }
737cdf0e10cSrcweir break;
738cdf0e10cSrcweir
739d9a8b508SZheng Fan case SID_CHAR_DLG_EFFECT:
740cdf0e10cSrcweir case SID_CHAR_DLG: // Dialog-Button
741cdf0e10cSrcweir case SID_ATTR_CHAR_FONT: // Controller nicht angezeigt
742cdf0e10cSrcweir case SID_ATTR_CHAR_FONTHEIGHT:
743d9a8b508SZheng Fan bDone = ExecuteCharDlg( aEditAttr, aNewAttr , nSlot);
744cdf0e10cSrcweir break;
745cdf0e10cSrcweir
746cdf0e10cSrcweir case SID_PARA_DLG:
747cdf0e10cSrcweir bDone = ExecuteParaDlg( aEditAttr, aNewAttr );
748cdf0e10cSrcweir break;
749cdf0e10cSrcweir
750cdf0e10cSrcweir case SID_ATTR_CHAR_WEIGHT:
751cdf0e10cSrcweir aNewAttr.Put( (const SvxWeightItem&)aEditAttr.Get( EE_CHAR_WEIGHT ) );
752cdf0e10cSrcweir break;
753cdf0e10cSrcweir
754cdf0e10cSrcweir case SID_ATTR_CHAR_POSTURE:
755cdf0e10cSrcweir aNewAttr.Put( (const SvxPostureItem&)aEditAttr.Get( EE_CHAR_ITALIC ) );
756cdf0e10cSrcweir break;
757cdf0e10cSrcweir
758cdf0e10cSrcweir case SID_ATTR_CHAR_UNDERLINE:
759cdf0e10cSrcweir aNewAttr.Put( (const SvxUnderlineItem&)aEditAttr.Get( EE_CHAR_UNDERLINE ) );
760cdf0e10cSrcweir break;
761cdf0e10cSrcweir
762cdf0e10cSrcweir case SID_ATTR_CHAR_OVERLINE:
763cdf0e10cSrcweir aNewAttr.Put( (const SvxOverlineItem&)aEditAttr.Get( EE_CHAR_OVERLINE ) );
764cdf0e10cSrcweir break;
765cdf0e10cSrcweir
766cdf0e10cSrcweir case SID_ATTR_CHAR_CONTOUR:
767cdf0e10cSrcweir aNewAttr.Put( (const SvxContourItem&)aEditAttr.Get( EE_CHAR_OUTLINE ) );
768cdf0e10cSrcweir break;
769cdf0e10cSrcweir
770cdf0e10cSrcweir case SID_ATTR_CHAR_SHADOWED:
771cdf0e10cSrcweir aNewAttr.Put( (const SvxShadowedItem&)aEditAttr.Get( EE_CHAR_SHADOW ) );
772cdf0e10cSrcweir break;
773cdf0e10cSrcweir
774cdf0e10cSrcweir case SID_ATTR_CHAR_STRIKEOUT:
775cdf0e10cSrcweir aNewAttr.Put( (const SvxCrossedOutItem&)aEditAttr.Get( EE_CHAR_STRIKEOUT ) );
776cdf0e10cSrcweir break;
777cdf0e10cSrcweir
778cdf0e10cSrcweir case SID_ALIGNLEFT:
779cdf0e10cSrcweir case SID_ALIGN_ANY_LEFT:
780cdf0e10cSrcweir aNewAttr.Put( SvxAdjustItem( SVX_ADJUST_LEFT, EE_PARA_JUST ) );
781cdf0e10cSrcweir break;
782cdf0e10cSrcweir
783cdf0e10cSrcweir case SID_ALIGNCENTERHOR:
784cdf0e10cSrcweir case SID_ALIGN_ANY_HCENTER:
785cdf0e10cSrcweir aNewAttr.Put( SvxAdjustItem( SVX_ADJUST_CENTER, EE_PARA_JUST ) );
786cdf0e10cSrcweir break;
787cdf0e10cSrcweir
788cdf0e10cSrcweir case SID_ALIGNRIGHT:
789cdf0e10cSrcweir case SID_ALIGN_ANY_RIGHT:
790cdf0e10cSrcweir aNewAttr.Put( SvxAdjustItem( SVX_ADJUST_RIGHT, EE_PARA_JUST ) );
791cdf0e10cSrcweir break;
792cdf0e10cSrcweir
793cdf0e10cSrcweir case SID_ALIGNBLOCK:
794cdf0e10cSrcweir case SID_ALIGN_ANY_JUSTIFIED:
795cdf0e10cSrcweir aNewAttr.Put( SvxAdjustItem( SVX_ADJUST_BLOCK, EE_PARA_JUST ) );
796cdf0e10cSrcweir break;
797cdf0e10cSrcweir
798cdf0e10cSrcweir case SID_ATTR_PARA_LINESPACE_10:
799cdf0e10cSrcweir {
800cdf0e10cSrcweir SvxLineSpacingItem aItem( SVX_LINESPACE_ONE_LINE, EE_PARA_SBL );
801cdf0e10cSrcweir aItem.SetPropLineSpace( 100 );
802cdf0e10cSrcweir aNewAttr.Put( aItem );
803cdf0e10cSrcweir }
804cdf0e10cSrcweir break;
805cdf0e10cSrcweir
806cdf0e10cSrcweir case SID_ATTR_PARA_LINESPACE_15:
807cdf0e10cSrcweir {
808cdf0e10cSrcweir SvxLineSpacingItem aItem( SVX_LINESPACE_ONE_POINT_FIVE_LINES, EE_PARA_SBL );
809cdf0e10cSrcweir aItem.SetPropLineSpace( 150 );
810cdf0e10cSrcweir aNewAttr.Put( aItem );
811cdf0e10cSrcweir }
812cdf0e10cSrcweir break;
813cdf0e10cSrcweir
814cdf0e10cSrcweir case SID_ATTR_PARA_LINESPACE_20:
815cdf0e10cSrcweir {
816cdf0e10cSrcweir SvxLineSpacingItem aItem( SVX_LINESPACE_TWO_LINES, EE_PARA_SBL );
817cdf0e10cSrcweir aItem.SetPropLineSpace( 200 );
818cdf0e10cSrcweir aNewAttr.Put( aItem );
819cdf0e10cSrcweir }
820cdf0e10cSrcweir break;
821cdf0e10cSrcweir
822cdf0e10cSrcweir case SID_SET_SUPER_SCRIPT:
823cdf0e10cSrcweir {
824cdf0e10cSrcweir SvxEscapementItem aItem(EE_CHAR_ESCAPEMENT);
825cdf0e10cSrcweir SvxEscapement eEsc = (SvxEscapement) ( (const SvxEscapementItem&)
826cdf0e10cSrcweir aEditAttr.Get( EE_CHAR_ESCAPEMENT ) ).GetEnumValue();
827cdf0e10cSrcweir
828cdf0e10cSrcweir if( eEsc == SVX_ESCAPEMENT_SUPERSCRIPT )
829cdf0e10cSrcweir aItem.SetEscapement( SVX_ESCAPEMENT_OFF );
830cdf0e10cSrcweir else
831cdf0e10cSrcweir aItem.SetEscapement( SVX_ESCAPEMENT_SUPERSCRIPT );
832cdf0e10cSrcweir aNewAttr.Put( aItem );
833cdf0e10cSrcweir }
834cdf0e10cSrcweir break;
835cdf0e10cSrcweir case SID_SET_SUB_SCRIPT:
836cdf0e10cSrcweir {
837cdf0e10cSrcweir SvxEscapementItem aItem(EE_CHAR_ESCAPEMENT);
838cdf0e10cSrcweir SvxEscapement eEsc = (SvxEscapement) ( (const SvxEscapementItem&)
839cdf0e10cSrcweir aEditAttr.Get( EE_CHAR_ESCAPEMENT ) ).GetEnumValue();
840cdf0e10cSrcweir
841cdf0e10cSrcweir if( eEsc == SVX_ESCAPEMENT_SUBSCRIPT )
842cdf0e10cSrcweir aItem.SetEscapement( SVX_ESCAPEMENT_OFF );
843cdf0e10cSrcweir else
844cdf0e10cSrcweir aItem.SetEscapement( SVX_ESCAPEMENT_SUBSCRIPT );
845cdf0e10cSrcweir aNewAttr.Put( aItem );
846cdf0e10cSrcweir }
847cdf0e10cSrcweir break;
848cdf0e10cSrcweir
849cdf0e10cSrcweir case SID_DRAWTEXT_ATTR_DLG:
850cdf0e10cSrcweir {
851cdf0e10cSrcweir SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
852cdf0e10cSrcweir SfxAbstractTabDialog *pDlg = pFact->CreateTextTabDialog( pViewData->GetDialogParent(), &aEditAttr, pView );
853cdf0e10cSrcweir
854cdf0e10cSrcweir bDone = ( RET_OK == pDlg->Execute() );
855cdf0e10cSrcweir
856cdf0e10cSrcweir if ( bDone )
857cdf0e10cSrcweir aNewAttr.Put( *pDlg->GetOutputItemSet() );
858cdf0e10cSrcweir
859cdf0e10cSrcweir delete pDlg;
860512ec161SZheng Fan
861512ec161SZheng Fan SfxBindings& rBindings = pViewData->GetBindings();
862512ec161SZheng Fan rBindings.Invalidate( SID_TABLE_VERT_NONE );
863512ec161SZheng Fan rBindings.Invalidate( SID_TABLE_VERT_CENTER );
864512ec161SZheng Fan rBindings.Invalidate( SID_TABLE_VERT_BOTTOM );
865cdf0e10cSrcweir }
866cdf0e10cSrcweir break;
867cdf0e10cSrcweir }
868cdf0e10cSrcweir
869cdf0e10cSrcweir if ( bDone ) // wurden Attribute geaendert?
870cdf0e10cSrcweir {
871cdf0e10cSrcweir rReq.Done( aNewAttr );
872cdf0e10cSrcweir pArgs = rReq.GetArgs();
873cdf0e10cSrcweir }
874cdf0e10cSrcweir }
875cdf0e10cSrcweir
876cdf0e10cSrcweir if ( pArgs )
877cdf0e10cSrcweir {
878cdf0e10cSrcweir if ( bArgsInReq &&
879cdf0e10cSrcweir ( nSlot == SID_ATTR_CHAR_FONT || nSlot == SID_ATTR_CHAR_FONTHEIGHT ||
880cdf0e10cSrcweir nSlot == SID_ATTR_CHAR_WEIGHT || nSlot == SID_ATTR_CHAR_POSTURE ) )
881cdf0e10cSrcweir {
882cdf0e10cSrcweir // font items from toolbox controller have to be applied for the right script type
883cdf0e10cSrcweir
884cdf0e10cSrcweir // #i78017 establish the same behaviour as in Writer
885cdf0e10cSrcweir sal_uInt16 nScript = SCRIPTTYPE_LATIN | SCRIPTTYPE_ASIAN | SCRIPTTYPE_COMPLEX;
886cdf0e10cSrcweir if (nSlot == SID_ATTR_CHAR_FONT)
887cdf0e10cSrcweir nScript = pView->GetScriptType();
888cdf0e10cSrcweir
889cdf0e10cSrcweir SfxItemPool& rPool = GetPool();
890cdf0e10cSrcweir SvxScriptSetItem aSetItem( nSlot, rPool );
891cdf0e10cSrcweir sal_uInt16 nWhich = rPool.GetWhich( nSlot );
892cdf0e10cSrcweir aSetItem.PutItemForScriptType( nScript, pArgs->Get( nWhich ) );
893cdf0e10cSrcweir
894cdf0e10cSrcweir pView->SetAttributes( aSetItem.GetItemSet() );
895cdf0e10cSrcweir }
896766ce4d0SZheng Fan else if( nSlot == SID_ATTR_PARA_LRSPACE )
897766ce4d0SZheng Fan {
898766ce4d0SZheng Fan sal_uInt16 nId = SID_ATTR_PARA_LRSPACE;
899766ce4d0SZheng Fan const SvxLRSpaceItem& rItem = (const SvxLRSpaceItem&)
900766ce4d0SZheng Fan pArgs->Get( nId );
901766ce4d0SZheng Fan SfxItemSet aEditAttr( GetPool(), EE_PARA_LRSPACE, EE_PARA_LRSPACE );
902766ce4d0SZheng Fan nId = EE_PARA_LRSPACE;
903766ce4d0SZheng Fan SvxLRSpaceItem aLRSpaceItem( rItem.GetLeft(),
904766ce4d0SZheng Fan rItem.GetRight(), rItem.GetTxtLeft(),
905766ce4d0SZheng Fan rItem.GetTxtFirstLineOfst(), nId );
906766ce4d0SZheng Fan aEditAttr.Put( aLRSpaceItem );
907766ce4d0SZheng Fan // rReq.Done( aEditAttr );
908766ce4d0SZheng Fan // pArgs = rReq.GetArgs();
909766ce4d0SZheng Fan // pView->SetAttributes( *pArgs );
910766ce4d0SZheng Fan pView->SetAttributes( aEditAttr );
911766ce4d0SZheng Fan // Invalidate(SID_ATTR_PARA_LRSPACE);
912766ce4d0SZheng Fan }
913766ce4d0SZheng Fan else if( nSlot == SID_ATTR_PARA_LINESPACE )
914766ce4d0SZheng Fan {
915766ce4d0SZheng Fan SvxLineSpacingItem aLineSpaceItem = (const SvxLineSpacingItem&)pArgs->Get(
916766ce4d0SZheng Fan GetPool().GetWhich(nSlot));
917766ce4d0SZheng Fan SfxItemSet aEditAttr( GetPool(), EE_PARA_SBL, EE_PARA_SBL );
918766ce4d0SZheng Fan aEditAttr.Put( aLineSpaceItem );
919766ce4d0SZheng Fan // rReq.Done( aEditAttr );
920766ce4d0SZheng Fan // pArgs = rReq.GetArgs();
921766ce4d0SZheng Fan // pView->SetAttributes( *pArgs );
922766ce4d0SZheng Fan pView->SetAttributes( aEditAttr );
923766ce4d0SZheng Fan // Invalidate(SID_ATTR_PARA_LINESPACE);
924766ce4d0SZheng Fan }
925766ce4d0SZheng Fan else if( nSlot == SID_ATTR_PARA_ULSPACE )
926766ce4d0SZheng Fan {
927766ce4d0SZheng Fan SvxULSpaceItem aULSpaceItem = (const SvxULSpaceItem&)pArgs->Get(
928766ce4d0SZheng Fan GetPool().GetWhich(nSlot));
929766ce4d0SZheng Fan SfxItemSet aEditAttr( GetPool(), EE_PARA_ULSPACE, EE_PARA_ULSPACE );
930766ce4d0SZheng Fan aULSpaceItem.SetWhich(EE_PARA_ULSPACE);
931766ce4d0SZheng Fan aEditAttr.Put( aULSpaceItem );
932766ce4d0SZheng Fan // rReq.Done( aEditAttr );
933766ce4d0SZheng Fan // pArgs = rReq.GetArgs();
934766ce4d0SZheng Fan // pView->SetAttributes( *pArgs );
935766ce4d0SZheng Fan pView->SetAttributes( aEditAttr );
936766ce4d0SZheng Fan // Invalidate(SID_ATTR_PARA_ULSPACE);
937766ce4d0SZheng Fan }
938512ec161SZheng Fan else if(nSlot == SID_SET_SUPER_SCRIPT )
939512ec161SZheng Fan {
940512ec161SZheng Fan SfxItemSet aEditAttr(pView->GetModel()->GetItemPool());
941512ec161SZheng Fan pView->GetAttributes(aEditAttr);
942512ec161SZheng Fan SfxItemSet aNewAttr( *aEditAttr.GetPool(), aEditAttr.GetRanges() );
943512ec161SZheng Fan
944512ec161SZheng Fan SvxEscapementItem aItem(EE_CHAR_ESCAPEMENT);
945512ec161SZheng Fan SvxEscapement eEsc = (SvxEscapement) ( (const SvxEscapementItem&)
946512ec161SZheng Fan aEditAttr.Get( EE_CHAR_ESCAPEMENT ) ).GetEnumValue();
947512ec161SZheng Fan
948512ec161SZheng Fan if( eEsc == SVX_ESCAPEMENT_SUPERSCRIPT )
949512ec161SZheng Fan aItem.SetEscapement( SVX_ESCAPEMENT_OFF );
950512ec161SZheng Fan else
951512ec161SZheng Fan aItem.SetEscapement( SVX_ESCAPEMENT_SUPERSCRIPT );
952512ec161SZheng Fan aNewAttr.Put( aItem );
953512ec161SZheng Fan pView->SetAttributes( aNewAttr );
954512ec161SZheng Fan }
955512ec161SZheng Fan else if( nSlot == SID_SET_SUB_SCRIPT )
956512ec161SZheng Fan {
957512ec161SZheng Fan SfxItemSet aEditAttr(pView->GetModel()->GetItemPool());
958512ec161SZheng Fan pView->GetAttributes(aEditAttr);
959512ec161SZheng Fan SfxItemSet aNewAttr( *aEditAttr.GetPool(), aEditAttr.GetRanges() );
960512ec161SZheng Fan
961512ec161SZheng Fan SvxEscapementItem aItem(EE_CHAR_ESCAPEMENT);
962512ec161SZheng Fan SvxEscapement eEsc = (SvxEscapement) ( (const SvxEscapementItem&)
963512ec161SZheng Fan aEditAttr.Get( EE_CHAR_ESCAPEMENT ) ).GetEnumValue();
964512ec161SZheng Fan
965512ec161SZheng Fan if( eEsc == SVX_ESCAPEMENT_SUBSCRIPT )
966512ec161SZheng Fan aItem.SetEscapement( SVX_ESCAPEMENT_OFF );
967512ec161SZheng Fan else
968512ec161SZheng Fan aItem.SetEscapement( SVX_ESCAPEMENT_SUBSCRIPT );
969512ec161SZheng Fan aNewAttr.Put( aItem );
970512ec161SZheng Fan pView->SetAttributes( aNewAttr );
971512ec161SZheng Fan }
972512ec161SZheng Fan
973512ec161SZheng Fan else if (bArgsInReq &&
974512ec161SZheng Fan ( nSlot == SID_TABLE_VERT_NONE || nSlot == SID_TABLE_VERT_CENTER ||
975512ec161SZheng Fan nSlot == SID_TABLE_VERT_BOTTOM ) )
976512ec161SZheng Fan {
977512ec161SZheng Fan SdrTextVertAdjust eTVA = SDRTEXTVERTADJUST_TOP;
978512ec161SZheng Fan if (nSlot == SID_TABLE_VERT_CENTER)
979512ec161SZheng Fan eTVA = SDRTEXTVERTADJUST_CENTER;
980512ec161SZheng Fan else if (nSlot == SID_TABLE_VERT_BOTTOM)
981512ec161SZheng Fan eTVA = SDRTEXTVERTADJUST_BOTTOM;
982512ec161SZheng Fan
983512ec161SZheng Fan SfxItemSet aEditAttr(pView->GetModel()->GetItemPool());
984512ec161SZheng Fan SfxItemSet aNewAttr( *aEditAttr.GetPool(), aEditAttr.GetRanges() );
985512ec161SZheng Fan aNewAttr.Put(SdrTextVertAdjustItem(eTVA));
986512ec161SZheng Fan pView->SetAttributes(aNewAttr);
987512ec161SZheng Fan }
988766ce4d0SZheng Fan else if (bArgsInReq &&
989766ce4d0SZheng Fan (nSlot == SID_ATTR_PARA_ADJUST_LEFT || nSlot == SID_ATTR_PARA_ADJUST_CENTER || nSlot == SID_ATTR_PARA_ADJUST_RIGHT || nSlot == SID_ATTR_PARA_ADJUST_BLOCK ))
990766ce4d0SZheng Fan {
991766ce4d0SZheng Fan SfxItemSet aEditAttr(pView->GetModel()->GetItemPool());
992766ce4d0SZheng Fan SfxItemSet aNewAttr( *aEditAttr.GetPool(), aEditAttr.GetRanges() );
993766ce4d0SZheng Fan switch ( nSlot )
994766ce4d0SZheng Fan {
995766ce4d0SZheng Fan case SID_ATTR_PARA_ADJUST_LEFT:
996766ce4d0SZheng Fan aNewAttr.Put( SvxAdjustItem( SVX_ADJUST_LEFT, EE_PARA_JUST ) );
997766ce4d0SZheng Fan break;
998766ce4d0SZheng Fan case SID_ATTR_PARA_ADJUST_CENTER:
999766ce4d0SZheng Fan aNewAttr.Put( SvxAdjustItem( SVX_ADJUST_CENTER, EE_PARA_JUST ) );
1000766ce4d0SZheng Fan break;
1001766ce4d0SZheng Fan case SID_ATTR_PARA_ADJUST_RIGHT:
1002766ce4d0SZheng Fan aNewAttr.Put( SvxAdjustItem( SVX_ADJUST_RIGHT, EE_PARA_JUST ) );
1003766ce4d0SZheng Fan break;
1004766ce4d0SZheng Fan case SID_ATTR_PARA_ADJUST_BLOCK:
1005766ce4d0SZheng Fan aNewAttr.Put( SvxAdjustItem( SVX_ADJUST_BLOCK, EE_PARA_JUST ) );
1006766ce4d0SZheng Fan break;
1007766ce4d0SZheng Fan }
1008766ce4d0SZheng Fan pView->SetAttributes(aNewAttr);
1009766ce4d0SZheng Fan }
1010cdf0e10cSrcweir else
1011cdf0e10cSrcweir {
1012cdf0e10cSrcweir // use args directly
1013cdf0e10cSrcweir
1014cdf0e10cSrcweir pView->SetAttributes( *pArgs );
1015cdf0e10cSrcweir }
1016cdf0e10cSrcweir pViewData->GetScDrawView()->InvalidateDrawTextAttrs();
1017cdf0e10cSrcweir }
1018cdf0e10cSrcweir }
1019cdf0e10cSrcweir
GetAttrState(SfxItemSet & rDestSet)1020cdf0e10cSrcweir void __EXPORT ScDrawTextObjectBar::GetAttrState( SfxItemSet& rDestSet )
1021cdf0e10cSrcweir {
1022cdf0e10cSrcweir if ( IsNoteEdit() )
1023cdf0e10cSrcweir {
1024cdf0e10cSrcweir // issue 21255 - Notes now support rich text formatting.
1025cdf0e10cSrcweir }
1026cdf0e10cSrcweir
1027cdf0e10cSrcweir SvtLanguageOptions aLangOpt;
1028cdf0e10cSrcweir sal_Bool bDisableCTLFont = !aLangOpt.IsCTLFontEnabled();
1029cdf0e10cSrcweir sal_Bool bDisableVerticalText = !aLangOpt.IsVerticalTextEnabled();
1030cdf0e10cSrcweir
1031cdf0e10cSrcweir SdrView* pView = pViewData->GetScDrawView();
1032cdf0e10cSrcweir SfxItemSet aAttrSet(pView->GetModel()->GetItemPool());
1033cdf0e10cSrcweir pView->GetAttributes(aAttrSet);
1034cdf0e10cSrcweir
1035cdf0e10cSrcweir // direkte Attribute
1036cdf0e10cSrcweir
1037cdf0e10cSrcweir rDestSet.Put( aAttrSet );
1038cdf0e10cSrcweir
1039cdf0e10cSrcweir // choose font info according to selection script type
1040cdf0e10cSrcweir
1041cdf0e10cSrcweir sal_uInt16 nScript = pView->GetScriptType();
1042cdf0e10cSrcweir
1043cdf0e10cSrcweir // #i55929# input-language-dependent script type (depends on input language if nothing selected)
1044cdf0e10cSrcweir sal_uInt16 nInputScript = nScript;
1045cdf0e10cSrcweir OutlinerView* pOutView = pView->GetTextEditOutlinerView();
1046cdf0e10cSrcweir if (pOutView && !pOutView->GetSelection().HasRange())
1047cdf0e10cSrcweir {
1048cdf0e10cSrcweir LanguageType nInputLang = pViewData->GetActiveWin()->GetInputLanguage();
1049cdf0e10cSrcweir if (nInputLang != LANGUAGE_DONTKNOW && nInputLang != LANGUAGE_SYSTEM)
1050cdf0e10cSrcweir nInputScript = SvtLanguageOptions::GetScriptTypeOfLanguage( nInputLang );
1051cdf0e10cSrcweir }
1052cdf0e10cSrcweir
1053cdf0e10cSrcweir // #i55929# according to spec, nInputScript is used for font and font height only
1054cdf0e10cSrcweir if ( rDestSet.GetItemState( EE_CHAR_FONTINFO ) != SFX_ITEM_UNKNOWN )
1055cdf0e10cSrcweir ScViewUtil::PutItemScript( rDestSet, aAttrSet, EE_CHAR_FONTINFO, nInputScript );
1056cdf0e10cSrcweir if ( rDestSet.GetItemState( EE_CHAR_FONTHEIGHT ) != SFX_ITEM_UNKNOWN )
1057cdf0e10cSrcweir ScViewUtil::PutItemScript( rDestSet, aAttrSet, EE_CHAR_FONTHEIGHT, nInputScript );
1058cdf0e10cSrcweir if ( rDestSet.GetItemState( EE_CHAR_WEIGHT ) != SFX_ITEM_UNKNOWN )
1059cdf0e10cSrcweir ScViewUtil::PutItemScript( rDestSet, aAttrSet, EE_CHAR_WEIGHT, nScript );
1060cdf0e10cSrcweir if ( rDestSet.GetItemState( EE_CHAR_ITALIC ) != SFX_ITEM_UNKNOWN )
1061cdf0e10cSrcweir ScViewUtil::PutItemScript( rDestSet, aAttrSet, EE_CHAR_ITALIC, nScript );
1062cdf0e10cSrcweir // Ausrichtung
1063cdf0e10cSrcweir
1064cdf0e10cSrcweir SvxAdjust eAdj = ((const SvxAdjustItem&)aAttrSet.Get(EE_PARA_JUST)).GetAdjust();
1065cdf0e10cSrcweir switch( eAdj )
1066cdf0e10cSrcweir {
1067cdf0e10cSrcweir case SVX_ADJUST_LEFT:
1068766ce4d0SZheng Fan {
1069cdf0e10cSrcweir rDestSet.Put( SfxBoolItem( SID_ALIGNLEFT, sal_True ) );
1070766ce4d0SZheng Fan rDestSet.Put( SfxBoolItem( SID_ATTR_PARA_ADJUST_LEFT, sal_True ) );
1071766ce4d0SZheng Fan }
1072cdf0e10cSrcweir break;
1073cdf0e10cSrcweir case SVX_ADJUST_CENTER:
1074766ce4d0SZheng Fan {
1075cdf0e10cSrcweir rDestSet.Put( SfxBoolItem( SID_ALIGNCENTERHOR, sal_True ) );
1076766ce4d0SZheng Fan rDestSet.Put( SfxBoolItem( SID_ATTR_PARA_ADJUST_CENTER, sal_True ) );
1077766ce4d0SZheng Fan }
1078cdf0e10cSrcweir break;
1079cdf0e10cSrcweir case SVX_ADJUST_RIGHT:
1080766ce4d0SZheng Fan {
1081cdf0e10cSrcweir rDestSet.Put( SfxBoolItem( SID_ALIGNRIGHT, sal_True ) );
1082766ce4d0SZheng Fan rDestSet.Put( SfxBoolItem( SID_ATTR_PARA_ADJUST_RIGHT, sal_True ) );
1083766ce4d0SZheng Fan }
1084cdf0e10cSrcweir break;
1085cdf0e10cSrcweir case SVX_ADJUST_BLOCK:
1086766ce4d0SZheng Fan {
1087cdf0e10cSrcweir rDestSet.Put( SfxBoolItem( SID_ALIGNBLOCK, sal_True ) );
1088766ce4d0SZheng Fan rDestSet.Put( SfxBoolItem( SID_ATTR_PARA_ADJUST_BLOCK, sal_True ) );
1089766ce4d0SZheng Fan }
1090cdf0e10cSrcweir break;
1091cdf0e10cSrcweir default:
1092cdf0e10cSrcweir {
1093cdf0e10cSrcweir // added to avoid warnings
1094cdf0e10cSrcweir }
1095cdf0e10cSrcweir }
1096cdf0e10cSrcweir // pseudo slots for Format menu
1097cdf0e10cSrcweir rDestSet.Put( SfxBoolItem( SID_ALIGN_ANY_LEFT, eAdj == SVX_ADJUST_LEFT ) );
1098cdf0e10cSrcweir rDestSet.Put( SfxBoolItem( SID_ALIGN_ANY_HCENTER, eAdj == SVX_ADJUST_CENTER ) );
1099cdf0e10cSrcweir rDestSet.Put( SfxBoolItem( SID_ALIGN_ANY_RIGHT, eAdj == SVX_ADJUST_RIGHT ) );
1100cdf0e10cSrcweir rDestSet.Put( SfxBoolItem( SID_ALIGN_ANY_JUSTIFIED, eAdj == SVX_ADJUST_BLOCK ) );
1101cdf0e10cSrcweir
1102766ce4d0SZheng Fan SvxLRSpaceItem aLR = ((const SvxLRSpaceItem&)aAttrSet.Get( EE_PARA_LRSPACE ));
1103766ce4d0SZheng Fan aLR.SetWhich(SID_ATTR_PARA_LRSPACE);
1104766ce4d0SZheng Fan rDestSet.Put(aLR);
1105766ce4d0SZheng Fan Invalidate( SID_ATTR_PARA_LRSPACE );
1106766ce4d0SZheng Fan SfxItemState eState = aAttrSet.GetItemState( EE_PARA_LRSPACE );
1107766ce4d0SZheng Fan if ( eState == SFX_ITEM_DONTCARE )
1108766ce4d0SZheng Fan rDestSet.InvalidateItem(SID_ATTR_PARA_LRSPACE);
1109766ce4d0SZheng Fan //xuxu for Line Space
1110766ce4d0SZheng Fan SvxLineSpacingItem aLineSP = ((const SvxLineSpacingItem&)aAttrSet.
1111766ce4d0SZheng Fan Get( EE_PARA_SBL ));
1112766ce4d0SZheng Fan aLineSP.SetWhich(SID_ATTR_PARA_LINESPACE);
1113766ce4d0SZheng Fan rDestSet.Put(aLineSP);
1114766ce4d0SZheng Fan Invalidate(SID_ATTR_PARA_LINESPACE);
1115766ce4d0SZheng Fan eState = aAttrSet.GetItemState( EE_PARA_SBL );
1116766ce4d0SZheng Fan if ( eState == SFX_ITEM_DONTCARE )
1117766ce4d0SZheng Fan rDestSet.InvalidateItem(SID_ATTR_PARA_LINESPACE);
1118766ce4d0SZheng Fan //xuxu for UL Space
1119766ce4d0SZheng Fan SvxULSpaceItem aULSP = ((const SvxULSpaceItem&)aAttrSet.
1120766ce4d0SZheng Fan Get( EE_PARA_ULSPACE ));
1121766ce4d0SZheng Fan aULSP.SetWhich(SID_ATTR_PARA_ULSPACE);
1122766ce4d0SZheng Fan rDestSet.Put(aULSP);
1123766ce4d0SZheng Fan Invalidate(SID_ATTR_PARA_ULSPACE);
1124766ce4d0SZheng Fan eState = aAttrSet.GetItemState( EE_PARA_ULSPACE );
1125766ce4d0SZheng Fan if ( eState == SFX_ITEM_DONTCARE )
1126766ce4d0SZheng Fan rDestSet.InvalidateItem(SID_ATTR_PARA_ULSPACE);
1127766ce4d0SZheng Fan
1128cdf0e10cSrcweir // Zeilenabstand
1129cdf0e10cSrcweir
1130cdf0e10cSrcweir sal_uInt16 nLineSpace = (sal_uInt16)
1131cdf0e10cSrcweir ((const SvxLineSpacingItem&)aAttrSet.
1132cdf0e10cSrcweir Get( EE_PARA_SBL )).GetPropLineSpace();
1133cdf0e10cSrcweir switch( nLineSpace )
1134cdf0e10cSrcweir {
1135cdf0e10cSrcweir case 100:
1136cdf0e10cSrcweir rDestSet.Put( SfxBoolItem( SID_ATTR_PARA_LINESPACE_10, sal_True ) );
1137cdf0e10cSrcweir break;
1138cdf0e10cSrcweir case 150:
1139cdf0e10cSrcweir rDestSet.Put( SfxBoolItem( SID_ATTR_PARA_LINESPACE_15, sal_True ) );
1140cdf0e10cSrcweir break;
1141cdf0e10cSrcweir case 200:
1142cdf0e10cSrcweir rDestSet.Put( SfxBoolItem( SID_ATTR_PARA_LINESPACE_20, sal_True ) );
1143cdf0e10cSrcweir break;
1144cdf0e10cSrcweir }
1145cdf0e10cSrcweir
1146cdf0e10cSrcweir // hoch-/tiefgestellt
1147cdf0e10cSrcweir
1148cdf0e10cSrcweir SvxEscapement eEsc = (SvxEscapement) ( (const SvxEscapementItem&)
1149cdf0e10cSrcweir aAttrSet.Get( EE_CHAR_ESCAPEMENT ) ).GetEnumValue();
1150cdf0e10cSrcweir if( eEsc == SVX_ESCAPEMENT_SUPERSCRIPT )
1151cdf0e10cSrcweir rDestSet.Put( SfxBoolItem( SID_SET_SUPER_SCRIPT, sal_True ) );
1152cdf0e10cSrcweir else if( eEsc == SVX_ESCAPEMENT_SUBSCRIPT )
1153cdf0e10cSrcweir rDestSet.Put( SfxBoolItem( SID_SET_SUB_SCRIPT, sal_True ) );
1154cdf0e10cSrcweir
1155cdf0e10cSrcweir // Unterstreichung
1156cdf0e10cSrcweir
1157766ce4d0SZheng Fan eState = aAttrSet.GetItemState( EE_CHAR_UNDERLINE, sal_True );
1158cdf0e10cSrcweir if ( eState == SFX_ITEM_DONTCARE )
1159cdf0e10cSrcweir {
1160cdf0e10cSrcweir rDestSet.InvalidateItem( SID_ULINE_VAL_NONE );
1161cdf0e10cSrcweir rDestSet.InvalidateItem( SID_ULINE_VAL_SINGLE );
1162cdf0e10cSrcweir rDestSet.InvalidateItem( SID_ULINE_VAL_DOUBLE );
1163cdf0e10cSrcweir rDestSet.InvalidateItem( SID_ULINE_VAL_DOTTED );
1164cdf0e10cSrcweir }
1165cdf0e10cSrcweir else
1166cdf0e10cSrcweir {
1167cdf0e10cSrcweir FontUnderline eUnderline = ((const SvxUnderlineItem&)
1168cdf0e10cSrcweir aAttrSet.Get(EE_CHAR_UNDERLINE)).GetLineStyle();
1169cdf0e10cSrcweir sal_uInt16 nId = SID_ULINE_VAL_NONE;
1170cdf0e10cSrcweir switch (eUnderline)
1171cdf0e10cSrcweir {
1172cdf0e10cSrcweir case UNDERLINE_SINGLE: nId = SID_ULINE_VAL_SINGLE; break;
1173cdf0e10cSrcweir case UNDERLINE_DOUBLE: nId = SID_ULINE_VAL_DOUBLE; break;
1174cdf0e10cSrcweir case UNDERLINE_DOTTED: nId = SID_ULINE_VAL_DOTTED; break;
1175cdf0e10cSrcweir default:
1176cdf0e10cSrcweir break;
1177cdf0e10cSrcweir }
1178cdf0e10cSrcweir rDestSet.Put( SfxBoolItem( nId, sal_True ) );
1179cdf0e10cSrcweir }
1180cdf0e10cSrcweir
1181cdf0e10cSrcweir // horizontal / vertical
1182cdf0e10cSrcweir
1183cdf0e10cSrcweir sal_Bool bLeftToRight = sal_True;
1184cdf0e10cSrcweir
1185cdf0e10cSrcweir SdrOutliner* pOutl = pView->GetTextEditOutliner();
1186cdf0e10cSrcweir if( pOutl )
1187cdf0e10cSrcweir {
1188cdf0e10cSrcweir if( pOutl->IsVertical() )
1189cdf0e10cSrcweir bLeftToRight = sal_False;
1190cdf0e10cSrcweir }
1191cdf0e10cSrcweir else
1192cdf0e10cSrcweir bLeftToRight = ( (const SvxWritingModeItem&) aAttrSet.Get( SDRATTR_TEXTDIRECTION ) ).GetValue() == com::sun::star::text::WritingMode_LR_TB;
1193cdf0e10cSrcweir
1194cdf0e10cSrcweir if ( bDisableVerticalText )
1195cdf0e10cSrcweir {
1196cdf0e10cSrcweir rDestSet.DisableItem( SID_TEXTDIRECTION_LEFT_TO_RIGHT );
1197cdf0e10cSrcweir rDestSet.DisableItem( SID_TEXTDIRECTION_TOP_TO_BOTTOM );
1198cdf0e10cSrcweir }
1199cdf0e10cSrcweir else
1200cdf0e10cSrcweir {
1201cdf0e10cSrcweir rDestSet.Put( SfxBoolItem( SID_TEXTDIRECTION_LEFT_TO_RIGHT, bLeftToRight ) );
1202cdf0e10cSrcweir rDestSet.Put( SfxBoolItem( SID_TEXTDIRECTION_TOP_TO_BOTTOM, !bLeftToRight ) );
1203cdf0e10cSrcweir }
1204cdf0e10cSrcweir
1205cdf0e10cSrcweir // left-to-right or right-to-left
1206cdf0e10cSrcweir
1207cdf0e10cSrcweir if ( !bLeftToRight || bDisableCTLFont )
1208cdf0e10cSrcweir {
1209cdf0e10cSrcweir // disabled if vertical
1210cdf0e10cSrcweir rDestSet.DisableItem( SID_ATTR_PARA_LEFT_TO_RIGHT );
1211cdf0e10cSrcweir rDestSet.DisableItem( SID_ATTR_PARA_RIGHT_TO_LEFT );
1212cdf0e10cSrcweir }
1213cdf0e10cSrcweir else if ( aAttrSet.GetItemState( EE_PARA_WRITINGDIR ) == SFX_ITEM_DONTCARE )
1214cdf0e10cSrcweir {
1215cdf0e10cSrcweir rDestSet.InvalidateItem( SID_ATTR_PARA_LEFT_TO_RIGHT );
1216cdf0e10cSrcweir rDestSet.InvalidateItem( SID_ATTR_PARA_RIGHT_TO_LEFT );
1217cdf0e10cSrcweir }
1218cdf0e10cSrcweir else
1219cdf0e10cSrcweir {
1220cdf0e10cSrcweir SvxFrameDirection eAttrDir = (SvxFrameDirection)((const SvxFrameDirectionItem&)
1221cdf0e10cSrcweir aAttrSet.Get( EE_PARA_WRITINGDIR )).GetValue();
1222cdf0e10cSrcweir if ( eAttrDir == FRMDIR_ENVIRONMENT )
1223cdf0e10cSrcweir {
1224cdf0e10cSrcweir // get "environment" direction from page style
1225cdf0e10cSrcweir if ( pViewData->GetDocument()->GetEditTextDirection( pViewData->GetTabNo() ) == EE_HTEXTDIR_R2L )
1226cdf0e10cSrcweir eAttrDir = FRMDIR_HORI_RIGHT_TOP;
1227cdf0e10cSrcweir else
1228cdf0e10cSrcweir eAttrDir = FRMDIR_HORI_LEFT_TOP;
1229cdf0e10cSrcweir }
1230cdf0e10cSrcweir rDestSet.Put( SfxBoolItem( SID_ATTR_PARA_LEFT_TO_RIGHT, ( eAttrDir == FRMDIR_HORI_LEFT_TOP ) ) );
1231cdf0e10cSrcweir rDestSet.Put( SfxBoolItem( SID_ATTR_PARA_RIGHT_TO_LEFT, ( eAttrDir == FRMDIR_HORI_RIGHT_TOP ) ) );
1232cdf0e10cSrcweir }
1233cdf0e10cSrcweir }
1234cdf0e10cSrcweir
ExecuteTrans(SfxRequest & rReq)1235cdf0e10cSrcweir void ScDrawTextObjectBar::ExecuteTrans( SfxRequest& rReq )
1236cdf0e10cSrcweir {
1237cdf0e10cSrcweir sal_Int32 nType = ScViewUtil::GetTransliterationType( rReq.GetSlot() );
1238cdf0e10cSrcweir if ( nType )
1239cdf0e10cSrcweir {
1240cdf0e10cSrcweir ScDrawView* pView = pViewData->GetScDrawView();
1241cdf0e10cSrcweir OutlinerView* pOutView = pView->GetTextEditOutlinerView();
1242cdf0e10cSrcweir if ( pOutView )
1243cdf0e10cSrcweir {
1244cdf0e10cSrcweir // change selected text in object
1245cdf0e10cSrcweir pOutView->TransliterateText( nType );
1246cdf0e10cSrcweir }
1247cdf0e10cSrcweir else
1248cdf0e10cSrcweir {
1249cdf0e10cSrcweir //! apply to whole objects?
1250cdf0e10cSrcweir }
1251cdf0e10cSrcweir }
1252cdf0e10cSrcweir }
1253512ec161SZheng Fan
GetStatePropPanelAttr(SfxItemSet & rSet)1254512ec161SZheng Fan void ScDrawTextObjectBar::GetStatePropPanelAttr(SfxItemSet &rSet)
1255512ec161SZheng Fan {
1256512ec161SZheng Fan SfxWhichIter aIter( rSet );
1257512ec161SZheng Fan sal_uInt16 nWhich = aIter.FirstWhich();
1258512ec161SZheng Fan
1259512ec161SZheng Fan SdrView* pView = pViewData->GetScDrawView();
1260512ec161SZheng Fan
1261512ec161SZheng Fan SfxItemSet aEditAttr(pView->GetModel()->GetItemPool());
1262512ec161SZheng Fan pView->GetAttributes(aEditAttr);
1263512ec161SZheng Fan //SfxItemSet aAttrs( *aEditAttr.GetPool(), aEditAttr.GetRanges() );
1264512ec161SZheng Fan
1265512ec161SZheng Fan while ( nWhich )
1266512ec161SZheng Fan {
1267512ec161SZheng Fan sal_uInt16 nSlotId = SfxItemPool::IsWhich(nWhich)
1268512ec161SZheng Fan ? GetPool().GetSlotId(nWhich)
1269512ec161SZheng Fan : nWhich;
1270512ec161SZheng Fan switch ( nSlotId )
1271512ec161SZheng Fan {
1272512ec161SZheng Fan case SID_TABLE_VERT_NONE:
1273512ec161SZheng Fan case SID_TABLE_VERT_CENTER:
1274512ec161SZheng Fan case SID_TABLE_VERT_BOTTOM:
1275512ec161SZheng Fan sal_Bool bContour = sal_False;
1276512ec161SZheng Fan SfxItemState eConState = aEditAttr.GetItemState( SDRATTR_TEXT_CONTOURFRAME );
1277512ec161SZheng Fan if( eConState != SFX_ITEM_DONTCARE )
1278512ec161SZheng Fan {
1279512ec161SZheng Fan bContour = ( ( const SdrTextContourFrameItem& )aEditAttr.Get( SDRATTR_TEXT_CONTOURFRAME ) ).GetValue();
1280512ec161SZheng Fan }
1281512ec161SZheng Fan if (bContour) break;
1282512ec161SZheng Fan
1283512ec161SZheng Fan SfxItemState eVState = aEditAttr.GetItemState( SDRATTR_TEXT_VERTADJUST );
1284512ec161SZheng Fan //SfxItemState eHState = aAttrs.GetItemState( SDRATTR_TEXT_HORZADJUST );
1285512ec161SZheng Fan
1286512ec161SZheng Fan //if(SFX_ITEM_DONTCARE != eVState && SFX_ITEM_DONTCARE != eHState)
1287512ec161SZheng Fan if(SFX_ITEM_DONTCARE != eVState)
1288512ec161SZheng Fan {
1289512ec161SZheng Fan SdrTextVertAdjust eTVA = (SdrTextVertAdjust)((const SdrTextVertAdjustItem&)aEditAttr.Get(SDRATTR_TEXT_VERTADJUST)).GetValue();
1290512ec161SZheng Fan sal_Bool bSet = nSlotId == SID_TABLE_VERT_NONE && eTVA == SDRTEXTVERTADJUST_TOP||
1291512ec161SZheng Fan nSlotId == SID_TABLE_VERT_CENTER && eTVA == SDRTEXTVERTADJUST_CENTER ||
1292512ec161SZheng Fan nSlotId == SID_TABLE_VERT_BOTTOM && eTVA == SDRTEXTVERTADJUST_BOTTOM;
1293512ec161SZheng Fan rSet.Put(SfxBoolItem(nSlotId, bSet));
1294512ec161SZheng Fan }
1295512ec161SZheng Fan else
1296512ec161SZheng Fan {
1297512ec161SZheng Fan rSet.Put(SfxBoolItem(nSlotId, sal_False));
1298512ec161SZheng Fan }
1299512ec161SZheng Fan break;
1300512ec161SZheng Fan }
1301512ec161SZheng Fan nWhich = aIter.NextWhich();
1302512ec161SZheng Fan }
1303512ec161SZheng Fan }
1304