Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #include <com/sun/star/linguistic2/XThesaurus.hpp>
30 : : #include <com/sun/star/lang/Locale.hpp>
31 : : #include <comphelper/string.hxx>
32 : : #include "scitems.hxx"
33 : :
34 : : #include <editeng/adjitem.hxx>
35 : : #include <svx/clipfmtitem.hxx>
36 : : #include <editeng/cntritem.hxx>
37 : : #include <editeng/crsditem.hxx>
38 : : #include <editeng/editeng.hxx>
39 : : #include <editeng/escpitem.hxx>
40 : : #include <editeng/flditem.hxx>
41 : : #include <editeng/fontitem.hxx>
42 : : #include <editeng/frmdiritem.hxx>
43 : : #include <svx/hlnkitem.hxx>
44 : : #include <editeng/lspcitem.hxx>
45 : : #include <svx/svdoutl.hxx>
46 : : #include <editeng/unolingu.hxx>
47 : : #include <editeng/outlobj.hxx>
48 : : #include <editeng/postitem.hxx>
49 : : #include <editeng/scripttypeitem.hxx>
50 : : #include <editeng/shdditem.hxx>
51 : : #include <svl/srchitem.hxx>
52 : : #include <editeng/udlnitem.hxx>
53 : : #include <editeng/wghtitem.hxx>
54 : : #include <editeng/writingmodeitem.hxx>
55 : : #include <sfx2/app.hxx>
56 : : #include <sfx2/dispatch.hxx>
57 : : #include <sfx2/objface.hxx>
58 : : #include <sfx2/objsh.hxx>
59 : : #include <sfx2/request.hxx>
60 : : #include <sfx2/viewfrm.hxx>
61 : : #include <svtools/cliplistener.hxx>
62 : : #include <svtools/transfer.hxx>
63 : : #include <svl/whiter.hxx>
64 : : #include <svl/languageoptions.hxx>
65 : : #include <vcl/msgbox.hxx>
66 : :
67 : : #include <svx/svxdlg.hxx>
68 : : #include <svx/dialogs.hrc>
69 : :
70 : : #include "sc.hrc"
71 : : #include "globstr.hrc"
72 : : #include "scmod.hxx"
73 : : #include "drtxtob.hxx"
74 : : #include "fudraw.hxx"
75 : : #include "viewdata.hxx"
76 : : #include "document.hxx"
77 : : #include "drawview.hxx"
78 : : #include "viewutil.hxx"
79 : : #include "scresid.hxx"
80 : : #include "tabvwsh.hxx"
81 : :
82 : : #define ScDrawTextObjectBar
83 : : #include "scslots.hxx"
84 : :
85 : :
86 : : using namespace ::com::sun::star;
87 : :
88 : :
89 [ + + ][ + - ]: 255 : SFX_IMPL_INTERFACE( ScDrawTextObjectBar, SfxShell, ScResId(SCSTR_DRAWTEXTSHELL) )
[ + - ]
90 : : {
91 [ + - ]: 51 : SFX_OBJECTBAR_REGISTRATION( SFX_OBJECTBAR_OBJECT|SFX_VISIBILITY_STANDARD|SFX_VISIBILITY_SERVER,
92 [ + - ]: 51 : ScResId(RID_TEXT_TOOLBOX) );
93 [ + - ][ + - ]: 51 : SFX_POPUPMENU_REGISTRATION( ScResId(RID_POPUP_DRAWTEXT) );
94 : 51 : SFX_CHILDWINDOW_REGISTRATION( ScGetFontWorkId() );
95 : 51 : }
96 : :
97 [ # # ][ # # ]: 0 : TYPEINIT1( ScDrawTextObjectBar, SfxShell );
98 : :
99 : :
100 : :
101 : : // abschalten der nicht erwuenschten Acceleratoren:
102 : :
103 : 0 : void ScDrawTextObjectBar::StateDisableItems( SfxItemSet &rSet )
104 : : {
105 [ # # ]: 0 : SfxWhichIter aIter(rSet);
106 [ # # ]: 0 : sal_uInt16 nWhich = aIter.FirstWhich();
107 : :
108 [ # # ]: 0 : while (nWhich)
109 : : {
110 [ # # ]: 0 : rSet.DisableItem( nWhich );
111 [ # # ]: 0 : nWhich = aIter.NextWhich();
112 [ # # ]: 0 : }
113 : 0 : }
114 : :
115 : 0 : ScDrawTextObjectBar::ScDrawTextObjectBar(ScViewData* pData) :
116 : 0 : SfxShell(pData->GetViewShell()),
117 : : pViewData(pData),
118 : : pClipEvtLstnr(NULL),
119 : 0 : bPastePossible(false)
120 : : {
121 [ # # ]: 0 : SetPool( pViewData->GetScDrawView()->GetDefaultAttr().GetPool() );
122 : :
123 : : // UndoManager wird beim Umschalten in den Edit-Modus umgesetzt...
124 [ # # ][ # # ]: 0 : ::svl::IUndoManager* pMgr = pViewData->GetSfxDocShell()->GetUndoManager();
125 [ # # ]: 0 : SetUndoManager( pMgr );
126 [ # # ][ # # ]: 0 : if ( !pViewData->GetDocument()->IsUndoEnabled() )
127 : : {
128 [ # # ]: 0 : pMgr->SetMaxUndoActionCount( 0 );
129 : : }
130 : :
131 [ # # ]: 0 : SetHelpId( HID_SCSHELL_DRTXTOB );
132 [ # # ][ # # ]: 0 : SetName(rtl::OUString("DrawText"));
[ # # ]
133 : 0 : }
134 : :
135 : 0 : ScDrawTextObjectBar::~ScDrawTextObjectBar()
136 : : {
137 [ # # ]: 0 : if ( pClipEvtLstnr )
138 : : {
139 [ # # ][ # # ]: 0 : pClipEvtLstnr->AddRemoveListener( pViewData->GetActiveWin(), false );
140 : :
141 : : // 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 [ # # ]: 0 : pClipEvtLstnr->ClearCallbackLink();
144 : :
145 : 0 : pClipEvtLstnr->release();
146 : : }
147 [ # # ]: 0 : }
148 : :
149 : : //========================================================================
150 : : //
151 : : // Funktionen
152 : : //
153 : : //========================================================================
154 : :
155 : 0 : void ScDrawTextObjectBar::Execute( SfxRequest &rReq )
156 : : {
157 : 0 : ScDrawView* pView = pViewData->GetScDrawView();
158 : 0 : OutlinerView* pOutView = pView->GetTextEditOutlinerView();
159 : 0 : Outliner* pOutliner = pView->GetTextEditOutliner();
160 : :
161 [ # # ][ # # ]: 0 : if (!pOutView || !pOutliner)
162 : : {
163 : 0 : ExecuteGlobal( rReq ); // auf ganze Objekte
164 : 0 : return;
165 : : }
166 : :
167 : 0 : const SfxItemSet* pReqArgs = rReq.GetArgs();
168 : 0 : sal_uInt16 nSlot = rReq.GetSlot();
169 [ # # # # : 0 : switch ( nSlot )
# # # # #
# # # # ]
170 : : {
171 : : case SID_COPY:
172 : 0 : pOutView->Copy();
173 : 0 : break;
174 : :
175 : : case SID_CUT:
176 : 0 : pOutView->Cut();
177 : 0 : break;
178 : :
179 : : case SID_PASTE:
180 : 0 : pOutView->PasteSpecial();
181 : 0 : break;
182 : :
183 : : case SID_CLIPBOARD_FORMAT_ITEMS:
184 : : {
185 : 0 : sal_uLong nFormat = 0;
186 : : const SfxPoolItem* pItem;
187 [ # # ][ # # ]: 0 : if ( pReqArgs &&
[ # # ][ # # ]
188 [ # # ]: 0 : pReqArgs->GetItemState(nSlot, sal_True, &pItem) == SFX_ITEM_SET &&
189 [ # # ][ # # ]: 0 : pItem->ISA(SfxUInt32Item) )
190 : : {
191 : 0 : nFormat = ((const SfxUInt32Item*)pItem)->GetValue();
192 : : }
193 : :
194 [ # # ]: 0 : if ( nFormat )
195 : : {
196 [ # # ]: 0 : if (nFormat == SOT_FORMAT_STRING)
197 [ # # ]: 0 : pOutView->Paste();
198 : : else
199 [ # # ]: 0 : pOutView->PasteSpecial();
200 : : }
201 : : }
202 : 0 : break;
203 : :
204 : : case SID_PASTE_SPECIAL:
205 : 0 : ExecutePasteContents( rReq );
206 : 0 : break;
207 : :
208 : : case SID_SELECTALL:
209 : : {
210 [ # # ]: 0 : sal_uLong nCount = pOutliner->GetParagraphCount();
211 : 0 : ESelection aSel( 0,0,(sal_uInt16)nCount,0 );
212 [ # # ]: 0 : pOutView->SetSelection( aSel );
213 : : }
214 : 0 : break;
215 : :
216 : : case SID_CHARMAP:
217 : : {
218 : : const SvxFontItem& rItem = (const SvxFontItem&)
219 [ # # ][ # # ]: 0 : pOutView->GetAttribs().Get(EE_CHAR_FONTINFO);
[ # # ]
220 : :
221 [ # # ]: 0 : String aString;
222 [ # # ]: 0 : SvxFontItem aNewItem( EE_CHAR_FONTINFO );
223 : :
224 : 0 : const SfxItemSet *pArgs = rReq.GetArgs();
225 : 0 : const SfxPoolItem* pItem = 0;
226 [ # # ]: 0 : if( pArgs )
227 [ # # ][ # # ]: 0 : pArgs->GetItemState(GetPool().GetWhich(SID_CHARMAP), false, &pItem);
228 : :
229 [ # # ]: 0 : if ( pItem )
230 : : {
231 [ # # ]: 0 : aString = ((const SfxStringItem*)pItem)->GetValue();
232 : 0 : const SfxPoolItem* pFtItem = NULL;
233 [ # # ][ # # ]: 0 : pArgs->GetItemState( GetPool().GetWhich(SID_ATTR_SPECIALCHAR), false, &pFtItem);
234 [ # # ][ # # ]: 0 : const SfxStringItem* pFontItem = PTR_CAST( SfxStringItem, pFtItem );
[ # # ][ # # ]
235 [ # # ]: 0 : if ( pFontItem )
236 : : {
237 [ # # ]: 0 : String aFontName(pFontItem->GetValue());
238 [ # # ]: 0 : Font aFont(aFontName, Size(1,1)); // Size nur wg. CTOR
239 [ # # ]: 0 : aNewItem = SvxFontItem( aFont.GetFamily(), aFont.GetName(),
240 [ # # ]: 0 : aFont.GetStyleName(), aFont.GetPitch(),
241 [ # # ][ # # ]: 0 : aFont.GetCharSet(), ATTR_FONT );
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
242 : : }
243 : : else
244 [ # # ]: 0 : aNewItem = rItem;
245 : : }
246 : : else
247 [ # # ]: 0 : ScViewUtil::ExecuteCharMap( rItem, *pViewData->GetViewShell()->GetViewFrame(), aNewItem, aString );
248 : :
249 [ # # ]: 0 : if ( aString.Len() )
250 : : {
251 [ # # ][ # # ]: 0 : SfxItemSet aSet( pOutliner->GetEmptyItemSet() );
252 [ # # ]: 0 : aSet.Put( aNewItem );
253 : : // SetAttribs an der View selektiert ein Wort, wenn nichts selektiert ist
254 [ # # ][ # # ]: 0 : pOutView->GetOutliner()->QuickSetAttribs( aSet, pOutView->GetSelection() );
255 [ # # ][ # # ]: 0 : pOutView->InsertText(aString);
256 : : }
257 : :
258 [ # # ][ # # ]: 0 : Invalidate( SID_ATTR_CHAR_FONT );
[ # # ]
259 : : }
260 : 0 : break;
261 : :
262 : : case SID_HYPERLINK_SETLINK:
263 [ # # ]: 0 : if( pReqArgs )
264 : : {
265 : : const SfxPoolItem* pItem;
266 [ # # ][ # # ]: 0 : if ( pReqArgs->GetItemState( SID_HYPERLINK_SETLINK, sal_True, &pItem ) == SFX_ITEM_SET )
267 : : {
268 : 0 : const SvxHyperlinkItem* pHyper = (const SvxHyperlinkItem*) pItem;
269 : 0 : const String& rName = pHyper->GetName();
270 : 0 : const String& rURL = pHyper->GetURL();
271 : 0 : const String& rTarget = pHyper->GetTargetFrame();
272 : 0 : SvxLinkInsertMode eMode = pHyper->GetInsertMode();
273 : :
274 : 0 : sal_Bool bDone = false;
275 [ # # ][ # # ]: 0 : if ( pOutView && ( eMode == HLINK_DEFAULT || eMode == HLINK_FIELD ) )
[ # # ]
276 : : {
277 [ # # ]: 0 : const SvxFieldItem* pFieldItem = pOutView->GetFieldAtSelection();
278 [ # # ]: 0 : if (pFieldItem)
279 : : {
280 : 0 : const SvxFieldData* pField = pFieldItem->GetField();
281 [ # # ][ # # ]: 0 : if ( pField && pField->ISA(SvxURLField) )
[ # # ][ # # ]
[ # # ]
282 : : {
283 : : // altes Feld selektieren
284 : :
285 [ # # ]: 0 : ESelection aSel = pOutView->GetSelection();
286 : 0 : aSel.Adjust();
287 : 0 : aSel.nEndPara = aSel.nStartPara;
288 : 0 : aSel.nEndPos = aSel.nStartPos + 1;
289 [ # # ]: 0 : pOutView->SetSelection( aSel );
290 : : }
291 : : }
292 : :
293 : : // neues Feld einfuegen
294 : :
295 [ # # ][ # # ]: 0 : SvxURLField aURLField( rURL, rName, SVXURLFORMAT_REPR );
[ # # ]
296 [ # # ]: 0 : aURLField.SetTargetFrame( rTarget );
297 [ # # ]: 0 : SvxFieldItem aURLItem( aURLField, EE_FEATURE_FIELD );
298 [ # # ]: 0 : pOutView->InsertField( aURLItem );
299 : :
300 : : // select new field
301 : :
302 [ # # ]: 0 : ESelection aSel = pOutView->GetSelection();
303 [ # # ][ # # ]: 0 : if ( aSel.nStartPos == aSel.nEndPos && aSel.nStartPos > 0 )
304 : : {
305 : : // Cursor is behind the inserted field -> extend selection to the left
306 : :
307 : 0 : --aSel.nStartPos;
308 [ # # ]: 0 : pOutView->SetSelection( aSel );
309 : : }
310 : :
311 [ # # ][ # # ]: 0 : bDone = sal_True;
312 : : }
313 : :
314 [ # # ]: 0 : if (!bDone)
315 [ # # ]: 0 : ExecuteGlobal( rReq ); // normal an der View
316 : :
317 : : // InsertURL an der ViewShell schaltet bei "Text" die DrawShell ab !!!
318 : : }
319 : : }
320 : 0 : break;
321 : :
322 : : case SID_OPEN_HYPERLINK:
323 : : {
324 [ # # ]: 0 : if ( pOutView )
325 : : {
326 : 0 : const SvxFieldItem* pFieldItem = pOutView->GetFieldAtSelection();
327 [ # # ]: 0 : if ( pFieldItem )
328 : : {
329 : 0 : const SvxFieldData* pField = pFieldItem->GetField();
330 [ # # ][ # # ]: 0 : if( pField && pField->ISA( SvxURLField ) )
[ # # ]
331 : : {
332 : 0 : const SvxURLField* pURLField = static_cast< const SvxURLField* >( pField );
333 [ # # ][ # # ]: 0 : ScGlobal::OpenURL( pURLField->GetURL(), pURLField->GetTargetFrame() );
[ # # ]
334 : : }
335 : : }
336 : : }
337 : : }
338 : 0 : break;
339 : :
340 : : case SID_ENABLE_HYPHENATION:
341 : : case SID_TEXTDIRECTION_LEFT_TO_RIGHT:
342 : : case SID_TEXTDIRECTION_TOP_TO_BOTTOM:
343 : 0 : pView->ScEndTextEdit(); // end text edit before switching direction
344 : 0 : ExecuteGlobal( rReq );
345 : : // restore consistent state between shells and functions:
346 : 0 : pViewData->GetDispatcher().Execute(SID_OBJECT_SELECT, SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD);
347 : 0 : break;
348 : :
349 : : case SID_THES:
350 : : {
351 [ # # ]: 0 : String aReplaceText;
352 [ # # ][ # # ]: 0 : SFX_REQUEST_ARG( rReq, pItem2, SfxStringItem, SID_THES, false );
353 [ # # ]: 0 : if (pItem2)
354 [ # # ]: 0 : aReplaceText = pItem2->GetValue();
355 [ # # ]: 0 : if (aReplaceText.Len() > 0)
356 [ # # ][ # # ]: 0 : ReplaceTextWithSynonym( pOutView->GetEditView(), aReplaceText );
357 : : }
358 : 0 : break;
359 : :
360 : : case SID_THESAURUS:
361 : : {
362 : 0 : pOutView->StartThesaurus();
363 : : }
364 : 0 : break;
365 : :
366 : : }
367 : : }
368 : :
369 : 0 : void ScDrawTextObjectBar::GetState( SfxItemSet& rSet )
370 : : {
371 : 0 : SfxViewFrame* pViewFrm = pViewData->GetViewShell()->GetViewFrame();
372 : 0 : sal_Bool bHasFontWork = pViewFrm->HasChildWindow(SID_FONTWORK);
373 : 0 : sal_Bool bDisableFontWork = false;
374 : :
375 [ # # ]: 0 : if (IsNoteEdit())
376 : : {
377 : : // #i21255# notes now support rich text formatting (#i74140# but not fontwork)
378 : 0 : bDisableFontWork = sal_True;
379 : : }
380 : :
381 [ # # ]: 0 : if ( bDisableFontWork )
382 : 0 : rSet.DisableItem( SID_FONTWORK );
383 : : else
384 [ # # ]: 0 : rSet.Put(SfxBoolItem(SID_FONTWORK, bHasFontWork));
385 : :
386 [ # # ]: 0 : if ( rSet.GetItemState( SID_HYPERLINK_GETLINK ) != SFX_ITEM_UNKNOWN )
387 : : {
388 [ # # ]: 0 : SvxHyperlinkItem aHLinkItem;
389 [ # # ]: 0 : SdrView* pView = pViewData->GetScDrawView();
390 : 0 : OutlinerView* pOutView = pView->GetTextEditOutlinerView();
391 [ # # ]: 0 : if ( pOutView )
392 : : {
393 : 0 : sal_Bool bField = false;
394 [ # # ]: 0 : const SvxFieldItem* pFieldItem = pOutView->GetFieldAtSelection();
395 [ # # ]: 0 : if (pFieldItem)
396 : : {
397 : 0 : const SvxFieldData* pField = pFieldItem->GetField();
398 [ # # ][ # # ]: 0 : if ( pField && pField->ISA(SvxURLField) )
[ # # ][ # # ]
[ # # ]
399 : : {
400 : 0 : const SvxURLField* pURLField = (const SvxURLField*) pField;
401 [ # # ][ # # ]: 0 : aHLinkItem.SetName( pURLField->GetRepresentation() );
[ # # ]
402 [ # # ][ # # ]: 0 : aHLinkItem.SetURL( pURLField->GetURL() );
[ # # ]
403 [ # # ][ # # ]: 0 : aHLinkItem.SetTargetFrame( pURLField->GetTargetFrame() );
[ # # ]
404 : 0 : bField = sal_True;
405 : : }
406 : : }
407 [ # # ]: 0 : if (!bField)
408 : : {
409 : : // use selected text as name for urls
410 [ # # ]: 0 : String sReturn = pOutView->GetSelected();
411 [ # # ]: 0 : sReturn.Erase(255);
412 [ # # ][ # # ]: 0 : aHLinkItem.SetName(comphelper::string::stripEnd(sReturn, ' '));
[ # # ][ # # ]
[ # # ][ # # ]
413 : : }
414 : : }
415 [ # # ][ # # ]: 0 : rSet.Put(aHLinkItem);
416 : : }
417 : :
418 [ # # ]: 0 : if ( rSet.GetItemState( SID_OPEN_HYPERLINK ) != SFX_ITEM_UNKNOWN )
419 : : {
420 : 0 : SdrView* pView = pViewData->GetScDrawView();
421 : 0 : OutlinerView* pOutView = pView->GetTextEditOutlinerView();
422 : 0 : bool bEnable = false;
423 [ # # ]: 0 : if ( pOutView )
424 : : {
425 : 0 : const SvxFieldItem* pFieldItem = pOutView->GetFieldAtSelection();
426 [ # # ]: 0 : if ( pFieldItem )
427 : : {
428 : 0 : const SvxFieldData* pField = pFieldItem->GetField();
429 [ # # ][ # # ]: 0 : bEnable = pField && pField->ISA( SvxURLField );
430 : : }
431 : : }
432 [ # # ]: 0 : if( !bEnable )
433 : 0 : rSet.DisableItem( SID_OPEN_HYPERLINK );
434 : : }
435 : :
436 [ # # ]: 0 : if( rSet.GetItemState( SID_TRANSLITERATE_HALFWIDTH ) != SFX_ITEM_UNKNOWN )
437 : 0 : ScViewUtil::HideDisabledSlot( rSet, pViewFrm->GetBindings(), SID_TRANSLITERATE_HALFWIDTH );
438 [ # # ]: 0 : if( rSet.GetItemState( SID_TRANSLITERATE_FULLWIDTH ) != SFX_ITEM_UNKNOWN )
439 : 0 : ScViewUtil::HideDisabledSlot( rSet, pViewFrm->GetBindings(), SID_TRANSLITERATE_FULLWIDTH );
440 [ # # ]: 0 : if( rSet.GetItemState( SID_TRANSLITERATE_HIRAGANA ) != SFX_ITEM_UNKNOWN )
441 : 0 : ScViewUtil::HideDisabledSlot( rSet, pViewFrm->GetBindings(), SID_TRANSLITERATE_HIRAGANA );
442 [ # # ]: 0 : if( rSet.GetItemState( SID_TRANSLITERATE_KATAGANA ) != SFX_ITEM_UNKNOWN )
443 : 0 : ScViewUtil::HideDisabledSlot( rSet, pViewFrm->GetBindings(), SID_TRANSLITERATE_KATAGANA );
444 : :
445 [ # # ]: 0 : if ( rSet.GetItemState( SID_ENABLE_HYPHENATION ) != SFX_ITEM_UNKNOWN )
446 : : {
447 [ # # ]: 0 : SdrView* pView = pViewData->GetScDrawView();
448 [ # # ]: 0 : SfxItemSet aAttrs( pView->GetModel()->GetItemPool() );
449 [ # # ]: 0 : pView->GetAttributes( aAttrs );
450 [ # # ][ # # ]: 0 : if( aAttrs.GetItemState( EE_PARA_HYPHENATE ) >= SFX_ITEM_AVAILABLE )
451 : : {
452 [ # # ]: 0 : sal_Bool bValue = ( (const SfxBoolItem&) aAttrs.Get( EE_PARA_HYPHENATE ) ).GetValue();
453 [ # # ][ # # ]: 0 : rSet.Put( SfxBoolItem( SID_ENABLE_HYPHENATION, bValue ) );
[ # # ]
454 [ # # ]: 0 : }
455 : : }
456 : :
457 [ # # # # ]: 0 : if ( rSet.GetItemState( SID_THES ) != SFX_ITEM_UNKNOWN ||
[ # # ]
458 : 0 : rSet.GetItemState( SID_THESAURUS ) != SFX_ITEM_UNKNOWN )
459 : : {
460 [ # # ]: 0 : SdrView * pView = pViewData->GetScDrawView();
461 : 0 : OutlinerView* pOutView = pView->GetTextEditOutlinerView();
462 : :
463 [ # # ]: 0 : String aStatusVal;
464 : 0 : LanguageType nLang = LANGUAGE_NONE;
465 : 0 : bool bIsLookUpWord = false;
466 [ # # ]: 0 : if ( pOutView )
467 : : {
468 : 0 : EditView& rEditView = pOutView->GetEditView();
469 [ # # ]: 0 : bIsLookUpWord = GetStatusValueForThesaurusFromContext( aStatusVal, nLang, rEditView );
470 : : }
471 [ # # ][ # # ]: 0 : rSet.Put( SfxStringItem( SID_THES, aStatusVal ) );
[ # # ]
472 : :
473 : : // disable thesaurus main menu and context menu entry if there is nothing to look up
474 [ # # ]: 0 : sal_Bool bCanDoThesaurus = ScModule::HasThesaurusLanguage( nLang );
475 [ # # ][ # # ]: 0 : if (!bIsLookUpWord || !bCanDoThesaurus)
476 [ # # ]: 0 : rSet.DisableItem( SID_THES );
477 [ # # ]: 0 : if (!bCanDoThesaurus)
478 [ # # ][ # # ]: 0 : rSet.DisableItem( SID_THESAURUS );
479 : : }
480 : 0 : }
481 : :
482 : 0 : IMPL_LINK( ScDrawTextObjectBar, ClipboardChanged, TransferableDataHelper*, pDataHelper )
483 : : {
484 [ # # ]: 0 : if ( pDataHelper )
485 : : {
486 [ # # ][ # # ]: 0 : bPastePossible = ( pDataHelper->HasFormat( SOT_FORMAT_STRING ) || pDataHelper->HasFormat( SOT_FORMAT_RTF ) );
487 : :
488 : 0 : SfxBindings& rBindings = pViewData->GetBindings();
489 : 0 : rBindings.Invalidate( SID_PASTE );
490 : 0 : rBindings.Invalidate( SID_PASTE_SPECIAL );
491 : 0 : rBindings.Invalidate( SID_CLIPBOARD_FORMAT_ITEMS );
492 : : }
493 : 0 : return 0;
494 : : }
495 : :
496 : 0 : void ScDrawTextObjectBar::GetClipState( SfxItemSet& rSet )
497 : : {
498 [ # # ]: 0 : SdrView* pView = pViewData->GetScDrawView();
499 [ # # ]: 0 : if ( !pView->GetTextEditOutlinerView() )
500 : : {
501 [ # # ]: 0 : GetGlobalClipState( rSet );
502 : 0 : return;
503 : : }
504 : :
505 [ # # ]: 0 : if ( !pClipEvtLstnr )
506 : : {
507 : : // create listener
508 [ # # ][ # # ]: 0 : pClipEvtLstnr = new TransferableClipboardListener( LINK( this, ScDrawTextObjectBar, ClipboardChanged ) );
509 : 0 : pClipEvtLstnr->acquire();
510 [ # # ]: 0 : Window* pWin = pViewData->GetActiveWin();
511 [ # # ]: 0 : pClipEvtLstnr->AddRemoveListener( pWin, sal_True );
512 : :
513 : : // get initial state
514 [ # # ][ # # ]: 0 : TransferableDataHelper aDataHelper( TransferableDataHelper::CreateFromSystemClipboard( pViewData->GetActiveWin() ) );
515 [ # # ][ # # ]: 0 : bPastePossible = ( aDataHelper.HasFormat( SOT_FORMAT_STRING ) || aDataHelper.HasFormat( SOT_FORMAT_RTF ) );
[ # # ][ # # ]
[ # # ]
516 : : }
517 : :
518 [ # # ]: 0 : SfxWhichIter aIter( rSet );
519 [ # # ]: 0 : sal_uInt16 nWhich = aIter.FirstWhich();
520 [ # # ]: 0 : while (nWhich)
521 : : {
522 [ # # # ]: 0 : switch (nWhich)
523 : : {
524 : : case SID_PASTE:
525 : : case SID_PASTE_SPECIAL:
526 [ # # ]: 0 : if( !bPastePossible )
527 [ # # ]: 0 : rSet.DisableItem( nWhich );
528 : 0 : break;
529 : : case SID_CLIPBOARD_FORMAT_ITEMS:
530 [ # # ]: 0 : if ( bPastePossible )
531 : : {
532 [ # # ]: 0 : SvxClipboardFmtItem aFormats( SID_CLIPBOARD_FORMAT_ITEMS );
533 : : TransferableDataHelper aDataHelper(
534 [ # # ][ # # ]: 0 : TransferableDataHelper::CreateFromSystemClipboard( pViewData->GetActiveWin() ) );
535 : :
536 [ # # ][ # # ]: 0 : if ( aDataHelper.HasFormat( SOT_FORMAT_STRING ) )
537 [ # # ]: 0 : aFormats.AddClipbrdFormat( SOT_FORMAT_STRING );
538 [ # # ][ # # ]: 0 : if ( aDataHelper.HasFormat( SOT_FORMAT_RTF ) )
539 [ # # ]: 0 : aFormats.AddClipbrdFormat( SOT_FORMAT_RTF );
540 : :
541 [ # # ][ # # ]: 0 : rSet.Put( aFormats );
[ # # ]
542 : : }
543 : : else
544 [ # # ]: 0 : rSet.DisableItem( nWhich );
545 : 0 : break;
546 : : }
547 [ # # ]: 0 : nWhich = aIter.NextWhich();
548 [ # # ]: 0 : }
549 : : }
550 : :
551 : : //========================================================================
552 : : //
553 : : // Attribute
554 : : //
555 : : //========================================================================
556 : :
557 : 0 : void ScDrawTextObjectBar::ExecuteToggle( SfxRequest &rReq )
558 : : {
559 : : // Unterstreichung
560 : :
561 [ # # ]: 0 : SdrView* pView = pViewData->GetScDrawView();
562 : :
563 : 0 : sal_uInt16 nSlot = rReq.GetSlot();
564 : :
565 [ # # ]: 0 : SfxItemSet aSet( pView->GetDefaultAttr() );
566 : :
567 [ # # ]: 0 : SfxItemSet aViewAttr(pView->GetModel()->GetItemPool());
568 [ # # ]: 0 : pView->GetAttributes(aViewAttr);
569 : :
570 : : // Unterstreichung
571 : : FontUnderline eOld = ((const SvxUnderlineItem&) aViewAttr.
572 [ # # ]: 0 : Get(EE_CHAR_UNDERLINE)).GetLineStyle();
573 : 0 : FontUnderline eNew = eOld;
574 [ # # # # : 0 : switch (nSlot)
# ]
575 : : {
576 : : case SID_ULINE_VAL_NONE:
577 : 0 : eNew = UNDERLINE_NONE;
578 : 0 : break;
579 : : case SID_ULINE_VAL_SINGLE:
580 : 0 : eNew = ( eOld == UNDERLINE_SINGLE ) ? UNDERLINE_NONE : UNDERLINE_SINGLE;
581 : 0 : break;
582 : : case SID_ULINE_VAL_DOUBLE:
583 [ # # ]: 0 : eNew = ( eOld == UNDERLINE_DOUBLE ) ? UNDERLINE_NONE : UNDERLINE_DOUBLE;
584 : 0 : break;
585 : : case SID_ULINE_VAL_DOTTED:
586 [ # # ]: 0 : eNew = ( eOld == UNDERLINE_DOTTED ) ? UNDERLINE_NONE : UNDERLINE_DOTTED;
587 : 0 : break;
588 : : default:
589 : 0 : break;
590 : : }
591 [ # # ][ # # ]: 0 : aSet.Put( SvxUnderlineItem( eNew, EE_CHAR_UNDERLINE ) );
[ # # ]
592 : :
593 [ # # ]: 0 : pView->SetAttributes( aSet );
594 [ # # ]: 0 : rReq.Done();
595 [ # # ][ # # ]: 0 : pViewData->GetScDrawView()->InvalidateDrawTextAttrs();
[ # # ][ # # ]
596 : 0 : }
597 : :
598 : 0 : void lcl_RemoveFields( OutlinerView& rOutView )
599 : : {
600 : : //! Outliner should have RemoveFields with a selection
601 : :
602 : 0 : Outliner* pOutliner = rOutView.GetOutliner();
603 [ # # ]: 0 : if (!pOutliner) return;
604 : :
605 [ # # ]: 0 : ESelection aOldSel = rOutView.GetSelection();
606 : 0 : ESelection aSel = aOldSel;
607 : 0 : aSel.Adjust();
608 : 0 : xub_StrLen nNewEnd = aSel.nEndPos;
609 : :
610 [ # # ]: 0 : sal_Bool bUpdate = pOutliner->GetUpdateMode();
611 : 0 : sal_Bool bChanged = false;
612 : :
613 : : //! GetPortions and GetAttribs should be const!
614 : 0 : EditEngine& rEditEng = (EditEngine&)pOutliner->GetEditEngine();
615 : :
616 [ # # ]: 0 : sal_uLong nParCount = pOutliner->GetParagraphCount();
617 [ # # ]: 0 : for (sal_uLong nPar=0; nPar<nParCount; nPar++)
618 [ # # ][ # # ]: 0 : if ( nPar >= aSel.nStartPara && nPar <= aSel.nEndPara )
619 : : {
620 [ # # ]: 0 : std::vector<sal_uInt16> aPortions;
621 [ # # ]: 0 : rEditEng.GetPortions( (sal_uInt16)nPar, aPortions );
622 : : //! GetPortions should use xub_StrLen instead of USHORT
623 : :
624 [ # # ]: 0 : for ( size_t nPos = aPortions.size(); nPos; )
625 : : {
626 : 0 : --nPos;
627 [ # # ]: 0 : sal_uInt16 nEnd = aPortions[ nPos ];
628 [ # # ][ # # ]: 0 : sal_uInt16 nStart = nPos ? aPortions[ nPos - 1 ] : 0;
629 : : // fields are single characters
630 [ # # ][ # # ]: 0 : if ( nEnd == nStart+1 &&
[ # # ][ # # ]
[ # # ]
631 : : ( nPar > aSel.nStartPara || nStart >= aSel.nStartPos ) &&
632 : : ( nPar < aSel.nEndPara || nEnd <= aSel.nEndPos ) )
633 : : {
634 : 0 : ESelection aFieldSel( (sal_uInt16)nPar, nStart, (sal_uInt16)nPar, nEnd );
635 [ # # ]: 0 : SfxItemSet aSet = rEditEng.GetAttribs( aFieldSel );
636 [ # # ][ # # ]: 0 : if ( aSet.GetItemState( EE_FEATURE_FIELD ) == SFX_ITEM_ON )
637 : : {
638 [ # # ]: 0 : if (!bChanged)
639 : : {
640 [ # # ]: 0 : if (bUpdate)
641 [ # # ]: 0 : pOutliner->SetUpdateMode( false );
642 [ # # ][ # # ]: 0 : String aName = ScGlobal::GetRscString( STR_UNDO_DELETECONTENTS );
643 [ # # ][ # # ]: 0 : pOutliner->GetUndoManager().EnterListAction( aName, aName );
644 [ # # ]: 0 : bChanged = sal_True;
645 : : }
646 : :
647 [ # # ]: 0 : String aFieldText = rEditEng.GetText( aFieldSel );
648 [ # # ]: 0 : pOutliner->QuickInsertText( aFieldText, aFieldSel );
649 [ # # ]: 0 : if ( nPar == aSel.nEndPara )
650 : : {
651 : 0 : nNewEnd = sal::static_int_cast<xub_StrLen>( nNewEnd + aFieldText.Len() );
652 : 0 : --nNewEnd;
653 [ # # ]: 0 : }
654 [ # # ]: 0 : }
655 : : }
656 : 0 : }
657 : : }
658 : :
659 [ # # ][ # # ]: 0 : if (bUpdate && bChanged)
660 : : {
661 [ # # ][ # # ]: 0 : pOutliner->GetUndoManager().LeaveListAction();
662 [ # # ]: 0 : pOutliner->SetUpdateMode( sal_True );
663 : : }
664 : :
665 [ # # ]: 0 : if ( aOldSel.IsEqual( aSel ) ) // aSel is adjusted
666 : 0 : aOldSel.nEndPos = nNewEnd;
667 : : else
668 : 0 : aOldSel.nStartPos = nNewEnd; // if aOldSel is backwards
669 [ # # ]: 0 : rOutView.SetSelection( aOldSel );
670 : : }
671 : :
672 : 0 : void ScDrawTextObjectBar::ExecuteAttr( SfxRequest &rReq )
673 : : {
674 : 0 : SdrView* pView = pViewData->GetScDrawView();
675 : 0 : const SfxItemSet* pArgs = rReq.GetArgs();
676 : 0 : sal_uInt16 nSlot = rReq.GetSlot();
677 : :
678 : 0 : sal_Bool bArgsInReq = ( pArgs != NULL );
679 [ # # ]: 0 : if ( !bArgsInReq )
680 : : {
681 [ # # ]: 0 : SfxItemSet aEditAttr(pView->GetModel()->GetItemPool());
682 [ # # ]: 0 : pView->GetAttributes(aEditAttr);
683 [ # # ]: 0 : SfxItemSet aNewAttr( *aEditAttr.GetPool(), aEditAttr.GetRanges() );
684 : 0 : sal_Bool bDone = sal_True;
685 : :
686 [ # # # # : 0 : switch ( nSlot )
# # # # #
# # # # #
# # # # #
# # ]
687 : : {
688 : : case SID_TEXT_STANDARD: // Harte Textattributierung loeschen
689 : : {
690 [ # # ]: 0 : OutlinerView* pOutView = pView->IsTextEdit() ?
691 [ # # ]: 0 : pView->GetTextEditOutlinerView() : NULL;
692 [ # # ]: 0 : if ( pOutView )
693 [ # # ][ # # ]: 0 : pOutView->Paint( Rectangle() );
694 : :
695 [ # # ]: 0 : SfxItemSet aEmptyAttr( *aEditAttr.GetPool(), EE_ITEMS_START, EE_ITEMS_END );
696 [ # # ]: 0 : pView->SetAttributes( aEmptyAttr, sal_True );
697 : :
698 [ # # ]: 0 : if ( pOutView )
699 : : {
700 [ # # ]: 0 : lcl_RemoveFields( *pOutView );
701 [ # # ]: 0 : pOutView->ShowCursor();
702 : : }
703 : :
704 [ # # ]: 0 : rReq.Done( aEmptyAttr );
705 [ # # ][ # # ]: 0 : pViewData->GetScDrawView()->InvalidateDrawTextAttrs();
706 [ # # ]: 0 : bDone = false; // bereits hier passiert
707 : : }
708 : 0 : break;
709 : :
710 : : case SID_CHAR_DLG: // Dialog-Button
711 : : case SID_ATTR_CHAR_FONT: // Controller nicht angezeigt
712 : : case SID_ATTR_CHAR_FONTHEIGHT:
713 [ # # ]: 0 : bDone = ExecuteCharDlg( aEditAttr, aNewAttr );
714 : 0 : break;
715 : :
716 : : case SID_PARA_DLG:
717 [ # # ]: 0 : bDone = ExecuteParaDlg( aEditAttr, aNewAttr );
718 : 0 : break;
719 : :
720 : : case SID_ATTR_CHAR_WEIGHT:
721 [ # # ][ # # ]: 0 : aNewAttr.Put( (const SvxWeightItem&)aEditAttr.Get( EE_CHAR_WEIGHT ) );
722 : 0 : break;
723 : :
724 : : case SID_ATTR_CHAR_POSTURE:
725 [ # # ][ # # ]: 0 : aNewAttr.Put( (const SvxPostureItem&)aEditAttr.Get( EE_CHAR_ITALIC ) );
726 : 0 : break;
727 : :
728 : : case SID_ATTR_CHAR_UNDERLINE:
729 [ # # ][ # # ]: 0 : aNewAttr.Put( (const SvxUnderlineItem&)aEditAttr.Get( EE_CHAR_UNDERLINE ) );
730 : 0 : break;
731 : :
732 : : case SID_ATTR_CHAR_OVERLINE:
733 [ # # ][ # # ]: 0 : aNewAttr.Put( (const SvxOverlineItem&)aEditAttr.Get( EE_CHAR_OVERLINE ) );
734 : 0 : break;
735 : :
736 : : case SID_ATTR_CHAR_CONTOUR:
737 [ # # ][ # # ]: 0 : aNewAttr.Put( (const SvxContourItem&)aEditAttr.Get( EE_CHAR_OUTLINE ) );
738 : 0 : break;
739 : :
740 : : case SID_ATTR_CHAR_SHADOWED:
741 [ # # ][ # # ]: 0 : aNewAttr.Put( (const SvxShadowedItem&)aEditAttr.Get( EE_CHAR_SHADOW ) );
742 : 0 : break;
743 : :
744 : : case SID_ATTR_CHAR_STRIKEOUT:
745 [ # # ][ # # ]: 0 : aNewAttr.Put( (const SvxCrossedOutItem&)aEditAttr.Get( EE_CHAR_STRIKEOUT ) );
746 : 0 : break;
747 : :
748 : : case SID_ALIGNLEFT:
749 : : case SID_ALIGN_ANY_LEFT:
750 [ # # ][ # # ]: 0 : aNewAttr.Put( SvxAdjustItem( SVX_ADJUST_LEFT, EE_PARA_JUST ) );
[ # # ]
751 : 0 : break;
752 : :
753 : : case SID_ALIGNCENTERHOR:
754 : : case SID_ALIGN_ANY_HCENTER:
755 [ # # ][ # # ]: 0 : aNewAttr.Put( SvxAdjustItem( SVX_ADJUST_CENTER, EE_PARA_JUST ) );
[ # # ]
756 : 0 : break;
757 : :
758 : : case SID_ALIGNRIGHT:
759 : : case SID_ALIGN_ANY_RIGHT:
760 [ # # ][ # # ]: 0 : aNewAttr.Put( SvxAdjustItem( SVX_ADJUST_RIGHT, EE_PARA_JUST ) );
[ # # ]
761 : 0 : break;
762 : :
763 : : case SID_ALIGNBLOCK:
764 : : case SID_ALIGN_ANY_JUSTIFIED:
765 [ # # ][ # # ]: 0 : aNewAttr.Put( SvxAdjustItem( SVX_ADJUST_BLOCK, EE_PARA_JUST ) );
[ # # ]
766 : 0 : break;
767 : :
768 : : case SID_ATTR_PARA_LINESPACE_10:
769 : : {
770 [ # # ]: 0 : SvxLineSpacingItem aItem( SVX_LINESPACE_ONE_LINE, EE_PARA_SBL );
771 : 0 : aItem.SetPropLineSpace( 100 );
772 [ # # ][ # # ]: 0 : aNewAttr.Put( aItem );
773 : : }
774 : 0 : break;
775 : :
776 : : case SID_ATTR_PARA_LINESPACE_15:
777 : : {
778 [ # # ]: 0 : SvxLineSpacingItem aItem( SVX_LINESPACE_ONE_POINT_FIVE_LINES, EE_PARA_SBL );
779 : 0 : aItem.SetPropLineSpace( 150 );
780 [ # # ][ # # ]: 0 : aNewAttr.Put( aItem );
781 : : }
782 : 0 : break;
783 : :
784 : : case SID_ATTR_PARA_LINESPACE_20:
785 : : {
786 [ # # ]: 0 : SvxLineSpacingItem aItem( SVX_LINESPACE_TWO_LINES, EE_PARA_SBL );
787 : 0 : aItem.SetPropLineSpace( 200 );
788 [ # # ][ # # ]: 0 : aNewAttr.Put( aItem );
789 : : }
790 : 0 : break;
791 : :
792 : : case SID_SET_SUPER_SCRIPT:
793 : : {
794 [ # # ]: 0 : SvxEscapementItem aItem(EE_CHAR_ESCAPEMENT);
795 : : SvxEscapement eEsc = (SvxEscapement) ( (const SvxEscapementItem&)
796 [ # # ][ # # ]: 0 : aEditAttr.Get( EE_CHAR_ESCAPEMENT ) ).GetEnumValue();
797 : :
798 [ # # ]: 0 : if( eEsc == SVX_ESCAPEMENT_SUPERSCRIPT )
799 : 0 : aItem.SetEscapement( SVX_ESCAPEMENT_OFF );
800 : : else
801 : 0 : aItem.SetEscapement( SVX_ESCAPEMENT_SUPERSCRIPT );
802 [ # # ][ # # ]: 0 : aNewAttr.Put( aItem );
803 : : }
804 : 0 : break;
805 : : case SID_SET_SUB_SCRIPT:
806 : : {
807 [ # # ]: 0 : SvxEscapementItem aItem(EE_CHAR_ESCAPEMENT);
808 : : SvxEscapement eEsc = (SvxEscapement) ( (const SvxEscapementItem&)
809 [ # # ][ # # ]: 0 : aEditAttr.Get( EE_CHAR_ESCAPEMENT ) ).GetEnumValue();
810 : :
811 [ # # ]: 0 : if( eEsc == SVX_ESCAPEMENT_SUBSCRIPT )
812 : 0 : aItem.SetEscapement( SVX_ESCAPEMENT_OFF );
813 : : else
814 : 0 : aItem.SetEscapement( SVX_ESCAPEMENT_SUBSCRIPT );
815 [ # # ][ # # ]: 0 : aNewAttr.Put( aItem );
816 : : }
817 : 0 : break;
818 : :
819 : : case SID_DRAWTEXT_ATTR_DLG:
820 : : {
821 [ # # ]: 0 : SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
822 [ # # ][ # # ]: 0 : SfxAbstractTabDialog *pDlg = pFact->CreateTextTabDialog( pViewData->GetDialogParent(), &aEditAttr, pView );
823 : :
824 [ # # ]: 0 : bDone = ( RET_OK == pDlg->Execute() );
825 : :
826 [ # # ]: 0 : if ( bDone )
827 [ # # ][ # # ]: 0 : aNewAttr.Put( *pDlg->GetOutputItemSet() );
828 : :
829 [ # # ][ # # ]: 0 : delete pDlg;
830 : : }
831 : 0 : break;
832 : : }
833 : :
834 [ # # ]: 0 : if ( bDone ) // wurden Attribute geaendert?
835 : : {
836 [ # # ]: 0 : rReq.Done( aNewAttr );
837 : 0 : pArgs = rReq.GetArgs();
838 [ # # ][ # # ]: 0 : }
839 : : }
840 : :
841 [ # # ]: 0 : if ( pArgs )
842 : : {
843 [ # # ][ # # ]: 0 : if ( bArgsInReq &&
[ # # ][ # # ]
[ # # ]
844 : : ( nSlot == SID_ATTR_CHAR_FONT || nSlot == SID_ATTR_CHAR_FONTHEIGHT ||
845 : : nSlot == SID_ATTR_CHAR_WEIGHT || nSlot == SID_ATTR_CHAR_POSTURE ) )
846 : : {
847 : : // font items from toolbox controller have to be applied for the right script type
848 : :
849 : : // #i78017 establish the same behaviour as in Writer
850 : 0 : sal_uInt16 nScript = SCRIPTTYPE_LATIN | SCRIPTTYPE_ASIAN | SCRIPTTYPE_COMPLEX;
851 [ # # ]: 0 : if (nSlot == SID_ATTR_CHAR_FONT)
852 [ # # ]: 0 : nScript = pView->GetScriptType();
853 : :
854 : 0 : SfxItemPool& rPool = GetPool();
855 [ # # ]: 0 : SvxScriptSetItem aSetItem( nSlot, rPool );
856 [ # # ]: 0 : sal_uInt16 nWhich = rPool.GetWhich( nSlot );
857 [ # # ][ # # ]: 0 : aSetItem.PutItemForScriptType( nScript, pArgs->Get( nWhich ) );
858 : :
859 [ # # ][ # # ]: 0 : pView->SetAttributes( aSetItem.GetItemSet() );
860 : : }
861 : : else
862 : : {
863 : : // use args directly
864 : :
865 : 0 : pView->SetAttributes( *pArgs );
866 : : }
867 : 0 : pViewData->GetScDrawView()->InvalidateDrawTextAttrs();
868 : : }
869 : 0 : }
870 : :
871 : 0 : void ScDrawTextObjectBar::GetAttrState( SfxItemSet& rDestSet )
872 : : {
873 [ # # ]: 0 : if ( IsNoteEdit() )
874 : : {
875 : : // issue 21255 - Notes now support rich text formatting.
876 : : }
877 : :
878 [ # # ]: 0 : SvtLanguageOptions aLangOpt;
879 [ # # ]: 0 : sal_Bool bDisableCTLFont = !aLangOpt.IsCTLFontEnabled();
880 [ # # ]: 0 : sal_Bool bDisableVerticalText = !aLangOpt.IsVerticalTextEnabled();
881 : :
882 [ # # ]: 0 : SdrView* pView = pViewData->GetScDrawView();
883 [ # # ]: 0 : SfxItemSet aAttrSet(pView->GetModel()->GetItemPool());
884 [ # # ]: 0 : pView->GetAttributes(aAttrSet);
885 : :
886 : : // direkte Attribute
887 : :
888 [ # # ]: 0 : rDestSet.Put( aAttrSet );
889 : :
890 : : // choose font info according to selection script type
891 : :
892 [ # # ]: 0 : sal_uInt16 nScript = pView->GetScriptType();
893 : :
894 : : // #i55929# input-language-dependent script type (depends on input language if nothing selected)
895 : 0 : sal_uInt16 nInputScript = nScript;
896 : 0 : OutlinerView* pOutView = pView->GetTextEditOutlinerView();
897 [ # # ][ # # ]: 0 : if (pOutView && !pOutView->GetSelection().HasRange())
[ # # ]
[ # # # # ]
[ # # ]
898 : : {
899 [ # # ][ # # ]: 0 : LanguageType nInputLang = pViewData->GetActiveWin()->GetInputLanguage();
900 [ # # ][ # # ]: 0 : if (nInputLang != LANGUAGE_DONTKNOW && nInputLang != LANGUAGE_SYSTEM)
901 [ # # ]: 0 : nInputScript = SvtLanguageOptions::GetScriptTypeOfLanguage( nInputLang );
902 : : }
903 : :
904 : : // #i55929# according to spec, nInputScript is used for font and font height only
905 [ # # ][ # # ]: 0 : if ( rDestSet.GetItemState( EE_CHAR_FONTINFO ) != SFX_ITEM_UNKNOWN )
906 [ # # ]: 0 : ScViewUtil::PutItemScript( rDestSet, aAttrSet, EE_CHAR_FONTINFO, nInputScript );
907 [ # # ][ # # ]: 0 : if ( rDestSet.GetItemState( EE_CHAR_FONTHEIGHT ) != SFX_ITEM_UNKNOWN )
908 [ # # ]: 0 : ScViewUtil::PutItemScript( rDestSet, aAttrSet, EE_CHAR_FONTHEIGHT, nInputScript );
909 [ # # ][ # # ]: 0 : if ( rDestSet.GetItemState( EE_CHAR_WEIGHT ) != SFX_ITEM_UNKNOWN )
910 [ # # ]: 0 : ScViewUtil::PutItemScript( rDestSet, aAttrSet, EE_CHAR_WEIGHT, nScript );
911 [ # # ][ # # ]: 0 : if ( rDestSet.GetItemState( EE_CHAR_ITALIC ) != SFX_ITEM_UNKNOWN )
912 [ # # ]: 0 : ScViewUtil::PutItemScript( rDestSet, aAttrSet, EE_CHAR_ITALIC, nScript );
913 : :
914 : : // Ausrichtung
915 : :
916 [ # # ]: 0 : SvxAdjust eAdj = ((const SvxAdjustItem&)aAttrSet.Get(EE_PARA_JUST)).GetAdjust();
917 [ # # # # : 0 : switch( eAdj )
# ]
918 : : {
919 : : case SVX_ADJUST_LEFT:
920 [ # # ][ # # ]: 0 : rDestSet.Put( SfxBoolItem( SID_ALIGNLEFT, sal_True ) );
[ # # ]
921 : 0 : break;
922 : : case SVX_ADJUST_CENTER:
923 [ # # ][ # # ]: 0 : rDestSet.Put( SfxBoolItem( SID_ALIGNCENTERHOR, sal_True ) );
[ # # ]
924 : 0 : break;
925 : : case SVX_ADJUST_RIGHT:
926 [ # # ][ # # ]: 0 : rDestSet.Put( SfxBoolItem( SID_ALIGNRIGHT, sal_True ) );
[ # # ]
927 : 0 : break;
928 : : case SVX_ADJUST_BLOCK:
929 [ # # ][ # # ]: 0 : rDestSet.Put( SfxBoolItem( SID_ALIGNBLOCK, sal_True ) );
[ # # ]
930 : 0 : break;
931 : : default:
932 : : {
933 : : // added to avoid warnings
934 : : }
935 : : }
936 : : // pseudo slots for Format menu
937 [ # # ][ # # ]: 0 : rDestSet.Put( SfxBoolItem( SID_ALIGN_ANY_LEFT, eAdj == SVX_ADJUST_LEFT ) );
[ # # ]
938 [ # # ][ # # ]: 0 : rDestSet.Put( SfxBoolItem( SID_ALIGN_ANY_HCENTER, eAdj == SVX_ADJUST_CENTER ) );
[ # # ]
939 [ # # ][ # # ]: 0 : rDestSet.Put( SfxBoolItem( SID_ALIGN_ANY_RIGHT, eAdj == SVX_ADJUST_RIGHT ) );
[ # # ]
940 [ # # ][ # # ]: 0 : rDestSet.Put( SfxBoolItem( SID_ALIGN_ANY_JUSTIFIED, eAdj == SVX_ADJUST_BLOCK ) );
[ # # ]
941 : :
942 : : // Zeilenabstand
943 : :
944 : : sal_uInt16 nLineSpace = (sal_uInt16)
945 : : ((const SvxLineSpacingItem&)aAttrSet.
946 [ # # ]: 0 : Get( EE_PARA_SBL )).GetPropLineSpace();
947 [ # # # # ]: 0 : switch( nLineSpace )
948 : : {
949 : : case 100:
950 [ # # ][ # # ]: 0 : rDestSet.Put( SfxBoolItem( SID_ATTR_PARA_LINESPACE_10, sal_True ) );
[ # # ]
951 : 0 : break;
952 : : case 150:
953 [ # # ][ # # ]: 0 : rDestSet.Put( SfxBoolItem( SID_ATTR_PARA_LINESPACE_15, sal_True ) );
[ # # ]
954 : 0 : break;
955 : : case 200:
956 [ # # ][ # # ]: 0 : rDestSet.Put( SfxBoolItem( SID_ATTR_PARA_LINESPACE_20, sal_True ) );
[ # # ]
957 : 0 : break;
958 : : }
959 : :
960 : : // hoch-/tiefgestellt
961 : :
962 : : SvxEscapement eEsc = (SvxEscapement) ( (const SvxEscapementItem&)
963 [ # # ][ # # ]: 0 : aAttrSet.Get( EE_CHAR_ESCAPEMENT ) ).GetEnumValue();
964 [ # # ]: 0 : if( eEsc == SVX_ESCAPEMENT_SUPERSCRIPT )
965 [ # # ][ # # ]: 0 : rDestSet.Put( SfxBoolItem( SID_SET_SUPER_SCRIPT, sal_True ) );
[ # # ]
966 [ # # ]: 0 : else if( eEsc == SVX_ESCAPEMENT_SUBSCRIPT )
967 [ # # ][ # # ]: 0 : rDestSet.Put( SfxBoolItem( SID_SET_SUB_SCRIPT, sal_True ) );
[ # # ]
968 : :
969 : : // Unterstreichung
970 : :
971 [ # # ]: 0 : SfxItemState eState = aAttrSet.GetItemState( EE_CHAR_UNDERLINE, sal_True );
972 [ # # ]: 0 : if ( eState == SFX_ITEM_DONTCARE )
973 : : {
974 [ # # ]: 0 : rDestSet.InvalidateItem( SID_ULINE_VAL_NONE );
975 [ # # ]: 0 : rDestSet.InvalidateItem( SID_ULINE_VAL_SINGLE );
976 [ # # ]: 0 : rDestSet.InvalidateItem( SID_ULINE_VAL_DOUBLE );
977 [ # # ]: 0 : rDestSet.InvalidateItem( SID_ULINE_VAL_DOTTED );
978 : : }
979 : : else
980 : : {
981 : : FontUnderline eUnderline = ((const SvxUnderlineItem&)
982 [ # # ]: 0 : aAttrSet.Get(EE_CHAR_UNDERLINE)).GetLineStyle();
983 : 0 : sal_uInt16 nId = SID_ULINE_VAL_NONE;
984 [ # # # # ]: 0 : switch (eUnderline)
985 : : {
986 : 0 : case UNDERLINE_SINGLE: nId = SID_ULINE_VAL_SINGLE; break;
987 : 0 : case UNDERLINE_DOUBLE: nId = SID_ULINE_VAL_DOUBLE; break;
988 : 0 : case UNDERLINE_DOTTED: nId = SID_ULINE_VAL_DOTTED; break;
989 : : default:
990 : 0 : break;
991 : : }
992 [ # # ][ # # ]: 0 : rDestSet.Put( SfxBoolItem( nId, sal_True ) );
[ # # ]
993 : : }
994 : :
995 : : // horizontal / vertical
996 : :
997 : 0 : sal_Bool bLeftToRight = sal_True;
998 : :
999 : 0 : SdrOutliner* pOutl = pView->GetTextEditOutliner();
1000 [ # # ]: 0 : if( pOutl )
1001 : : {
1002 [ # # ][ # # ]: 0 : if( pOutl->IsVertical() )
1003 : 0 : bLeftToRight = false;
1004 : : }
1005 : : else
1006 [ # # ]: 0 : bLeftToRight = ( (const SvxWritingModeItem&) aAttrSet.Get( SDRATTR_TEXTDIRECTION ) ).GetValue() == com::sun::star::text::WritingMode_LR_TB;
1007 : :
1008 [ # # ]: 0 : if ( bDisableVerticalText )
1009 : : {
1010 [ # # ]: 0 : rDestSet.DisableItem( SID_TEXTDIRECTION_LEFT_TO_RIGHT );
1011 [ # # ]: 0 : rDestSet.DisableItem( SID_TEXTDIRECTION_TOP_TO_BOTTOM );
1012 : : }
1013 : : else
1014 : : {
1015 [ # # ][ # # ]: 0 : rDestSet.Put( SfxBoolItem( SID_TEXTDIRECTION_LEFT_TO_RIGHT, bLeftToRight ) );
[ # # ]
1016 [ # # ][ # # ]: 0 : rDestSet.Put( SfxBoolItem( SID_TEXTDIRECTION_TOP_TO_BOTTOM, !bLeftToRight ) );
[ # # ]
1017 : : }
1018 : :
1019 : : // left-to-right or right-to-left
1020 : :
1021 [ # # ][ # # ]: 0 : if ( !bLeftToRight || bDisableCTLFont )
1022 : : {
1023 : : // disabled if vertical
1024 [ # # ]: 0 : rDestSet.DisableItem( SID_ATTR_PARA_LEFT_TO_RIGHT );
1025 [ # # ]: 0 : rDestSet.DisableItem( SID_ATTR_PARA_RIGHT_TO_LEFT );
1026 : : }
1027 [ # # ][ # # ]: 0 : else if ( aAttrSet.GetItemState( EE_PARA_WRITINGDIR ) == SFX_ITEM_DONTCARE )
1028 : : {
1029 [ # # ]: 0 : rDestSet.InvalidateItem( SID_ATTR_PARA_LEFT_TO_RIGHT );
1030 [ # # ]: 0 : rDestSet.InvalidateItem( SID_ATTR_PARA_RIGHT_TO_LEFT );
1031 : : }
1032 : : else
1033 : : {
1034 : : SvxFrameDirection eAttrDir = (SvxFrameDirection)((const SvxFrameDirectionItem&)
1035 [ # # ]: 0 : aAttrSet.Get( EE_PARA_WRITINGDIR )).GetValue();
1036 [ # # ]: 0 : if ( eAttrDir == FRMDIR_ENVIRONMENT )
1037 : : {
1038 : : // get "environment" direction from page style
1039 [ # # ][ # # ]: 0 : if ( pViewData->GetDocument()->GetEditTextDirection( pViewData->GetTabNo() ) == EE_HTEXTDIR_R2L )
[ # # ]
1040 : 0 : eAttrDir = FRMDIR_HORI_RIGHT_TOP;
1041 : : else
1042 : 0 : eAttrDir = FRMDIR_HORI_LEFT_TOP;
1043 : : }
1044 [ # # ][ # # ]: 0 : rDestSet.Put( SfxBoolItem( SID_ATTR_PARA_LEFT_TO_RIGHT, ( eAttrDir == FRMDIR_HORI_LEFT_TOP ) ) );
[ # # ]
1045 [ # # ][ # # ]: 0 : rDestSet.Put( SfxBoolItem( SID_ATTR_PARA_RIGHT_TO_LEFT, ( eAttrDir == FRMDIR_HORI_RIGHT_TOP ) ) );
[ # # ]
1046 [ # # ][ # # ]: 0 : }
1047 : 0 : }
1048 : :
1049 : 0 : void ScDrawTextObjectBar::ExecuteTrans( SfxRequest& rReq )
1050 : : {
1051 : 0 : sal_Int32 nType = ScViewUtil::GetTransliterationType( rReq.GetSlot() );
1052 [ # # ]: 0 : if ( nType )
1053 : : {
1054 : 0 : ScDrawView* pView = pViewData->GetScDrawView();
1055 : 0 : OutlinerView* pOutView = pView->GetTextEditOutlinerView();
1056 [ # # ]: 0 : if ( pOutView )
1057 : : {
1058 : : // change selected text in object
1059 : 0 : pOutView->TransliterateText( nType );
1060 : : }
1061 : : else
1062 : : {
1063 : : //! apply to whole objects?
1064 : : }
1065 : : }
1066 : 0 : }
1067 : :
1068 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|