/src/libreoffice/svx/source/toolbars/fontworkbar.cxx
Line | Count | Source |
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 <svx/svdundo.hxx> |
21 | | #include <sfx2/request.hxx> |
22 | | #include <sfx2/objface.hxx> |
23 | | #include <sfx2/toolbarids.hxx> |
24 | | #include <sfx2/viewsh.hxx> |
25 | | #include <svx/unoapi.hxx> |
26 | | #include <com/sun/star/drawing/XShape.hpp> |
27 | | #include <com/sun/star/drawing/XEnhancedCustomShapeDefaulter.hpp> |
28 | | #include <sal/log.hxx> |
29 | | #include <svx/dialmgr.hxx> |
30 | | #include <svx/svdoashp.hxx> |
31 | | #include <svx/strings.hrc> |
32 | | #include <svx/svdpage.hxx> |
33 | | #include <svx/svdview.hxx> |
34 | | #include <svx/sdasitm.hxx> |
35 | | #include <svx/gallery.hxx> |
36 | | #include <svx/fmmodel.hxx> |
37 | | #include <svx/sdtfsitm.hxx> |
38 | | #include <svl/itempool.hxx> |
39 | | #include <svl/stritem.hxx> |
40 | | #include <sfx2/bindings.hxx> |
41 | | #include <editeng/eeitem.hxx> |
42 | | #include <editeng/charscaleitem.hxx> |
43 | | #include <editeng/kernitem.hxx> |
44 | | |
45 | | #include <svx/svxids.hrc> |
46 | | #include <svx/fontworkbar.hxx> |
47 | | #include <svx/fontworkgallery.hxx> |
48 | | #include <tools/debug.hxx> |
49 | | |
50 | | |
51 | | using namespace ::svx; |
52 | | using namespace ::com::sun::star; |
53 | | using namespace ::com::sun::star::beans; |
54 | | using namespace ::com::sun::star::uno; |
55 | | |
56 | | static void SetAlignmentState( SdrView const * pSdrView, SfxItemSet& rSet ) |
57 | 0 | { |
58 | 0 | const SdrMarkList& rMarkList = pSdrView->GetMarkedObjectList(); |
59 | 0 | const size_t nCount = rMarkList.GetMarkCount(); |
60 | |
|
61 | 0 | sal_Int32 nAlignment = -1; |
62 | 0 | for( size_t i = 0; i < nCount; ++i ) |
63 | 0 | { |
64 | 0 | SdrObject* pObj = rMarkList.GetMark( i )->GetMarkedSdrObj(); |
65 | 0 | if( dynamic_cast<const SdrObjCustomShape*>( pObj) != nullptr ) |
66 | 0 | { |
67 | 0 | sal_Int32 nOldAlignment = nAlignment; |
68 | 0 | const SdrTextHorzAdjustItem& rTextHorzAdjustItem = pObj->GetMergedItem( SDRATTR_TEXT_HORZADJUST ); |
69 | 0 | const SdrTextFitToSizeTypeItem& rTextFitToSizeTypeItem = pObj->GetMergedItem( SDRATTR_TEXT_FITTOSIZE ); |
70 | 0 | switch ( rTextHorzAdjustItem.GetValue() ) |
71 | 0 | { |
72 | 0 | case SDRTEXTHORZADJUST_LEFT : nAlignment = 0; break; |
73 | 0 | case SDRTEXTHORZADJUST_CENTER : nAlignment = 1; break; |
74 | 0 | case SDRTEXTHORZADJUST_RIGHT : nAlignment = 2; break; |
75 | 0 | case SDRTEXTHORZADJUST_BLOCK : |
76 | 0 | { |
77 | 0 | auto const fit(rTextFitToSizeTypeItem.GetValue()); |
78 | 0 | if (fit == drawing::TextFitToSizeType_NONE) |
79 | 0 | { |
80 | 0 | nAlignment = 3; |
81 | 0 | } |
82 | 0 | else if (fit == drawing::TextFitToSizeType_ALLLINES || |
83 | 0 | fit == drawing::TextFitToSizeType_PROPORTIONAL) |
84 | 0 | { |
85 | 0 | nAlignment = 4; |
86 | 0 | } |
87 | 0 | } |
88 | 0 | } |
89 | 0 | if ( ( nOldAlignment != -1 ) && ( nOldAlignment != nAlignment ) ) |
90 | 0 | { |
91 | 0 | nAlignment = -1; |
92 | 0 | break; |
93 | 0 | } |
94 | 0 | } |
95 | 0 | } |
96 | 0 | rSet.Put( SfxInt32Item( SID_FONTWORK_ALIGNMENT, nAlignment ) ); |
97 | 0 | } |
98 | | |
99 | | static void SetCharacterSpacingState( SdrView const * pSdrView, SfxItemSet& rSet ) |
100 | 0 | { |
101 | 0 | const SdrMarkList& rMarkList = pSdrView->GetMarkedObjectList(); |
102 | 0 | const size_t nCount = rMarkList.GetMarkCount(); |
103 | |
|
104 | 0 | sal_Int32 nCharacterSpacing = -1; |
105 | 0 | for( size_t i = 0; i < nCount; ++i ) |
106 | 0 | { |
107 | 0 | SdrObject* pObj = rMarkList.GetMark( i )->GetMarkedSdrObj(); |
108 | 0 | if( dynamic_cast<const SdrObjCustomShape*>( pObj) != nullptr ) |
109 | 0 | { |
110 | 0 | sal_Int32 nOldCharacterSpacing = nCharacterSpacing; |
111 | 0 | const SvxCharScaleWidthItem& rCharScaleWidthItem = pObj->GetMergedItem( EE_CHAR_FONTWIDTH ); |
112 | 0 | nCharacterSpacing = rCharScaleWidthItem.GetValue(); |
113 | 0 | if ( ( nOldCharacterSpacing != -1 ) && ( nOldCharacterSpacing != nCharacterSpacing ) ) |
114 | 0 | { |
115 | 0 | nCharacterSpacing = -1; |
116 | 0 | break; |
117 | 0 | } |
118 | 0 | } |
119 | 0 | } |
120 | 0 | rSet.Put( SfxInt32Item( SID_FONTWORK_CHARACTER_SPACING, nCharacterSpacing ) ); |
121 | 0 | } |
122 | | |
123 | | |
124 | | static void SetKernCharacterPairsState( SdrView const * pSdrView, SfxItemSet& rSet ) |
125 | 0 | { |
126 | 0 | const SdrMarkList& rMarkList = pSdrView->GetMarkedObjectList(); |
127 | 0 | const size_t nCount = rMarkList.GetMarkCount(); |
128 | |
|
129 | 0 | bool bChecked = false; |
130 | 0 | for( size_t i = 0; i < nCount; ++i ) |
131 | 0 | { |
132 | 0 | SdrObject* pObj = rMarkList.GetMark( i )->GetMarkedSdrObj(); |
133 | 0 | if( dynamic_cast<const SdrObjCustomShape*>( pObj) != nullptr ) |
134 | 0 | { |
135 | 0 | const SvxKerningItem& rKerningItem = pObj->GetMergedItem( EE_CHAR_KERNING ); |
136 | 0 | if ( rKerningItem.GetValue() ) |
137 | 0 | bChecked = true; |
138 | 0 | } |
139 | 0 | } |
140 | 0 | rSet.Put( SfxBoolItem( SID_FONTWORK_KERN_CHARACTER_PAIRS, bChecked ) ); |
141 | 0 | } |
142 | | |
143 | | static void SetFontWorkShapeTypeState( SdrView const * pSdrView, SfxItemSet& rSet ) |
144 | 0 | { |
145 | 0 | const SdrMarkList& rMarkList = pSdrView->GetMarkedObjectList(); |
146 | 0 | const size_t nCount = rMarkList.GetMarkCount(); |
147 | |
|
148 | 0 | OUString aFontWorkShapeType; |
149 | |
|
150 | 0 | for( size_t i = 0; i < nCount; ++i ) |
151 | 0 | { |
152 | 0 | SdrObject* pObj = rMarkList.GetMark( i )->GetMarkedSdrObj(); |
153 | 0 | if( dynamic_cast<const SdrObjCustomShape*>( pObj) != nullptr ) |
154 | 0 | { |
155 | 0 | const SdrCustomShapeGeometryItem & rGeometryItem( pObj->GetMergedItem( SDRATTR_CUSTOMSHAPE_GEOMETRY ) ); |
156 | 0 | const Any* pAny = rGeometryItem.GetPropertyValueByName( u"Type"_ustr ); |
157 | 0 | if( pAny ) |
158 | 0 | { |
159 | 0 | OUString aType; |
160 | 0 | if ( *pAny >>= aType ) |
161 | 0 | { |
162 | 0 | if ( !aFontWorkShapeType.isEmpty() ) |
163 | 0 | { |
164 | 0 | if ( aFontWorkShapeType != aType ) // different FontWorkShapeTypes selected ? |
165 | 0 | { |
166 | 0 | aFontWorkShapeType.clear(); |
167 | 0 | break; |
168 | 0 | } |
169 | 0 | } |
170 | 0 | aFontWorkShapeType = aType; |
171 | 0 | } |
172 | 0 | } |
173 | 0 | } |
174 | 0 | } |
175 | 0 | rSet.Put( SfxStringItem( SID_FONTWORK_SHAPE_TYPE, aFontWorkShapeType ) ); |
176 | 0 | } |
177 | | |
178 | | // Declare the default interface. (The slotmap must not be empty, so |
179 | | // we enter something which never occurs here (hopefully).) |
180 | | constexpr SfxSlot aFontworkBarSlots_Impl[] = |
181 | | { |
182 | | { 0, SfxGroupId::NONE, SfxSlotMode::NONE, 0, 0, nullptr, nullptr, nullptr, nullptr, nullptr, 0, SfxDisableFlags::NONE, u""_ustr } |
183 | | }; |
184 | | |
185 | | SFX_IMPL_INTERFACE(FontworkBar, SfxShell) |
186 | | |
187 | | void FontworkBar::InitInterface_Impl() |
188 | 0 | { |
189 | 0 | GetStaticInterface()->RegisterObjectBar(SFX_OBJECTBAR_OBJECT, SfxVisibilityFlags::Invisible, ToolbarId::Svx_Fontwork_Bar); |
190 | 0 | } |
191 | | |
192 | | |
193 | | FontworkBar::FontworkBar(SfxViewShell* pViewShell ) |
194 | 0 | : SfxShell(pViewShell) |
195 | 0 | { |
196 | 0 | DBG_ASSERT( pViewShell, "svx::FontworkBar::FontworkBar(), I need a viewshell!" ); |
197 | 0 | if( pViewShell ) |
198 | 0 | SetPool(&pViewShell->GetPool()); |
199 | |
|
200 | 0 | SetName( SvxResId( RID_SVX_FONTWORK_BAR )); |
201 | 0 | } |
202 | | |
203 | | FontworkBar::~FontworkBar() |
204 | 0 | { |
205 | 0 | SetRepeatTarget(nullptr); |
206 | 0 | } |
207 | | |
208 | | namespace svx { |
209 | | bool checkForFontWork( const SdrObject* pObj ) |
210 | 0 | { |
211 | 0 | static constexpr OUString sTextPath = u"TextPath"_ustr; |
212 | 0 | bool bFound = false; |
213 | |
|
214 | 0 | if( dynamic_cast<const SdrObjCustomShape*>( pObj) != nullptr ) |
215 | 0 | { |
216 | 0 | const SdrCustomShapeGeometryItem & rGeometryItem( pObj->GetMergedItem( SDRATTR_CUSTOMSHAPE_GEOMETRY ) ); |
217 | 0 | const Any* pAny = rGeometryItem.GetPropertyValueByName( sTextPath, sTextPath ); |
218 | 0 | if( pAny ) |
219 | 0 | *pAny >>= bFound; |
220 | 0 | } |
221 | |
|
222 | 0 | return bFound; |
223 | 0 | } |
224 | | |
225 | | bool checkForSelectedFontWork( SdrView const * pSdrView ) |
226 | 0 | { |
227 | 0 | const SdrMarkList& rMarkList = pSdrView->GetMarkedObjectList(); |
228 | 0 | const size_t nCount = rMarkList.GetMarkCount(); |
229 | 0 | bool bFound = false; |
230 | 0 | for(size_t i=0; (i<nCount) && !bFound ; ++i) |
231 | 0 | { |
232 | 0 | SdrObject* pObj = rMarkList.GetMark(i)->GetMarkedSdrObj(); |
233 | 0 | bFound = checkForFontWork(pObj); |
234 | 0 | } |
235 | 0 | return bFound; |
236 | 0 | } |
237 | | |
238 | | static void impl_execute( SfxRequest const & rReq, SdrCustomShapeGeometryItem& rGeometryItem, SdrObject* pObj ) |
239 | 0 | { |
240 | 0 | sal_uInt16 nSID = rReq.GetSlot(); |
241 | 0 | switch( nSID ) |
242 | 0 | { |
243 | 0 | case SID_FONTWORK_SAME_LETTER_HEIGHTS: |
244 | 0 | { |
245 | 0 | css::uno::Any* pAny = rGeometryItem.GetPropertyValueByName( u"TextPath"_ustr, u"SameLetterHeights"_ustr ); |
246 | |
|
247 | 0 | bool bOn = false; |
248 | 0 | if( pAny ) |
249 | 0 | (*pAny) >>= bOn; |
250 | 0 | bOn = !bOn; |
251 | 0 | css::beans::PropertyValue aPropValue; |
252 | 0 | aPropValue.Name = "SameLetterHeights"; |
253 | 0 | aPropValue.Value <<= bOn; |
254 | 0 | rGeometryItem.SetPropertyValue(u"TextPath"_ustr, aPropValue); |
255 | 0 | } |
256 | 0 | break; |
257 | | |
258 | 0 | case SID_FONTWORK_ALIGNMENT: |
259 | 0 | { |
260 | 0 | const SfxInt32Item* pAlignItem = nullptr; |
261 | 0 | if( rReq.GetArgs() && rReq.GetArgs()->GetItemState( SID_FONTWORK_ALIGNMENT, true, &pAlignItem ) == SfxItemState::SET ) |
262 | 0 | { |
263 | 0 | sal_Int32 nValue = pAlignItem->GetValue(); |
264 | 0 | if ( ( nValue >= 0 ) && ( nValue < 5 ) ) |
265 | 0 | { |
266 | 0 | drawing::TextFitToSizeType eFTS = drawing::TextFitToSizeType_NONE; |
267 | 0 | SdrTextHorzAdjust eHorzAdjust; |
268 | 0 | switch ( nValue ) |
269 | 0 | { |
270 | 0 | case 4 : eFTS = drawing::TextFitToSizeType_ALLLINES; [[fallthrough]]; |
271 | 0 | case 3 : eHorzAdjust = SDRTEXTHORZADJUST_BLOCK; break; |
272 | 0 | default: eHorzAdjust = SDRTEXTHORZADJUST_LEFT; break; |
273 | 0 | case 1 : eHorzAdjust = SDRTEXTHORZADJUST_CENTER; break; |
274 | 0 | case 2 : eHorzAdjust = SDRTEXTHORZADJUST_RIGHT; break; |
275 | 0 | } |
276 | 0 | pObj->SetMergedItem( SdrTextHorzAdjustItem( eHorzAdjust ) ); |
277 | 0 | pObj->SetMergedItem( SdrTextFitToSizeTypeItem( eFTS ) ); |
278 | 0 | pObj->BroadcastObjectChange(); |
279 | 0 | } |
280 | 0 | } |
281 | 0 | } |
282 | 0 | break; |
283 | | |
284 | 0 | case SID_FONTWORK_CHARACTER_SPACING: |
285 | 0 | { |
286 | 0 | const SfxInt32Item* pSpacingItem = nullptr; |
287 | 0 | if( rReq.GetArgs() && ( rReq.GetArgs()->GetItemState( SID_FONTWORK_CHARACTER_SPACING, true, &pSpacingItem ) == SfxItemState::SET ) ) |
288 | 0 | { |
289 | 0 | sal_Int32 nCharSpacing = pSpacingItem->GetValue(); |
290 | 0 | pObj->SetMergedItem( SvxCharScaleWidthItem( static_cast<sal_uInt16>(nCharSpacing), EE_CHAR_FONTWIDTH ) ); |
291 | 0 | pObj->BroadcastObjectChange(); |
292 | 0 | } |
293 | 0 | } |
294 | 0 | break; |
295 | | |
296 | 0 | case SID_FONTWORK_KERN_CHARACTER_PAIRS: |
297 | 0 | { |
298 | 0 | if( rReq.GetArgs() && ( rReq.GetArgs()->GetItemState( SID_FONTWORK_KERN_CHARACTER_PAIRS ) == SfxItemState::SET ) ) |
299 | 0 | { |
300 | | // sal_Bool bKernCharacterPairs = ((const SfxBoolItem*)rReq.GetArgs()->GetItem(SID_FONTWORK_KERN_CHARACTER_PAIRS))->GetValue(); |
301 | | //TODO: pObj->SetMergedItem( SvxCharScaleWidthItem( (sal_uInt16)nCharSpacing, EE_CHAR_FONTWIDTH ) ); |
302 | 0 | pObj->BroadcastObjectChange(); |
303 | 0 | } |
304 | 0 | } |
305 | 0 | break; |
306 | 0 | } |
307 | 0 | } |
308 | | |
309 | | static void GetGeometryForCustomShape( SdrCustomShapeGeometryItem& rGeometryItem, const OUString& rCustomShape ) |
310 | 0 | { |
311 | 0 | static constexpr OUString sType( u"Type"_ustr ); |
312 | |
|
313 | 0 | css::beans::PropertyValue aPropVal; |
314 | 0 | aPropVal.Name = sType; |
315 | 0 | aPropVal.Value <<= rCustomShape; |
316 | 0 | rGeometryItem.SetPropertyValue( aPropVal ); |
317 | |
|
318 | 0 | static constexpr OUString sAdjustmentValues( u"AdjustmentValues"_ustr ); |
319 | 0 | static constexpr OUString sCoordinateOrigin( u"CoordinateOrigin"_ustr ); |
320 | 0 | static constexpr OUString sCoordinateSize( u"CoordinateSize"_ustr ); |
321 | 0 | static constexpr OUString sEquations( u"Equations"_ustr ); |
322 | 0 | static constexpr OUString sHandles( u"Handles"_ustr ); |
323 | 0 | static constexpr OUString sPath( u"Path"_ustr ); |
324 | 0 | rGeometryItem.ClearPropertyValue( sAdjustmentValues ); |
325 | 0 | rGeometryItem.ClearPropertyValue( sCoordinateOrigin ); |
326 | 0 | rGeometryItem.ClearPropertyValue( sCoordinateSize ); |
327 | 0 | rGeometryItem.ClearPropertyValue( sEquations ); |
328 | 0 | rGeometryItem.ClearPropertyValue( sHandles ); |
329 | 0 | rGeometryItem.ClearPropertyValue( sPath ); |
330 | | |
331 | | /* SJ: CustomShapes that are available in the gallery are having the highest |
332 | | priority, so we will take a look there before taking the internal default */ |
333 | |
|
334 | 0 | if ( !GalleryExplorer::GetSdrObjCount( GALLERY_THEME_POWERPOINT ) ) |
335 | 0 | return; |
336 | | |
337 | 0 | std::vector< OUString > aObjList; |
338 | 0 | if ( !GalleryExplorer::FillObjListTitle( GALLERY_THEME_POWERPOINT, aObjList ) ) |
339 | 0 | return; |
340 | | |
341 | 0 | for ( std::vector<OUString>::size_type i = 0; i < aObjList.size(); i++ ) |
342 | 0 | { |
343 | 0 | if ( aObjList[ i ].equalsIgnoreAsciiCase( rCustomShape ) ) |
344 | 0 | { |
345 | 0 | FmFormModel aFormModel; |
346 | |
|
347 | 0 | if ( GalleryExplorer::GetSdrObj( GALLERY_THEME_POWERPOINT, i, &aFormModel ) ) |
348 | 0 | { |
349 | 0 | const SdrObject* pSourceObj = nullptr; |
350 | 0 | if (aFormModel.GetPageCount() > 0) |
351 | 0 | pSourceObj = aFormModel.GetPage( 0 )->GetObj( 0 ); |
352 | 0 | SAL_WARN_IF(!pSourceObj, "svx.form", "No content in gallery custom shape '" << rCustomShape << "'" ); |
353 | 0 | if( pSourceObj ) |
354 | 0 | { |
355 | 0 | PropertyValue aPropVal_; |
356 | 0 | const SdrCustomShapeGeometryItem& rSourceGeometry = pSourceObj->GetMergedItem( SDRATTR_CUSTOMSHAPE_GEOMETRY ); |
357 | 0 | const css::uno::Any* pAny = rSourceGeometry.GetPropertyValueByName( sType ); |
358 | 0 | if ( pAny ) |
359 | 0 | { |
360 | 0 | aPropVal_.Name = sType; |
361 | 0 | aPropVal_.Value = *pAny; |
362 | 0 | rGeometryItem.SetPropertyValue( aPropVal_ ); |
363 | 0 | } |
364 | 0 | pAny = rSourceGeometry.GetPropertyValueByName( sAdjustmentValues ); |
365 | 0 | if ( pAny ) |
366 | 0 | { |
367 | 0 | aPropVal_.Name = sAdjustmentValues; |
368 | 0 | aPropVal_.Value = *pAny; |
369 | 0 | rGeometryItem.SetPropertyValue( aPropVal_ ); |
370 | 0 | } |
371 | 0 | pAny = rSourceGeometry.GetPropertyValueByName( sCoordinateOrigin ); |
372 | 0 | if ( pAny ) |
373 | 0 | { |
374 | 0 | aPropVal_.Name = sCoordinateOrigin; |
375 | 0 | aPropVal_.Value = *pAny; |
376 | 0 | rGeometryItem.SetPropertyValue( aPropVal_ ); |
377 | 0 | } |
378 | 0 | pAny = rSourceGeometry.GetPropertyValueByName( sCoordinateSize ); |
379 | 0 | if ( pAny ) |
380 | 0 | { |
381 | 0 | aPropVal_.Name = sCoordinateSize; |
382 | 0 | aPropVal_.Value = *pAny; |
383 | 0 | rGeometryItem.SetPropertyValue( aPropVal_ ); |
384 | 0 | } |
385 | 0 | pAny = rSourceGeometry.GetPropertyValueByName( sEquations ); |
386 | 0 | if ( pAny ) |
387 | 0 | { |
388 | 0 | aPropVal_.Name = sEquations; |
389 | 0 | aPropVal_.Value = *pAny; |
390 | 0 | rGeometryItem.SetPropertyValue( aPropVal_ ); |
391 | 0 | } |
392 | 0 | pAny = rSourceGeometry.GetPropertyValueByName( sHandles ); |
393 | 0 | if ( pAny ) |
394 | 0 | { |
395 | 0 | aPropVal_.Name = sHandles; |
396 | 0 | aPropVal_.Value = *pAny; |
397 | 0 | rGeometryItem.SetPropertyValue( aPropVal_ ); |
398 | 0 | } |
399 | 0 | pAny = rSourceGeometry.GetPropertyValueByName( sPath ); |
400 | 0 | if ( pAny ) |
401 | 0 | { |
402 | 0 | aPropVal_.Name = sPath; |
403 | 0 | aPropVal_.Value = *pAny; |
404 | 0 | rGeometryItem.SetPropertyValue( aPropVal_ ); |
405 | 0 | } |
406 | 0 | } |
407 | 0 | } |
408 | 0 | } |
409 | 0 | } |
410 | 0 | } |
411 | | |
412 | | |
413 | | void FontworkBar::execute( SdrView& rSdrView, SfxRequest const & rReq, SfxBindings& rBindings ) |
414 | 0 | { |
415 | 0 | TranslateId pStrResId; |
416 | |
|
417 | 0 | sal_uInt16 nSID = rReq.GetSlot(); |
418 | 0 | switch( nSID ) |
419 | 0 | { |
420 | 0 | case SID_FONTWORK_GALLERY_FLOATER: |
421 | 0 | { |
422 | 0 | std::shared_ptr<FontWorkGalleryDialog> pDlg = std::make_shared<FontWorkGalleryDialog>(rReq.GetFrameWeld(), rSdrView, rBindings.GetActiveFrame()); |
423 | 0 | weld::DialogController::runAsync(pDlg, [](int){}); |
424 | 0 | } |
425 | 0 | break; |
426 | | |
427 | 0 | case SID_FONTWORK_SHAPE_TYPE: |
428 | 0 | { |
429 | 0 | OUString aCustomShape; |
430 | 0 | const SfxItemSet* pArgs = rReq.GetArgs(); |
431 | 0 | if ( pArgs ) |
432 | 0 | { |
433 | 0 | const SfxStringItem& rItm = static_cast<const SfxStringItem&>(pArgs->Get( rReq.GetSlot() )); |
434 | 0 | aCustomShape = rItm.GetValue(); |
435 | 0 | } |
436 | 0 | if ( !aCustomShape.isEmpty() ) |
437 | 0 | { |
438 | 0 | const SdrMarkList& rMarkList = rSdrView.GetMarkedObjectList(); |
439 | 0 | const size_t nCount = rMarkList.GetMarkCount(); |
440 | 0 | for( size_t i = 0; i < nCount; ++i ) |
441 | 0 | { |
442 | 0 | SdrObject* pObj = rMarkList.GetMark( i )->GetMarkedSdrObj(); |
443 | 0 | if( auto pCustomShape = dynamic_cast<SdrObjCustomShape*>( pObj) ) |
444 | 0 | { |
445 | 0 | const bool bUndo = rSdrView.IsUndoEnabled(); |
446 | |
|
447 | 0 | if( bUndo ) |
448 | 0 | { |
449 | 0 | OUString aStr( SvxResId( RID_SVXSTR_UNDO_APPLY_FONTWORK_SHAPE ) ); |
450 | 0 | rSdrView.BegUndo(aStr); |
451 | 0 | rSdrView.AddUndo(rSdrView.GetModel().GetSdrUndoFactory().CreateUndoAttrObject(*pObj)); |
452 | 0 | } |
453 | 0 | SdrCustomShapeGeometryItem aGeometryItem( pObj->GetMergedItem( SDRATTR_CUSTOMSHAPE_GEOMETRY ) ); |
454 | 0 | GetGeometryForCustomShape( aGeometryItem, aCustomShape ); |
455 | 0 | pObj->SetMergedItem( aGeometryItem ); |
456 | |
|
457 | 0 | Reference< drawing::XShape > aXShape = GetXShapeForSdrObject( pCustomShape ); |
458 | 0 | if ( aXShape.is() ) |
459 | 0 | { |
460 | 0 | Reference< drawing::XEnhancedCustomShapeDefaulter > xDefaulter( aXShape, UNO_QUERY ); |
461 | 0 | if( xDefaulter.is() ) |
462 | 0 | xDefaulter->createCustomShapeDefaults( aCustomShape ); |
463 | 0 | } |
464 | |
|
465 | 0 | pObj->BroadcastObjectChange(); |
466 | 0 | if (bUndo) |
467 | 0 | rSdrView.EndUndo(); |
468 | 0 | rSdrView.AdjustMarkHdl(); //HMH sal_True ); |
469 | 0 | rBindings.Invalidate( SID_FONTWORK_SHAPE_TYPE ); |
470 | 0 | } |
471 | 0 | } |
472 | 0 | } |
473 | 0 | } |
474 | 0 | break; |
475 | | |
476 | 0 | case SID_FONTWORK_CHARACTER_SPACING_DIALOG : |
477 | 0 | { |
478 | 0 | const SfxInt32Item* pSpacingItem = nullptr; |
479 | 0 | if( rReq.GetArgs() && ( rReq.GetArgs()->GetItemState( SID_FONTWORK_CHARACTER_SPACING, true, &pSpacingItem ) == SfxItemState::SET ) ) |
480 | 0 | { |
481 | 0 | sal_Int32 nCharSpacing = pSpacingItem->GetValue(); |
482 | 0 | FontworkCharacterSpacingDialog aDlg(rReq.GetFrameWeld(), nCharSpacing); |
483 | 0 | sal_uInt16 nRet = aDlg.run(); |
484 | 0 | if (nRet != RET_CANCEL) |
485 | 0 | { |
486 | 0 | SfxInt32Item aItem(SID_FONTWORK_CHARACTER_SPACING, aDlg.getScale()); |
487 | 0 | const SfxPoolItem* aItems[] = { &aItem, nullptr }; |
488 | 0 | rBindings.Execute( SID_FONTWORK_CHARACTER_SPACING, aItems ); |
489 | 0 | } |
490 | 0 | } |
491 | 0 | } |
492 | 0 | break; |
493 | | |
494 | 0 | case SID_FONTWORK_SHAPE: |
495 | 0 | case SID_FONTWORK_ALIGNMENT: |
496 | 0 | { |
497 | 0 | if ( !pStrResId ) |
498 | 0 | pStrResId = RID_SVXSTR_UNDO_APPLY_FONTWORK_ALIGNMENT; |
499 | 0 | [[fallthrough]]; |
500 | 0 | } |
501 | 0 | case SID_FONTWORK_CHARACTER_SPACING: |
502 | 0 | { |
503 | 0 | if ( !pStrResId ) |
504 | 0 | pStrResId = RID_SVXSTR_UNDO_APPLY_FONTWORK_CHARACTER_SPACING; |
505 | 0 | [[fallthrough]]; |
506 | 0 | } |
507 | 0 | case SID_FONTWORK_KERN_CHARACTER_PAIRS: |
508 | 0 | { |
509 | 0 | if ( !pStrResId ) |
510 | 0 | pStrResId = RID_SVXSTR_UNDO_APPLY_FONTWORK_CHARACTER_SPACING; |
511 | 0 | [[fallthrough]]; |
512 | 0 | } |
513 | 0 | case SID_FONTWORK_SAME_LETTER_HEIGHTS: |
514 | 0 | { |
515 | 0 | if ( !pStrResId ) |
516 | 0 | pStrResId = RID_SVXSTR_UNDO_APPLY_FONTWORK_SAME_LETTER_HEIGHT; |
517 | |
|
518 | 0 | const SdrMarkList& rMarkList = rSdrView.GetMarkedObjectList(); |
519 | 0 | const size_t nCount = rMarkList.GetMarkCount(); |
520 | 0 | for( size_t i = 0; i < nCount; ++i ) |
521 | 0 | { |
522 | 0 | SdrObject* pObj = rMarkList.GetMark(i)->GetMarkedSdrObj(); |
523 | 0 | if( dynamic_cast<const SdrObjCustomShape*>( pObj) != nullptr ) |
524 | 0 | { |
525 | 0 | const bool bUndo = rSdrView.IsUndoEnabled(); |
526 | 0 | if( bUndo ) |
527 | 0 | { |
528 | 0 | OUString aStr( SvxResId( pStrResId ) ); |
529 | 0 | rSdrView.BegUndo(aStr); |
530 | 0 | rSdrView.AddUndo(rSdrView.GetModel().GetSdrUndoFactory().CreateUndoAttrObject(*pObj)); |
531 | 0 | } |
532 | 0 | SdrCustomShapeGeometryItem aGeometryItem( pObj->GetMergedItem( SDRATTR_CUSTOMSHAPE_GEOMETRY ) ); |
533 | 0 | impl_execute( rReq, aGeometryItem, pObj ); |
534 | 0 | pObj->SetMergedItem( aGeometryItem ); |
535 | 0 | pObj->BroadcastObjectChange(); |
536 | 0 | if (bUndo) |
537 | 0 | rSdrView.EndUndo(); |
538 | 0 | } |
539 | 0 | } |
540 | 0 | } |
541 | 0 | break; |
542 | 0 | } |
543 | 0 | } |
544 | | |
545 | | void FontworkBar::getState( SdrView const * pSdrView, SfxItemSet& rSet ) |
546 | 0 | { |
547 | 0 | if ( checkForSelectedFontWork( pSdrView ) ) |
548 | 0 | { |
549 | 0 | SetAlignmentState( pSdrView, rSet ); |
550 | 0 | SetCharacterSpacingState( pSdrView, rSet ); |
551 | 0 | SetKernCharacterPairsState( pSdrView, rSet ); |
552 | 0 | SetFontWorkShapeTypeState( pSdrView, rSet ); |
553 | 0 | } |
554 | 0 | else |
555 | 0 | { |
556 | 0 | rSet.DisableItem( SID_FONTWORK_ALIGNMENT_FLOATER ); |
557 | 0 | rSet.DisableItem( SID_FONTWORK_ALIGNMENT ); |
558 | 0 | rSet.DisableItem( SID_FONTWORK_CHARACTER_SPACING_FLOATER ); |
559 | 0 | rSet.DisableItem( SID_FONTWORK_CHARACTER_SPACING ); |
560 | 0 | rSet.DisableItem( SID_FONTWORK_KERN_CHARACTER_PAIRS ); |
561 | 0 | rSet.DisableItem( SID_FONTWORK_SAME_LETTER_HEIGHTS ); |
562 | 0 | rSet.DisableItem( SID_FONTWORK_SHAPE_TYPE ); |
563 | 0 | } |
564 | 0 | } |
565 | | } |
566 | | |
567 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |