Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / sw / source / uibase / shells / annotsh.cxx
blob4343cd869160c99d165a196ff8ad1fe2c7620719
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <hintids.hxx>
22 #include <com/sun/star/i18n/TextConversionOption.hpp>
23 #include <com/sun/star/lang/XInitialization.hpp>
24 #include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
25 #include <com/sun/star/awt/XWindow.hpp>
26 #include <com/sun/star/uno/XComponentContext.hpp>
27 #include <com/sun/star/beans/XPropertySet.hpp>
28 #include <com/sun/star/linguistic2/XThesaurus.hpp>
30 #include <i18nutil/transliteration.hxx>
31 #include <sfx2/objface.hxx>
32 #include <sfx2/viewfrm.hxx>
33 #include <sfx2/bindings.hxx>
34 #include <sfx2/dispatch.hxx>
35 #include <sfx2/request.hxx>
36 #include <editeng/eeitem.hxx>
37 #include <editeng/flstitem.hxx>
38 #include <editeng/spltitem.hxx>
39 #include <editeng/lrspitem.hxx>
40 #include <editeng/ulspitem.hxx>
41 #include <editeng/orphitem.hxx>
42 #include <editeng/formatbreakitem.hxx>
43 #include <editeng/widwitem.hxx>
44 #include <editeng/kernitem.hxx>
45 #include <editeng/escapementitem.hxx>
46 #include <editeng/lspcitem.hxx>
47 #include <editeng/adjustitem.hxx>
48 #include <editeng/hyphenzoneitem.hxx>
49 #include <editeng/udlnitem.hxx>
50 #include <editeng/fontitem.hxx>
51 #include <svx/clipfmtitem.hxx>
52 #include <svl/stritem.hxx>
53 #include <svl/slstitm.hxx>
54 #include <editeng/frmdiritem.hxx>
55 #include <svl/whiter.hxx>
56 #include <svl/cjkoptions.hxx>
57 #include <svl/ctloptions.hxx>
58 #include <unotools/useroptions.hxx>
59 #include <editeng/flditem.hxx>
60 #include <svx/hlnkitem.hxx>
61 #include <sfx2/htmlmode.hxx>
62 #include <editeng/langitem.hxx>
63 #include <editeng/scripttypeitem.hxx>
64 #include <swundo.hxx>
65 #include <doc.hxx>
66 #include <viewopt.hxx>
67 #include <wrtsh.hxx>
68 #include <chrdlgmodes.hxx>
69 #include <edtwin.hxx>
70 #include <SwRewriter.hxx>
72 #include <cmdid.h>
73 #include <strings.hrc>
74 #include <breakit.hxx>
75 #include <annotsh.hxx>
76 #include <view.hxx>
77 #include <PostItMgr.hxx>
78 #include <AnnotationWin.hxx>
80 #include <swtypes.hxx>
82 #include <svx/svxdlg.hxx>
84 #include <vcl/EnumContext.hxx>
85 #include <svl/itempool.hxx>
86 #include <editeng/outliner.hxx>
87 #include <editeng/editview.hxx>
88 #include <osl/diagnose.h>
90 #include <svl/languageoptions.hxx>
92 #include <svl/undo.hxx>
93 #include <swabstdlg.hxx>
95 #include <comphelper/string.hxx>
96 #include <comphelper/propertysequence.hxx>
97 #include <cppuhelper/bootstrap.hxx>
99 #include <langhelper.hxx>
101 #include <memory>
103 using namespace ::com::sun::star;
104 using namespace ::com::sun::star::uno;
105 using namespace ::com::sun::star::beans;
106 using namespace ::com::sun::star::i18n;
108 #define ShellClass_SwAnnotationShell
110 #include <sfx2/msg.hxx>
111 #include <swslots.hxx>
113 SFX_IMPL_INTERFACE(SwAnnotationShell, SfxShell)
115 void SwAnnotationShell::InitInterface_Impl()
117 GetStaticInterface()->RegisterObjectBar(SFX_OBJECTBAR_OBJECT, SfxVisibilityFlags::Invisible, ToolbarId::Text_Toolbox_Sw);
119 GetStaticInterface()->RegisterPopupMenu("annotation");
123 SfxItemPool* SwAnnotationShell::GetAnnotationPool(SwView const & rV)
125 SwWrtShell &rSh = rV.GetWrtShell();
126 return rSh.GetAttrPool().GetSecondaryPool();
129 SwAnnotationShell::SwAnnotationShell( SwView& r )
130 : m_rView(r)
132 SetPool(SwAnnotationShell::GetAnnotationPool(m_rView));
133 SfxShell::SetContextName(vcl::EnumContext::GetContextName(vcl::EnumContext::Context::Annotation));
136 SwAnnotationShell::~SwAnnotationShell()
138 if (m_rView.GetWrtShell().CanInsert())
139 m_rView.ShowCursor(true);
142 SfxUndoManager* SwAnnotationShell::GetUndoManager()
144 SwPostItMgr* pPostItMgr = m_rView.GetPostItMgr();
145 if ( !pPostItMgr ||
146 !pPostItMgr->HasActiveSidebarWin() )
148 OSL_ENSURE(pPostItMgr,"PostItMgr::Layout(): We are looping forever");
149 return nullptr;
151 return &pPostItMgr->GetActiveSidebarWin()->GetOutlinerView()->GetOutliner()->GetUndoManager();
154 void SwAnnotationShell::Exec( SfxRequest &rReq )
156 //TODO: clean this up!!!!
157 SwPostItMgr* pPostItMgr = m_rView.GetPostItMgr();
158 if ( !pPostItMgr || !pPostItMgr->HasActiveSidebarWin() )
159 return;
161 OutlinerView* pOLV = pPostItMgr->GetActiveSidebarWin()->GetOutlinerView();
162 SfxItemSet aEditAttr(pOLV->GetAttribs());
163 SfxItemSet aNewAttr(*aEditAttr.GetPool(), aEditAttr.GetRanges());
165 sal_uInt16 nSlot = rReq.GetSlot();
166 sal_uInt16 nWhich = GetPool().GetWhich(nSlot);
167 const SfxItemSet *pNewAttrs = rReq.GetArgs();
168 sal_uInt16 nEEWhich = 0;
169 switch (nSlot)
171 case SID_PARASPACE_INCREASE:
172 case SID_PARASPACE_DECREASE:
174 SvxULSpaceItem aULSpace( aEditAttr.Get( EE_PARA_ULSPACE ) );
175 sal_uInt16 nUpper = aULSpace.GetUpper();
176 sal_uInt16 nLower = aULSpace.GetLower();
178 if ( nSlot == SID_PARASPACE_INCREASE )
180 nUpper = std::min< sal_uInt16 >( nUpper + 57, 5670 );
181 nLower = std::min< sal_uInt16 >( nLower + 57, 5670 );
183 else
185 nUpper = std::max< sal_Int16 >( nUpper - 57, 0 );
186 nLower = std::max< sal_Int16 >( nLower - 57, 0 );
189 aULSpace.SetUpper( nUpper );
190 aULSpace.SetLower( nLower );
191 aNewAttr.Put( aULSpace );
192 rReq.Done();
194 break;
195 case SID_ATTR_PARA_LRSPACE:
197 SvxLRSpaceItem aParaMargin(static_cast<const SvxLRSpaceItem&>(rReq.
198 GetArgs()->Get(nSlot)));
199 aParaMargin.SetWhich( EE_PARA_LRSPACE );
201 aNewAttr.Put(aParaMargin);
202 rReq.Done();
203 break;
205 case SID_ATTR_PARA_LINESPACE:
207 SvxLineSpacingItem aParaMargin = static_cast<const SvxLineSpacingItem&>(pNewAttrs->Get(
208 GetPool().GetWhich(nSlot)));
209 aParaMargin.SetWhich( EE_PARA_SBL );
211 aNewAttr.Put(aParaMargin);
212 rReq.Done();
213 break;
215 case SID_ATTR_PARA_ULSPACE:
217 SvxULSpaceItem aULSpace = static_cast<const SvxULSpaceItem&>(pNewAttrs->Get(
218 GetPool().GetWhich(nSlot)));
219 aULSpace.SetWhich( EE_PARA_ULSPACE );
220 aNewAttr.Put( aULSpace );
221 rReq.Done();
223 break;
224 case FN_GROW_FONT_SIZE:
225 case FN_SHRINK_FONT_SIZE:
227 const SfxObjectShell* pObjSh = SfxObjectShell::Current();
228 const SvxFontListItem* pFontListItem = static_cast<const SvxFontListItem*>
229 (pObjSh ? pObjSh->GetItem(SID_ATTR_CHAR_FONTLIST) : nullptr);
230 const FontList* pFontList = pFontListItem ? pFontListItem->GetFontList() : nullptr;
231 pOLV->GetEditView().ChangeFontSize( nSlot == FN_GROW_FONT_SIZE, pFontList );
233 break;
235 case SID_ATTR_CHAR_FONT:
236 case SID_ATTR_CHAR_FONTHEIGHT:
237 case SID_ATTR_CHAR_WEIGHT:
238 case SID_ATTR_CHAR_POSTURE:
240 SfxItemPool* pSecondPool = aEditAttr.GetPool()->GetSecondaryPool();
241 if( !pSecondPool )
242 pSecondPool = aEditAttr.GetPool();
243 SvxScriptSetItem aSetItem( nSlot, *pSecondPool );
244 aSetItem.PutItemForScriptType( pOLV->GetSelectedScriptType(), pNewAttrs->Get( nWhich ));
245 aNewAttr.Put( aSetItem.GetItemSet() );
246 rReq.Done();
247 break;
249 case SID_ATTR_CHAR_COLOR: nEEWhich = EE_CHAR_COLOR; break;
250 case SID_ATTR_CHAR_BACK_COLOR: nEEWhich = EE_CHAR_BKGCOLOR; break;
251 case SID_ATTR_CHAR_UNDERLINE:
253 if( rReq.GetArgs() )
255 const SvxUnderlineItem* pItem = rReq.GetArg<SvxUnderlineItem>(SID_ATTR_CHAR_UNDERLINE);
256 if (pItem)
258 aNewAttr.Put(*pItem);
260 else
262 FontLineStyle eFU = aEditAttr.Get( EE_CHAR_UNDERLINE ).GetLineStyle();
263 aNewAttr.Put( SvxUnderlineItem( eFU != LINESTYLE_NONE ?LINESTYLE_NONE : LINESTYLE_SINGLE, EE_CHAR_UNDERLINE ) );
266 break;
268 case SID_ATTR_CHAR_OVERLINE:
270 FontLineStyle eFO = aEditAttr.Get(EE_CHAR_OVERLINE).GetLineStyle();
271 aNewAttr.Put(SvxOverlineItem(eFO == LINESTYLE_SINGLE ? LINESTYLE_NONE : LINESTYLE_SINGLE, EE_CHAR_OVERLINE));
272 break;
274 case SID_ATTR_CHAR_CONTOUR: nEEWhich = EE_CHAR_OUTLINE; break;
275 case SID_ATTR_CHAR_SHADOWED: nEEWhich = EE_CHAR_SHADOW; break;
276 case SID_ATTR_CHAR_STRIKEOUT: nEEWhich = EE_CHAR_STRIKEOUT; break;
277 case SID_ATTR_CHAR_WORDLINEMODE: nEEWhich = EE_CHAR_WLM; break;
278 case SID_ATTR_CHAR_RELIEF : nEEWhich = EE_CHAR_RELIEF; break;
279 case SID_ATTR_CHAR_LANGUAGE : nEEWhich = EE_CHAR_LANGUAGE;break;
280 case SID_ATTR_CHAR_KERNING : nEEWhich = EE_CHAR_KERNING; break;
281 case SID_ATTR_CHAR_SCALEWIDTH: nEEWhich = EE_CHAR_FONTWIDTH; break;
282 case SID_ATTR_CHAR_AUTOKERN : nEEWhich = EE_CHAR_PAIRKERNING; break;
283 case SID_ATTR_CHAR_ESCAPEMENT: nEEWhich = EE_CHAR_ESCAPEMENT; break;
284 case SID_ATTR_PARA_ADJUST_LEFT:
285 aNewAttr.Put(SvxAdjustItem(SvxAdjust::Left, EE_PARA_JUST));
286 break;
287 case SID_ATTR_PARA_ADJUST_CENTER:
288 aNewAttr.Put(SvxAdjustItem(SvxAdjust::Center, EE_PARA_JUST));
289 break;
290 case SID_ATTR_PARA_ADJUST_RIGHT:
291 aNewAttr.Put(SvxAdjustItem(SvxAdjust::Right, EE_PARA_JUST));
292 break;
293 case SID_ATTR_PARA_ADJUST_BLOCK:
294 aNewAttr.Put(SvxAdjustItem(SvxAdjust::Block, EE_PARA_JUST));
295 break;
297 case SID_ATTR_PARA_LINESPACE_10:
299 SvxLineSpacingItem aItem(LINE_SPACE_DEFAULT_HEIGHT, EE_PARA_SBL);
300 aItem.SetPropLineSpace(100);
301 aNewAttr.Put(aItem);
303 break;
304 case SID_ATTR_PARA_LINESPACE_115:
306 SvxLineSpacingItem aItem(LINE_SPACE_DEFAULT_HEIGHT, EE_PARA_SBL);
307 aItem.SetPropLineSpace(115);
308 aNewAttr.Put(aItem);
310 break;
311 case SID_ATTR_PARA_LINESPACE_15:
313 SvxLineSpacingItem aItem(LINE_SPACE_DEFAULT_HEIGHT, EE_PARA_SBL);
314 aItem.SetPropLineSpace(150);
315 aNewAttr.Put(aItem);
317 break;
318 case SID_ATTR_PARA_LINESPACE_20:
320 SvxLineSpacingItem aItem(LINE_SPACE_DEFAULT_HEIGHT, EE_PARA_SBL);
321 aItem.SetPropLineSpace(200);
322 aNewAttr.Put(aItem);
324 break;
325 case SID_SELECTALL:
327 Outliner * pOutliner = pOLV->GetOutliner();
328 if(pOutliner)
330 sal_Int32 nParaCount = pOutliner->GetParagraphCount();
331 if (nParaCount > 0)
332 pOLV->SelectRange(0, nParaCount );
334 break;
336 case FN_FORMAT_RESET:
338 pPostItMgr->GetActiveSidebarWin()->ResetAttributes();
339 rReq.Done();
340 break;
342 case FN_SET_SUPER_SCRIPT:
344 SvxEscapementItem aItem(EE_CHAR_ESCAPEMENT);
345 SvxEscapement eEsc = static_cast<SvxEscapement>(aEditAttr.Get( EE_CHAR_ESCAPEMENT ).GetEnumValue());
347 if( eEsc == SvxEscapement::Superscript )
348 aItem.SetEscapement( SvxEscapement::Off );
349 else
350 aItem.SetEscapement( SvxEscapement::Superscript );
351 aNewAttr.Put( aItem );
353 break;
354 case FN_SET_SUB_SCRIPT:
356 SvxEscapementItem aItem(EE_CHAR_ESCAPEMENT);
357 SvxEscapement eEsc = static_cast<SvxEscapement>(aEditAttr.Get( EE_CHAR_ESCAPEMENT ).GetEnumValue());
359 if( eEsc == SvxEscapement::Subscript )
360 aItem.SetEscapement( SvxEscapement::Off );
361 else
362 aItem.SetEscapement( SvxEscapement::Subscript );
363 aNewAttr.Put( aItem );
365 break;
366 case SID_HYPERLINK_SETLINK:
368 const SfxPoolItem* pItem = nullptr;
369 if(pNewAttrs)
370 pNewAttrs->GetItemState(nSlot, false, &pItem);
372 if(pItem)
374 const SvxHyperlinkItem& rHLinkItem = *static_cast<const SvxHyperlinkItem *>(pItem);
375 SvxURLField aField(rHLinkItem.GetURL(), rHLinkItem.GetName(), SvxURLFormat::AppDefault);
376 aField.SetTargetFrame(rHLinkItem.GetTargetFrame());
378 const SvxFieldItem* pFieldItem = pOLV->GetFieldAtSelection();
380 if (pFieldItem && dynamic_cast<const SvxURLField *>(pFieldItem->GetField()) != nullptr)
382 // Select the field so that it will be deleted during insert
383 ESelection aSel = pOLV->GetSelection();
384 aSel.nEndPos++;
385 pOLV->SetSelection(aSel);
387 if (pPostItMgr->GetActiveSidebarWin()->GetLayoutStatus()!=SwPostItHelper::DELETED)
388 pOLV->InsertField(SvxFieldItem(aField, EE_FEATURE_FIELD));
390 break;
392 case FN_INSERT_SOFT_HYPHEN:
393 case FN_INSERT_HARDHYPHEN:
394 case FN_INSERT_HARD_SPACE:
395 case FN_INSERT_NNBSP:
396 case SID_INSERT_RLM :
397 case SID_INSERT_LRM :
398 case SID_INSERT_WJ :
399 case SID_INSERT_ZWSP:
401 sal_Unicode cIns = 0;
402 switch(rReq.GetSlot())
404 case FN_INSERT_SOFT_HYPHEN: cIns = CHAR_SOFTHYPHEN; break;
405 case FN_INSERT_HARDHYPHEN: cIns = CHAR_HARDHYPHEN; break;
406 case FN_INSERT_HARD_SPACE: cIns = CHAR_HARDBLANK; break;
407 case FN_INSERT_NNBSP: cIns = CHAR_NNBSP; break;
408 case SID_INSERT_RLM : cIns = CHAR_RLM ; break;
409 case SID_INSERT_LRM : cIns = CHAR_LRM ; break;
410 case SID_INSERT_ZWSP : cIns = CHAR_ZWSP ; break;
411 case SID_INSERT_WJ: cIns = CHAR_WJ; break;
413 pOLV->InsertText( OUString(cIns));
414 rReq.Done();
415 break;
417 case SID_CHARMAP:
419 if (pPostItMgr->GetActiveSidebarWin()->GetLayoutStatus()!=SwPostItHelper::DELETED)
420 InsertSymbol(rReq);
421 break;
423 case FN_INSERT_STRING:
425 const SfxPoolItem* pItem = nullptr;
426 if (pNewAttrs)
427 pNewAttrs->GetItemState(nSlot, false, &pItem );
428 if (pItem && pPostItMgr->GetActiveSidebarWin()->GetLayoutStatus()!=SwPostItHelper::DELETED)
429 pOLV->InsertText(static_cast<const SfxStringItem *>(pItem)->GetValue());
430 break;
432 case FN_FORMAT_FOOTNOTE_DLG:
434 m_rView.ExecFormatFootnote();
435 break;
437 case FN_NUMBERING_OUTLINE_DLG:
439 m_rView.ExecNumberingOutline(GetPool());
440 rReq.Done();
442 break;
443 case SID_OPEN_XML_FILTERSETTINGS:
445 HandleOpenXmlFilterSettings(rReq);
447 break;
448 case FN_WORDCOUNT_DIALOG:
450 m_rView.UpdateWordCount(this, nSlot);
451 break;
453 case SID_CHAR_DLG_EFFECT:
454 case SID_CHAR_DLG_POSITION:
455 case SID_CHAR_DLG:
457 const SfxItemSet* pArgs = rReq.GetArgs();
458 const SfxStringItem* pItem = rReq.GetArg<SfxStringItem>(FN_PARAM_1);
460 if( !pArgs || pItem )
462 /* mod
463 SwView* pView = &GetView();
464 FieldUnit eMetric = ::GetDfltMetric(dynamic_cast<SwWebView*>( pView) != nullptr );
465 SW_MOD()->PutItem(SfxUInt16Item(SID_ATTR_METRIC, eMetric));
467 SfxItemSetFixed<XATTR_FILLSTYLE, XATTR_FILLCOLOR, EE_ITEMS_START, EE_ITEMS_END> aDlgAttr(GetPool());
469 // util::Language does not exist in the EditEngine! Therefore not included in the set.
471 aDlgAttr.Put( aEditAttr );
472 aDlgAttr.Put( SvxKerningItem(0, RES_CHRATR_KERNING) );
474 SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
475 ScopedVclPtr<SfxAbstractTabDialog> pDlg(pFact->CreateSwCharDlg(m_rView.GetFrameWeld(), m_rView, aDlgAttr, SwCharDlgMode::Ann));
476 if (nSlot == SID_CHAR_DLG_EFFECT)
478 pDlg->SetCurPageId("fonteffects");
480 if (nSlot == SID_CHAR_DLG_POSITION)
482 pDlg->SetCurPageId("position");
484 else if (pItem)
486 pDlg->SetCurPageId(pItem->GetValue());
489 sal_uInt16 nRet = pDlg->Execute();
490 if(RET_OK == nRet )
492 rReq.Done( *( pDlg->GetOutputItemSet() ) );
493 aNewAttr.Put(*pDlg->GetOutputItemSet());
495 if(RET_OK != nRet)
496 return ;
498 else
499 aNewAttr.Put(*pArgs);
500 break;
502 case SID_PARA_DLG:
504 const SfxItemSet* pArgs = rReq.GetArgs();
506 if (!pArgs)
508 /* mod todo ???
509 SwView* pView = &GetView();
510 FieldUnit eMetric = ::GetDfltMetric(dynamic_cast<SwWebView*>( pView) != nullptr );
511 SW_MOD()->PutItem(SfxUInt16Item(SID_ATTR_METRIC, eMetric));
513 SfxItemSetFixed<
514 EE_ITEMS_START, EE_ITEMS_END,
515 SID_ATTR_PARA_HYPHENZONE, SID_ATTR_PARA_WIDOWS>
516 aDlgAttr( GetPool() );
518 aDlgAttr.Put(aEditAttr);
520 aDlgAttr.Put( SvxHyphenZoneItem( false, RES_PARATR_HYPHENZONE) );
521 aDlgAttr.Put( SvxFormatBreakItem( SvxBreak::NONE, RES_BREAK ) );
522 aDlgAttr.Put( SvxFormatSplitItem( true, RES_PARATR_SPLIT ) );
523 aDlgAttr.Put( SvxWidowsItem( 0, RES_PARATR_WIDOWS ) );
524 aDlgAttr.Put( SvxOrphansItem( 0, RES_PARATR_ORPHANS ) );
526 SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
527 ScopedVclPtr<SfxAbstractTabDialog> pDlg(pFact->CreateSwParaDlg(m_rView.GetFrameWeld(), m_rView, aDlgAttr, true));
528 sal_uInt16 nRet = pDlg->Execute();
529 if(RET_OK == nRet)
531 rReq.Done( *( pDlg->GetOutputItemSet() ) );
532 aNewAttr.Put(*pDlg->GetOutputItemSet());
534 if(RET_OK != nRet)
535 return;
537 else
538 aNewAttr.Put(*pArgs);
539 break;
542 case SID_AUTOSPELL_CHECK:
544 m_rView.ExecuteSlot(rReq);
545 break;
547 case SID_ATTR_PARA_LEFT_TO_RIGHT:
548 case SID_ATTR_PARA_RIGHT_TO_LEFT:
550 bool bLeftToRight = nSlot == SID_ATTR_PARA_LEFT_TO_RIGHT;
552 const SfxPoolItem* pPoolItem;
553 if( pNewAttrs && SfxItemState::SET == pNewAttrs->GetItemState( nSlot, true, &pPoolItem ) )
555 if( !static_cast<const SfxBoolItem*>(pPoolItem)->GetValue() )
556 bLeftToRight = !bLeftToRight;
558 SfxItemSetFixed<
559 EE_PARA_WRITINGDIR, EE_PARA_WRITINGDIR,
560 EE_PARA_JUST, EE_PARA_JUST>
561 aAttr( *aNewAttr.GetPool() );
563 SvxAdjust nAdjust = SvxAdjust::Left;
564 if( const SvxAdjustItem* pAdjustItem = aEditAttr.GetItemIfSet(EE_PARA_JUST ) )
565 nAdjust = pAdjustItem->GetAdjust();
567 if( bLeftToRight )
569 aAttr.Put( SvxFrameDirectionItem( SvxFrameDirection::Horizontal_LR_TB, EE_PARA_WRITINGDIR ) );
570 if( nAdjust == SvxAdjust::Right )
571 aAttr.Put( SvxAdjustItem( SvxAdjust::Left, EE_PARA_JUST ) );
573 else
575 aAttr.Put( SvxFrameDirectionItem( SvxFrameDirection::Horizontal_RL_TB, EE_PARA_WRITINGDIR ) );
576 if( nAdjust == SvxAdjust::Left )
577 aAttr.Put( SvxAdjustItem( SvxAdjust::Right, EE_PARA_JUST ) );
579 pOLV->SetAttribs(aAttr);
580 break;
584 if(nEEWhich && pNewAttrs)
586 aNewAttr.Put(pNewAttrs->Get(nWhich).CloneSetWhich(nEEWhich));
588 else if (nEEWhich == EE_CHAR_COLOR)
590 m_rView.GetViewFrame().GetDispatcher()->Execute(SID_CHAR_DLG_EFFECT);
592 else if (nEEWhich == EE_CHAR_KERNING)
594 m_rView.GetViewFrame().GetDispatcher()->Execute(SID_CHAR_DLG_POSITION);
598 tools::Rectangle aOutRect = pOLV->GetOutputArea();
599 if (tools::Rectangle() != aOutRect && aNewAttr.Count())
600 pOLV->SetAttribs(aNewAttr);
602 m_rView.GetViewFrame().GetBindings().InvalidateAll(false);
603 if ( pOLV->GetOutliner()->IsModified() )
604 m_rView.GetWrtShell().SetModified();
608 void SwAnnotationShell::GetState(SfxItemSet& rSet)
610 //TODO: clean this up!!!
611 // FN_SET_SUPER_SCRIPT
612 //SID_ATTR_PARA_ADJUST
613 //SID_ATTR_PARA_ADJUST_BLOCK
615 SwPostItMgr* pPostItMgr = m_rView.GetPostItMgr();
616 if ( !pPostItMgr || !pPostItMgr->HasActiveSidebarWin() )
617 return;
619 OutlinerView* pOLV = pPostItMgr->GetActiveSidebarWin()->GetOutlinerView();
620 SfxItemSet aEditAttr(pOLV->GetAttribs());
622 SfxWhichIter aIter(rSet);
623 sal_uInt16 nWhich = aIter.FirstWhich();
624 while(nWhich)
626 sal_uInt16 nEEWhich = 0;
627 sal_uInt16 nSlotId = GetPool().GetSlotId( nWhich );
628 switch( nSlotId )
630 case SID_ATTR_PARA_LRSPACE:
631 case SID_ATTR_PARA_LEFTSPACE:
632 case SID_ATTR_PARA_RIGHTSPACE:
633 case SID_ATTR_PARA_FIRSTLINESPACE:
635 SfxItemState eState = aEditAttr.GetItemState( EE_PARA_LRSPACE );
636 if( eState >= SfxItemState::DEFAULT )
638 SvxLRSpaceItem aLR = aEditAttr.Get( EE_PARA_LRSPACE );
639 aLR.SetWhich(nSlotId);
640 rSet.Put(aLR);
642 else
643 rSet.InvalidateItem(nSlotId);
645 break;
646 case SID_ATTR_PARA_LINESPACE:
648 SfxItemState eState = aEditAttr.GetItemState( EE_PARA_SBL );
649 if( eState >= SfxItemState::DEFAULT )
651 const SvxLineSpacingItem& aLR = aEditAttr.Get( EE_PARA_SBL );
652 rSet.Put(aLR);
654 else
655 rSet.InvalidateItem(nSlotId);
657 break;
658 case SID_ATTR_PARA_ULSPACE:
659 case SID_ATTR_PARA_ABOVESPACE:
660 case SID_ATTR_PARA_BELOWSPACE:
661 case SID_PARASPACE_INCREASE:
662 case SID_PARASPACE_DECREASE:
664 SfxItemState eState = aEditAttr.GetItemState( EE_PARA_ULSPACE );
665 if( eState >= SfxItemState::DEFAULT )
667 SvxULSpaceItem aULSpace = aEditAttr.Get( EE_PARA_ULSPACE );
668 if ( !aULSpace.GetUpper() && !aULSpace.GetLower() )
669 rSet.DisableItem( SID_PARASPACE_DECREASE );
670 else if ( aULSpace.GetUpper() >= 5670 && aULSpace.GetLower() >= 5670 )
671 rSet.DisableItem( SID_PARASPACE_INCREASE );
672 if ( nSlotId == SID_ATTR_PARA_ULSPACE
673 || nSlotId == SID_ATTR_PARA_BELOWSPACE
674 || nSlotId == SID_ATTR_PARA_ABOVESPACE
677 aULSpace.SetWhich(nSlotId);
678 rSet.Put(aULSpace);
681 else
683 rSet.DisableItem( SID_PARASPACE_INCREASE );
684 rSet.DisableItem( SID_PARASPACE_DECREASE );
685 rSet.InvalidateItem( SID_ATTR_PARA_ULSPACE );
686 rSet.InvalidateItem( SID_ATTR_PARA_ABOVESPACE );
687 rSet.InvalidateItem( SID_ATTR_PARA_BELOWSPACE );
690 break;
691 case SID_ATTR_CHAR_FONT:
692 case SID_ATTR_CHAR_FONTHEIGHT:
693 case SID_ATTR_CHAR_WEIGHT:
694 case SID_ATTR_CHAR_POSTURE:
696 SvtScriptType nScriptType = pOLV->GetSelectedScriptType();
697 SfxItemPool* pSecondPool = aEditAttr.GetPool()->GetSecondaryPool();
698 if( !pSecondPool )
699 pSecondPool = aEditAttr.GetPool();
700 SvxScriptSetItem aSetItem( nSlotId, *pSecondPool );
701 aSetItem.GetItemSet().Put( aEditAttr, false );
702 const SfxPoolItem* pI = aSetItem.GetItemOfScript( nScriptType );
703 if( pI )
705 rSet.Put(pI->CloneSetWhich(nWhich));
707 else
708 rSet.InvalidateItem( nWhich );
710 break;
711 case SID_ATTR_CHAR_COLOR: nEEWhich = EE_CHAR_COLOR; break;
712 case SID_ATTR_CHAR_BACK_COLOR: nEEWhich = EE_CHAR_BKGCOLOR; break;
713 case SID_ATTR_CHAR_UNDERLINE: nEEWhich = EE_CHAR_UNDERLINE;break;
714 case SID_ATTR_CHAR_OVERLINE: nEEWhich = EE_CHAR_OVERLINE;break;
715 case SID_ATTR_CHAR_CONTOUR: nEEWhich = EE_CHAR_OUTLINE; break;
716 case SID_ATTR_CHAR_SHADOWED: nEEWhich = EE_CHAR_SHADOW;break;
717 case SID_ATTR_CHAR_STRIKEOUT: nEEWhich = EE_CHAR_STRIKEOUT;break;
718 case SID_ATTR_CHAR_LANGUAGE : nEEWhich = EE_CHAR_LANGUAGE;break;
719 case SID_ATTR_CHAR_ESCAPEMENT: nEEWhich = EE_CHAR_ESCAPEMENT;break;
720 case SID_ATTR_CHAR_KERNING: nEEWhich = EE_CHAR_KERNING;break;
721 case FN_SET_SUPER_SCRIPT:
722 case FN_SET_SUB_SCRIPT:
724 SvxEscapement nEsc;
725 if (nWhich==FN_SET_SUPER_SCRIPT)
726 nEsc = SvxEscapement::Superscript;
727 else
728 nEsc = SvxEscapement::Subscript;
730 const SfxPoolItem *pEscItem = &aEditAttr.Get( EE_CHAR_ESCAPEMENT );
731 if( nEsc == static_cast<const SvxEscapementItem*>(pEscItem)->GetEscapement() )
732 rSet.Put( SfxBoolItem( nWhich, true ));
733 else
734 rSet.InvalidateItem( nWhich );
735 break;
737 case SID_ATTR_PARA_ADJUST_LEFT:
738 case SID_ATTR_PARA_ADJUST_RIGHT:
739 case SID_ATTR_PARA_ADJUST_CENTER:
740 case SID_ATTR_PARA_ADJUST_BLOCK:
742 SvxAdjust eAdjust = SvxAdjust::Left;
743 if (nWhich==SID_ATTR_PARA_ADJUST_LEFT)
744 eAdjust = SvxAdjust::Left;
745 else if (nWhich==SID_ATTR_PARA_ADJUST_RIGHT)
746 eAdjust = SvxAdjust::Right;
747 else if (nWhich==SID_ATTR_PARA_ADJUST_CENTER)
748 eAdjust = SvxAdjust::Center;
749 else if (nWhich==SID_ATTR_PARA_ADJUST_BLOCK)
750 eAdjust = SvxAdjust::Block;
752 const SvxAdjustItem *pAdjust = aEditAttr.GetItemIfSet( EE_PARA_JUST, false );
754 if( !pAdjust || IsInvalidItem( pAdjust ))
756 rSet.InvalidateItem( nSlotId );
758 else
760 if ( eAdjust == pAdjust->GetAdjust())
761 rSet.Put( SfxBoolItem( nWhich, true ));
762 else
763 rSet.InvalidateItem( nWhich );
765 break;
767 case SID_ATTR_PARA_LINESPACE_10:
768 case SID_ATTR_PARA_LINESPACE_115:
769 case SID_ATTR_PARA_LINESPACE_15:
770 case SID_ATTR_PARA_LINESPACE_20:
772 int nLSpace = 0;
773 if (nWhich==SID_ATTR_PARA_LINESPACE_10)
774 nLSpace = 100;
775 else if (nWhich==SID_ATTR_PARA_LINESPACE_115)
776 nLSpace = 115;
777 else if (nWhich==SID_ATTR_PARA_LINESPACE_15)
778 nLSpace = 150;
779 else if (nWhich==SID_ATTR_PARA_LINESPACE_20)
780 nLSpace = 200;
782 const SvxLineSpacingItem *pLSpace = aEditAttr.GetItemIfSet( EE_PARA_SBL, false );
784 if( !pLSpace || IsInvalidItem( pLSpace ))
786 rSet.InvalidateItem( nSlotId );
788 else
790 if( nLSpace == pLSpace->GetPropLineSpace() )
791 rSet.Put( SfxBoolItem( nWhich, true ));
792 else
794 // tdf#114631 - disable non selected line spacing
795 rSet.Put(SfxBoolItem(nWhich, false));
798 break;
800 case SID_AUTOSPELL_CHECK:
802 const SfxPoolItem* pState = m_rView.GetSlotState(nWhich);
803 if (pState)
804 rSet.Put(SfxBoolItem(nWhich, static_cast<const SfxBoolItem*>(pState)->GetValue()));
805 else
806 rSet.DisableItem( nWhich );
807 break;
809 case SID_ATTR_PARA_LEFT_TO_RIGHT:
810 case SID_ATTR_PARA_RIGHT_TO_LEFT:
812 if ( !SvtCTLOptions::IsCTLFontEnabled() )
813 rSet.DisableItem( nWhich );
814 else
816 if(pOLV->GetOutliner() && pOLV->GetOutliner()->IsVertical())
817 rSet.DisableItem( nWhich );
818 else
820 bool bFlag = false;
821 switch( aEditAttr.Get( EE_PARA_WRITINGDIR ).GetValue() )
823 case SvxFrameDirection::Horizontal_LR_TB:
825 bFlag = nWhich == SID_ATTR_PARA_LEFT_TO_RIGHT;
826 rSet.Put( SfxBoolItem( nWhich, bFlag ));
827 break;
829 case SvxFrameDirection::Horizontal_RL_TB:
831 bFlag = nWhich != SID_ATTR_PARA_LEFT_TO_RIGHT;
832 rSet.Put( SfxBoolItem( nWhich, bFlag ));
833 break;
835 default:
836 break;
841 break;
842 case SID_INSERT_RLM :
843 case SID_INSERT_LRM :
845 bool bEnabled = SvtCTLOptions::IsCTLFontEnabled();
846 m_rView.GetViewFrame().GetBindings().SetVisibleState( nWhich, bEnabled );
847 if(!bEnabled)
848 rSet.DisableItem(nWhich);
850 break;
851 default:
852 rSet.InvalidateItem( nWhich );
853 break;
856 if(nEEWhich)
858 rSet.Put(aEditAttr.Get(nEEWhich).CloneSetWhich(nWhich));
859 if(nEEWhich == EE_CHAR_KERNING)
861 SfxItemState eState = aEditAttr.GetItemState( EE_CHAR_KERNING );
862 if ( eState == SfxItemState::DONTCARE )
864 rSet.InvalidateItem(EE_CHAR_KERNING);
869 if (pPostItMgr->GetActiveSidebarWin()->GetLayoutStatus()==SwPostItHelper::DELETED)
870 rSet.DisableItem( nWhich );
872 nWhich = aIter.NextWhich();
876 void SwAnnotationShell::ExecSearch(SfxRequest& rReq)
878 m_rView.ExecSearch(rReq);
881 void SwAnnotationShell::StateSearch(SfxItemSet &rSet)
883 m_rView.StateSearch(rSet);
886 void SwAnnotationShell::ExecClpbrd(SfxRequest const &rReq)
888 SwPostItMgr* pPostItMgr = m_rView.GetPostItMgr();
889 if ( !pPostItMgr || !pPostItMgr->HasActiveSidebarWin() )
890 return;
892 OutlinerView* pOLV = pPostItMgr->GetActiveSidebarWin()->GetOutlinerView();
894 tools::Long aOldHeight = pPostItMgr->GetActiveSidebarWin()->GetPostItTextHeight();
895 sal_uInt16 nSlot = rReq.GetSlot();
896 switch (nSlot)
898 case SID_CUT:
899 if ( (pPostItMgr->GetActiveSidebarWin()->GetLayoutStatus()!=SwPostItHelper::DELETED) && pOLV->HasSelection() )
900 pOLV->Cut();
901 break;
902 case SID_COPY:
903 if( pOLV->HasSelection() )
904 pOLV->Copy();
905 break;
906 case SID_PASTE:
907 if (pPostItMgr->GetActiveSidebarWin()->GetLayoutStatus()!=SwPostItHelper::DELETED)
908 pOLV->PasteSpecial();
909 break;
910 case SID_PASTE_UNFORMATTED:
911 if (pPostItMgr->GetActiveSidebarWin()->GetLayoutStatus()!=SwPostItHelper::DELETED)
912 pOLV->Paste();
913 break;
914 case SID_PASTE_SPECIAL:
916 if (pPostItMgr->GetActiveSidebarWin()->GetLayoutStatus()!=SwPostItHelper::DELETED)
918 SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
919 ScopedVclPtr<SfxAbstractPasteDialog> pDlg(pFact->CreatePasteDialog(m_rView.GetEditWin().GetFrameWeld()));
921 pDlg->Insert( SotClipboardFormatId::STRING, OUString() );
922 pDlg->Insert( SotClipboardFormatId::RTF, OUString() );
923 pDlg->Insert( SotClipboardFormatId::RICHTEXT, OUString() );
925 TransferableDataHelper aDataHelper( TransferableDataHelper::CreateFromSystemClipboard( &m_rView.GetEditWin() ) );
927 SotClipboardFormatId nFormat = pDlg->GetFormat( aDataHelper.GetTransferable() );
929 if (nFormat != SotClipboardFormatId::NONE)
931 if (nFormat == SotClipboardFormatId::STRING)
932 pOLV->Paste();
933 else
934 pOLV->PasteSpecial();
937 break;
939 case SID_CLIPBOARD_FORMAT_ITEMS:
941 SotClipboardFormatId nFormat = SotClipboardFormatId::NONE;
942 const SfxPoolItem* pItem;
943 if (rReq.GetArgs() && rReq.GetArgs()->GetItemState(nSlot, true, &pItem) == SfxItemState::SET)
945 if (const SfxUInt32Item* pUInt32Item = dynamic_cast<const SfxUInt32Item *>(pItem))
946 nFormat = static_cast<SotClipboardFormatId>(pUInt32Item->GetValue());
949 if ( nFormat != SotClipboardFormatId::NONE )
951 if (SotClipboardFormatId::STRING == nFormat)
952 pOLV->Paste();
953 else
954 pOLV->PasteSpecial();
956 break;
959 pPostItMgr->GetActiveSidebarWin()->ResizeIfNecessary(aOldHeight,pPostItMgr->GetActiveSidebarWin()->GetPostItTextHeight());
962 void SwAnnotationShell::StateClpbrd(SfxItemSet &rSet)
964 SwPostItMgr* pPostItMgr = m_rView.GetPostItMgr();
965 if ( !pPostItMgr || !pPostItMgr->HasActiveSidebarWin() )
966 return;
967 OutlinerView* pOLV = pPostItMgr->GetActiveSidebarWin()->GetOutlinerView();
969 TransferableDataHelper aDataHelper( TransferableDataHelper::CreateFromSystemClipboard( &m_rView.GetEditWin() ) );
970 bool bPastePossible = ( aDataHelper.HasFormat( SotClipboardFormatId::STRING ) || aDataHelper.HasFormat( SotClipboardFormatId::RTF )
971 || aDataHelper.HasFormat( SotClipboardFormatId::RICHTEXT ));
972 bPastePossible = bPastePossible && (pPostItMgr->GetActiveSidebarWin()->GetLayoutStatus()!=SwPostItHelper::DELETED);
974 SfxWhichIter aIter(rSet);
975 sal_uInt16 nWhich = aIter.FirstWhich();
977 while(nWhich)
979 switch(nWhich)
981 case SID_CUT:
983 if (pPostItMgr->GetActiveSidebarWin()->GetLayoutStatus() == SwPostItHelper::DELETED)
984 rSet.DisableItem( nWhich );
985 [[fallthrough]];
987 case SID_COPY:
989 SfxObjectShell* pObjectShell = GetObjectShell();
990 if (!pOLV->HasSelection() || (pObjectShell && pObjectShell->isContentExtractionLocked()) )
991 rSet.DisableItem( nWhich );
992 break;
994 case SID_PASTE:
995 case SID_PASTE_UNFORMATTED:
996 case SID_PASTE_SPECIAL:
998 if( !bPastePossible )
999 rSet.DisableItem( nWhich );
1000 break;
1002 case SID_CLIPBOARD_FORMAT_ITEMS:
1004 if ( bPastePossible )
1006 SvxClipboardFormatItem aFormats( SID_CLIPBOARD_FORMAT_ITEMS );
1007 if ( aDataHelper.HasFormat( SotClipboardFormatId::RTF ) )
1008 aFormats.AddClipbrdFormat( SotClipboardFormatId::RTF );
1009 if ( aDataHelper.HasFormat( SotClipboardFormatId::RICHTEXT ) )
1010 aFormats.AddClipbrdFormat( SotClipboardFormatId::RICHTEXT );
1011 aFormats.AddClipbrdFormat( SotClipboardFormatId::STRING );
1012 rSet.Put( aFormats );
1014 else
1015 rSet.DisableItem( nWhich );
1016 break;
1019 nWhich = aIter.NextWhich();
1023 void SwAnnotationShell::StateStatusLine(SfxItemSet &rSet)
1025 SfxWhichIter aIter( rSet );
1026 sal_uInt16 nWhich = aIter.FirstWhich();
1028 while( nWhich )
1030 switch( nWhich )
1032 case FN_STAT_SELMODE:
1034 rSet.Put(SfxUInt16Item(FN_STAT_SELMODE, 0));
1035 rSet.DisableItem( nWhich );
1036 break;
1038 case FN_STAT_TEMPLATE:
1040 rSet.DisableItem( nWhich );
1041 break;
1044 nWhich = aIter.NextWhich();
1048 void SwAnnotationShell::StateInsert(SfxItemSet &rSet)
1050 SwPostItMgr* pPostItMgr = m_rView.GetPostItMgr();
1051 if ( !pPostItMgr || !pPostItMgr->HasActiveSidebarWin() )
1052 return;
1054 OutlinerView* pOLV = pPostItMgr->GetActiveSidebarWin()->GetOutlinerView();
1055 SfxWhichIter aIter(rSet);
1056 sal_uInt16 nWhich = aIter.FirstWhich();
1058 while(nWhich)
1060 switch(nWhich)
1062 case SID_HYPERLINK_GETLINK:
1064 SvxHyperlinkItem aHLinkItem;
1065 aHLinkItem.SetInsertMode(HLINK_FIELD);
1067 const SvxFieldItem* pFieldItem = pOLV->GetFieldAtSelection();
1069 if (pFieldItem)
1071 if (const SvxURLField* pURLField = dynamic_cast<const SvxURLField *>(pFieldItem->GetField()))
1073 aHLinkItem.SetName(pURLField->GetRepresentation());
1074 aHLinkItem.SetURL(pURLField->GetURL());
1075 aHLinkItem.SetTargetFrame(pURLField->GetTargetFrame());
1078 else
1080 OUString sSel(pOLV->GetSelected());
1081 sSel = sSel.copy(0, std::min<sal_Int32>(255, sSel.getLength()));
1082 aHLinkItem.SetName(comphelper::string::stripEnd(sSel, ' '));
1085 sal_uInt16 nHtmlMode = ::GetHtmlMode(m_rView.GetDocShell());
1086 aHLinkItem.SetInsertMode(static_cast<SvxLinkInsertMode>(aHLinkItem.GetInsertMode() |
1087 ((nHtmlMode & HTMLMODE_ON) != 0 ? HLINK_HTMLMODE : 0)));
1089 rSet.Put(aHLinkItem);
1091 break;
1094 if (pPostItMgr->GetActiveSidebarWin()->GetLayoutStatus()==SwPostItHelper::DELETED)
1095 rSet.DisableItem( nWhich );
1097 nWhich = aIter.NextWhich();
1101 void SwAnnotationShell::NoteExec(SfxRequest const &rReq)
1103 SwPostItMgr* pPostItMgr = m_rView.GetPostItMgr();
1104 if ( !pPostItMgr )
1105 return;
1107 sal_uInt16 nSlot = rReq.GetSlot();
1108 switch (nSlot)
1110 case FN_REPLY:
1111 case FN_POSTIT:
1112 case FN_DELETE_COMMENT:
1113 case FN_DELETE_COMMENT_THREAD:
1114 case FN_RESOLVE_NOTE:
1115 case FN_RESOLVE_NOTE_THREAD:
1116 if ( pPostItMgr->HasActiveSidebarWin() )
1117 pPostItMgr->GetActiveSidebarWin()->ExecuteCommand(nSlot);
1118 break;
1119 case FN_DELETE_ALL_NOTES:
1120 pPostItMgr->Delete();
1121 break;
1122 case FN_FORMAT_ALL_NOTES:
1123 pPostItMgr->ExecuteFormatAllDialog(m_rView);
1124 break;
1125 case FN_DELETE_NOTE_AUTHOR:
1127 const SfxStringItem* pItem = rReq.GetArg<SfxStringItem>(nSlot);
1128 if ( pItem )
1129 pPostItMgr->Delete( pItem->GetValue() );
1130 else if ( pPostItMgr->HasActiveSidebarWin() )
1131 pPostItMgr->Delete( pPostItMgr->GetActiveSidebarWin()->GetAuthor() );
1132 break;
1134 case FN_HIDE_NOTE:
1135 break;
1136 case FN_HIDE_ALL_NOTES:
1137 pPostItMgr->Hide();
1138 break;
1139 case FN_HIDE_NOTE_AUTHOR:
1141 const SfxStringItem* pItem = rReq.GetArg<SfxStringItem>(nSlot);
1142 if ( pItem )
1143 pPostItMgr->Hide( pItem->GetValue() );
1144 else if ( pPostItMgr->HasActiveSidebarWin() )
1145 pPostItMgr->Hide( pPostItMgr->GetActiveSidebarWin()->GetAuthor() );
1150 void SwAnnotationShell::GetNoteState(SfxItemSet &rSet)
1152 SwPostItMgr* pPostItMgr = m_rView.GetPostItMgr();
1153 SfxWhichIter aIter(rSet);
1154 sal_uInt16 nWhich = aIter.FirstWhich();
1155 while(nWhich)
1157 sal_uInt16 nSlotId = GetPool().GetSlotId( nWhich );
1158 switch( nSlotId )
1160 case FN_POSTIT:
1161 case FN_DELETE_ALL_NOTES:
1162 case FN_FORMAT_ALL_NOTES:
1163 case FN_HIDE_NOTE:
1164 case FN_HIDE_ALL_NOTES:
1165 case FN_DELETE_COMMENT:
1166 case FN_DELETE_COMMENT_THREAD:
1168 if( !pPostItMgr
1169 || !pPostItMgr->HasActiveAnnotationWin() )
1171 rSet.DisableItem(nWhich);
1173 break;
1175 case FN_RESOLVE_NOTE:
1177 if( !pPostItMgr
1178 || !pPostItMgr->HasActiveAnnotationWin() )
1180 rSet.DisableItem(nWhich);
1182 else
1184 SfxBoolItem aBool(nWhich, pPostItMgr->GetActiveSidebarWin()->IsResolved());
1185 rSet.Put( aBool );
1187 break;
1189 case FN_RESOLVE_NOTE_THREAD:
1191 if( !pPostItMgr
1192 || !pPostItMgr->HasActiveAnnotationWin() )
1194 rSet.DisableItem(nWhich);
1196 else
1198 SfxBoolItem aBool(nWhich, pPostItMgr->GetActiveSidebarWin()->IsThreadResolved());
1199 rSet.Put( aBool );
1201 break;
1203 case FN_DELETE_NOTE_AUTHOR:
1204 case FN_HIDE_NOTE_AUTHOR:
1206 if( !pPostItMgr
1207 || !pPostItMgr->HasActiveAnnotationWin() )
1209 rSet.DisableItem(nWhich);
1211 else
1213 OUString aText( nSlotId == FN_DELETE_NOTE_AUTHOR ?
1214 SwResId( STR_DELETE_NOTE_AUTHOR ) : SwResId( STR_HIDE_NOTE_AUTHOR ) );
1215 SwRewriter aRewriter;
1216 aRewriter.AddRule( UndoArg1, pPostItMgr->GetActiveSidebarWin()->GetAuthor() );
1217 aText = aRewriter.Apply( aText );
1218 SfxStringItem aItem( nSlotId, aText );
1219 rSet.Put( aItem );
1221 break;
1223 case FN_REPLY:
1225 if ( !pPostItMgr ||
1226 !pPostItMgr->HasActiveAnnotationWin() )
1228 rSet.DisableItem(nWhich);
1230 else
1232 SvtUserOptions aUserOpt;
1233 OUString sAuthor;
1234 if( (sAuthor = aUserOpt.GetFullName()).isEmpty() &&
1235 (sAuthor = aUserOpt.GetID()).isEmpty() )
1236 sAuthor = SwResId( STR_REDLINE_UNKNOWN_AUTHOR );
1237 if (sAuthor == pPostItMgr->GetActiveSidebarWin()->GetAuthor())
1238 rSet.DisableItem(nWhich);
1240 break;
1242 default:
1243 rSet.InvalidateItem( nWhich );
1244 break;
1247 if (pPostItMgr && pPostItMgr->HasActiveSidebarWin())
1249 if ( (pPostItMgr->GetActiveSidebarWin()->IsReadOnlyOrProtected()) &&
1250 ( (nSlotId==FN_DELETE_COMMENT) || (nSlotId==FN_REPLY) ) )
1251 rSet.DisableItem( nWhich );
1253 nWhich = aIter.NextWhich();
1257 void SwAnnotationShell::ExecLingu(SfxRequest &rReq)
1259 SwPostItMgr* pPostItMgr = m_rView.GetPostItMgr();
1260 if ( !pPostItMgr || !pPostItMgr->HasActiveSidebarWin() )
1261 return;
1263 OutlinerView* pOLV = pPostItMgr->GetActiveSidebarWin()->GetOutlinerView();
1264 sal_uInt16 nSlot = rReq.GetSlot();
1265 SwWrtShell &rSh = m_rView.GetWrtShell();
1266 bool bRestoreSelection = false;
1267 ESelection aOldSelection;
1269 switch (nSlot)
1271 case SID_LANGUAGE_STATUS:
1273 aOldSelection = pOLV->GetSelection();
1274 if (!pOLV->GetEditView().HasSelection())
1276 pOLV->GetEditView().SelectCurrentWord();
1279 bRestoreSelection = SwLangHelper::SetLanguageStatus(pOLV,rReq,m_rView,rSh);
1280 break;
1282 case SID_THES:
1284 OUString aReplaceText;
1285 const SfxStringItem* pItem2 = rReq.GetArg(FN_PARAM_THES_WORD_REPLACE);
1286 if (pItem2)
1287 aReplaceText = pItem2->GetValue();
1288 if (!aReplaceText.isEmpty())
1289 ReplaceTextWithSynonym( pOLV->GetEditView(), aReplaceText );
1290 break;
1292 case SID_THESAURUS:
1294 pOLV->StartThesaurus(rReq.GetFrameWeld());
1295 break;
1297 case SID_HANGUL_HANJA_CONVERSION:
1298 pOLV->StartTextConversion(rReq.GetFrameWeld(), LANGUAGE_KOREAN, LANGUAGE_KOREAN, nullptr,
1299 i18n::TextConversionOption::CHARACTER_BY_CHARACTER, true, false);
1300 break;
1302 case SID_CHINESE_CONVERSION:
1304 //open ChineseTranslationDialog
1305 Reference< XComponentContext > xContext(
1306 ::cppu::defaultBootstrap_InitialComponentContext() ); //@todo get context from calc if that has one
1307 if(xContext.is())
1309 Reference< lang::XMultiComponentFactory > xMCF( xContext->getServiceManager() );
1310 if(xMCF.is())
1312 Reference< ui::dialogs::XExecutableDialog > xDialog(
1313 xMCF->createInstanceWithContext(
1314 "com.sun.star.linguistic2.ChineseTranslationDialog", xContext),
1315 UNO_QUERY);
1316 Reference< lang::XInitialization > xInit( xDialog, UNO_QUERY );
1317 if( xInit.is() )
1319 // initialize dialog
1320 uno::Sequence<uno::Any> aSeq(comphelper::InitAnyPropertySequence(
1322 {"ParentWindow", uno::Any(Reference<awt::XWindow>())}
1323 }));
1324 xInit->initialize( aSeq );
1326 //execute dialog
1327 sal_Int16 nDialogRet = xDialog->execute();
1328 if( RET_OK == nDialogRet )
1330 //get some parameters from the dialog
1331 bool bToSimplified = true;
1332 bool bUseVariants = true;
1333 bool bCommonTerms = true;
1334 Reference< beans::XPropertySet > xProp( xDialog, UNO_QUERY );
1335 if( xProp.is() )
1339 xProp->getPropertyValue( "IsDirectionToSimplified" ) >>= bToSimplified;
1340 xProp->getPropertyValue( "IsUseCharacterVariants" ) >>= bUseVariants;
1341 xProp->getPropertyValue( "IsTranslateCommonTerms" ) >>= bCommonTerms;
1343 catch (const Exception&)
1348 //execute translation
1349 LanguageType nSourceLang = bToSimplified ? LANGUAGE_CHINESE_TRADITIONAL : LANGUAGE_CHINESE_SIMPLIFIED;
1350 LanguageType nTargetLang = bToSimplified ? LANGUAGE_CHINESE_SIMPLIFIED : LANGUAGE_CHINESE_TRADITIONAL;
1351 sal_Int32 nOptions = bUseVariants ? i18n::TextConversionOption::USE_CHARACTER_VARIANTS : 0;
1352 if( !bCommonTerms )
1353 nOptions = nOptions | i18n::TextConversionOption::CHARACTER_BY_CHARACTER;
1355 vcl::Font aTargetFont = OutputDevice::GetDefaultFont( DefaultFontType::CJK_TEXT,
1356 nTargetLang, GetDefaultFontFlags::OnlyOne );
1358 pOLV->StartTextConversion(rReq.GetFrameWeld(), nSourceLang, nTargetLang, &aTargetFont, nOptions, false, false);
1361 Reference< lang::XComponent > xComponent( xDialog, UNO_QUERY );
1362 if( xComponent.is() )
1363 xComponent->dispose();
1367 break;
1370 if (bRestoreSelection)
1372 // restore selection
1373 pOLV->GetEditView().SetSelection( aOldSelection );
1377 void SwAnnotationShell::GetLinguState(SfxItemSet &rSet)
1379 SwPostItMgr* pPostItMgr = m_rView.GetPostItMgr();
1380 if ( !pPostItMgr || !pPostItMgr->HasActiveSidebarWin() )
1381 return;
1383 OutlinerView* pOLV = pPostItMgr->GetActiveSidebarWin()->GetOutlinerView();
1385 SfxWhichIter aIter(rSet);
1386 sal_uInt16 nWhich = aIter.FirstWhich();
1387 while(nWhich)
1389 switch (nWhich)
1391 case SID_LANGUAGE_STATUS:
1393 SwLangHelper::GetLanguageStatus(pOLV,rSet);
1394 break;
1397 case SID_THES:
1399 OUString aStatusVal;
1400 LanguageType nLang = LANGUAGE_NONE;
1401 bool bIsLookUpWord = GetStatusValueForThesaurusFromContext( aStatusVal, nLang, pOLV->GetEditView() );
1402 rSet.Put( SfxStringItem( SID_THES, aStatusVal ) );
1404 // disable "Thesaurus" context menu entry if there is nothing to look up
1405 uno::Reference< linguistic2::XThesaurus > xThes( ::GetThesaurus() );
1406 if (!bIsLookUpWord ||
1407 !xThes.is() || nLang == LANGUAGE_NONE || !xThes->hasLocale( LanguageTag::convertToLocale( nLang ) ))
1408 rSet.DisableItem( SID_THES );
1409 break;
1412 // disable "Thesaurus" if the language is not supported
1413 case SID_THESAURUS:
1415 const SfxPoolItem &rItem = m_rView.GetWrtShell().GetDoc()->GetDefault(
1416 GetWhichOfScript( RES_CHRATR_LANGUAGE,
1417 SvtLanguageOptions::GetI18NScriptTypeOfLanguage( GetAppLanguage())) );
1418 LanguageType nLang = static_cast<const SvxLanguageItem &>(
1419 rItem).GetLanguage();
1420 uno::Reference< linguistic2::XThesaurus > xThes( ::GetThesaurus() );
1421 if (!xThes.is() || nLang == LANGUAGE_NONE ||
1422 !xThes->hasLocale( LanguageTag::convertToLocale( nLang ) ))
1423 rSet.DisableItem( SID_THESAURUS );
1425 break;
1426 case SID_HANGUL_HANJA_CONVERSION:
1427 case SID_CHINESE_CONVERSION:
1429 if (!SvtCJKOptions::IsAnyEnabled())
1431 m_rView.GetViewFrame().GetBindings().SetVisibleState( nWhich, false );
1432 rSet.DisableItem(nWhich);
1434 else
1435 m_rView.GetViewFrame().GetBindings().SetVisibleState( nWhich, true );
1437 break;
1440 if (pPostItMgr->GetActiveSidebarWin()->GetLayoutStatus()==SwPostItHelper::DELETED)
1441 rSet.DisableItem( nWhich );
1443 nWhich = aIter.NextWhich();
1447 void SwAnnotationShell::ExecTransliteration(SfxRequest const &rReq)
1449 SwPostItMgr* pPostItMgr = m_rView.GetPostItMgr();
1450 if (!pPostItMgr || !pPostItMgr->HasActiveSidebarWin())
1451 return;
1453 OutlinerView* pOLV = pPostItMgr->GetActiveSidebarWin()->GetOutlinerView();
1455 if (!pOLV)
1456 return;
1458 TransliterationFlags nMode = TransliterationFlags::NONE;
1460 switch( rReq.GetSlot() )
1462 case SID_TRANSLITERATE_SENTENCE_CASE:
1463 nMode = TransliterationFlags::SENTENCE_CASE;
1464 break;
1465 case SID_TRANSLITERATE_TITLE_CASE:
1466 nMode = TransliterationFlags::TITLE_CASE;
1467 break;
1468 case SID_TRANSLITERATE_TOGGLE_CASE:
1469 nMode = TransliterationFlags::TOGGLE_CASE;
1470 break;
1471 case SID_TRANSLITERATE_UPPER:
1472 nMode = TransliterationFlags::LOWERCASE_UPPERCASE;
1473 break;
1474 case SID_TRANSLITERATE_LOWER:
1475 nMode = TransliterationFlags::UPPERCASE_LOWERCASE;
1476 break;
1477 case SID_TRANSLITERATE_HALFWIDTH:
1478 nMode = TransliterationFlags::FULLWIDTH_HALFWIDTH;
1479 break;
1480 case SID_TRANSLITERATE_FULLWIDTH:
1481 nMode = TransliterationFlags::HALFWIDTH_FULLWIDTH;
1482 break;
1483 case SID_TRANSLITERATE_HIRAGANA:
1484 nMode = TransliterationFlags::KATAKANA_HIRAGANA;
1485 break;
1486 case SID_TRANSLITERATE_KATAKANA:
1487 nMode = TransliterationFlags::HIRAGANA_KATAKANA;
1488 break;
1490 default:
1491 OSL_ENSURE(false, "wrong dispatcher");
1494 if( nMode != TransliterationFlags::NONE )
1495 pOLV->TransliterateText( nMode );
1498 void SwAnnotationShell::ExecRotateTransliteration( SfxRequest const & rReq )
1500 if( rReq.GetSlot() != SID_TRANSLITERATE_ROTATE_CASE )
1501 return;
1503 SwPostItMgr* pPostItMgr = m_rView.GetPostItMgr();
1504 if (!pPostItMgr || !pPostItMgr->HasActiveSidebarWin())
1505 return;
1507 OutlinerView* pOLV = pPostItMgr->GetActiveSidebarWin()->GetOutlinerView();
1509 if (!pOLV)
1510 return;
1512 pOLV->TransliterateText(m_aRotateCase.getNextMode());
1515 void SwAnnotationShell::ExecUndo(SfxRequest &rReq)
1517 const SfxItemSet* pArgs = rReq.GetArgs();
1518 SfxUndoManager* pUndoManager = GetUndoManager();
1519 SwWrtShell &rSh = m_rView.GetWrtShell();
1520 SwUndoId nUndoId(SwUndoId::EMPTY);
1522 // tdf#147928 get these before "undo" which may delete this SwAnnotationShell
1523 SwPostItMgr* pPostItMgr = m_rView.GetPostItMgr();
1524 SfxBindings& rBindings = m_rView.GetViewFrame().GetBindings();
1526 tools::Long aOldHeight = pPostItMgr->HasActiveSidebarWin()
1527 ? pPostItMgr->GetActiveSidebarWin()->GetPostItTextHeight()
1528 : 0;
1530 sal_uInt16 nId = rReq.GetSlot();
1531 sal_uInt16 nCnt = 1;
1532 const SfxPoolItem* pItem=nullptr;
1533 if( pArgs && SfxItemState::SET == pArgs->GetItemState( nId, false, &pItem ) )
1534 nCnt = static_cast<const SfxUInt16Item*>(pItem)->GetValue();
1535 switch( nId )
1537 case SID_UNDO:
1539 rSh.GetLastUndoInfo(nullptr, &nUndoId);
1540 if (nUndoId == SwUndoId::CONFLICT)
1542 rReq.SetReturnValue( SfxUInt32Item(nId, static_cast<sal_uInt32>(SID_REPAIRPACKAGE)) );
1543 break;
1546 if ( pUndoManager )
1548 sal_uInt16 nCount = pUndoManager->GetUndoActionCount();
1549 sal_uInt16 nSteps = nCnt;
1550 if ( nCount < nCnt )
1552 nCnt = nCnt - nCount;
1553 nSteps = nCount;
1555 else
1556 nCnt = 0;
1558 while( nSteps-- )
1559 pUndoManager->Undo();
1562 if ( nCnt )
1563 rSh.Do( SwWrtShell::UNDO, nCnt );
1565 break;
1568 case SID_REDO:
1570 (void)rSh.GetFirstRedoInfo(nullptr, &nUndoId);
1571 if (nUndoId == SwUndoId::CONFLICT)
1573 rReq.SetReturnValue( SfxUInt32Item(nId, static_cast<sal_uInt32>(SID_REPAIRPACKAGE)) );
1574 break;
1577 if ( pUndoManager )
1579 sal_uInt16 nCount = pUndoManager->GetRedoActionCount();
1580 sal_uInt16 nSteps = nCnt;
1581 if ( nCount < nCnt )
1583 nCnt = nCnt - nCount;
1584 nSteps = nCount;
1586 else
1587 nCnt = 0;
1589 while( nSteps-- )
1590 pUndoManager->Redo();
1593 if ( nCnt )
1594 rSh.Do( SwWrtShell::REDO, nCnt );
1596 break;
1600 rBindings.InvalidateAll(false);
1602 if (pPostItMgr->HasActiveSidebarWin())
1603 pPostItMgr->GetActiveSidebarWin()->ResizeIfNecessary(aOldHeight, pPostItMgr->GetActiveSidebarWin()->GetPostItTextHeight());
1606 void SwAnnotationShell::StateUndo(SfxItemSet &rSet)
1608 SwPostItMgr* pPostItMgr = m_rView.GetPostItMgr();
1609 if ( !pPostItMgr || !pPostItMgr->HasActiveSidebarWin() )
1610 return;
1612 SfxWhichIter aIter(rSet);
1613 SwUndoId nUndoId(SwUndoId::EMPTY);
1614 sal_uInt16 nWhich = aIter.FirstWhich();
1615 SfxUndoManager* pUndoManager = GetUndoManager();
1616 SfxViewFrame& rSfxViewFrame = m_rView.GetViewFrame();
1617 SwWrtShell &rSh = m_rView.GetWrtShell();
1619 while( nWhich )
1621 switch ( nWhich )
1623 case SID_UNDO:
1625 sal_uInt16 nCount = pUndoManager ? pUndoManager->GetUndoActionCount() : 0;
1626 if ( nCount )
1627 rSfxViewFrame.GetSlotState( nWhich, rSfxViewFrame.GetInterface(), &rSet );
1628 else if (rSh.GetLastUndoInfo(nullptr, &nUndoId))
1630 rSet.Put( SfxStringItem( nWhich, rSh.GetDoString(SwWrtShell::UNDO)) );
1632 else if (nUndoId == SwUndoId::CONFLICT)
1634 rSet.Put( SfxUInt32Item(nWhich, static_cast<sal_uInt32>(SID_REPAIRPACKAGE)) );
1636 else
1637 rSet.DisableItem(nWhich);
1638 break;
1640 case SID_REDO:
1642 sal_uInt16 nCount = pUndoManager ? pUndoManager->GetRedoActionCount() : 0;
1643 if ( nCount )
1644 rSfxViewFrame.GetSlotState( nWhich, rSfxViewFrame.GetInterface(), &rSet );
1645 else if (rSh.GetFirstRedoInfo(nullptr, &nUndoId))
1647 rSet.Put(SfxStringItem( nWhich, rSh.GetDoString(SwWrtShell::REDO)) );
1649 else if (nUndoId == SwUndoId::CONFLICT)
1651 rSet.Put( SfxUInt32Item(nWhich, static_cast<sal_uInt32>(SID_REPAIRPACKAGE)) );
1653 else
1654 rSet.DisableItem(nWhich);
1655 break;
1657 case SID_GETUNDOSTRINGS:
1658 case SID_GETREDOSTRINGS:
1660 if( pUndoManager )
1662 OUString (SfxUndoManager::*fnGetComment)( size_t, bool const ) const;
1664 sal_uInt16 nCount;
1665 if( SID_GETUNDOSTRINGS == nWhich )
1667 nCount = pUndoManager->GetUndoActionCount();
1668 fnGetComment = &SfxUndoManager::GetUndoActionComment;
1670 else
1672 nCount = pUndoManager->GetRedoActionCount();
1673 fnGetComment = &SfxUndoManager::GetRedoActionComment;
1676 OUStringBuffer sList;
1677 if( nCount )
1679 for( sal_uInt16 n = 0; n < nCount; ++n )
1680 sList.append( (pUndoManager->*fnGetComment)( n, SfxUndoManager::TopLevel ) + "\n");
1683 SfxStringListItem aItem( nWhich );
1684 if ((nWhich == SID_GETUNDOSTRINGS) &&
1685 rSh.GetLastUndoInfo(nullptr, nullptr))
1687 rSh.GetDoStrings( SwWrtShell::UNDO, aItem );
1689 else if ((nWhich == SID_GETREDOSTRINGS) &&
1690 (rSh.GetFirstRedoInfo(nullptr, nullptr)))
1692 rSh.GetDoStrings( SwWrtShell::REDO, aItem );
1695 sList.append(aItem.GetString());
1696 aItem.SetString( sList.makeStringAndClear() );
1697 rSet.Put( aItem );
1699 else
1700 rSet.DisableItem( nWhich );
1702 break;
1704 default:
1706 rSfxViewFrame.GetSlotState( nWhich, rSfxViewFrame.GetInterface(), &rSet );
1707 break;
1712 if (pPostItMgr->GetActiveSidebarWin()->GetLayoutStatus()==SwPostItHelper::DELETED)
1713 rSet.DisableItem( nWhich );
1715 nWhich = aIter.NextWhich();
1719 void SwAnnotationShell::StateDisableItems( SfxItemSet &rSet )
1721 SfxWhichIter aIter(rSet);
1722 sal_uInt16 nWhich = aIter.FirstWhich();
1723 while (nWhich)
1725 rSet.DisableItem( nWhich );
1726 nWhich = aIter.NextWhich();
1730 void SwAnnotationShell::InsertSymbol(SfxRequest& rReq)
1732 SwPostItMgr* pPostItMgr = m_rView.GetPostItMgr();
1733 if ( !pPostItMgr || !pPostItMgr->HasActiveSidebarWin() )
1734 return;
1736 OutlinerView* pOLV = pPostItMgr->GetActiveSidebarWin()->GetOutlinerView();
1738 const SfxItemSet *pArgs = rReq.GetArgs();
1739 const SfxStringItem* pCharMapItem = nullptr;
1740 if( pArgs )
1741 pCharMapItem = pArgs->GetItemIfSet(SID_CHARMAP, false);
1743 OUString sSym;
1744 OUString sFontName;
1745 if ( pCharMapItem )
1747 sSym = pCharMapItem->GetValue();
1748 const SfxStringItem* pFontItem = pArgs->GetItemIfSet( SID_ATTR_SPECIALCHAR, false);
1749 if (pFontItem)
1750 sFontName = pFontItem->GetValue();
1753 SfxItemSet aSet(pOLV->GetAttribs());
1754 SvtScriptType nScript = pOLV->GetSelectedScriptType();
1755 std::shared_ptr<SvxFontItem> aSetDlgFont(std::make_shared<SvxFontItem>(RES_CHRATR_FONT));
1757 SvxScriptSetItem aSetItem( SID_ATTR_CHAR_FONT, *aSet.GetPool() );
1758 aSetItem.GetItemSet().Put( aSet, false );
1759 const SfxPoolItem* pI = aSetItem.GetItemOfScript( nScript );
1760 if( pI )
1762 aSetDlgFont.reset(static_cast<SvxFontItem*>(pI->Clone()));
1764 else
1766 TypedWhichId<SvxFontItem> nFontWhich =
1767 GetWhichOfScript(
1768 SID_ATTR_CHAR_FONT,
1769 SvtLanguageOptions::GetI18NScriptTypeOfLanguage( GetAppLanguage() ) );
1770 aSetDlgFont.reset(aSet.Get(nFontWhich).Clone());
1773 if (sFontName.isEmpty())
1774 sFontName = aSetDlgFont->GetFamilyName();
1777 vcl::Font aFont(sFontName, Size(1,1));
1778 if( sSym.isEmpty() )
1780 SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
1782 SfxAllItemSet aAllSet( GetPool() );
1783 aAllSet.Put( SfxBoolItem( FN_PARAM_1, false ) );
1785 SwViewOption aOpt(*m_rView.GetWrtShell().GetViewOptions());
1786 const OUString& sSymbolFont = aOpt.GetSymbolFont();
1787 if( !sSymbolFont.isEmpty() )
1788 aAllSet.Put( SfxStringItem( SID_FONT_NAME, sSymbolFont ) );
1789 else
1790 aAllSet.Put( SfxStringItem( SID_FONT_NAME, aSetDlgFont->GetFamilyName() ) );
1792 // If character is selected then it can be shown.
1793 auto xFrame = m_rView.GetViewFrame().GetFrame().GetFrameInterface();
1794 ScopedVclPtr<SfxAbstractDialog> pDlg(pFact->CreateCharMapDialog(m_rView.GetFrameWeld(), aAllSet, xFrame));
1795 pDlg->Execute();
1796 return;
1799 // do not flicker
1800 pOLV->HideCursor();
1801 Outliner * pOutliner = pOLV->GetOutliner();
1802 pOutliner->SetUpdateLayout(false);
1804 SfxItemSet aOldSet( pOLV->GetAttribs() );
1805 SfxItemSetFixed<
1806 EE_CHAR_FONTINFO, EE_CHAR_FONTINFO,
1807 EE_CHAR_FONTINFO_CJK, EE_CHAR_FONTINFO_CTL>
1808 aFontSet( *aOldSet.GetPool() );
1809 aFontSet.Set( aOldSet );
1811 // Insert string
1812 pOLV->InsertText( sSym);
1814 // Attributing (set font)
1815 SfxItemSet aSetFont( *aFontSet.GetPool(), aFontSet.GetRanges() );
1816 SvxFontItem aFontItem (aFont.GetFamilyType(), aFont.GetFamilyName(),
1817 aFont.GetStyleName(), aFont.GetPitch(),
1818 aFont.GetCharSet(),
1819 EE_CHAR_FONTINFO );
1820 SvtScriptType nScriptBreak = g_pBreakIt->GetAllScriptsOfText( sSym );
1821 if( SvtScriptType::LATIN & nScriptBreak )
1822 aSetFont.Put( aFontItem );
1823 if( SvtScriptType::ASIAN & nScriptBreak )
1825 aFontItem.SetWhich(EE_CHAR_FONTINFO_CJK);
1826 aSetFont.Put( aFontItem );
1828 if( SvtScriptType::COMPLEX & nScriptBreak )
1830 aFontItem.SetWhich(EE_CHAR_FONTINFO_CTL);
1831 aSetFont.Put( aFontItem );
1833 pOLV->SetAttribs(aSetFont);
1835 // Erase selection
1836 ESelection aSel(pOLV->GetSelection());
1837 aSel.nStartPara = aSel.nEndPara;
1838 aSel.nStartPos = aSel.nEndPos;
1839 pOLV->SetSelection(aSel);
1841 // Restore old font
1842 pOLV->SetAttribs( aFontSet );
1844 // From now on show it again
1845 pOutliner->SetUpdateLayout(true);
1846 pOLV->ShowCursor();
1848 rReq.AppendItem( SfxStringItem( SID_CHARMAP, sSym ) );
1849 if(!aFont.GetFamilyName().isEmpty())
1850 rReq.AppendItem( SfxStringItem( SID_ATTR_SPECIALCHAR, aFont.GetFamilyName() ) );
1851 rReq.Done();
1855 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */