LibreOffice Module sd (master) 1
drviewsf.cxx
Go to the documentation of this file.
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 <DrawViewShell.hxx>
21#include <com/sun/star/form/FormButtonType.hpp>
22#include <com/sun/star/beans/XPropertySet.hpp>
23#include <comphelper/string.hxx>
24#include <svx/svxids.hrc>
25#include <svx/sdmetitm.hxx>
26#include <svx/hlnkitem.hxx>
27#include <editeng/eeitem.hxx>
28#include <editeng/flditem.hxx>
29#include <editeng/udlnitem.hxx>
30#include <sfx2/viewfrm.hxx>
31#include <svl/whiter.hxx>
32#include <svl/eitem.hxx>
33#include <svl/intitem.hxx>
34#include <svl/itempool.hxx>
35#include <sfx2/tplpitem.hxx>
36#include <sfx2/bindings.hxx>
37#include <svx/xdef.hxx>
38#include <svx/svdoutl.hxx>
39#include <svx/svdouno.hxx>
40#include <svx/fmshell.hxx>
41#include <svl/cjkoptions.hxx>
42
43#include <app.hrc>
44
45#include <sdmod.hxx>
46#include <stlsheet.hxx>
47#include <drawview.hxx>
48#include <drawdoc.hxx>
49#include <Window.hxx>
50#include <ViewShellBase.hxx>
51#include <FormShellManager.hxx>
52#include <anminfo.hxx>
53
54#include <editeng/lspcitem.hxx>
55#include <editeng/ulspitem.hxx>
56#include <editeng/lrspitem.hxx>
58#include <editeng/numitem.hxx>
61#include <svx/nbdtmgfact.hxx>
62#include <svx/nbdtmg.hxx>
63#include <memory>
64
65using namespace com::sun::star::drawing;
66using namespace svx::sidebar;
67using namespace ::com::sun::star;
68
69namespace sd {
70
75{
76 if (rSet.GetItemState(SID_RELOAD) != SfxItemState::UNKNOWN)
77 {
78 // let "last version" of SFx en/disable
79 GetViewFrame()->GetSlotState (SID_RELOAD, nullptr, &rSet);
80 }
81
82 if (SfxItemState::DEFAULT == rSet.GetItemState(SID_HYPERLINK_GETLINK))
83 {
84 SvxHyperlinkItem aHLinkItem;
85
86 OutlinerView* pOLV = mpDrawView->GetTextEditOutlinerView();
87
88 if (pOLV)
89 {
90 const SvxFieldData* pField = pOLV->GetFieldAtCursor();
91 if( auto pUrlField = dynamic_cast< const SvxURLField *>( pField ) )
92 {
93 aHLinkItem.SetName(pUrlField->GetRepresentation());
94 aHLinkItem.SetURL(pUrlField->GetURL());
95 aHLinkItem.SetTargetFrame(pUrlField->GetTargetFrame());
96 }
97 else
98 {
99 // use selected text as name for urls
100 OUString sReturn = pOLV->GetSelected();
101 if (sReturn.getLength() > 255)
102 sReturn = sReturn.copy(0, 255);
103 aHLinkItem.SetName(comphelper::string::stripEnd(sReturn, ' '));
104 }
105 }
106 else
107 {
108 if (mpDrawView->GetMarkedObjectList().GetMarkCount() > 0)
109 {
110 bool bFound = false;
111
112 SdrObject* pMarkedObj = mpDrawView->GetMarkedObjectList().GetMark(0)->GetMarkedSdrObj();
113 if( pMarkedObj && (SdrInventor::FmForm == pMarkedObj->GetObjInventor()) )
114 {
115 SdrUnoObj* pUnoCtrl = dynamic_cast< SdrUnoObj* >( pMarkedObj );
116
117 if(pUnoCtrl) try
118 {
119 uno::Reference< awt::XControlModel > xControlModel( pUnoCtrl->GetUnoControlModel(), uno::UNO_SET_THROW );
120 uno::Reference< beans::XPropertySet > xPropSet( xControlModel, uno::UNO_QUERY_THROW );
121 uno::Reference< beans::XPropertySetInfo > xPropInfo( xPropSet->getPropertySetInfo(), uno::UNO_SET_THROW );
122
123 form::FormButtonType eButtonType = form::FormButtonType_URL;
124 static constexpr OUStringLiteral sButtonType( u"ButtonType" );
125 if(xPropInfo->hasPropertyByName( sButtonType ) && (xPropSet->getPropertyValue( sButtonType ) >>= eButtonType ) )
126 {
127 OUString aString;
128
129 // Label
130 static constexpr OUStringLiteral sLabel( u"Label" );
131 if(xPropInfo->hasPropertyByName(sLabel))
132 {
133 if( xPropSet->getPropertyValue(sLabel) >>= aString )
134 aHLinkItem.SetName(aString);
135 }
136
137 // URL
138 static constexpr OUStringLiteral sTargetURL( u"TargetURL" );
139 if(xPropInfo->hasPropertyByName(sTargetURL))
140 {
141 if( xPropSet->getPropertyValue(sTargetURL) >>= aString )
142 aHLinkItem.SetURL(aString);
143 }
144
145 // Target
146 static constexpr OUStringLiteral sTargetFrame( u"TargetFrame" );
147 if(xPropInfo->hasPropertyByName(sTargetFrame) )
148 {
149 if( xPropSet->getPropertyValue(sTargetFrame) >>= aString )
150 aHLinkItem.SetTargetFrame(aString);
151 }
152
153 aHLinkItem.SetInsertMode(HLINK_BUTTON);
154 bFound = true;
155 }
156 }
157 catch( uno::Exception& )
158 {
159 }
160 }
161
162 // try interaction link
163 if( !bFound && pMarkedObj )
164 {
166 if( pInfo && (pInfo->meClickAction == presentation::ClickAction_DOCUMENT) )
167 aHLinkItem.SetURL( pInfo->GetBookmark());
168 aHLinkItem.SetInsertMode(HLINK_BUTTON);
169 }
170 }
171 }
172
173 rSet.Put(aHLinkItem);
174 }
175 rSet.Put( SfxBoolItem( SID_READONLY_MODE, mbReadOnly ) );
176
177 // output quality
178 if( SfxItemState::DEFAULT == rSet.GetItemState( SID_OUTPUT_QUALITY_COLOR ) ||
179 SfxItemState::DEFAULT == rSet.GetItemState( SID_OUTPUT_QUALITY_GRAYSCALE ) ||
180 SfxItemState::DEFAULT == rSet.GetItemState( SID_OUTPUT_QUALITY_BLACKWHITE ) ||
181 SfxItemState::DEFAULT == rSet.GetItemState( SID_OUTPUT_QUALITY_CONTRAST ) )
182 {
183 const sal_uLong nMode = static_cast<sal_Int32>(GetActiveWindow()->GetOutDev()->GetDrawMode());
184 rSet.Put( SfxBoolItem( SID_OUTPUT_QUALITY_COLOR, sal_uLong(OUTPUT_DRAWMODE_COLOR) == nMode ) );
185 rSet.Put( SfxBoolItem( SID_OUTPUT_QUALITY_GRAYSCALE, static_cast<sal_uLong>(OUTPUT_DRAWMODE_GRAYSCALE) == nMode ) );
186 rSet.Put( SfxBoolItem( SID_OUTPUT_QUALITY_BLACKWHITE, static_cast<sal_uLong>(OUTPUT_DRAWMODE_BLACKWHITE) == nMode ) );
187 rSet.Put( SfxBoolItem( SID_OUTPUT_QUALITY_CONTRAST, static_cast<sal_uLong>(OUTPUT_DRAWMODE_CONTRAST) == nMode ) );
188 }
189
190 if ( SfxItemState::DEFAULT == rSet.GetItemState(SID_MAIL_SCROLLBODY_PAGEDOWN) )
191 {
192 rSet.Put( SfxBoolItem( SID_MAIL_SCROLLBODY_PAGEDOWN, true ) );
193 }
194
195 if ( SfxItemState::DEFAULT == rSet.GetItemState(SID_ATTR_YEAR2000) )
196 {
197 FmFormShell* pFormShell = GetViewShellBase().GetFormShellManager()->GetFormShell();
198 if (pFormShell != nullptr)
199 {
200 sal_uInt16 nState = 0;
201 if (pFormShell->GetY2KState(nState))
202 rSet.Put( SfxUInt16Item( SID_ATTR_YEAR2000, nState ) );
203 else
204 rSet.DisableItem( SID_ATTR_YEAR2000 );
205 }
206 }
207
208 if ( !GetView()->GetTextEditOutliner() )
209 {
211 {
212 GetViewFrame()->GetBindings().SetVisibleState( SID_TRANSLITERATE_HALFWIDTH, false );
213 GetViewFrame()->GetBindings().SetVisibleState( SID_TRANSLITERATE_FULLWIDTH, false );
214 GetViewFrame()->GetBindings().SetVisibleState( SID_TRANSLITERATE_HIRAGANA, false );
215 GetViewFrame()->GetBindings().SetVisibleState( SID_TRANSLITERATE_KATAKANA, false );
216 }
217 else
218 {
219 GetViewFrame()->GetBindings().SetVisibleState( SID_TRANSLITERATE_HALFWIDTH, true );
220 GetViewFrame()->GetBindings().SetVisibleState( SID_TRANSLITERATE_FULLWIDTH, true );
221 GetViewFrame()->GetBindings().SetVisibleState( SID_TRANSLITERATE_HIRAGANA, true );
222 GetViewFrame()->GetBindings().SetVisibleState( SID_TRANSLITERATE_KATAKANA, true );
223 }
224
225 rSet.DisableItem( SID_TRANSLITERATE_SENTENCE_CASE );
226 rSet.DisableItem( SID_TRANSLITERATE_TITLE_CASE );
227 rSet.DisableItem( SID_TRANSLITERATE_TOGGLE_CASE );
228 rSet.DisableItem( SID_TRANSLITERATE_UPPER );
229 rSet.DisableItem( SID_TRANSLITERATE_LOWER );
230 rSet.DisableItem( SID_TRANSLITERATE_HALFWIDTH );
231 rSet.DisableItem( SID_TRANSLITERATE_FULLWIDTH );
232 rSet.DisableItem( SID_TRANSLITERATE_HIRAGANA );
233 rSet.DisableItem( SID_TRANSLITERATE_KATAKANA );
234 }
235 else
236 {
238 {
239 GetViewFrame()->GetBindings().SetVisibleState( SID_TRANSLITERATE_HALFWIDTH, false );
240 GetViewFrame()->GetBindings().SetVisibleState( SID_TRANSLITERATE_FULLWIDTH, false );
241 GetViewFrame()->GetBindings().SetVisibleState( SID_TRANSLITERATE_HIRAGANA, false );
242 GetViewFrame()->GetBindings().SetVisibleState( SID_TRANSLITERATE_KATAKANA, false );
243 rSet.DisableItem( SID_TRANSLITERATE_HALFWIDTH );
244 rSet.DisableItem( SID_TRANSLITERATE_FULLWIDTH );
245 rSet.DisableItem( SID_TRANSLITERATE_HIRAGANA );
246 rSet.DisableItem( SID_TRANSLITERATE_KATAKANA );
247 }
248 else
249 {
250 GetViewFrame()->GetBindings().SetVisibleState( SID_TRANSLITERATE_HALFWIDTH, true );
251 GetViewFrame()->GetBindings().SetVisibleState( SID_TRANSLITERATE_FULLWIDTH, true );
252 GetViewFrame()->GetBindings().SetVisibleState( SID_TRANSLITERATE_HIRAGANA, true );
253 GetViewFrame()->GetBindings().SetVisibleState( SID_TRANSLITERATE_KATAKANA, true );
254 }
255 }
256}
257
259{
260 SfxWhichIter aIter( rSet );
261 sal_uInt16 nWhich = aIter.FirstWhich();
262
263 bool bAttr = false;
264 SfxAllItemSet aAllSet( *rSet.GetPool() );
265
266 while ( nWhich )
267 {
268 sal_uInt16 nSlotId = SfxItemPool::IsWhich(nWhich)
269 ? GetPool().GetSlotId(nWhich)
270 : nWhich;
271 switch ( nSlotId )
272 {
273 case SID_ATTR_PARA_ADJUST_LEFT:
274 {
275 SfxItemSet aAttrs( GetDoc()->GetPool() );
276 mpDrawView->GetAttributes( aAttrs );
277
278 SvxAdjust eAdj = aAttrs.Get( EE_PARA_JUST ).GetAdjust();
279 if ( eAdj == SvxAdjust::Left)
280 {
281 rSet.Put( SfxBoolItem( SID_ATTR_PARA_ADJUST_LEFT, true ) );
282 }
283
284 bAttr = true;
285
286 Invalidate(nSlotId);
287 }
288 break;
289 case SID_ATTR_PARA_ADJUST_CENTER:
290 {
291 SfxItemSet aAttrs( GetDoc()->GetPool() );
292 mpDrawView->GetAttributes( aAttrs );
293
294 SvxAdjust eAdj = aAttrs.Get( EE_PARA_JUST ).GetAdjust();
295 if ( eAdj == SvxAdjust::Center)
296 {
297 rSet.Put( SfxBoolItem( SID_ATTR_PARA_ADJUST_CENTER, true ) );
298 }
299
300 bAttr = true;
301
302 Invalidate(nSlotId);
303 }
304 break;
305 case SID_ATTR_PARA_ADJUST_RIGHT:
306 {
307 SfxItemSet aAttrs( GetDoc()->GetPool() );
308 mpDrawView->GetAttributes( aAttrs );
309
310 SvxAdjust eAdj = aAttrs.Get( EE_PARA_JUST ).GetAdjust();
311 if ( eAdj == SvxAdjust::Right)
312 {
313 rSet.Put( SfxBoolItem( SID_ATTR_PARA_ADJUST_RIGHT, true ) );
314 }
315
316 bAttr = true;
317
318 Invalidate(nSlotId);
319 }
320 break;
321 case SID_ATTR_PARA_ADJUST_BLOCK:
322 {
323 SfxItemSet aAttrs( GetDoc()->GetPool() );
324 mpDrawView->GetAttributes( aAttrs );
325
326 SvxAdjust eAdj = aAttrs.Get( EE_PARA_JUST ).GetAdjust();
327 if ( eAdj == SvxAdjust::Block)
328 {
329 rSet.Put( SfxBoolItem( SID_ATTR_PARA_ADJUST_BLOCK, true ) );
330 }
331
332 bAttr = true;
333
334 Invalidate(nSlotId);
335 }
336 break;
337 case SID_ATTR_PARA_LRSPACE:
338 {
339 SfxItemSet aAttrs( GetDoc()->GetPool() );
340 mpDrawView->GetAttributes( aAttrs );
341 SvxLRSpaceItem aLRSpace = aAttrs.Get( EE_PARA_LRSPACE );
342 aLRSpace.SetWhich(SID_ATTR_PARA_LRSPACE);
343 rSet.Put(aLRSpace);
344 bAttr = true;
345 Invalidate(SID_ATTR_PARA_LRSPACE);
346 }
347 break;
348 case SID_ATTR_PARA_LINESPACE:
349 {
350 SfxItemSet aAttrs( GetDoc()->GetPool() );
351 mpDrawView->GetAttributes( aAttrs );
352 SvxLineSpacingItem aLineLR = aAttrs.Get( EE_PARA_SBL );
353 rSet.Put(aLineLR);
354 bAttr = true;
355 Invalidate(SID_ATTR_PARA_LINESPACE);
356 }
357 break;
358 case SID_ATTR_PARA_ULSPACE:
359 {
360 SfxItemSet aAttrs( GetDoc()->GetPool() );
361 mpDrawView->GetAttributes( aAttrs );
362 SvxULSpaceItem aULSP = aAttrs.Get( EE_PARA_ULSPACE );
363 aULSP.SetWhich(SID_ATTR_PARA_ULSPACE);
364 rSet.Put(aULSP);
365 bAttr = true;
366 Invalidate(SID_ATTR_PARA_ULSPACE);
367 }
368 break;
369 case SID_ULINE_VAL_NONE:
370 case SID_ULINE_VAL_SINGLE:
371 case SID_ULINE_VAL_DOUBLE:
372 case SID_ULINE_VAL_DOTTED:
373 {
374 SfxItemSet aAttrs( GetDoc()->GetPool() );
375 mpDrawView->GetAttributes( aAttrs );
376 if( aAttrs.GetItemState( EE_CHAR_UNDERLINE ) >= SfxItemState::DEFAULT )
377 {
378 FontLineStyle eLineStyle = aAttrs.Get(EE_CHAR_UNDERLINE).GetLineStyle();
379
380 switch (nSlotId)
381 {
382 case SID_ULINE_VAL_NONE:
383 rSet.Put(SfxBoolItem(nSlotId, eLineStyle == LINESTYLE_NONE));
384 break;
385 case SID_ULINE_VAL_SINGLE:
386 rSet.Put(SfxBoolItem(nSlotId, eLineStyle == LINESTYLE_SINGLE));
387 break;
388 case SID_ULINE_VAL_DOUBLE:
389 rSet.Put(SfxBoolItem(nSlotId, eLineStyle == LINESTYLE_DOUBLE));
390 break;
391 case SID_ULINE_VAL_DOTTED:
392 rSet.Put(SfxBoolItem(nSlotId, eLineStyle == LINESTYLE_DOTTED));
393 break;
394 }
395 }
396
397 bAttr = true;
398
399 Invalidate(nSlotId);
400 }
401 break;
402 case SID_ATTR_FILL_STYLE:
403 case SID_ATTR_FILL_COLOR:
404 case SID_ATTR_FILL_GRADIENT:
405 case SID_ATTR_FILL_HATCH:
406 case SID_ATTR_FILL_BITMAP:
407 case SID_ATTR_FILL_SHADOW:
408 case SID_ATTR_SHADOW_COLOR:
409 case SID_ATTR_SHADOW_TRANSPARENCE:
410 case SID_ATTR_SHADOW_BLUR:
411 case SID_ATTR_SHADOW_XDISTANCE:
412 case SID_ATTR_SHADOW_YDISTANCE:
413 case SID_ATTR_FILL_USE_SLIDE_BACKGROUND:
414 case SID_ATTR_FILL_TRANSPARENCE:
415 case SID_ATTR_FILL_FLOATTRANSPARENCE:
416 case SID_ATTR_LINE_STYLE:
417 case SID_ATTR_LINE_DASH:
418 case SID_ATTR_LINE_WIDTH:
419 case SID_ATTR_LINE_COLOR:
420 case SID_ATTR_LINE_TRANSPARENCE:
421 case SID_ATTR_LINE_JOINT:
422 case SID_ATTR_LINE_CAP:
423 case SID_ATTR_TEXT_FITTOSIZE:
424 case SID_ATTR_CHAR_FONT:
425 case SID_ATTR_CHAR_FONTHEIGHT:
426 case SID_ATTR_CHAR_SHADOWED:
427 case SID_ATTR_CHAR_POSTURE:
428 case SID_ATTR_CHAR_OVERLINE:
429 case SID_ATTR_CHAR_UNDERLINE:
430 case SID_ATTR_CHAR_STRIKEOUT:
431 case SID_ATTR_CHAR_CONTOUR:
432 case SID_ATTR_CHAR_WEIGHT:
433 case SID_ATTR_CHAR_COLOR:
434 case SID_ATTR_CHAR_KERNING:
435 case SID_ATTR_CHAR_CASEMAP:
436 case SID_ATTR_GLOW_COLOR:
437 case SID_ATTR_GLOW_RADIUS:
438 case SID_ATTR_GLOW_TRANSPARENCY:
439 case SID_ATTR_SOFTEDGE_RADIUS:
440 case SID_SET_SUB_SCRIPT:
441 case SID_SET_SUPER_SCRIPT:
442 {
443 bAttr = true;
444 }
445 break;
446
447 case SID_ATTR_TEXTCOLUMNS_NUMBER:
448 case SID_ATTR_TEXTCOLUMNS_SPACING:
449 {
450 SfxItemSet aAttrs(GetDoc()->GetPool());
451 mpDrawView->GetAttributes(aAttrs);
452 const sal_uInt16 nActWhich = nSlotId == SID_ATTR_TEXTCOLUMNS_NUMBER
455 rSet.Put(aAttrs.Get(nActWhich).CloneSetWhich(nSlotId));
456 }
457 break;
458
459 case SID_HYPHENATION:
460 {
461 SfxItemSet aAttrs( GetDoc()->GetPool() );
462 mpDrawView->GetAttributes( aAttrs );
463 if( aAttrs.GetItemState( EE_PARA_HYPHENATE ) >= SfxItemState::DEFAULT )
464 {
465 bool bValue = aAttrs.Get( EE_PARA_HYPHENATE ).GetValue();
466 rSet.Put( SfxBoolItem( SID_HYPHENATION, bValue ) );
467 }
468 }
469 break;
470
471 case SID_STYLE_FAMILY2:
472 case SID_STYLE_FAMILY3:
473 case SID_STYLE_FAMILY5:
474 case SID_STYLE_APPLY: // StyleControl
475 {
476 SfxStyleSheet* pStyleSheet = mpDrawView->GetStyleSheet();
477 if( pStyleSheet )
478 {
479 if( nSlotId != SID_STYLE_APPLY && !mpDrawView->AreObjectsMarked() )
480 {
481 SfxTemplateItem aTmpItem( nWhich, OUString() );
482 aAllSet.Put( aTmpItem, aTmpItem.Which() );
483 }
484 else
485 {
486 if (pStyleSheet->GetFamily() == SfxStyleFamily::Page)
487 pStyleSheet = static_cast<SdStyleSheet*>(pStyleSheet)->GetPseudoStyleSheet();
488
489 if( pStyleSheet )
490 {
491 SfxStyleFamily eFamily = pStyleSheet->GetFamily();
492
493 if ((eFamily == SfxStyleFamily::Para && nSlotId == SID_STYLE_FAMILY2) ||
494 (eFamily == SfxStyleFamily::Frame && nSlotId == SID_STYLE_FAMILY3) ||
495 (eFamily == SfxStyleFamily::Pseudo && nSlotId == SID_STYLE_FAMILY5))
496 {
497 SfxTemplateItem aTmpItem ( nWhich, pStyleSheet->GetName() );
498 aAllSet.Put( aTmpItem, aTmpItem.Which() );
499 }
500 else
501 {
502 SfxTemplateItem aTmpItem(nWhich, OUString());
503 aAllSet.Put(aTmpItem,aTmpItem.Which() );
504 }
505 }
506 }
507 }
508 else
509 { SfxTemplateItem aItem( nWhich, OUString() );
510 aAllSet.Put( aItem, aItem.Which() );
511 }
512 }
513 break;
514
515 case SID_SET_DEFAULT:
516 {
517 if( !mpDrawView->GetMarkedObjectList().GetMarkCount() ||
518 ( !mpDrawView->IsTextEdit() && !mpDrawView->GetStyleSheet() )
519 )
520 rSet.DisableItem( nWhich );
521 }
522 break;
523
524 case SID_REMOVE_HYPERLINK:
525 {
526 if (!URLFieldHelper::IsCursorAtURLField(mpDrawView->GetTextEditOutlinerView()))
527 rSet.DisableItem(nWhich);
528 }
529 break;
530
531 case SID_STYLE_WATERCAN:
532 {
533 std::unique_ptr<SfxUInt16Item> pFamilyItem;
534 GetViewFrame()->GetBindings().QueryState(SID_STYLE_FAMILY, pFamilyItem);
535 if (pFamilyItem && static_cast<SfxStyleFamily>(pFamilyItem->GetValue()) == SfxStyleFamily::Pseudo)
536 rSet.Put(SfxBoolItem(nWhich,false));
537 else
538 {
539 SfxBoolItem aItem(nWhich, SD_MOD()->GetWaterCan());
540 aAllSet.Put( aItem, aItem.Which());
541 }
542 }
543 break;
544
545 case SID_STYLE_NEW:
546 {
547 std::unique_ptr<SfxUInt16Item> pFamilyItem;
548 GetViewFrame()->GetBindings().QueryState(SID_STYLE_FAMILY, pFamilyItem);
549 if (pFamilyItem && static_cast<SfxStyleFamily>(pFamilyItem->GetValue()) == SfxStyleFamily::Pseudo)
550 {
551 rSet.DisableItem(nWhich);
552 }
553 }
554 break;
555
556 case SID_STYLE_DRAGHIERARCHIE:
557 {
558 std::unique_ptr<SfxUInt16Item> pFamilyItem;
559 GetViewFrame()->GetBindings().QueryState(SID_STYLE_FAMILY, pFamilyItem);
560 if (pFamilyItem && static_cast<SfxStyleFamily>(pFamilyItem->GetValue()) == SfxStyleFamily::Pseudo)
561 rSet.DisableItem(nWhich);
562 }
563 break;
564
565 case SID_STYLE_NEW_BY_EXAMPLE:
566 {
567 // It is not possible to create PseudoStyleSheets 'by Example';
568 // normal style sheets need a selected object for that
569
570 std::unique_ptr<SfxUInt16Item> pFamilyItem;
571 GetViewFrame()->GetBindings().QueryState(SID_STYLE_FAMILY, pFamilyItem);
572 if (pFamilyItem)
573 {
574 if (static_cast<SfxStyleFamily>(pFamilyItem->GetValue()) == SfxStyleFamily::Pseudo)
575 {
576 rSet.DisableItem(nWhich);
577 }
578 else if (static_cast<SfxStyleFamily>(pFamilyItem->GetValue()) == SfxStyleFamily::Para)
579 {
580 if (!mpDrawView->AreObjectsMarked())
581 {
582 rSet.DisableItem(nWhich);
583 }
584 }
585 }
586 // if there is no (yet) a style designer, we have to go back into the
587 // view state; an actual set family can not be considered
588 else
589 {
590 if (!mpDrawView->AreObjectsMarked())
591 {
592 rSet.DisableItem(nWhich);
593 }
594 }
595 }
596 break;
597
598 case SID_STYLE_UPDATE_BY_EXAMPLE:
599 {
600 if (!mpDrawView->AreObjectsMarked())
601 {
602 rSet.DisableItem(nWhich);
603 }
604 }
605 break;
606 case FN_BUL_NUM_RULE_INDEX:
607 case FN_NUM_NUM_RULE_INDEX:
608 {
609 SfxItemSet aEditAttr( GetDoc()->GetPool() );
610 mpDrawView->GetAttributes( aEditAttr );
611
613 aNewAttr.Put( aEditAttr, false );
614
615 std::unique_ptr<SvxNumRule> pNumRule;
616 const SfxPoolItem* pTmpItem=nullptr;
617 TypedWhichId<SvxNumBulletItem> nNumItemId = SID_ATTR_NUMBERING_RULE;
618 sal_uInt16 nActNumLvl = mpDrawView->GetSelectionLevel();
619 pTmpItem=GetNumBulletItem(aNewAttr, nNumItemId);
620
621 if (pTmpItem)
622 pNumRule.reset(new SvxNumRule(static_cast<const SvxNumBulletItem*>(pTmpItem)->GetNumRule()));
623
624 if ( pNumRule )
625 {
626 sal_uInt16 nMask = 1;
627 sal_uInt16 nCount = 0;
628 sal_uInt16 nCurLevel = sal_uInt16(0xFFFF);
629 for(sal_uInt16 i = 0; i < pNumRule->GetLevelCount(); i++)
630 {
631 if(nActNumLvl & nMask)
632 {
633 nCount++;
634 nCurLevel = i;
635 }
636 nMask <<= 1;
637 }
638 if ( nCount == 1 )
639 {
640 const SvxNumberFormat* pNumFmt = pNumRule->Get(nCurLevel);
641 if ( pNumFmt )
642 {
643 bool bBullets = false;
644 switch(pNumFmt->GetNumberingType())
645 {
647 case SVX_NUM_BITMAP:
648 bBullets = true;
649 break;
650
651 default:
652 bBullets = false;
653 }
654
655 rSet.Put(SfxUInt16Item(FN_BUL_NUM_RULE_INDEX,sal_uInt16(0xFFFF)));
656 rSet.Put(SfxUInt16Item(FN_NUM_NUM_RULE_INDEX,sal_uInt16(0xFFFF)));
657 if ( bBullets )
658 {
659 NBOTypeMgrBase* pBullets = NBOutlineTypeMgrFact::CreateInstance(NBOType::Bullets);
660 if ( pBullets )
661 {
662 sal_uInt16 nBulIndex = pBullets->GetNBOIndexForNumRule(*pNumRule,nActNumLvl);
663 rSet.Put(SfxUInt16Item(FN_BUL_NUM_RULE_INDEX,nBulIndex));
664 }
665 }else
666 {
667 NBOTypeMgrBase* pNumbering = NBOutlineTypeMgrFact::CreateInstance(NBOType::Numbering);
668 if ( pNumbering )
669 {
670 sal_uInt16 nBulIndex = pNumbering->GetNBOIndexForNumRule(*pNumRule,nActNumLvl);
671 rSet.Put(SfxUInt16Item(FN_NUM_NUM_RULE_INDEX,nBulIndex));
672 }
673 }
674 }
675 }
676 }
677 }
678 break;
679 case FN_NUM_BULLET_ON:
680 case FN_NUM_NUMBERING_ON:
681 {
682 bool bEnable = false;
683 const SdrMarkList& rMarkList = mpDrawView->GetMarkedObjectList();
684 const size_t nMarkCount = rMarkList.GetMarkCount();
685 for (size_t nIndex = 0; nIndex < nMarkCount; ++nIndex)
686 {
687 SdrTextObj* pTextObj = DynCastSdrTextObj(rMarkList.GetMark(nIndex)->GetMarkedSdrObj());
688 if (pTextObj && pTextObj->GetObjInventor() == SdrInventor::Default)
689 {
690 if (pTextObj->GetObjIdentifier() != SdrObjKind::OLE2)
691 {
692 bEnable = true;
693 break;
694 }
695 }
696 }
697 if (bEnable)
698 {
699 rSet.Put(SfxBoolItem(FN_NUM_BULLET_ON, false));
700 rSet.Put(SfxBoolItem(FN_NUM_NUMBERING_ON, false));
701 }
702 else
703 {
704 rSet.DisableItem(FN_NUM_BULLET_ON);
705 rSet.DisableItem(FN_NUM_NUMBERING_ON);
706 }
707 }
708 break;
709 }
710 nWhich = aIter.NextWhich();
711 }
712
713 std::optional<SfxItemSet> pSet;
714
715 if( bAttr )
716 {
717 pSet.emplace( GetDoc()->GetPool() );
718 mpDrawView->GetAttributes( *pSet );
719 rSet.Put( *pSet, false );
720 }
721
722 rSet.Put( aAllSet, false );
723
724 // there were changes at area and/or line attributes
725 if( !(bAttr && pSet) )
726 return;
727
728 // if the view owns selected objects, corresponding items have to be
729 // changed from SfxItemState::DEFAULT (_ON) to SfxItemState::DISABLED
730 if( mpDrawView->AreObjectsMarked() )
731 {
732 SfxWhichIter aNewIter( *pSet );
733 nWhich = aNewIter.FirstWhich();
734 while( nWhich )
735 {
736 if (nWhich >= XATTR_LINE_FIRST && nWhich <= XATTR_LINE_LAST
737 && SfxItemState::DEFAULT == aNewIter.GetItemState() )
738 {
739 rSet.ClearItem( nWhich );
740 rSet.DisableItem( nWhich );
741 }
742 nWhich = aNewIter.NextWhich();
743 }
744 }
745
746 SfxItemState eState = pSet->GetItemState( EE_PARA_LRSPACE );
747 if ( eState == SfxItemState::DONTCARE )
748 {
750 rSet.InvalidateItem(SID_ATTR_PARA_LRSPACE);
751 }
752 eState = pSet->GetItemState( EE_PARA_SBL );
753 if ( eState == SfxItemState::DONTCARE )
754 {
756 rSet.InvalidateItem(SID_ATTR_PARA_LINESPACE);
757 }
758 eState = pSet->GetItemState( EE_PARA_ULSPACE );
759 if ( eState == SfxItemState::DONTCARE )
760 {
762 rSet.InvalidateItem(SID_ATTR_PARA_ULSPACE);
763 }
764
765 SvxEscapement eEsc = static_cast<SvxEscapement>(pSet->Get( EE_CHAR_ESCAPEMENT ).GetEnumValue());
766 rSet.Put(SfxBoolItem(SID_SET_SUPER_SCRIPT, eEsc == SvxEscapement::Superscript));
767 rSet.Put(SfxBoolItem(SID_SET_SUB_SCRIPT, eEsc == SvxEscapement::Subscript));
768
769 eState = pSet->GetItemState( EE_CHAR_KERNING );
770 if ( eState == SfxItemState::DONTCARE )
771 {
773 rSet.InvalidateItem(SID_ATTR_CHAR_KERNING);
774 }
775}
776
777OUString DrawViewShell::GetSelectionText(bool bCompleteWords)
778{
779 OUString aStrSelection;
780 ::Outliner* pOl = mpDrawView->GetTextEditOutliner();
781 OutlinerView* pOlView = mpDrawView->GetTextEditOutlinerView();
782
783 if (pOl && pOlView)
784 {
785 if (bCompleteWords)
786 {
787 ESelection aSel = pOlView->GetSelection();
788 OUString aStrCurrentDelimiters = pOl->GetWordDelimiters();
789
790 pOl->SetWordDelimiters(" .,;\"'");
791 aStrSelection = pOl->GetWord( aSel.nEndPara, aSel.nEndPos );
792 pOl->SetWordDelimiters( aStrCurrentDelimiters );
793 }
794 else
795 {
796 aStrSelection = pOlView->GetSelected();
797 }
798 }
799
800 return aStrSelection;
801}
802
803bool DrawViewShell::HasSelection(bool bText) const
804{
805 bool bReturn = false;
806
807 if (bText)
808 {
809 OutlinerView* pOlView = mpDrawView->GetTextEditOutlinerView();
810
811 if (pOlView && !pOlView->GetSelected().isEmpty())
812 {
813 bReturn = true;
814 }
815 }
816 else if (mpDrawView->GetMarkedObjectList().GetMarkCount() != 0)
817 {
818 bReturn = true;
819 }
820
821 return bReturn;
822}
823
824} // end of namespace sd
825
826/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
bool GetY2KState(sal_uInt16 &nReturn)
ESelection GetSelection() const
const SvxFieldData * GetFieldAtCursor() const
OUString GetSelected() const
OUString GetWord(sal_Int32 nPara, sal_Int32 nIndex)
void SetWordDelimiters(const OUString &rDelimiters)
OUString const & GetWordDelimiters() const
DrawModeFlags GetDrawMode() const
css::presentation::ClickAction meClickAction
Action at mouse click.
Definition: anminfo.hxx:48
OUString GetBookmark() const
Definition: anminfo.cxx:110
static SdAnimationInfo * GetShapeUserData(SdrObject &rObject, bool bCreate=false)
Definition: drawdoc2.cxx:959
size_t GetMarkCount() const
SdrMark * GetMark(size_t nNum) const
SdrObject * GetMarkedSdrObj() const
virtual SdrInventor GetObjInventor() const
virtual SdrObjKind GetObjIdentifier() const override
const css::uno::Reference< css::awt::XControlModel > & GetUnoControlModel() const
void SetVisibleState(sal_uInt16 nId, bool bShow)
SfxItemState QueryState(sal_uInt16 nSID, std::unique_ptr< SfxPoolItem > &rpState)
sal_uInt16 GetSlotId(sal_uInt16 nWhich) const
static bool IsWhich(sal_uInt16 nId)
SfxItemPool * GetPool() const
sal_uInt16 ClearItem(sal_uInt16 nWhich=0)
SfxItemState GetItemState(sal_uInt16 nWhich, bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
const SfxPoolItem & Get(sal_uInt16 nWhich, bool bSrchInParent=true) const
void DisableItem(sal_uInt16 nWhich)
void InvalidateItem(sal_uInt16 nWhich)
sal_uInt16 Which() const
std::unique_ptr< SfxPoolItem > CloneSetWhich(sal_uInt16 nNewWhich) const
const SfxPoolItem * GetSlotState(sal_uInt16 nSlotId, const SfxInterface *pIF=nullptr, SfxItemSet *pStateSet=nullptr)
SfxItemPool & GetPool() const
virtual void Invalidate(sal_uInt16 nId=0)
const OUString & GetName() const
SfxStyleFamily GetFamily() const
SfxBindings & GetBindings()
sal_uInt16 FirstWhich()
SfxItemState GetItemState(bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
sal_uInt16 NextWhich()
void SetName(const OUString &rName)
void SetInsertMode(SvxLinkInsertMode eNew)
void SetURL(const OUString &rURL)
void SetTargetFrame(const OUString &rTarget)
SvxNumType GetNumberingType() const
static bool IsCursorAtURLField(const EditView &pEditView)
void GetAttrState(SfxItemSet &rSet)
Definition: drviewsf.cxx:258
OUString GetSelectionText(bool bCompleteWords)
Definition: drviewsf.cxx:777
std::unique_ptr< DrawView > mpDrawView
bool HasSelection(bool bText) const
Definition: drviewsf.cxx:803
void GetCtrlState(SfxItemSet &rSet)
Set state of controller SfxSlots.
Definition: drviewsf.cxx:74
std::shared_ptr< FormShellManager > const & GetFormShellManager() const
SdDrawDocument * GetDoc() const
Definition: viewshel.cxx:1412
::sd::Window * GetActiveWindow() const
The active window is usually the mpContentWindow.
Definition: ViewShell.hxx:155
::sd::View * GetView() const
Definition: ViewShell.hxx:144
SD_DLLPUBLIC ViewShellBase & GetViewShellBase() const
Definition: viewshel.cxx:1397
SD_DLLPUBLIC SfxViewFrame * GetViewFrame() const
Definition: viewshel.cxx:118
const SvxNumBulletItem * GetNumBulletItem(SfxItemSet &aNewAttr, TypedWhichId< SvxNumBulletItem > &nNumItemId)
Definition: viewshel.cxx:839
virtual sal_uInt16 GetNBOIndexForNumRule(SvxNumRule &aNum, sal_uInt16 mLevel, sal_uInt16 nFromIndex=0)=0
::OutputDevice const * GetOutDev() const
int nCount
float u
constexpr TypedWhichId< SfxBoolItem > EE_PARA_HYPHENATE(EE_PARA_START+6)
constexpr TypedWhichId< SvxKerningItem > EE_CHAR_KERNING(EE_CHAR_START+12)
constexpr TypedWhichId< SvxUnderlineItem > EE_CHAR_UNDERLINE(EE_CHAR_START+5)
constexpr TypedWhichId< SvxAdjustItem > EE_PARA_JUST(EE_PARA_START+16)
constexpr TypedWhichId< SvxULSpaceItem > EE_PARA_ULSPACE(EE_PARA_START+14)
constexpr TypedWhichId< SvxLRSpaceItem > EE_PARA_LRSPACE(EE_PARA_START+13)
constexpr TypedWhichId< SvxLineSpacingItem > EE_PARA_SBL(EE_PARA_START+15)
constexpr TypedWhichId< SvxEscapementItem > EE_CHAR_ESCAPEMENT(EE_CHAR_START+10)
sal_Int32 nState
FontLineStyle
LINESTYLE_SINGLE
LINESTYLE_DOUBLE
LINESTYLE_NONE
LINESTYLE_DOTTED
HLINK_BUTTON
sal_Int32 nIndex
bool IsChangeCaseMapEnabled()
SwNumRule * GetNumRule(SwTextFormatColl &rTextFormatColl)
OString stripEnd(const OString &rIn, char c)
int i
const DrawModeFlags OUTPUT_DRAWMODE_CONTRAST
Definition: ViewShell.hxx:72
const DrawModeFlags OUTPUT_DRAWMODE_GRAYSCALE
Definition: ViewShell.hxx:64
const DrawModeFlags OUTPUT_DRAWMODE_BLACKWHITE
Definition: ViewShell.hxx:68
const DrawModeFlags OUTPUT_DRAWMODE_COLOR
Definition: ViewShell.hxx:62
SfxItemState
#define SD_MOD()
Definition: sdmod.hxx:184
static SfxItemSet & rSet
sal_uIntPtr sal_uLong
sal_Int32 nEndPos
sal_Int32 nEndPara
SfxStyleFamily
constexpr TypedWhichId< SfxInt16Item > SDRATTR_TEXTCOLUMNS_NUMBER(SDRATTR_TEXTCOLUMNS_FIRST+0)
constexpr TypedWhichId< SdrMetricItem > SDRATTR_TEXTCOLUMNS_SPACING(SDRATTR_TEXTCOLUMNS_FIRST+1)
SVXCORE_DLLPUBLIC SdrTextObj * DynCastSdrTextObj(SdrObject *)
SvxEscapement
SVX_NUM_BITMAP
SVX_NUM_CHAR_SPECIAL
SvxAdjust
constexpr sal_uInt16 XATTR_LINE_FIRST(XATTR_START)
constexpr sal_uInt16 XATTR_LINE_LAST(XATTR_LINECAP)