File: | home/maarten/src/libreoffice/core/sw/source/uibase/shells/annotsh.cxx |
Warning: | line 421, column 34 Called C++ object pointer is null |
Press '?' to see keyboard shortcuts
Keyboard shortcuts:
1 | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ | |||
2 | /* | |||
3 | * This file is part of the LibreOffice project. | |||
4 | * | |||
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/. | |||
8 | * | |||
9 | * This file incorporates work covered by the following license notice: | |||
10 | * | |||
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 . | |||
18 | */ | |||
19 | ||||
20 | #include <hintids.hxx> | |||
21 | ||||
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> | |||
29 | ||||
30 | #include <i18nutil/transliteration.hxx> | |||
31 | #include <sfx2/objface.hxx> | |||
32 | #include <sfx2/viewfrm.hxx> | |||
33 | #include <sfx2/bindings.hxx> | |||
34 | #include <sfx2/request.hxx> | |||
35 | #include <editeng/eeitem.hxx> | |||
36 | #include <editeng/flstitem.hxx> | |||
37 | #include <editeng/spltitem.hxx> | |||
38 | #include <editeng/lrspitem.hxx> | |||
39 | #include <editeng/ulspitem.hxx> | |||
40 | #include <editeng/orphitem.hxx> | |||
41 | #include <editeng/formatbreakitem.hxx> | |||
42 | #include <editeng/widwitem.hxx> | |||
43 | #include <editeng/kernitem.hxx> | |||
44 | #include <editeng/escapementitem.hxx> | |||
45 | #include <editeng/lspcitem.hxx> | |||
46 | #include <editeng/adjustitem.hxx> | |||
47 | #include <editeng/crossedoutitem.hxx> | |||
48 | #include <editeng/shdditem.hxx> | |||
49 | #include <editeng/hyphenzoneitem.hxx> | |||
50 | #include <editeng/udlnitem.hxx> | |||
51 | #include <editeng/fontitem.hxx> | |||
52 | #include <svx/clipfmtitem.hxx> | |||
53 | #include <svl/stritem.hxx> | |||
54 | #include <svl/slstitm.hxx> | |||
55 | #include <editeng/colritem.hxx> | |||
56 | #include <editeng/contouritem.hxx> | |||
57 | #include <editeng/frmdiritem.hxx> | |||
58 | #include <svl/whiter.hxx> | |||
59 | #include <svl/cjkoptions.hxx> | |||
60 | #include <svl/ctloptions.hxx> | |||
61 | #include <unotools/useroptions.hxx> | |||
62 | #include <editeng/flditem.hxx> | |||
63 | #include <svx/hlnkitem.hxx> | |||
64 | #include <sfx2/htmlmode.hxx> | |||
65 | #include <editeng/langitem.hxx> | |||
66 | #include <editeng/scripttypeitem.hxx> | |||
67 | #include <swundo.hxx> | |||
68 | #include <doc.hxx> | |||
69 | #include <viewopt.hxx> | |||
70 | #include <wrtsh.hxx> | |||
71 | #include <chrdlgmodes.hxx> | |||
72 | #include <edtwin.hxx> | |||
73 | #include <SwRewriter.hxx> | |||
74 | ||||
75 | #include <cmdid.h> | |||
76 | #include <strings.hrc> | |||
77 | #include <breakit.hxx> | |||
78 | #include <annotsh.hxx> | |||
79 | #include <view.hxx> | |||
80 | #include <PostItMgr.hxx> | |||
81 | #include <AnnotationWin.hxx> | |||
82 | ||||
83 | #include <swtypes.hxx> | |||
84 | ||||
85 | #include <svx/svxdlg.hxx> | |||
86 | ||||
87 | #include <vcl/EnumContext.hxx> | |||
88 | #include <svl/itempool.hxx> | |||
89 | #include <editeng/outliner.hxx> | |||
90 | #include <editeng/editview.hxx> | |||
91 | ||||
92 | #include <svl/languageoptions.hxx> | |||
93 | ||||
94 | #include <svl/undo.hxx> | |||
95 | #include <swabstdlg.hxx> | |||
96 | ||||
97 | #include <comphelper/string.hxx> | |||
98 | #include <comphelper/propertysequence.hxx> | |||
99 | #include <cppuhelper/bootstrap.hxx> | |||
100 | ||||
101 | #include <langhelper.hxx> | |||
102 | ||||
103 | #include <memory> | |||
104 | ||||
105 | using namespace ::com::sun::star; | |||
106 | using namespace ::com::sun::star::uno; | |||
107 | using namespace ::com::sun::star::beans; | |||
108 | using namespace ::com::sun::star::i18n; | |||
109 | ||||
110 | #define ShellClass_SwAnnotationShell | |||
111 | ||||
112 | #include <sfx2/msg.hxx> | |||
113 | #include <swslots.hxx> | |||
114 | ||||
115 | SFX_IMPL_INTERFACE(SwAnnotationShell, SfxShell)SfxInterface* SwAnnotationShell::pInterface = nullptr; SfxInterface * SwAnnotationShell::GetStaticInterface() { if ( !pInterface ) { pInterface = new SfxInterface( "SwAnnotationShell", false, GetInterfaceId(), SfxShell::GetStaticInterface(), aSwAnnotationShellSlots_Impl [0], sal_uInt16(sizeof(aSwAnnotationShellSlots_Impl) / sizeof (SfxSlot) ) ); InitInterface_Impl(); } return pInterface; } SfxInterface * SwAnnotationShell::GetInterface() const { return GetStaticInterface (); } void SwAnnotationShell::RegisterInterface(const SfxModule * pMod) { GetStaticInterface()->Register(pMod); } | |||
116 | ||||
117 | void SwAnnotationShell::InitInterface_Impl() | |||
118 | { | |||
119 | GetStaticInterface()->RegisterObjectBar(SFX_OBJECTBAR_OBJECT1, SfxVisibilityFlags::Invisible, ToolbarId::Text_Toolbox_Sw); | |||
120 | ||||
121 | GetStaticInterface()->RegisterPopupMenu("annotation"); | |||
122 | } | |||
123 | ||||
124 | ||||
125 | SfxItemPool* SwAnnotationShell::GetAnnotationPool(SwView const & rV) | |||
126 | { | |||
127 | SwWrtShell &rSh = rV.GetWrtShell(); | |||
128 | return rSh.GetAttrPool().GetSecondaryPool(); | |||
129 | } | |||
130 | ||||
131 | SwAnnotationShell::SwAnnotationShell( SwView& r ) | |||
132 | : rView(r) | |||
133 | { | |||
134 | SetPool(SwAnnotationShell::GetAnnotationPool(rView)); | |||
135 | SfxShell::SetContextName(vcl::EnumContext::GetContextName(vcl::EnumContext::Context::Annotation)); | |||
136 | } | |||
137 | ||||
138 | SwAnnotationShell::~SwAnnotationShell() | |||
139 | { | |||
140 | } | |||
141 | ||||
142 | SfxUndoManager* SwAnnotationShell::GetUndoManager() | |||
143 | { | |||
144 | SwPostItMgr* pPostItMgr = rView.GetPostItMgr(); | |||
145 | if ( !pPostItMgr || | |||
146 | !pPostItMgr->HasActiveSidebarWin() ) | |||
147 | { | |||
148 | OSL_ENSURE(pPostItMgr,"PostItMgr::Layout(): We are looping forever")do { if (true && (!(pPostItMgr))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/sw/source/uibase/shells/annotsh.cxx" ":" "148" ": "), "%s", "PostItMgr::Layout(): We are looping forever" ); } } while (false); | |||
149 | return nullptr; | |||
150 | } | |||
151 | return &pPostItMgr->GetActiveSidebarWin()->GetOutlinerView()->GetOutliner()->GetUndoManager(); | |||
152 | } | |||
153 | ||||
154 | void SwAnnotationShell::Exec( SfxRequest &rReq ) | |||
155 | { | |||
156 | //TODO: clean this up!!!! | |||
157 | SwPostItMgr* pPostItMgr = rView.GetPostItMgr(); | |||
158 | if ( !pPostItMgr || !pPostItMgr->HasActiveSidebarWin() ) | |||
| ||||
159 | return; | |||
160 | ||||
161 | OutlinerView* pOLV = pPostItMgr->GetActiveSidebarWin()->GetOutlinerView(); | |||
162 | SfxItemSet aEditAttr(pOLV->GetAttribs()); | |||
163 | SfxItemSet aNewAttr(*aEditAttr.GetPool(), aEditAttr.GetRanges()); | |||
164 | ||||
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) | |||
170 | { | |||
171 | case SID_PARASPACE_INCREASE( 10000 + 1145 ): | |||
172 | case SID_PARASPACE_DECREASE( 10000 + 1146 ): | |||
173 | { | |||
174 | SvxULSpaceItem aULSpace( aEditAttr.Get( EE_PARA_ULSPACE ) ); | |||
175 | sal_uInt16 nUpper = aULSpace.GetUpper(); | |||
176 | sal_uInt16 nLower = aULSpace.GetLower(); | |||
177 | ||||
178 | if ( nSlot == SID_PARASPACE_INCREASE( 10000 + 1145 ) ) | |||
179 | { | |||
180 | nUpper = std::min< sal_uInt16 >( nUpper + 57, 5670 ); | |||
181 | nLower = std::min< sal_uInt16 >( nLower + 57, 5670 ); | |||
182 | } | |||
183 | else | |||
184 | { | |||
185 | nUpper = std::max< sal_Int16 >( nUpper - 57, 0 ); | |||
186 | nLower = std::max< sal_Int16 >( nLower - 57, 0 ); | |||
187 | } | |||
188 | ||||
189 | aULSpace.SetUpper( nUpper ); | |||
190 | aULSpace.SetLower( nLower ); | |||
191 | aNewAttr.Put( aULSpace ); | |||
192 | rReq.Done(); | |||
193 | } | |||
194 | break; | |||
195 | case SID_ATTR_PARA_LRSPACE( 10000 + 43 ): | |||
196 | { | |||
197 | SvxLRSpaceItem aParaMargin(static_cast<const SvxLRSpaceItem&>(rReq. | |||
198 | GetArgs()->Get(nSlot))); | |||
199 | aParaMargin.SetWhich( EE_PARA_LRSPACE ); | |||
200 | ||||
201 | aNewAttr.Put(aParaMargin); | |||
202 | rReq.Done(); | |||
203 | break; | |||
204 | } | |||
205 | case SID_ATTR_PARA_LINESPACE( 10000 + 33 ): | |||
206 | { | |||
207 | SvxLineSpacingItem aParaMargin = static_cast<const SvxLineSpacingItem&>(pNewAttrs->Get( | |||
208 | GetPool().GetWhich(nSlot))); | |||
209 | aParaMargin.SetWhich( EE_PARA_SBL ); | |||
210 | ||||
211 | aNewAttr.Put(aParaMargin); | |||
212 | rReq.Done(); | |||
213 | break; | |||
214 | } | |||
215 | case SID_ATTR_PARA_ULSPACE( 10000 + 42 ): | |||
216 | { | |||
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(); | |||
222 | } | |||
223 | break; | |||
224 | case FN_GROW_FONT_SIZE((20000 + 400) + 3 ): | |||
225 | case FN_SHRINK_FONT_SIZE((20000 + 400) + 4 ): | |||
226 | { | |||
227 | const SvxFontListItem* pFontListItem = static_cast< const SvxFontListItem* > | |||
228 | ( SfxObjectShell::Current()->GetItem( SID_ATTR_CHAR_FONTLIST( 10000 + 22 ) ) ); | |||
229 | const FontList* pFontList = pFontListItem ? pFontListItem->GetFontList() : nullptr; | |||
230 | pOLV->GetEditView().ChangeFontSize( nSlot == FN_GROW_FONT_SIZE((20000 + 400) + 3 ), pFontList ); | |||
231 | } | |||
232 | break; | |||
233 | ||||
234 | case SID_ATTR_CHAR_FONT( 10000 + 7 ): | |||
235 | case SID_ATTR_CHAR_FONTHEIGHT( 10000 + 15 ): | |||
236 | case SID_ATTR_CHAR_WEIGHT( 10000 + 9 ): | |||
237 | case SID_ATTR_CHAR_POSTURE( 10000 + 8 ): | |||
238 | { | |||
239 | SfxItemPool* pSecondPool = aEditAttr.GetPool()->GetSecondaryPool(); | |||
240 | if( !pSecondPool ) | |||
241 | pSecondPool = aEditAttr.GetPool(); | |||
242 | SvxScriptSetItem aSetItem( nSlot, *pSecondPool ); | |||
243 | aSetItem.PutItemForScriptType( pOLV->GetSelectedScriptType(), pNewAttrs->Get( nWhich )); | |||
244 | aNewAttr.Put( aSetItem.GetItemSet() ); | |||
245 | rReq.Done(); | |||
246 | break; | |||
247 | } | |||
248 | case SID_ATTR_CHAR_COLOR( 10000 + 17 ): nEEWhich = EE_CHAR_COLOR; break; | |||
249 | case SID_ATTR_CHAR_BACK_COLOR( 10000 + 1153 ): nEEWhich = EE_CHAR_BKGCOLOR; break; | |||
250 | case SID_ATTR_CHAR_UNDERLINE( 10000 + 14 ): | |||
251 | { | |||
252 | if( rReq.GetArgs() ) | |||
253 | { | |||
254 | const SvxUnderlineItem* pItem = rReq.GetArg<SvxUnderlineItem>(SID_ATTR_CHAR_UNDERLINE( 10000 + 14 )); | |||
255 | if (pItem) | |||
256 | { | |||
257 | aNewAttr.Put(*pItem); | |||
258 | } | |||
259 | else | |||
260 | { | |||
261 | FontLineStyle eFU = aEditAttr.Get( EE_CHAR_UNDERLINE ).GetLineStyle(); | |||
262 | aNewAttr.Put( SvxUnderlineItem( eFU != LINESTYLE_NONE ?LINESTYLE_NONE : LINESTYLE_SINGLE, EE_CHAR_UNDERLINE ) ); | |||
263 | } | |||
264 | } | |||
265 | break; | |||
266 | } | |||
267 | case SID_ATTR_CHAR_OVERLINE( ((10000 + 1499) + 1) + 68 ): | |||
268 | { | |||
269 | FontLineStyle eFO = aEditAttr.Get(EE_CHAR_OVERLINE).GetLineStyle(); | |||
270 | aNewAttr.Put(SvxOverlineItem(eFO == LINESTYLE_SINGLE ? LINESTYLE_NONE : LINESTYLE_SINGLE, EE_CHAR_OVERLINE)); | |||
271 | break; | |||
272 | } | |||
273 | case SID_ATTR_CHAR_CONTOUR( 10000 + 12 ): nEEWhich = EE_CHAR_OUTLINE; break; | |||
274 | case SID_ATTR_CHAR_SHADOWED( 10000 + 10 ): nEEWhich = EE_CHAR_SHADOW; break; | |||
275 | case SID_ATTR_CHAR_STRIKEOUT( 10000 + 13 ): nEEWhich = EE_CHAR_STRIKEOUT; break; | |||
276 | case SID_ATTR_CHAR_WORDLINEMODE( 10000 + 11 ): nEEWhich = EE_CHAR_WLM; break; | |||
277 | case SID_ATTR_CHAR_RELIEF( 10000 + 920 ) : nEEWhich = EE_CHAR_RELIEF; break; | |||
278 | case SID_ATTR_CHAR_LANGUAGE( 10000 + 20 ) : nEEWhich = EE_CHAR_LANGUAGE;break; | |||
279 | case SID_ATTR_CHAR_KERNING( 10000 + 18 ) : nEEWhich = EE_CHAR_KERNING; break; | |||
280 | case SID_ATTR_CHAR_SCALEWIDTH( 10000 + 911 ): nEEWhich = EE_CHAR_FONTWIDTH; break; | |||
281 | case SID_ATTR_CHAR_AUTOKERN( 10000 + 67 ) : nEEWhich = EE_CHAR_PAIRKERNING; break; | |||
282 | case SID_ATTR_CHAR_ESCAPEMENT( 10000 + 21 ): nEEWhich = EE_CHAR_ESCAPEMENT; break; | |||
283 | case SID_ATTR_PARA_ADJUST_LEFT( 10000 + 28 ): | |||
284 | aNewAttr.Put(SvxAdjustItem(SvxAdjust::Left, EE_PARA_JUST)); | |||
285 | break; | |||
286 | case SID_ATTR_PARA_ADJUST_CENTER( 10000 + 30 ): | |||
287 | aNewAttr.Put(SvxAdjustItem(SvxAdjust::Center, EE_PARA_JUST)); | |||
288 | break; | |||
289 | case SID_ATTR_PARA_ADJUST_RIGHT( 10000 + 29 ): | |||
290 | aNewAttr.Put(SvxAdjustItem(SvxAdjust::Right, EE_PARA_JUST)); | |||
291 | break; | |||
292 | case SID_ATTR_PARA_ADJUST_BLOCK( 10000 + 31 ): | |||
293 | aNewAttr.Put(SvxAdjustItem(SvxAdjust::Block, EE_PARA_JUST)); | |||
294 | break; | |||
295 | ||||
296 | case SID_ATTR_PARA_LINESPACE_10( 10000 + 34 ): | |||
297 | { | |||
298 | SvxLineSpacingItem aItem(LINE_SPACE_DEFAULT_HEIGHT200, EE_PARA_SBL); | |||
299 | aItem.SetPropLineSpace(100); | |||
300 | aNewAttr.Put(aItem); | |||
301 | } | |||
302 | break; | |||
303 | case SID_ATTR_PARA_LINESPACE_15( 10000 + 35 ): | |||
304 | { | |||
305 | SvxLineSpacingItem aItem(LINE_SPACE_DEFAULT_HEIGHT200, EE_PARA_SBL); | |||
306 | aItem.SetPropLineSpace(150); | |||
307 | aNewAttr.Put(aItem); | |||
308 | } | |||
309 | break; | |||
310 | case SID_ATTR_PARA_LINESPACE_20( 10000 + 36 ): | |||
311 | { | |||
312 | SvxLineSpacingItem aItem(LINE_SPACE_DEFAULT_HEIGHT200, EE_PARA_SBL); | |||
313 | aItem.SetPropLineSpace(200); | |||
314 | aNewAttr.Put(aItem); | |||
315 | } | |||
316 | break; | |||
317 | case SID_SELECTALL(5000 + 723): | |||
318 | { | |||
319 | Outliner * pOutliner = pOLV->GetOutliner(); | |||
320 | if(pOutliner) | |||
321 | { | |||
322 | sal_Int32 nParaCount = pOutliner->GetParagraphCount(); | |||
323 | if (nParaCount > 0) | |||
324 | pOLV->SelectRange(0, nParaCount ); | |||
325 | } | |||
326 | break; | |||
327 | } | |||
328 | case FN_FORMAT_RESET((20000 + 400) + 69): | |||
329 | { | |||
330 | pPostItMgr->GetActiveSidebarWin()->ResetAttributes(); | |||
331 | rReq.Done(); | |||
332 | break; | |||
333 | } | |||
334 | case FN_SET_SUPER_SCRIPT((20000 + 400) + 11): | |||
335 | { | |||
336 | SvxEscapementItem aItem(EE_CHAR_ESCAPEMENT); | |||
337 | SvxEscapement eEsc = static_cast<SvxEscapement>(aEditAttr.Get( EE_CHAR_ESCAPEMENT ).GetEnumValue()); | |||
338 | ||||
339 | if( eEsc == SvxEscapement::Superscript ) | |||
340 | aItem.SetEscapement( SvxEscapement::Off ); | |||
341 | else | |||
342 | aItem.SetEscapement( SvxEscapement::Superscript ); | |||
343 | aNewAttr.Put( aItem ); | |||
344 | } | |||
345 | break; | |||
346 | case FN_SET_SUB_SCRIPT((20000 + 400) + 12): | |||
347 | { | |||
348 | SvxEscapementItem aItem(EE_CHAR_ESCAPEMENT); | |||
349 | SvxEscapement eEsc = static_cast<SvxEscapement>(aEditAttr.Get( EE_CHAR_ESCAPEMENT ).GetEnumValue()); | |||
350 | ||||
351 | if( eEsc == SvxEscapement::Subscript ) | |||
352 | aItem.SetEscapement( SvxEscapement::Off ); | |||
353 | else | |||
354 | aItem.SetEscapement( SvxEscapement::Subscript ); | |||
355 | aNewAttr.Put( aItem ); | |||
356 | } | |||
357 | break; | |||
358 | case SID_HYPERLINK_SETLINKTypedWhichId<SvxHyperlinkItem>(10000 + 362): | |||
359 | { | |||
360 | const SfxPoolItem* pItem = nullptr; | |||
361 | if(pNewAttrs) | |||
362 | pNewAttrs->GetItemState(nSlot, false, &pItem); | |||
363 | ||||
364 | if(pItem) | |||
365 | { | |||
366 | const SvxHyperlinkItem& rHLinkItem = *static_cast<const SvxHyperlinkItem *>(pItem); | |||
367 | SvxURLField aField(rHLinkItem.GetURL(), rHLinkItem.GetName(), SvxURLFormat::AppDefault); | |||
368 | aField.SetTargetFrame(rHLinkItem.GetTargetFrame()); | |||
369 | ||||
370 | const SvxFieldItem* pFieldItem = pOLV->GetFieldAtSelection(); | |||
371 | ||||
372 | if (pFieldItem && dynamic_cast<const SvxURLField *>(pFieldItem->GetField()) != nullptr) | |||
373 | { | |||
374 | // Select the field so that it will be deleted during insert | |||
375 | ESelection aSel = pOLV->GetSelection(); | |||
376 | aSel.nEndPos++; | |||
377 | pOLV->SetSelection(aSel); | |||
378 | } | |||
379 | if (pPostItMgr->GetActiveSidebarWin()->GetLayoutStatus()!=SwPostItHelper::DELETED) | |||
380 | pOLV->InsertField(SvxFieldItem(aField, EE_FEATURE_FIELD)); | |||
381 | } | |||
382 | break; | |||
383 | } | |||
384 | case FN_INSERT_SOFT_HYPHEN((20000 + 300) + 43): | |||
385 | case FN_INSERT_HARDHYPHEN((20000 + 300) + 85): | |||
386 | case FN_INSERT_HARD_SPACE((20000 + 300) + 44): | |||
387 | case FN_INSERT_NNBSP((20000 + 300) + 45): | |||
388 | case SID_INSERT_RLM( 10000 + 1056 ) : | |||
389 | case SID_INSERT_LRM( 10000 + 1057 ) : | |||
390 | case SID_INSERT_ZWNBSP( 10000 + 1059 ) : | |||
391 | case SID_INSERT_ZWSP( 10000 + 1058 ): | |||
392 | { | |||
393 | sal_Unicode cIns = 0; | |||
394 | switch(rReq.GetSlot()) | |||
395 | { | |||
396 | case FN_INSERT_SOFT_HYPHEN((20000 + 300) + 43): cIns = CHAR_SOFTHYPHENu'\x00AD'; break; | |||
397 | case FN_INSERT_HARDHYPHEN((20000 + 300) + 85): cIns = CHAR_HARDHYPHENu'\x2011'; break; | |||
398 | case FN_INSERT_HARD_SPACE((20000 + 300) + 44): cIns = CHAR_HARDBLANKu'\x00A0'; break; | |||
399 | case FN_INSERT_NNBSP((20000 + 300) + 45): cIns = CHAR_NNBSPu'\x202F'; break; | |||
400 | case SID_INSERT_RLM( 10000 + 1056 ) : cIns = CHAR_RLMu'\x200F' ; break; | |||
401 | case SID_INSERT_LRM( 10000 + 1057 ) : cIns = CHAR_LRMu'\x200E' ; break; | |||
402 | case SID_INSERT_ZWSP( 10000 + 1058 ) : cIns = CHAR_ZWSPu'\x200B' ; break; | |||
403 | case SID_INSERT_ZWNBSP( 10000 + 1059 ): cIns = CHAR_ZWNBSPu'\x2060'; break; | |||
404 | } | |||
405 | pOLV->InsertText( OUString(cIns)); | |||
406 | rReq.Done(); | |||
407 | break; | |||
408 | } | |||
409 | case SID_CHARMAP((10000 + 500) + 3): | |||
410 | { | |||
411 | if (pPostItMgr->GetActiveSidebarWin()->GetLayoutStatus()!=SwPostItHelper::DELETED) | |||
412 | InsertSymbol(rReq); | |||
413 | break; | |||
414 | } | |||
415 | case FN_INSERT_STRING((20000 + 300)+31): | |||
416 | { | |||
417 | const SfxPoolItem* pItem = nullptr; | |||
418 | if (pNewAttrs) | |||
419 | pNewAttrs->GetItemState(nSlot, false, &pItem ); | |||
420 | if (pPostItMgr->GetActiveSidebarWin()->GetLayoutStatus()!=SwPostItHelper::DELETED) | |||
421 | pOLV->InsertText(static_cast<const SfxStringItem *>(pItem)->GetValue()); | |||
| ||||
422 | break; | |||
423 | } | |||
424 | case FN_FORMAT_FOOTNOTE_DLG((20000 + 400) + 68): | |||
425 | { | |||
426 | rView.ExecFormatFootnote(); | |||
427 | break; | |||
428 | } | |||
429 | case FN_NUMBERING_OUTLINE_DLG((20000 + 600) + 12): | |||
430 | { | |||
431 | rView.ExecNumberingOutline(GetPool()); | |||
432 | rReq.Done(); | |||
433 | } | |||
434 | break; | |||
435 | case SID_OPEN_XML_FILTERSETTINGS( 10000 + 958 ): | |||
436 | { | |||
437 | HandleOpenXmlFilterSettings(rReq); | |||
438 | } | |||
439 | break; | |||
440 | case FN_WORDCOUNT_DIALOG((20000 + 2200) + 98): | |||
441 | { | |||
442 | rView.UpdateWordCount(this, nSlot); | |||
443 | break; | |||
444 | } | |||
445 | case SID_CHAR_DLG_EFFECT( 10000 + 1133 ): | |||
446 | case SID_CHAR_DLG( 10000 + 296 ): | |||
447 | { | |||
448 | const SfxItemSet* pArgs = rReq.GetArgs(); | |||
449 | const SfxStringItem* pItem = rReq.GetArg<SfxStringItem>(FN_PARAM_1((20000 + 1100)+60)); | |||
450 | ||||
451 | if( !pArgs || pItem ) | |||
452 | { | |||
453 | /* mod | |||
454 | SwView* pView = &GetView(); | |||
455 | FieldUnit eMetric = ::GetDfltMetric(dynamic_cast<SwWebView*>( pView) != nullptr ); | |||
456 | SW_MOD()->PutItem(SfxUInt16Item(SID_ATTR_METRIC, eMetric)); | |||
457 | */ | |||
458 | SfxItemSet aDlgAttr(GetPool(), svl::Items<XATTR_FILLSTYLE, XATTR_FILLCOLOR, EE_ITEMS_START, EE_ITEMS_END>{}); | |||
459 | ||||
460 | // util::Language does not exist in the EditEngine! Therefore not included in the set. | |||
461 | ||||
462 | aDlgAttr.Put( aEditAttr ); | |||
463 | aDlgAttr.Put( SvxKerningItem(0, RES_CHRATR_KERNING) ); | |||
464 | ||||
465 | SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); | |||
466 | ScopedVclPtr<SfxAbstractTabDialog> pDlg(pFact->CreateSwCharDlg(rView.GetFrameWeld(), rView, aDlgAttr, SwCharDlgMode::Ann)); | |||
467 | if (nSlot == SID_CHAR_DLG_EFFECT( 10000 + 1133 )) | |||
468 | { | |||
469 | pDlg->SetCurPageId("fonteffects"); | |||
470 | } | |||
471 | else if (pItem) | |||
472 | { | |||
473 | pDlg->SetCurPageId(OUStringToOString(pItem->GetValue(), RTL_TEXTENCODING_UTF8(((rtl_TextEncoding) 76)))); | |||
474 | } | |||
475 | ||||
476 | sal_uInt16 nRet = pDlg->Execute(); | |||
477 | if(RET_OK == nRet ) | |||
478 | { | |||
479 | rReq.Done( *( pDlg->GetOutputItemSet() ) ); | |||
480 | aNewAttr.Put(*pDlg->GetOutputItemSet()); | |||
481 | } | |||
482 | if(RET_OK != nRet) | |||
483 | return ; | |||
484 | } | |||
485 | else | |||
486 | aNewAttr.Put(*pArgs); | |||
487 | break; | |||
488 | } | |||
489 | case SID_PARA_DLG( 10000 + 297 ): | |||
490 | { | |||
491 | const SfxItemSet* pArgs = rReq.GetArgs(); | |||
492 | ||||
493 | if (!pArgs) | |||
494 | { | |||
495 | /* mod todo ??? | |||
496 | SwView* pView = &GetView(); | |||
497 | FieldUnit eMetric = ::GetDfltMetric(dynamic_cast<SwWebView*>( pView) != nullptr ); | |||
498 | SW_MOD()->PutItem(SfxUInt16Item(SID_ATTR_METRIC, eMetric)); | |||
499 | */ | |||
500 | SfxItemSet aDlgAttr( | |||
501 | GetPool(), | |||
502 | svl::Items< | |||
503 | EE_ITEMS_START, EE_ITEMS_END, | |||
504 | SID_ATTR_PARA_HYPHENZONE( 10000 + 38 ), SID_ATTR_PARA_WIDOWS( 10000 + 41 )>{}); | |||
505 | ||||
506 | aDlgAttr.Put(aEditAttr); | |||
507 | ||||
508 | aDlgAttr.Put( SvxHyphenZoneItem( false, RES_PARATR_HYPHENZONE) ); | |||
509 | aDlgAttr.Put( SvxFormatBreakItem( SvxBreak::NONE, RES_BREAK ) ); | |||
510 | aDlgAttr.Put( SvxFormatSplitItem( true, RES_PARATR_SPLIT ) ); | |||
511 | aDlgAttr.Put( SvxWidowsItem( 0, RES_PARATR_WIDOWS ) ); | |||
512 | aDlgAttr.Put( SvxOrphansItem( 0, RES_PARATR_ORPHANS ) ); | |||
513 | ||||
514 | SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); | |||
515 | ScopedVclPtr<SfxAbstractTabDialog> pDlg(pFact->CreateSwParaDlg(rView.GetFrameWeld(), rView, aDlgAttr, true)); | |||
516 | sal_uInt16 nRet = pDlg->Execute(); | |||
517 | if(RET_OK == nRet) | |||
518 | { | |||
519 | rReq.Done( *( pDlg->GetOutputItemSet() ) ); | |||
520 | aNewAttr.Put(*pDlg->GetOutputItemSet()); | |||
521 | } | |||
522 | if(RET_OK != nRet) | |||
523 | return; | |||
524 | } | |||
525 | else | |||
526 | aNewAttr.Put(*pArgs); | |||
527 | break; | |||
528 | } | |||
529 | ||||
530 | case SID_AUTOSPELL_CHECK(((((10000 + 1499) + 1) + 499) + 1) + 21): | |||
531 | { | |||
532 | rView.ExecuteSlot(rReq); | |||
533 | break; | |||
534 | } | |||
535 | case SID_ATTR_PARA_LEFT_TO_RIGHT( 10000 + 950 ): | |||
536 | case SID_ATTR_PARA_RIGHT_TO_LEFT( 10000 + 951 ): | |||
537 | { | |||
538 | bool bLeftToRight = nSlot == SID_ATTR_PARA_LEFT_TO_RIGHT( 10000 + 950 ); | |||
539 | ||||
540 | const SfxPoolItem* pPoolItem; | |||
541 | if( pNewAttrs && SfxItemState::SET == pNewAttrs->GetItemState( nSlot, true, &pPoolItem ) ) | |||
542 | { | |||
543 | if( !static_cast<const SfxBoolItem*>(pPoolItem)->GetValue() ) | |||
544 | bLeftToRight = !bLeftToRight; | |||
545 | } | |||
546 | SfxItemSet aAttr( | |||
547 | *aNewAttr.GetPool(), | |||
548 | svl::Items< | |||
549 | EE_PARA_WRITINGDIR, EE_PARA_WRITINGDIR, | |||
550 | EE_PARA_JUST, EE_PARA_JUST>{}); | |||
551 | ||||
552 | SvxAdjust nAdjust = SvxAdjust::Left; | |||
553 | if( SfxItemState::SET == aEditAttr.GetItemState(EE_PARA_JUST, true, &pPoolItem ) ) | |||
554 | nAdjust = static_cast<const SvxAdjustItem*>(pPoolItem)->GetAdjust(); | |||
555 | ||||
556 | if( bLeftToRight ) | |||
557 | { | |||
558 | aAttr.Put( SvxFrameDirectionItem( SvxFrameDirection::Horizontal_LR_TB, EE_PARA_WRITINGDIR ) ); | |||
559 | if( nAdjust == SvxAdjust::Right ) | |||
560 | aAttr.Put( SvxAdjustItem( SvxAdjust::Left, EE_PARA_JUST ) ); | |||
561 | } | |||
562 | else | |||
563 | { | |||
564 | aAttr.Put( SvxFrameDirectionItem( SvxFrameDirection::Horizontal_RL_TB, EE_PARA_WRITINGDIR ) ); | |||
565 | if( nAdjust == SvxAdjust::Left ) | |||
566 | aAttr.Put( SvxAdjustItem( SvxAdjust::Right, EE_PARA_JUST ) ); | |||
567 | } | |||
568 | pOLV->SetAttribs(aAttr); | |||
569 | break; | |||
570 | } | |||
571 | } | |||
572 | ||||
573 | if(nEEWhich && pNewAttrs) | |||
574 | { | |||
575 | aNewAttr.Put(pNewAttrs->Get(nWhich).CloneSetWhich(nEEWhich)); | |||
576 | } | |||
577 | ||||
578 | tools::Rectangle aOutRect = pOLV->GetOutputArea(); | |||
579 | if (tools::Rectangle() != aOutRect && aNewAttr.Count()) | |||
580 | pOLV->SetAttribs(aNewAttr); | |||
581 | ||||
582 | rView.GetViewFrame()->GetBindings().InvalidateAll(false); | |||
583 | if ( pOLV->GetOutliner()->IsModified() ) | |||
584 | rView.GetWrtShell().SetModified(); | |||
585 | ||||
586 | } | |||
587 | ||||
588 | void SwAnnotationShell::GetState(SfxItemSet& rSet) | |||
589 | { | |||
590 | //TODO: clean this up!!! | |||
591 | // FN_SET_SUPER_SCRIPT | |||
592 | //SID_ATTR_PARA_ADJUST | |||
593 | //SID_ATTR_PARA_ADJUST_BLOCK | |||
594 | ||||
595 | SwPostItMgr* pPostItMgr = rView.GetPostItMgr(); | |||
596 | if ( !pPostItMgr || !pPostItMgr->HasActiveSidebarWin() ) | |||
597 | return; | |||
598 | ||||
599 | OutlinerView* pOLV = pPostItMgr->GetActiveSidebarWin()->GetOutlinerView(); | |||
600 | SfxItemSet aEditAttr(pOLV->GetAttribs()); | |||
601 | ||||
602 | SfxWhichIter aIter(rSet); | |||
603 | sal_uInt16 nWhich = aIter.FirstWhich(); | |||
604 | while(nWhich) | |||
605 | { | |||
606 | sal_uInt16 nEEWhich = 0; | |||
607 | sal_uInt16 nSlotId = GetPool().GetSlotId( nWhich ); | |||
608 | switch( nSlotId ) | |||
609 | { | |||
610 | case SID_ATTR_PARA_LRSPACE( 10000 + 43 ): | |||
611 | case SID_ATTR_PARA_LEFTSPACE( 10000 + 44 ): | |||
612 | case SID_ATTR_PARA_RIGHTSPACE( 10000 + 45 ): | |||
613 | case SID_ATTR_PARA_FIRSTLINESPACE( 10000 + 46 ): | |||
614 | { | |||
615 | SfxItemState eState = aEditAttr.GetItemState( EE_PARA_LRSPACE ); | |||
616 | if( eState >= SfxItemState::DEFAULT ) | |||
617 | { | |||
618 | SvxLRSpaceItem aLR = aEditAttr.Get( EE_PARA_LRSPACE ); | |||
619 | aLR.SetWhich(nSlotId); | |||
620 | rSet.Put(aLR); | |||
621 | } | |||
622 | else | |||
623 | rSet.InvalidateItem(nSlotId); | |||
624 | } | |||
625 | break; | |||
626 | case SID_ATTR_PARA_LINESPACE( 10000 + 33 ): | |||
627 | { | |||
628 | SfxItemState eState = aEditAttr.GetItemState( EE_PARA_SBL ); | |||
629 | if( eState >= SfxItemState::DEFAULT ) | |||
630 | { | |||
631 | const SvxLineSpacingItem& aLR = aEditAttr.Get( EE_PARA_SBL ); | |||
632 | rSet.Put(aLR); | |||
633 | } | |||
634 | else | |||
635 | rSet.InvalidateItem(nSlotId); | |||
636 | } | |||
637 | break; | |||
638 | case SID_ATTR_PARA_ULSPACE( 10000 + 42 ): | |||
639 | case SID_ATTR_PARA_ABOVESPACE( 10000 + 64 ): | |||
640 | case SID_ATTR_PARA_BELOWSPACE( 10000 + 47 ): | |||
641 | case SID_PARASPACE_INCREASE( 10000 + 1145 ): | |||
642 | case SID_PARASPACE_DECREASE( 10000 + 1146 ): | |||
643 | { | |||
644 | SfxItemState eState = aEditAttr.GetItemState( EE_PARA_ULSPACE ); | |||
645 | if( eState >= SfxItemState::DEFAULT ) | |||
646 | { | |||
647 | SvxULSpaceItem aULSpace = aEditAttr.Get( EE_PARA_ULSPACE ); | |||
648 | if ( !aULSpace.GetUpper() && !aULSpace.GetLower() ) | |||
649 | rSet.DisableItem( SID_PARASPACE_DECREASE( 10000 + 1146 ) ); | |||
650 | else if ( aULSpace.GetUpper() >= 5670 && aULSpace.GetLower() >= 5670 ) | |||
651 | rSet.DisableItem( SID_PARASPACE_INCREASE( 10000 + 1145 ) ); | |||
652 | if ( nSlotId == SID_ATTR_PARA_ULSPACE( 10000 + 42 ) | |||
653 | || nSlotId == SID_ATTR_PARA_BELOWSPACE( 10000 + 47 ) | |||
654 | || nSlotId == SID_ATTR_PARA_ABOVESPACE( 10000 + 64 ) | |||
655 | ) | |||
656 | { | |||
657 | aULSpace.SetWhich(nSlotId); | |||
658 | rSet.Put(aULSpace); | |||
659 | } | |||
660 | } | |||
661 | else | |||
662 | { | |||
663 | rSet.DisableItem( SID_PARASPACE_INCREASE( 10000 + 1145 ) ); | |||
664 | rSet.DisableItem( SID_PARASPACE_DECREASE( 10000 + 1146 ) ); | |||
665 | rSet.InvalidateItem( SID_ATTR_PARA_ULSPACE( 10000 + 42 ) ); | |||
666 | rSet.InvalidateItem( SID_ATTR_PARA_ABOVESPACE( 10000 + 64 ) ); | |||
667 | rSet.InvalidateItem( SID_ATTR_PARA_BELOWSPACE( 10000 + 47 ) ); | |||
668 | } | |||
669 | } | |||
670 | break; | |||
671 | case SID_ATTR_CHAR_FONT( 10000 + 7 ): | |||
672 | case SID_ATTR_CHAR_FONTHEIGHT( 10000 + 15 ): | |||
673 | case SID_ATTR_CHAR_WEIGHT( 10000 + 9 ): | |||
674 | case SID_ATTR_CHAR_POSTURE( 10000 + 8 ): | |||
675 | { | |||
676 | SvtScriptType nScriptType = pOLV->GetSelectedScriptType(); | |||
677 | SfxItemPool* pSecondPool = aEditAttr.GetPool()->GetSecondaryPool(); | |||
678 | if( !pSecondPool ) | |||
679 | pSecondPool = aEditAttr.GetPool(); | |||
680 | SvxScriptSetItem aSetItem( nSlotId, *pSecondPool ); | |||
681 | aSetItem.GetItemSet().Put( aEditAttr, false ); | |||
682 | const SfxPoolItem* pI = aSetItem.GetItemOfScript( nScriptType ); | |||
683 | if( pI ) | |||
684 | { | |||
685 | rSet.Put(pI->CloneSetWhich(nWhich)); | |||
686 | } | |||
687 | else | |||
688 | rSet.InvalidateItem( nWhich ); | |||
689 | } | |||
690 | break; | |||
691 | case SID_ATTR_CHAR_COLOR( 10000 + 17 ): nEEWhich = EE_CHAR_COLOR; break; | |||
692 | case SID_ATTR_CHAR_BACK_COLOR( 10000 + 1153 ): nEEWhich = EE_CHAR_BKGCOLOR; break; | |||
693 | case SID_ATTR_CHAR_UNDERLINE( 10000 + 14 ): nEEWhich = EE_CHAR_UNDERLINE;break; | |||
694 | case SID_ATTR_CHAR_OVERLINE( ((10000 + 1499) + 1) + 68 ): nEEWhich = EE_CHAR_OVERLINE;break; | |||
695 | case SID_ATTR_CHAR_CONTOUR( 10000 + 12 ): nEEWhich = EE_CHAR_OUTLINE; break; | |||
696 | case SID_ATTR_CHAR_SHADOWED( 10000 + 10 ): nEEWhich = EE_CHAR_SHADOW;break; | |||
697 | case SID_ATTR_CHAR_STRIKEOUT( 10000 + 13 ): nEEWhich = EE_CHAR_STRIKEOUT;break; | |||
698 | case SID_ATTR_CHAR_LANGUAGE( 10000 + 20 ) : nEEWhich = EE_CHAR_LANGUAGE;break; | |||
699 | case SID_ATTR_CHAR_ESCAPEMENT( 10000 + 21 ): nEEWhich = EE_CHAR_ESCAPEMENT;break; | |||
700 | case SID_ATTR_CHAR_KERNING( 10000 + 18 ): nEEWhich = EE_CHAR_KERNING;break; | |||
701 | case FN_SET_SUPER_SCRIPT((20000 + 400) + 11): | |||
702 | case FN_SET_SUB_SCRIPT((20000 + 400) + 12): | |||
703 | { | |||
704 | SvxEscapement nEsc; | |||
705 | if (nWhich==FN_SET_SUPER_SCRIPT((20000 + 400) + 11)) | |||
706 | nEsc = SvxEscapement::Superscript; | |||
707 | else | |||
708 | nEsc = SvxEscapement::Subscript; | |||
709 | ||||
710 | const SfxPoolItem *pEscItem = &aEditAttr.Get( EE_CHAR_ESCAPEMENT ); | |||
711 | if( nEsc == static_cast<const SvxEscapementItem*>(pEscItem)->GetEscapement() ) | |||
712 | rSet.Put( SfxBoolItem( nWhich, true )); | |||
713 | else | |||
714 | rSet.InvalidateItem( nWhich ); | |||
715 | break; | |||
716 | } | |||
717 | case SID_ATTR_PARA_ADJUST_LEFT( 10000 + 28 ): | |||
718 | case SID_ATTR_PARA_ADJUST_RIGHT( 10000 + 29 ): | |||
719 | case SID_ATTR_PARA_ADJUST_CENTER( 10000 + 30 ): | |||
720 | case SID_ATTR_PARA_ADJUST_BLOCK( 10000 + 31 ): | |||
721 | { | |||
722 | SvxAdjust eAdjust = SvxAdjust::Left; | |||
723 | if (nWhich==SID_ATTR_PARA_ADJUST_LEFT( 10000 + 28 )) | |||
724 | eAdjust = SvxAdjust::Left; | |||
725 | else if (nWhich==SID_ATTR_PARA_ADJUST_RIGHT( 10000 + 29 )) | |||
726 | eAdjust = SvxAdjust::Right; | |||
727 | else if (nWhich==SID_ATTR_PARA_ADJUST_CENTER( 10000 + 30 )) | |||
728 | eAdjust = SvxAdjust::Center; | |||
729 | else if (nWhich==SID_ATTR_PARA_ADJUST_BLOCK( 10000 + 31 )) | |||
730 | eAdjust = SvxAdjust::Block; | |||
731 | ||||
732 | const SfxPoolItem *pAdjust = nullptr; | |||
733 | aEditAttr.GetItemState( EE_PARA_JUST, false, &pAdjust); | |||
734 | ||||
735 | if( !pAdjust || IsInvalidItem( pAdjust )) | |||
736 | { | |||
737 | rSet.InvalidateItem( nSlotId ); | |||
738 | } | |||
739 | else | |||
740 | { | |||
741 | if ( eAdjust == static_cast<const SvxAdjustItem*>(pAdjust)->GetAdjust()) | |||
742 | rSet.Put( SfxBoolItem( nWhich, true )); | |||
743 | else | |||
744 | rSet.InvalidateItem( nWhich ); | |||
745 | } | |||
746 | break; | |||
747 | } | |||
748 | case SID_ATTR_PARA_LINESPACE_10( 10000 + 34 ): | |||
749 | case SID_ATTR_PARA_LINESPACE_15( 10000 + 35 ): | |||
750 | case SID_ATTR_PARA_LINESPACE_20( 10000 + 36 ): | |||
751 | { | |||
752 | int nLSpace = 0; | |||
753 | if (nWhich==SID_ATTR_PARA_LINESPACE_10( 10000 + 34 )) | |||
754 | nLSpace = 100; | |||
755 | else if (nWhich==SID_ATTR_PARA_LINESPACE_15( 10000 + 35 )) | |||
756 | nLSpace = 150; | |||
757 | else if (nWhich==SID_ATTR_PARA_LINESPACE_20( 10000 + 36 )) | |||
758 | nLSpace = 200; | |||
759 | ||||
760 | const SfxPoolItem *pLSpace = nullptr; | |||
761 | aEditAttr.GetItemState( EE_PARA_SBL, false, &pLSpace ); | |||
762 | ||||
763 | if( !pLSpace || IsInvalidItem( pLSpace )) | |||
764 | { | |||
765 | rSet.InvalidateItem( nSlotId ); | |||
766 | } | |||
767 | else | |||
768 | { | |||
769 | if( nLSpace == static_cast<const SvxLineSpacingItem*>(pLSpace)->GetPropLineSpace() ) | |||
770 | rSet.Put( SfxBoolItem( nWhich, true )); | |||
771 | else | |||
772 | rSet.InvalidateItem( nWhich ); | |||
773 | } | |||
774 | break; | |||
775 | } | |||
776 | case SID_AUTOSPELL_CHECK(((((10000 + 1499) + 1) + 499) + 1) + 21): | |||
777 | { | |||
778 | const SfxPoolItem* pState = rView.GetSlotState(nWhich); | |||
779 | if (pState) | |||
780 | rSet.Put(SfxBoolItem(nWhich, static_cast<const SfxBoolItem*>(pState)->GetValue())); | |||
781 | else | |||
782 | rSet.DisableItem( nWhich ); | |||
783 | break; | |||
784 | } | |||
785 | case SID_ATTR_PARA_LEFT_TO_RIGHT( 10000 + 950 ): | |||
786 | case SID_ATTR_PARA_RIGHT_TO_LEFT( 10000 + 951 ): | |||
787 | { | |||
788 | if ( !SvtLanguageOptions().IsCTLFontEnabled() ) | |||
789 | rSet.DisableItem( nWhich ); | |||
790 | else | |||
791 | { | |||
792 | if(pOLV->GetOutliner() && pOLV->GetOutliner()->IsVertical()) | |||
793 | rSet.DisableItem( nWhich ); | |||
794 | else | |||
795 | { | |||
796 | bool bFlag = false; | |||
797 | switch( aEditAttr.Get( EE_PARA_WRITINGDIR ).GetValue() ) | |||
798 | { | |||
799 | case SvxFrameDirection::Horizontal_LR_TB: | |||
800 | { | |||
801 | bFlag = nWhich == SID_ATTR_PARA_LEFT_TO_RIGHT( 10000 + 950 ); | |||
802 | rSet.Put( SfxBoolItem( nWhich, bFlag )); | |||
803 | break; | |||
804 | } | |||
805 | case SvxFrameDirection::Horizontal_RL_TB: | |||
806 | { | |||
807 | bFlag = nWhich != SID_ATTR_PARA_LEFT_TO_RIGHT( 10000 + 950 ); | |||
808 | rSet.Put( SfxBoolItem( nWhich, bFlag )); | |||
809 | break; | |||
810 | } | |||
811 | default: | |||
812 | break; | |||
813 | } | |||
814 | } | |||
815 | } | |||
816 | } | |||
817 | break; | |||
818 | case SID_INSERT_RLM( 10000 + 1056 ) : | |||
819 | case SID_INSERT_LRM( 10000 + 1057 ) : | |||
820 | { | |||
821 | SvtCTLOptions aCTLOptions; | |||
822 | bool bEnabled = aCTLOptions.IsCTLFontEnabled(); | |||
823 | rView.GetViewFrame()->GetBindings().SetVisibleState( nWhich, bEnabled ); | |||
824 | if(!bEnabled) | |||
825 | rSet.DisableItem(nWhich); | |||
826 | } | |||
827 | break; | |||
828 | default: | |||
829 | rSet.InvalidateItem( nWhich ); | |||
830 | break; | |||
831 | } | |||
832 | ||||
833 | if(nEEWhich) | |||
834 | { | |||
835 | rSet.Put(aEditAttr.Get(nEEWhich).CloneSetWhich(nWhich)); | |||
836 | if(nEEWhich == EE_CHAR_KERNING) | |||
837 | { | |||
838 | SfxItemState eState = aEditAttr.GetItemState( EE_CHAR_KERNING ); | |||
839 | if ( eState == SfxItemState::DONTCARE ) | |||
840 | { | |||
841 | rSet.InvalidateItem(EE_CHAR_KERNING); | |||
842 | } | |||
843 | } | |||
844 | } | |||
845 | ||||
846 | if (pPostItMgr->GetActiveSidebarWin()->GetLayoutStatus()==SwPostItHelper::DELETED) | |||
847 | rSet.DisableItem( nWhich ); | |||
848 | ||||
849 | nWhich = aIter.NextWhich(); | |||
850 | } | |||
851 | } | |||
852 | ||||
853 | void SwAnnotationShell::ExecSearch(SfxRequest& rReq) | |||
854 | { | |||
855 | rView.ExecSearch(rReq); | |||
856 | } | |||
857 | ||||
858 | void SwAnnotationShell::StateSearch(SfxItemSet &rSet) | |||
859 | { | |||
860 | rView.StateSearch(rSet); | |||
861 | } | |||
862 | ||||
863 | void SwAnnotationShell::ExecClpbrd(SfxRequest const &rReq) | |||
864 | { | |||
865 | SwPostItMgr* pPostItMgr = rView.GetPostItMgr(); | |||
866 | if ( !pPostItMgr || !pPostItMgr->HasActiveSidebarWin() ) | |||
867 | return; | |||
868 | ||||
869 | OutlinerView* pOLV = pPostItMgr->GetActiveSidebarWin()->GetOutlinerView(); | |||
870 | ||||
871 | long aOldHeight = pPostItMgr->GetActiveSidebarWin()->GetPostItTextHeight(); | |||
872 | sal_uInt16 nSlot = rReq.GetSlot(); | |||
873 | switch (nSlot) | |||
874 | { | |||
875 | case SID_CUT(5000 + 710): | |||
876 | if ( (pPostItMgr->GetActiveSidebarWin()->GetLayoutStatus()!=SwPostItHelper::DELETED) && pOLV->HasSelection() ) | |||
877 | pOLV->Cut(); | |||
878 | break; | |||
879 | case SID_COPY(5000 + 711): | |||
880 | if( pOLV->HasSelection() ) | |||
881 | pOLV->Copy(); | |||
882 | break; | |||
883 | case SID_PASTE(5000 + 712): | |||
884 | if (pPostItMgr->GetActiveSidebarWin()->GetLayoutStatus()!=SwPostItHelper::DELETED) | |||
885 | pOLV->PasteSpecial(); | |||
886 | break; | |||
887 | case SID_PASTE_UNFORMATTED(5000 + 314): | |||
888 | if (pPostItMgr->GetActiveSidebarWin()->GetLayoutStatus()!=SwPostItHelper::DELETED) | |||
889 | pOLV->Paste(); | |||
890 | break; | |||
891 | case SID_PASTE_SPECIAL(5000 + 311): | |||
892 | { | |||
893 | if (pPostItMgr->GetActiveSidebarWin()->GetLayoutStatus()!=SwPostItHelper::DELETED) | |||
894 | { | |||
895 | SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); | |||
896 | ScopedVclPtr<SfxAbstractPasteDialog> pDlg(pFact->CreatePasteDialog(rView.GetEditWin().GetFrameWeld())); | |||
897 | ||||
898 | pDlg->Insert( SotClipboardFormatId::STRING, OUString() ); | |||
899 | pDlg->Insert( SotClipboardFormatId::RTF, OUString() ); | |||
900 | pDlg->Insert( SotClipboardFormatId::RICHTEXT, OUString() ); | |||
901 | ||||
902 | TransferableDataHelper aDataHelper( TransferableDataHelper::CreateFromSystemClipboard( &rView.GetEditWin() ) ); | |||
903 | ||||
904 | SotClipboardFormatId nFormat = pDlg->GetFormat( aDataHelper.GetTransferable() ); | |||
905 | ||||
906 | if (nFormat != SotClipboardFormatId::NONE) | |||
907 | { | |||
908 | if (nFormat == SotClipboardFormatId::STRING) | |||
909 | pOLV->Paste(); | |||
910 | else | |||
911 | pOLV->PasteSpecial(); | |||
912 | } | |||
913 | } | |||
914 | break; | |||
915 | } | |||
916 | case SID_CLIPBOARD_FORMAT_ITEMS(5000 + 312): | |||
917 | { | |||
918 | SotClipboardFormatId nFormat = SotClipboardFormatId::NONE; | |||
919 | const SfxPoolItem* pItem; | |||
920 | if (rReq.GetArgs() && rReq.GetArgs()->GetItemState(nSlot, true, &pItem) == SfxItemState::SET) | |||
921 | { | |||
922 | if (const SfxUInt32Item* pUInt32Item = dynamic_cast<const SfxUInt32Item *>(pItem)) | |||
923 | nFormat = static_cast<SotClipboardFormatId>(pUInt32Item->GetValue()); | |||
924 | } | |||
925 | ||||
926 | if ( nFormat != SotClipboardFormatId::NONE ) | |||
927 | { | |||
928 | if (SotClipboardFormatId::STRING == nFormat) | |||
929 | pOLV->Paste(); | |||
930 | else | |||
931 | pOLV->PasteSpecial(); | |||
932 | } | |||
933 | break; | |||
934 | } | |||
935 | } | |||
936 | pPostItMgr->GetActiveSidebarWin()->ResizeIfNecessary(aOldHeight,pPostItMgr->GetActiveSidebarWin()->GetPostItTextHeight()); | |||
937 | } | |||
938 | ||||
939 | void SwAnnotationShell::StateClpbrd(SfxItemSet &rSet) | |||
940 | { | |||
941 | SwPostItMgr* pPostItMgr = rView.GetPostItMgr(); | |||
942 | if ( !pPostItMgr || !pPostItMgr->HasActiveSidebarWin() ) | |||
943 | return; | |||
944 | OutlinerView* pOLV = pPostItMgr->GetActiveSidebarWin()->GetOutlinerView(); | |||
945 | ||||
946 | TransferableDataHelper aDataHelper( TransferableDataHelper::CreateFromSystemClipboard( &rView.GetEditWin() ) ); | |||
947 | bool bPastePossible = ( aDataHelper.HasFormat( SotClipboardFormatId::STRING ) || aDataHelper.HasFormat( SotClipboardFormatId::RTF ) | |||
948 | || aDataHelper.HasFormat( SotClipboardFormatId::RICHTEXT )); | |||
949 | bPastePossible = bPastePossible && (pPostItMgr->GetActiveSidebarWin()->GetLayoutStatus()!=SwPostItHelper::DELETED); | |||
950 | ||||
951 | SfxWhichIter aIter(rSet); | |||
952 | sal_uInt16 nWhich = aIter.FirstWhich(); | |||
953 | ||||
954 | while(nWhich) | |||
955 | { | |||
956 | switch(nWhich) | |||
957 | { | |||
958 | case SID_CUT(5000 + 710): | |||
959 | { | |||
960 | if (pPostItMgr->GetActiveSidebarWin()->GetLayoutStatus() == SwPostItHelper::DELETED) | |||
961 | rSet.DisableItem( nWhich ); | |||
962 | [[fallthrough]]; | |||
963 | } | |||
964 | case SID_COPY(5000 + 711): | |||
965 | { | |||
966 | SfxObjectShell* pObjectShell = GetObjectShell(); | |||
967 | if (!pOLV->HasSelection() || (pObjectShell && pObjectShell->isContentExtractionLocked()) ) | |||
968 | rSet.DisableItem( nWhich ); | |||
969 | break; | |||
970 | } | |||
971 | case SID_PASTE(5000 + 712): | |||
972 | case SID_PASTE_UNFORMATTED(5000 + 314): | |||
973 | case SID_PASTE_SPECIAL(5000 + 311): | |||
974 | { | |||
975 | if( !bPastePossible ) | |||
976 | rSet.DisableItem( nWhich ); | |||
977 | break; | |||
978 | } | |||
979 | case SID_CLIPBOARD_FORMAT_ITEMS(5000 + 312): | |||
980 | { | |||
981 | if ( bPastePossible ) | |||
982 | { | |||
983 | SvxClipboardFormatItem aFormats( SID_CLIPBOARD_FORMAT_ITEMS(5000 + 312) ); | |||
984 | if ( aDataHelper.HasFormat( SotClipboardFormatId::RTF ) ) | |||
985 | aFormats.AddClipbrdFormat( SotClipboardFormatId::RTF ); | |||
986 | if ( aDataHelper.HasFormat( SotClipboardFormatId::RICHTEXT ) ) | |||
987 | aFormats.AddClipbrdFormat( SotClipboardFormatId::RICHTEXT ); | |||
988 | aFormats.AddClipbrdFormat( SotClipboardFormatId::STRING ); | |||
989 | rSet.Put( aFormats ); | |||
990 | } | |||
991 | else | |||
992 | rSet.DisableItem( nWhich ); | |||
993 | break; | |||
994 | } | |||
995 | } | |||
996 | nWhich = aIter.NextWhich(); | |||
997 | } | |||
998 | } | |||
999 | ||||
1000 | void SwAnnotationShell::StateStatusLine(SfxItemSet &rSet) | |||
1001 | { | |||
1002 | SfxWhichIter aIter( rSet ); | |||
1003 | sal_uInt16 nWhich = aIter.FirstWhich(); | |||
1004 | ||||
1005 | while( nWhich ) | |||
1006 | { | |||
1007 | switch( nWhich ) | |||
1008 | { | |||
1009 | case FN_STAT_SELMODE((20000 + 1180) + 5): | |||
1010 | { | |||
1011 | rSet.Put(SfxUInt16Item(FN_STAT_SELMODE((20000 + 1180) + 5), 0)); | |||
1012 | rSet.DisableItem( nWhich ); | |||
1013 | break; | |||
1014 | } | |||
1015 | case FN_STAT_TEMPLATE((20000 + 1180) + 2): | |||
1016 | { | |||
1017 | rSet.DisableItem( nWhich ); | |||
1018 | break; | |||
1019 | } | |||
1020 | } | |||
1021 | nWhich = aIter.NextWhich(); | |||
1022 | } | |||
1023 | } | |||
1024 | ||||
1025 | void SwAnnotationShell::StateInsert(SfxItemSet &rSet) | |||
1026 | { | |||
1027 | SwPostItMgr* pPostItMgr = rView.GetPostItMgr(); | |||
1028 | if ( !pPostItMgr || !pPostItMgr->HasActiveSidebarWin() ) | |||
1029 | return; | |||
1030 | ||||
1031 | OutlinerView* pOLV = pPostItMgr->GetActiveSidebarWin()->GetOutlinerView(); | |||
1032 | SfxWhichIter aIter(rSet); | |||
1033 | sal_uInt16 nWhich = aIter.FirstWhich(); | |||
1034 | ||||
1035 | while(nWhich) | |||
1036 | { | |||
1037 | switch(nWhich) | |||
1038 | { | |||
1039 | case SID_HYPERLINK_GETLINK(10000 + 361): | |||
1040 | { | |||
1041 | SvxHyperlinkItem aHLinkItem; | |||
1042 | aHLinkItem.SetInsertMode(HLINK_FIELD); | |||
1043 | ||||
1044 | const SvxFieldItem* pFieldItem = pOLV->GetFieldAtSelection(); | |||
1045 | ||||
1046 | if (pFieldItem) | |||
1047 | { | |||
1048 | if (const SvxURLField* pURLField = dynamic_cast<const SvxURLField *>(pFieldItem->GetField())) | |||
1049 | { | |||
1050 | aHLinkItem.SetName(pURLField->GetRepresentation()); | |||
1051 | aHLinkItem.SetURL(pURLField->GetURL()); | |||
1052 | aHLinkItem.SetTargetFrame(pURLField->GetTargetFrame()); | |||
1053 | } | |||
1054 | } | |||
1055 | else | |||
1056 | { | |||
1057 | OUString sSel(pOLV->GetSelected()); | |||
1058 | sSel = sSel.copy(0, std::min<sal_Int32>(255, sSel.getLength())); | |||
1059 | aHLinkItem.SetName(comphelper::string::stripEnd(sSel, ' ')); | |||
1060 | } | |||
1061 | ||||
1062 | sal_uInt16 nHtmlMode = ::GetHtmlMode(rView.GetDocShell()); | |||
1063 | aHLinkItem.SetInsertMode(static_cast<SvxLinkInsertMode>(aHLinkItem.GetInsertMode() | | |||
1064 | ((nHtmlMode & HTMLMODE_ON) != 0 ? HLINK_HTMLMODE : 0))); | |||
1065 | ||||
1066 | rSet.Put(aHLinkItem); | |||
1067 | } | |||
1068 | break; | |||
1069 | } | |||
1070 | ||||
1071 | if (pPostItMgr->GetActiveSidebarWin()->GetLayoutStatus()==SwPostItHelper::DELETED) | |||
1072 | rSet.DisableItem( nWhich ); | |||
1073 | ||||
1074 | nWhich = aIter.NextWhich(); | |||
1075 | } | |||
1076 | } | |||
1077 | ||||
1078 | void SwAnnotationShell::NoteExec(SfxRequest const &rReq) | |||
1079 | { | |||
1080 | SwPostItMgr* pPostItMgr = rView.GetPostItMgr(); | |||
1081 | if ( !pPostItMgr ) | |||
1082 | return; | |||
1083 | ||||
1084 | sal_uInt16 nSlot = rReq.GetSlot(); | |||
1085 | switch (nSlot) | |||
1086 | { | |||
1087 | case FN_REPLY((20000 + 2500)+7): | |||
1088 | case FN_POSTIT((20000 + 300) + 29): | |||
1089 | case FN_DELETE_COMMENT((20000 + 2500)+6): | |||
1090 | case FN_DELETE_COMMENT_THREAD((20000 + 2500)+11): | |||
1091 | case FN_RESOLVE_NOTE((20000 + 2500)+9): | |||
1092 | case FN_RESOLVE_NOTE_THREAD((20000 + 2500)+10): | |||
1093 | if ( pPostItMgr->HasActiveSidebarWin() ) | |||
1094 | pPostItMgr->GetActiveSidebarWin()->ExecuteCommand(nSlot); | |||
1095 | break; | |||
1096 | case FN_DELETE_ALL_NOTES((20000 + 2500)+2): | |||
1097 | pPostItMgr->Delete(); | |||
1098 | break; | |||
1099 | case FN_FORMAT_ALL_NOTES((20000 + 2500)+8): | |||
1100 | pPostItMgr->ExecuteFormatAllDialog(rView); | |||
1101 | break; | |||
1102 | case FN_DELETE_NOTE_AUTHOR((20000 + 2500)+1): | |||
1103 | { | |||
1104 | const SfxStringItem* pItem = rReq.GetArg<SfxStringItem>(nSlot); | |||
1105 | if ( pItem ) | |||
1106 | pPostItMgr->Delete( pItem->GetValue() ); | |||
1107 | else if ( pPostItMgr->HasActiveSidebarWin() ) | |||
1108 | pPostItMgr->Delete( pPostItMgr->GetActiveSidebarWin()->GetAuthor() ); | |||
1109 | break; | |||
1110 | } | |||
1111 | case FN_HIDE_NOTE((20000 + 2500)+3): | |||
1112 | break; | |||
1113 | case FN_HIDE_ALL_NOTES((20000 + 2500)+5): | |||
1114 | pPostItMgr->Hide(); | |||
1115 | break; | |||
1116 | case FN_HIDE_NOTE_AUTHOR((20000 + 2500)+4): | |||
1117 | { | |||
1118 | const SfxStringItem* pItem = rReq.GetArg<SfxStringItem>(nSlot); | |||
1119 | if ( pItem ) | |||
1120 | pPostItMgr->Hide( pItem->GetValue() ); | |||
1121 | else if ( pPostItMgr->HasActiveSidebarWin() ) | |||
1122 | pPostItMgr->Hide( pPostItMgr->GetActiveSidebarWin()->GetAuthor() ); | |||
1123 | } | |||
1124 | } | |||
1125 | } | |||
1126 | ||||
1127 | void SwAnnotationShell::GetNoteState(SfxItemSet &rSet) | |||
1128 | { | |||
1129 | SwPostItMgr* pPostItMgr = rView.GetPostItMgr(); | |||
1130 | SfxWhichIter aIter(rSet); | |||
1131 | sal_uInt16 nWhich = aIter.FirstWhich(); | |||
1132 | while(nWhich) | |||
1133 | { | |||
1134 | sal_uInt16 nSlotId = GetPool().GetSlotId( nWhich ); | |||
1135 | switch( nSlotId ) | |||
1136 | { | |||
1137 | case FN_POSTIT((20000 + 300) + 29): | |||
1138 | case FN_DELETE_ALL_NOTES((20000 + 2500)+2): | |||
1139 | case FN_FORMAT_ALL_NOTES((20000 + 2500)+8): | |||
1140 | case FN_HIDE_NOTE((20000 + 2500)+3): | |||
1141 | case FN_HIDE_ALL_NOTES((20000 + 2500)+5): | |||
1142 | case FN_DELETE_COMMENT((20000 + 2500)+6): | |||
1143 | case FN_DELETE_COMMENT_THREAD((20000 + 2500)+11): | |||
1144 | { | |||
1145 | if( !pPostItMgr | |||
1146 | || !pPostItMgr->HasActiveAnnotationWin() ) | |||
1147 | { | |||
1148 | rSet.DisableItem(nWhich); | |||
1149 | } | |||
1150 | break; | |||
1151 | } | |||
1152 | case FN_RESOLVE_NOTE((20000 + 2500)+9): | |||
1153 | { | |||
1154 | if( !pPostItMgr | |||
1155 | || !pPostItMgr->HasActiveAnnotationWin() ) | |||
1156 | { | |||
1157 | rSet.DisableItem(nWhich); | |||
1158 | } | |||
1159 | else | |||
1160 | { | |||
1161 | SfxBoolItem aBool(nWhich, pPostItMgr->GetActiveSidebarWin()->IsResolved()); | |||
1162 | rSet.Put( aBool ); | |||
1163 | } | |||
1164 | break; | |||
1165 | } | |||
1166 | case FN_RESOLVE_NOTE_THREAD((20000 + 2500)+10): | |||
1167 | { | |||
1168 | if( !pPostItMgr | |||
1169 | || !pPostItMgr->HasActiveAnnotationWin() ) | |||
1170 | { | |||
1171 | rSet.DisableItem(nWhich); | |||
1172 | } | |||
1173 | else | |||
1174 | { | |||
1175 | SfxBoolItem aBool(nWhich, pPostItMgr->GetActiveSidebarWin()->IsThreadResolved()); | |||
1176 | rSet.Put( aBool ); | |||
1177 | } | |||
1178 | break; | |||
1179 | } | |||
1180 | case FN_DELETE_NOTE_AUTHOR((20000 + 2500)+1): | |||
1181 | case FN_HIDE_NOTE_AUTHOR((20000 + 2500)+4): | |||
1182 | { | |||
1183 | if( !pPostItMgr | |||
1184 | || !pPostItMgr->HasActiveAnnotationWin() ) | |||
1185 | { | |||
1186 | rSet.DisableItem(nWhich); | |||
1187 | } | |||
1188 | else | |||
1189 | { | |||
1190 | OUString aText( nSlotId == FN_DELETE_NOTE_AUTHOR((20000 + 2500)+1) ? | |||
1191 | SwResId( STR_DELETE_NOTE_AUTHORreinterpret_cast<char const *>("STR_DELETE_NOTE_AUTHOR" "\004" u8"Delete ~All Comments by $1") ) : SwResId( STR_HIDE_NOTE_AUTHORreinterpret_cast<char const *>("STR_HIDE_NOTE_AUTHOR" "\004" u8"H~ide All Comments by $1") ) ); | |||
1192 | SwRewriter aRewriter; | |||
1193 | aRewriter.AddRule( UndoArg1, pPostItMgr->GetActiveSidebarWin()->GetAuthor() ); | |||
1194 | aText = aRewriter.Apply( aText ); | |||
1195 | SfxStringItem aItem( nSlotId, aText ); | |||
1196 | rSet.Put( aItem ); | |||
1197 | } | |||
1198 | break; | |||
1199 | } | |||
1200 | case FN_REPLY((20000 + 2500)+7): | |||
1201 | { | |||
1202 | if ( !pPostItMgr || | |||
1203 | !pPostItMgr->HasActiveAnnotationWin() ) | |||
1204 | { | |||
1205 | rSet.DisableItem(nWhich); | |||
1206 | } | |||
1207 | else | |||
1208 | { | |||
1209 | SvtUserOptions aUserOpt; | |||
1210 | OUString sAuthor; | |||
1211 | if( (sAuthor = aUserOpt.GetFullName()).isEmpty() && | |||
1212 | (sAuthor = aUserOpt.GetID()).isEmpty() ) | |||
1213 | sAuthor = SwResId( STR_REDLINE_UNKNOWN_AUTHORreinterpret_cast<char const *>("STR_REDLINE_UNKNOWN_AUTHOR" "\004" u8"Unknown Author") ); | |||
1214 | if (sAuthor == pPostItMgr->GetActiveSidebarWin()->GetAuthor()) | |||
1215 | rSet.DisableItem(nWhich); | |||
1216 | } | |||
1217 | break; | |||
1218 | } | |||
1219 | default: | |||
1220 | rSet.InvalidateItem( nWhich ); | |||
1221 | break; | |||
1222 | } | |||
1223 | ||||
1224 | if (pPostItMgr && pPostItMgr->HasActiveSidebarWin()) | |||
1225 | { | |||
1226 | if ( (pPostItMgr->GetActiveSidebarWin()->IsProtected()) && | |||
1227 | ( (nSlotId==FN_DELETE_COMMENT((20000 + 2500)+6)) || (nSlotId==FN_REPLY((20000 + 2500)+7)) ) ) | |||
1228 | rSet.DisableItem( nWhich ); | |||
1229 | } | |||
1230 | nWhich = aIter.NextWhich(); | |||
1231 | } | |||
1232 | } | |||
1233 | ||||
1234 | void SwAnnotationShell::ExecLingu(SfxRequest &rReq) | |||
1235 | { | |||
1236 | SwPostItMgr* pPostItMgr = rView.GetPostItMgr(); | |||
1237 | if ( !pPostItMgr || !pPostItMgr->HasActiveSidebarWin() ) | |||
1238 | return; | |||
1239 | ||||
1240 | OutlinerView* pOLV = pPostItMgr->GetActiveSidebarWin()->GetOutlinerView(); | |||
1241 | sal_uInt16 nSlot = rReq.GetSlot(); | |||
1242 | SwWrtShell &rSh = rView.GetWrtShell(); | |||
1243 | bool bRestoreSelection = false; | |||
1244 | ESelection aOldSelection; | |||
1245 | ||||
1246 | switch (nSlot) | |||
1247 | { | |||
1248 | case SID_LANGUAGE_STATUS( 10000 + 1067 ): | |||
1249 | { | |||
1250 | aOldSelection = pOLV->GetSelection(); | |||
1251 | if (!pOLV->GetEditView().HasSelection()) | |||
1252 | { | |||
1253 | pOLV->GetEditView().SelectCurrentWord(); | |||
1254 | } | |||
1255 | ||||
1256 | bRestoreSelection = SwLangHelper::SetLanguageStatus(pOLV,rReq,rView,rSh); | |||
1257 | break; | |||
1258 | } | |||
1259 | case SID_THES(5000 + 698): | |||
1260 | { | |||
1261 | OUString aReplaceText; | |||
1262 | const SfxStringItem* pItem2 = rReq.GetArg<SfxStringItem>(SID_THES(5000 + 698)); | |||
1263 | if (pItem2) | |||
1264 | aReplaceText = pItem2->GetValue(); | |||
1265 | if (!aReplaceText.isEmpty()) | |||
1266 | ReplaceTextWithSynonym( pOLV->GetEditView(), aReplaceText ); | |||
1267 | break; | |||
1268 | } | |||
1269 | case SID_THESAURUS( 10000 + 245 ): | |||
1270 | { | |||
1271 | pOLV->StartThesaurus(); | |||
1272 | break; | |||
1273 | } | |||
1274 | case SID_HANGUL_HANJA_CONVERSION( 10000 + 959 ): | |||
1275 | pOLV->StartTextConversion( LANGUAGE_KOREANLanguageType(0x0412), LANGUAGE_KOREANLanguageType(0x0412), nullptr, | |||
1276 | i18n::TextConversionOption::CHARACTER_BY_CHARACTER, true, false ); | |||
1277 | break; | |||
1278 | ||||
1279 | case SID_CHINESE_CONVERSION( 10000 + 1016 ): | |||
1280 | { | |||
1281 | //open ChineseTranslationDialog | |||
1282 | Reference< XComponentContext > xContext( | |||
1283 | ::cppu::defaultBootstrap_InitialComponentContext() ); //@todo get context from calc if that has one | |||
1284 | if(xContext.is()) | |||
1285 | { | |||
1286 | Reference< lang::XMultiComponentFactory > xMCF( xContext->getServiceManager() ); | |||
1287 | if(xMCF.is()) | |||
1288 | { | |||
1289 | Reference< ui::dialogs::XExecutableDialog > xDialog( | |||
1290 | xMCF->createInstanceWithContext( | |||
1291 | "com.sun.star.linguistic2.ChineseTranslationDialog", xContext), | |||
1292 | UNO_QUERY); | |||
1293 | Reference< lang::XInitialization > xInit( xDialog, UNO_QUERY ); | |||
1294 | if( xInit.is() ) | |||
1295 | { | |||
1296 | // initialize dialog | |||
1297 | uno::Sequence<uno::Any> aSeq(comphelper::InitAnyPropertySequence( | |||
1298 | { | |||
1299 | {"ParentWindow", uno::Any(Reference<awt::XWindow>())} | |||
1300 | })); | |||
1301 | xInit->initialize( aSeq ); | |||
1302 | ||||
1303 | //execute dialog | |||
1304 | sal_Int16 nDialogRet = xDialog->execute(); | |||
1305 | if( RET_OK == nDialogRet ) | |||
1306 | { | |||
1307 | //get some parameters from the dialog | |||
1308 | bool bToSimplified = true; | |||
1309 | bool bUseVariants = true; | |||
1310 | bool bCommonTerms = true; | |||
1311 | Reference< beans::XPropertySet > xProp( xDialog, UNO_QUERY ); | |||
1312 | if( xProp.is() ) | |||
1313 | { | |||
1314 | try | |||
1315 | { | |||
1316 | xProp->getPropertyValue( "IsDirectionToSimplified" ) >>= bToSimplified; | |||
1317 | xProp->getPropertyValue( "IsUseCharacterVariants" ) >>= bUseVariants; | |||
1318 | xProp->getPropertyValue( "IsTranslateCommonTerms" ) >>= bCommonTerms; | |||
1319 | } | |||
1320 | catch (const Exception&) | |||
1321 | { | |||
1322 | } | |||
1323 | } | |||
1324 | ||||
1325 | //execute translation | |||
1326 | LanguageType nSourceLang = bToSimplified ? LANGUAGE_CHINESE_TRADITIONALLanguageType(0x0404) : LANGUAGE_CHINESE_SIMPLIFIEDLanguageType(0x0804); | |||
1327 | LanguageType nTargetLang = bToSimplified ? LANGUAGE_CHINESE_SIMPLIFIEDLanguageType(0x0804) : LANGUAGE_CHINESE_TRADITIONALLanguageType(0x0404); | |||
1328 | sal_Int32 nOptions = bUseVariants ? i18n::TextConversionOption::USE_CHARACTER_VARIANTS : 0; | |||
1329 | if( !bCommonTerms ) | |||
1330 | nOptions = nOptions | i18n::TextConversionOption::CHARACTER_BY_CHARACTER; | |||
1331 | ||||
1332 | vcl::Font aTargetFont = OutputDevice::GetDefaultFont( DefaultFontType::CJK_TEXT, | |||
1333 | nTargetLang, GetDefaultFontFlags::OnlyOne ); | |||
1334 | ||||
1335 | pOLV->StartTextConversion( nSourceLang, nTargetLang, &aTargetFont, nOptions, false, false ); | |||
1336 | } | |||
1337 | } | |||
1338 | Reference< lang::XComponent > xComponent( xDialog, UNO_QUERY ); | |||
1339 | if( xComponent.is() ) | |||
1340 | xComponent->dispose(); | |||
1341 | } | |||
1342 | } | |||
1343 | } | |||
1344 | break; | |||
1345 | } | |||
1346 | ||||
1347 | if (bRestoreSelection) | |||
1348 | { | |||
1349 | // restore selection | |||
1350 | pOLV->GetEditView().SetSelection( aOldSelection ); | |||
1351 | } | |||
1352 | } | |||
1353 | ||||
1354 | void SwAnnotationShell::GetLinguState(SfxItemSet &rSet) | |||
1355 | { | |||
1356 | SwPostItMgr* pPostItMgr = rView.GetPostItMgr(); | |||
1357 | if ( !pPostItMgr || !pPostItMgr->HasActiveSidebarWin() ) | |||
1358 | return; | |||
1359 | ||||
1360 | OutlinerView* pOLV = pPostItMgr->GetActiveSidebarWin()->GetOutlinerView(); | |||
1361 | ||||
1362 | SfxWhichIter aIter(rSet); | |||
1363 | sal_uInt16 nWhich = aIter.FirstWhich(); | |||
1364 | while(nWhich) | |||
1365 | { | |||
1366 | switch (nWhich) | |||
1367 | { | |||
1368 | case SID_LANGUAGE_STATUS( 10000 + 1067 ): | |||
1369 | { | |||
1370 | SwLangHelper::GetLanguageStatus(pOLV,rSet); | |||
1371 | break; | |||
1372 | } | |||
1373 | ||||
1374 | case SID_THES(5000 + 698): | |||
1375 | { | |||
1376 | OUString aStatusVal; | |||
1377 | LanguageType nLang = LANGUAGE_NONELanguageType(0x00FF); | |||
1378 | bool bIsLookUpWord = GetStatusValueForThesaurusFromContext( aStatusVal, nLang, pOLV->GetEditView() ); | |||
1379 | rSet.Put( SfxStringItem( SID_THES(5000 + 698), aStatusVal ) ); | |||
1380 | ||||
1381 | // disable "Thesaurus" context menu entry if there is nothing to look up | |||
1382 | uno::Reference< linguistic2::XThesaurus > xThes( ::GetThesaurus() ); | |||
1383 | if (!bIsLookUpWord || | |||
1384 | !xThes.is() || nLang == LANGUAGE_NONELanguageType(0x00FF) || !xThes->hasLocale( LanguageTag::convertToLocale( nLang ) )) | |||
1385 | rSet.DisableItem( SID_THES(5000 + 698) ); | |||
1386 | break; | |||
1387 | } | |||
1388 | ||||
1389 | // disable "Thesaurus" if the language is not supported | |||
1390 | case SID_THESAURUS( 10000 + 245 ): | |||
1391 | { | |||
1392 | const SfxPoolItem &rItem = rView.GetWrtShell().GetDoc()->GetDefault( | |||
1393 | GetWhichOfScript( RES_CHRATR_LANGUAGE, | |||
1394 | SvtLanguageOptions::GetI18NScriptTypeOfLanguage( GetAppLanguage())) ); | |||
1395 | LanguageType nLang = static_cast<const SvxLanguageItem &>( | |||
1396 | rItem).GetLanguage(); | |||
1397 | uno::Reference< linguistic2::XThesaurus > xThes( ::GetThesaurus() ); | |||
1398 | if (!xThes.is() || nLang == LANGUAGE_NONELanguageType(0x00FF) || | |||
1399 | !xThes->hasLocale( LanguageTag::convertToLocale( nLang ) )) | |||
1400 | rSet.DisableItem( SID_THESAURUS( 10000 + 245 ) ); | |||
1401 | } | |||
1402 | break; | |||
1403 | case SID_HANGUL_HANJA_CONVERSION( 10000 + 959 ): | |||
1404 | case SID_CHINESE_CONVERSION( 10000 + 1016 ): | |||
1405 | { | |||
1406 | if (!SvtCJKOptions().IsAnyEnabled()) | |||
1407 | { | |||
1408 | rView.GetViewFrame()->GetBindings().SetVisibleState( nWhich, false ); | |||
1409 | rSet.DisableItem(nWhich); | |||
1410 | } | |||
1411 | else | |||
1412 | rView.GetViewFrame()->GetBindings().SetVisibleState( nWhich, true ); | |||
1413 | } | |||
1414 | break; | |||
1415 | } | |||
1416 | ||||
1417 | if (pPostItMgr->GetActiveSidebarWin()->GetLayoutStatus()==SwPostItHelper::DELETED) | |||
1418 | rSet.DisableItem( nWhich ); | |||
1419 | ||||
1420 | nWhich = aIter.NextWhich(); | |||
1421 | } | |||
1422 | } | |||
1423 | ||||
1424 | void SwAnnotationShell::ExecTransliteration(SfxRequest const &rReq) | |||
1425 | { | |||
1426 | SwPostItMgr* pPostItMgr = rView.GetPostItMgr(); | |||
1427 | if (!pPostItMgr || !pPostItMgr->HasActiveSidebarWin()) | |||
1428 | return; | |||
1429 | ||||
1430 | OutlinerView* pOLV = pPostItMgr->GetActiveSidebarWin()->GetOutlinerView(); | |||
1431 | ||||
1432 | if (!pOLV) | |||
1433 | return; | |||
1434 | ||||
1435 | TransliterationFlags nMode = TransliterationFlags::NONE; | |||
1436 | ||||
1437 | switch( rReq.GetSlot() ) | |||
1438 | { | |||
1439 | case SID_TRANSLITERATE_SENTENCE_CASE( 10000 + 1102 ): | |||
1440 | nMode = TransliterationFlags::SENTENCE_CASE; | |||
1441 | break; | |||
1442 | case SID_TRANSLITERATE_TITLE_CASE( 10000 + 1103 ): | |||
1443 | nMode = TransliterationFlags::TITLE_CASE; | |||
1444 | break; | |||
1445 | case SID_TRANSLITERATE_TOGGLE_CASE( 10000 + 1104 ): | |||
1446 | nMode = TransliterationFlags::TOGGLE_CASE; | |||
1447 | break; | |||
1448 | case SID_TRANSLITERATE_UPPER( 10000 + 912 ): | |||
1449 | nMode = TransliterationFlags::LOWERCASE_UPPERCASE; | |||
1450 | break; | |||
1451 | case SID_TRANSLITERATE_LOWER( 10000 + 913 ): | |||
1452 | nMode = TransliterationFlags::UPPERCASE_LOWERCASE; | |||
1453 | break; | |||
1454 | case SID_TRANSLITERATE_HALFWIDTH( 10000 + 914 ): | |||
1455 | nMode = TransliterationFlags::FULLWIDTH_HALFWIDTH; | |||
1456 | break; | |||
1457 | case SID_TRANSLITERATE_FULLWIDTH( 10000 + 915 ): | |||
1458 | nMode = TransliterationFlags::HALFWIDTH_FULLWIDTH; | |||
1459 | break; | |||
1460 | case SID_TRANSLITERATE_HIRAGANA( 10000 + 916 ): | |||
1461 | nMode = TransliterationFlags::KATAKANA_HIRAGANA; | |||
1462 | break; | |||
1463 | case SID_TRANSLITERATE_KATAKANA( 10000 + 917 ): | |||
1464 | nMode = TransliterationFlags::HIRAGANA_KATAKANA; | |||
1465 | break; | |||
1466 | ||||
1467 | default: | |||
1468 | OSL_ENSURE(false, "wrong dispatcher")do { if (true && (!(false))) { sal_detail_logFormat(( SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/sw/source/uibase/shells/annotsh.cxx" ":" "1468" ": "), "%s", "wrong dispatcher"); } } while (false ); | |||
1469 | } | |||
1470 | ||||
1471 | if( nMode != TransliterationFlags::NONE ) | |||
1472 | pOLV->TransliterateText( nMode ); | |||
1473 | } | |||
1474 | ||||
1475 | void SwAnnotationShell::ExecRotateTransliteration( SfxRequest const & rReq ) | |||
1476 | { | |||
1477 | if( rReq.GetSlot() != SID_TRANSLITERATE_ROTATE_CASE( 10000 + 1105 ) ) | |||
1478 | return; | |||
1479 | ||||
1480 | SwPostItMgr* pPostItMgr = rView.GetPostItMgr(); | |||
1481 | if (!pPostItMgr || !pPostItMgr->HasActiveSidebarWin()) | |||
1482 | return; | |||
1483 | ||||
1484 | OutlinerView* pOLV = pPostItMgr->GetActiveSidebarWin()->GetOutlinerView(); | |||
1485 | ||||
1486 | if (!pOLV) | |||
1487 | return; | |||
1488 | ||||
1489 | pOLV->TransliterateText(m_aRotateCase.getNextMode()); | |||
1490 | } | |||
1491 | ||||
1492 | void SwAnnotationShell::ExecUndo(SfxRequest &rReq) | |||
1493 | { | |||
1494 | const SfxItemSet* pArgs = rReq.GetArgs(); | |||
1495 | SfxUndoManager* pUndoManager = GetUndoManager(); | |||
1496 | SwWrtShell &rSh = rView.GetWrtShell(); | |||
1497 | SwUndoId nUndoId(SwUndoId::EMPTY); | |||
1498 | ||||
1499 | long aOldHeight = rView.GetPostItMgr()->HasActiveSidebarWin() | |||
1500 | ? rView.GetPostItMgr()->GetActiveSidebarWin()->GetPostItTextHeight() | |||
1501 | : 0; | |||
1502 | ||||
1503 | sal_uInt16 nId = rReq.GetSlot(); | |||
1504 | sal_uInt16 nCnt = 1; | |||
1505 | const SfxPoolItem* pItem=nullptr; | |||
1506 | if( pArgs && SfxItemState::SET == pArgs->GetItemState( nId, false, &pItem ) ) | |||
1507 | nCnt = static_cast<const SfxUInt16Item*>(pItem)->GetValue(); | |||
1508 | switch( nId ) | |||
1509 | { | |||
1510 | case SID_UNDO(5000 + 701): | |||
1511 | { | |||
1512 | rSh.GetLastUndoInfo(nullptr, &nUndoId); | |||
1513 | if (nUndoId == SwUndoId::CONFLICT) | |||
1514 | { | |||
1515 | rReq.SetReturnValue( SfxUInt32Item(nId, static_cast<sal_uInt32>(SID_REPAIRPACKAGE(5000 + 1683))) ); | |||
1516 | break; | |||
1517 | } | |||
1518 | ||||
1519 | if ( pUndoManager ) | |||
1520 | { | |||
1521 | sal_uInt16 nCount = pUndoManager->GetUndoActionCount(); | |||
1522 | sal_uInt16 nSteps = nCnt; | |||
1523 | if ( nCount < nCnt ) | |||
1524 | { | |||
1525 | nCnt = nCnt - nCount; | |||
1526 | nSteps = nCount; | |||
1527 | } | |||
1528 | else | |||
1529 | nCnt = 0; | |||
1530 | ||||
1531 | while( nSteps-- ) | |||
1532 | pUndoManager->Undo(); | |||
1533 | } | |||
1534 | ||||
1535 | if ( nCnt ) | |||
1536 | rSh.Do( SwWrtShell::UNDO, nCnt ); | |||
1537 | ||||
1538 | break; | |||
1539 | } | |||
1540 | ||||
1541 | case SID_REDO(5000 + 700): | |||
1542 | { | |||
1543 | (void)rSh.GetFirstRedoInfo(nullptr, &nUndoId); | |||
1544 | if (nUndoId == SwUndoId::CONFLICT) | |||
1545 | { | |||
1546 | rReq.SetReturnValue( SfxUInt32Item(nId, static_cast<sal_uInt32>(SID_REPAIRPACKAGE(5000 + 1683))) ); | |||
1547 | break; | |||
1548 | } | |||
1549 | ||||
1550 | if ( pUndoManager ) | |||
1551 | { | |||
1552 | sal_uInt16 nCount = pUndoManager->GetRedoActionCount(); | |||
1553 | sal_uInt16 nSteps = nCnt; | |||
1554 | if ( nCount < nCnt ) | |||
1555 | { | |||
1556 | nCnt = nCnt - nCount; | |||
1557 | nSteps = nCount; | |||
1558 | } | |||
1559 | else | |||
1560 | nCnt = 0; | |||
1561 | ||||
1562 | while( nSteps-- ) | |||
1563 | pUndoManager->Redo(); | |||
1564 | } | |||
1565 | ||||
1566 | if ( nCnt ) | |||
1567 | rSh.Do( SwWrtShell::REDO, nCnt ); | |||
1568 | ||||
1569 | break; | |||
1570 | } | |||
1571 | } | |||
1572 | ||||
1573 | rView.GetViewFrame()->GetBindings().InvalidateAll(false); | |||
1574 | ||||
1575 | if (rView.GetPostItMgr()->HasActiveSidebarWin()) | |||
1576 | rView.GetPostItMgr()->GetActiveSidebarWin()->ResizeIfNecessary(aOldHeight,rView.GetPostItMgr()->GetActiveSidebarWin()->GetPostItTextHeight()); | |||
1577 | } | |||
1578 | ||||
1579 | void SwAnnotationShell::StateUndo(SfxItemSet &rSet) | |||
1580 | { | |||
1581 | SwPostItMgr* pPostItMgr = rView.GetPostItMgr(); | |||
1582 | if ( !pPostItMgr || !pPostItMgr->HasActiveSidebarWin() ) | |||
1583 | return; | |||
1584 | ||||
1585 | SfxWhichIter aIter(rSet); | |||
1586 | SwUndoId nUndoId(SwUndoId::EMPTY); | |||
1587 | sal_uInt16 nWhich = aIter.FirstWhich(); | |||
1588 | SfxUndoManager* pUndoManager = GetUndoManager(); | |||
1589 | SfxViewFrame *pSfxViewFrame = rView.GetViewFrame(); | |||
1590 | SwWrtShell &rSh = rView.GetWrtShell(); | |||
1591 | ||||
1592 | while( nWhich ) | |||
1593 | { | |||
1594 | switch ( nWhich ) | |||
1595 | { | |||
1596 | case SID_UNDO(5000 + 701): | |||
1597 | { | |||
1598 | sal_uInt16 nCount = pUndoManager ? pUndoManager->GetUndoActionCount() : 0; | |||
1599 | if ( nCount ) | |||
1600 | pSfxViewFrame->GetSlotState( nWhich, pSfxViewFrame->GetInterface(), &rSet ); | |||
1601 | else if (rSh.GetLastUndoInfo(nullptr, &nUndoId)) | |||
1602 | { | |||
1603 | rSet.Put( SfxStringItem( nWhich, rSh.GetDoString(SwWrtShell::UNDO)) ); | |||
1604 | } | |||
1605 | else if (nUndoId == SwUndoId::CONFLICT) | |||
1606 | { | |||
1607 | rSet.Put( SfxUInt32Item(nWhich, static_cast<sal_uInt32>(SID_REPAIRPACKAGE(5000 + 1683))) ); | |||
1608 | } | |||
1609 | else | |||
1610 | rSet.DisableItem(nWhich); | |||
1611 | break; | |||
1612 | } | |||
1613 | case SID_REDO(5000 + 700): | |||
1614 | { | |||
1615 | sal_uInt16 nCount = pUndoManager ? pUndoManager->GetRedoActionCount() : 0; | |||
1616 | if ( nCount ) | |||
1617 | pSfxViewFrame->GetSlotState( nWhich, pSfxViewFrame->GetInterface(), &rSet ); | |||
1618 | else if (rSh.GetFirstRedoInfo(nullptr, &nUndoId)) | |||
1619 | { | |||
1620 | rSet.Put(SfxStringItem( nWhich, rSh.GetDoString(SwWrtShell::REDO)) ); | |||
1621 | } | |||
1622 | else if (nUndoId == SwUndoId::CONFLICT) | |||
1623 | { | |||
1624 | rSet.Put( SfxUInt32Item(nWhich, static_cast<sal_uInt32>(SID_REPAIRPACKAGE(5000 + 1683))) ); | |||
1625 | } | |||
1626 | else | |||
1627 | rSet.DisableItem(nWhich); | |||
1628 | break; | |||
1629 | } | |||
1630 | case SID_GETUNDOSTRINGS( 10000 + 923 ): | |||
1631 | case SID_GETREDOSTRINGS( 10000 + 924 ): | |||
1632 | { | |||
1633 | if( pUndoManager ) | |||
1634 | { | |||
1635 | OUString (SfxUndoManager::*fnGetComment)( size_t, bool const ) const; | |||
1636 | ||||
1637 | sal_uInt16 nCount; | |||
1638 | if( SID_GETUNDOSTRINGS( 10000 + 923 ) == nWhich ) | |||
1639 | { | |||
1640 | nCount = pUndoManager->GetUndoActionCount(); | |||
1641 | fnGetComment = &SfxUndoManager::GetUndoActionComment; | |||
1642 | } | |||
1643 | else | |||
1644 | { | |||
1645 | nCount = pUndoManager->GetRedoActionCount(); | |||
1646 | fnGetComment = &SfxUndoManager::GetRedoActionComment; | |||
1647 | } | |||
1648 | ||||
1649 | OUStringBuffer sList; | |||
1650 | if( nCount ) | |||
1651 | { | |||
1652 | for( sal_uInt16 n = 0; n < nCount; ++n ) | |||
1653 | sList.append( (pUndoManager->*fnGetComment)( n, SfxUndoManager::TopLevel ) ).append("\n"); | |||
1654 | } | |||
1655 | ||||
1656 | SfxStringListItem aItem( nWhich ); | |||
1657 | if ((nWhich == SID_GETUNDOSTRINGS( 10000 + 923 )) && | |||
1658 | rSh.GetLastUndoInfo(nullptr, nullptr)) | |||
1659 | { | |||
1660 | rSh.GetDoStrings( SwWrtShell::UNDO, aItem ); | |||
1661 | } | |||
1662 | else if ((nWhich == SID_GETREDOSTRINGS( 10000 + 924 )) && | |||
1663 | (rSh.GetFirstRedoInfo(nullptr, nullptr))) | |||
1664 | { | |||
1665 | rSh.GetDoStrings( SwWrtShell::REDO, aItem ); | |||
1666 | } | |||
1667 | ||||
1668 | sList.append(aItem.GetString()); | |||
1669 | aItem.SetString( sList.makeStringAndClear() ); | |||
1670 | rSet.Put( aItem ); | |||
1671 | } | |||
1672 | else | |||
1673 | rSet.DisableItem( nWhich ); | |||
1674 | } | |||
1675 | break; | |||
1676 | ||||
1677 | default: | |||
1678 | { | |||
1679 | pSfxViewFrame->GetSlotState( nWhich, pSfxViewFrame->GetInterface(), &rSet ); | |||
1680 | break; | |||
1681 | } | |||
1682 | ||||
1683 | } | |||
1684 | ||||
1685 | if (pPostItMgr->GetActiveSidebarWin()->GetLayoutStatus()==SwPostItHelper::DELETED) | |||
1686 | rSet.DisableItem( nWhich ); | |||
1687 | ||||
1688 | nWhich = aIter.NextWhich(); | |||
1689 | } | |||
1690 | } | |||
1691 | ||||
1692 | void SwAnnotationShell::StateDisableItems( SfxItemSet &rSet ) | |||
1693 | { | |||
1694 | SfxWhichIter aIter(rSet); | |||
1695 | sal_uInt16 nWhich = aIter.FirstWhich(); | |||
1696 | while (nWhich) | |||
1697 | { | |||
1698 | rSet.DisableItem( nWhich ); | |||
1699 | nWhich = aIter.NextWhich(); | |||
1700 | } | |||
1701 | } | |||
1702 | ||||
1703 | void SwAnnotationShell::InsertSymbol(SfxRequest& rReq) | |||
1704 | { | |||
1705 | SwPostItMgr* pPostItMgr = rView.GetPostItMgr(); | |||
1706 | if ( !pPostItMgr || !pPostItMgr->HasActiveSidebarWin() ) | |||
1707 | return; | |||
1708 | ||||
1709 | OutlinerView* pOLV = pPostItMgr->GetActiveSidebarWin()->GetOutlinerView(); | |||
1710 | ||||
1711 | const SfxItemSet *pArgs = rReq.GetArgs(); | |||
1712 | const SfxPoolItem* pItem = nullptr; | |||
1713 | if( pArgs ) | |||
1714 | pArgs->GetItemState(GetPool().GetWhich(SID_CHARMAP((10000 + 500) + 3)), false, &pItem); | |||
1715 | ||||
1716 | OUString sSym; | |||
1717 | OUString sFontName; | |||
1718 | if ( pItem ) | |||
1719 | { | |||
1720 | sSym = static_cast<const SfxStringItem*>(pItem)->GetValue(); | |||
1721 | const SfxPoolItem* pFtItem = nullptr; | |||
1722 | pArgs->GetItemState( GetPool().GetWhich(SID_ATTR_SPECIALCHAR( 10000 + 1120 )), false, &pFtItem); | |||
1723 | ||||
1724 | if (const SfxStringItem* pFontItem = dynamic_cast<const SfxStringItem*>(pFtItem)) | |||
1725 | sFontName = pFontItem->GetValue(); | |||
1726 | } | |||
1727 | ||||
1728 | SfxItemSet aSet(pOLV->GetAttribs()); | |||
1729 | SvtScriptType nScript = pOLV->GetSelectedScriptType(); | |||
1730 | std::shared_ptr<SvxFontItem> aSetDlgFont(std::make_shared<SvxFontItem>(RES_CHRATR_FONT)); | |||
1731 | { | |||
1732 | SvxScriptSetItem aSetItem( SID_ATTR_CHAR_FONT( 10000 + 7 ), *aSet.GetPool() ); | |||
1733 | aSetItem.GetItemSet().Put( aSet, false ); | |||
1734 | const SfxPoolItem* pI = aSetItem.GetItemOfScript( nScript ); | |||
1735 | if( pI ) | |||
1736 | { | |||
1737 | aSetDlgFont.reset(static_cast<SvxFontItem*>(pI->Clone())); | |||
1738 | } | |||
1739 | else | |||
1740 | { | |||
1741 | aSetDlgFont.reset(static_cast<SvxFontItem*>(aSet.Get( GetWhichOfScript( | |||
1742 | SID_ATTR_CHAR_FONT( 10000 + 7 ), | |||
1743 | SvtLanguageOptions::GetI18NScriptTypeOfLanguage( GetAppLanguage() ) )).Clone())); | |||
1744 | } | |||
1745 | ||||
1746 | if (sFontName.isEmpty()) | |||
1747 | sFontName = aSetDlgFont->GetFamilyName(); | |||
1748 | } | |||
1749 | ||||
1750 | vcl::Font aFont(sFontName, Size(1,1)); | |||
1751 | if( sSym.isEmpty() ) | |||
1752 | { | |||
1753 | SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); | |||
1754 | ||||
1755 | SfxAllItemSet aAllSet( GetPool() ); | |||
1756 | aAllSet.Put( SfxBoolItem( FN_PARAM_1((20000 + 1100)+60), false ) ); | |||
1757 | ||||
1758 | SwViewOption aOpt(*rView.GetWrtShell().GetViewOptions()); | |||
1759 | const OUString& sSymbolFont = aOpt.GetSymbolFont(); | |||
1760 | if( !sSymbolFont.isEmpty() ) | |||
1761 | aAllSet.Put( SfxStringItem( SID_FONT_NAME(5000 + 1716), sSymbolFont ) ); | |||
1762 | else | |||
1763 | aAllSet.Put( SfxStringItem( SID_FONT_NAME(5000 + 1716), aSetDlgFont->GetFamilyName() ) ); | |||
1764 | ||||
1765 | // If character is selected then it can be shown. | |||
1766 | auto xFrame = rView.GetViewFrame()->GetFrame().GetFrameInterface(); | |||
1767 | ScopedVclPtr<SfxAbstractDialog> pDlg(pFact->CreateCharMapDialog(rView.GetFrameWeld(), aAllSet, xFrame)); | |||
1768 | pDlg->Execute(); | |||
1769 | return; | |||
1770 | } | |||
1771 | ||||
1772 | // do not flicker | |||
1773 | pOLV->HideCursor(); | |||
1774 | Outliner * pOutliner = pOLV->GetOutliner(); | |||
1775 | pOutliner->SetUpdateMode(false); | |||
1776 | ||||
1777 | SfxItemSet aOldSet( pOLV->GetAttribs() ); | |||
1778 | SfxItemSet aFontSet( | |||
1779 | *aOldSet.GetPool(), | |||
1780 | svl::Items< | |||
1781 | EE_CHAR_FONTINFO, EE_CHAR_FONTINFO, | |||
1782 | EE_CHAR_FONTINFO_CJK, EE_CHAR_FONTINFO_CTL>{}); | |||
1783 | aFontSet.Set( aOldSet ); | |||
1784 | ||||
1785 | // Insert string | |||
1786 | pOLV->InsertText( sSym); | |||
1787 | ||||
1788 | // Attributing (set font) | |||
1789 | SfxItemSet aSetFont( *aFontSet.GetPool(), aFontSet.GetRanges() ); | |||
1790 | SvxFontItem aFontItem (aFont.GetFamilyType(), aFont.GetFamilyName(), | |||
1791 | aFont.GetStyleName(), aFont.GetPitch(), | |||
1792 | aFont.GetCharSet(), | |||
1793 | EE_CHAR_FONTINFO ); | |||
1794 | SvtScriptType nScriptBreak = g_pBreakIt->GetAllScriptsOfText( sSym ); | |||
1795 | if( SvtScriptType::LATIN & nScriptBreak ) | |||
1796 | aSetFont.Put( aFontItem ); | |||
1797 | if( SvtScriptType::ASIAN & nScriptBreak ) | |||
1798 | { | |||
1799 | aFontItem.SetWhich(EE_CHAR_FONTINFO_CJK); | |||
1800 | aSetFont.Put( aFontItem ); | |||
1801 | } | |||
1802 | if( SvtScriptType::COMPLEX & nScriptBreak ) | |||
1803 | { | |||
1804 | aFontItem.SetWhich(EE_CHAR_FONTINFO_CTL); | |||
1805 | aSetFont.Put( aFontItem ); | |||
1806 | } | |||
1807 | pOLV->SetAttribs(aSetFont); | |||
1808 | ||||
1809 | // Erase selection | |||
1810 | ESelection aSel(pOLV->GetSelection()); | |||
1811 | aSel.nStartPara = aSel.nEndPara; | |||
1812 | aSel.nStartPos = aSel.nEndPos; | |||
1813 | pOLV->SetSelection(aSel); | |||
1814 | ||||
1815 | // Restore old font | |||
1816 | pOLV->SetAttribs( aFontSet ); | |||
1817 | ||||
1818 | // From now on show it again | |||
1819 | pOutliner->SetUpdateMode(true); | |||
1820 | pOLV->ShowCursor(); | |||
1821 | ||||
1822 | rReq.AppendItem( SfxStringItem( GetPool().GetWhich(SID_CHARMAP((10000 + 500) + 3)), sSym ) ); | |||
1823 | if(!aFont.GetFamilyName().isEmpty()) | |||
1824 | rReq.AppendItem( SfxStringItem( SID_ATTR_SPECIALCHAR( 10000 + 1120 ), aFont.GetFamilyName() ) ); | |||
1825 | rReq.Done(); | |||
1826 | ||||
1827 | } | |||
1828 | ||||
1829 | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |