android: Update app-specific/MIME type icons
[LibreOffice.git] / sd / source / ui / view / drviewsf.cxx
blobe74fe71dd45eef60e0952e30dd85269b5e0a240e
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <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>
43 #include <app.hrc>
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>
54 #include <editeng/lspcitem.hxx>
55 #include <editeng/ulspitem.hxx>
56 #include <editeng/lrspitem.hxx>
57 #include <editeng/escapementitem.hxx>
58 #include <editeng/numitem.hxx>
59 #include <editeng/adjustitem.hxx>
60 #include <editeng/urlfieldhelper.hxx>
61 #include <svx/nbdtmgfact.hxx>
62 #include <svx/nbdtmg.hxx>
63 #include <memory>
65 using namespace com::sun::star::drawing;
66 using namespace svx::sidebar;
67 using namespace ::com::sun::star;
69 namespace sd {
71 /**
72 * Set state of controller SfxSlots
74 void DrawViewShell::GetCtrlState(SfxItemSet &rSet)
76 if (rSet.GetItemState(SID_RELOAD) != SfxItemState::UNKNOWN)
78 // let "last version" of SFx en/disable
79 GetViewFrame()->GetSlotState (SID_RELOAD, nullptr, &rSet);
82 if (SfxItemState::DEFAULT == rSet.GetItemState(SID_HYPERLINK_GETLINK))
84 SvxHyperlinkItem aHLinkItem;
86 OutlinerView* pOLV = mpDrawView->GetTextEditOutlinerView();
88 if (pOLV)
90 const SvxFieldData* pField = pOLV->GetFieldAtCursor();
91 if( auto pUrlField = dynamic_cast< const SvxURLField *>( pField ) )
93 aHLinkItem.SetName(pUrlField->GetRepresentation());
94 aHLinkItem.SetURL(pUrlField->GetURL());
95 aHLinkItem.SetTargetFrame(pUrlField->GetTargetFrame());
97 else
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, ' '));
106 else
108 if (mpDrawView->GetMarkedObjectList().GetMarkCount() > 0)
110 bool bFound = false;
112 SdrObject* pMarkedObj = mpDrawView->GetMarkedObjectList().GetMark(0)->GetMarkedSdrObj();
113 if( pMarkedObj && (SdrInventor::FmForm == pMarkedObj->GetObjInventor()) )
115 SdrUnoObj* pUnoCtrl = dynamic_cast< SdrUnoObj* >( pMarkedObj );
117 if(pUnoCtrl) try
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 );
123 form::FormButtonType eButtonType = form::FormButtonType_URL;
124 static const OUStringLiteral sButtonType( u"ButtonType" );
125 if(xPropInfo->hasPropertyByName( sButtonType ) && (xPropSet->getPropertyValue( sButtonType ) >>= eButtonType ) )
127 OUString aString;
129 // Label
130 static const OUStringLiteral sLabel( u"Label" );
131 if(xPropInfo->hasPropertyByName(sLabel))
133 if( xPropSet->getPropertyValue(sLabel) >>= aString )
134 aHLinkItem.SetName(aString);
137 // URL
138 static const OUStringLiteral sTargetURL( u"TargetURL" );
139 if(xPropInfo->hasPropertyByName(sTargetURL))
141 if( xPropSet->getPropertyValue(sTargetURL) >>= aString )
142 aHLinkItem.SetURL(aString);
145 // Target
146 static const OUStringLiteral sTargetFrame( u"TargetFrame" );
147 if(xPropInfo->hasPropertyByName(sTargetFrame) )
149 if( xPropSet->getPropertyValue(sTargetFrame) >>= aString )
150 aHLinkItem.SetTargetFrame(aString);
153 aHLinkItem.SetInsertMode(HLINK_BUTTON);
154 bFound = true;
157 catch( uno::Exception& )
162 // try interaction link
163 if( !bFound && pMarkedObj )
165 SdAnimationInfo* pInfo = SdDrawDocument::GetShapeUserData(*pMarkedObj);
166 if( pInfo && (pInfo->meClickAction == presentation::ClickAction_DOCUMENT) )
167 aHLinkItem.SetURL( pInfo->GetBookmark());
168 aHLinkItem.SetInsertMode(HLINK_BUTTON);
173 rSet.Put(aHLinkItem);
175 rSet.Put( SfxBoolItem( SID_READONLY_MODE, mbReadOnly ) );
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 ) )
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 ) );
190 if ( SfxItemState::DEFAULT == rSet.GetItemState(SID_MAIL_SCROLLBODY_PAGEDOWN) )
192 rSet.Put( SfxBoolItem( SID_MAIL_SCROLLBODY_PAGEDOWN, true ) );
195 if ( SfxItemState::DEFAULT == rSet.GetItemState(SID_ATTR_YEAR2000) )
197 FmFormShell* pFormShell = GetViewShellBase().GetFormShellManager()->GetFormShell();
198 if (pFormShell != nullptr)
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 );
208 if ( !GetView()->GetTextEditOutliner() )
210 if( !SvtCJKOptions::IsChangeCaseMapEnabled() )
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 );
217 else
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 );
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 );
235 else
237 if( !SvtCJKOptions::IsChangeCaseMapEnabled() )
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 );
248 else
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 );
258 void DrawViewShell::GetAttrState( SfxItemSet& rSet )
260 SfxWhichIter aIter( rSet );
261 sal_uInt16 nWhich = aIter.FirstWhich();
263 bool bAttr = false;
264 SfxAllItemSet aAllSet( *rSet.GetPool() );
266 while ( nWhich )
268 sal_uInt16 nSlotId = SfxItemPool::IsWhich(nWhich)
269 ? GetPool().GetSlotId(nWhich)
270 : nWhich;
271 switch ( nSlotId )
273 case SID_ATTR_PARA_ADJUST_LEFT:
275 SfxItemSet aAttrs( GetDoc()->GetPool() );
276 mpDrawView->GetAttributes( aAttrs );
278 SvxAdjust eAdj = aAttrs.Get( EE_PARA_JUST ).GetAdjust();
279 if ( eAdj == SvxAdjust::Left)
281 rSet.Put( SfxBoolItem( SID_ATTR_PARA_ADJUST_LEFT, true ) );
284 bAttr = true;
286 Invalidate(nSlotId);
288 break;
289 case SID_ATTR_PARA_ADJUST_CENTER:
291 SfxItemSet aAttrs( GetDoc()->GetPool() );
292 mpDrawView->GetAttributes( aAttrs );
294 SvxAdjust eAdj = aAttrs.Get( EE_PARA_JUST ).GetAdjust();
295 if ( eAdj == SvxAdjust::Center)
297 rSet.Put( SfxBoolItem( SID_ATTR_PARA_ADJUST_CENTER, true ) );
300 bAttr = true;
302 Invalidate(nSlotId);
304 break;
305 case SID_ATTR_PARA_ADJUST_RIGHT:
307 SfxItemSet aAttrs( GetDoc()->GetPool() );
308 mpDrawView->GetAttributes( aAttrs );
310 SvxAdjust eAdj = aAttrs.Get( EE_PARA_JUST ).GetAdjust();
311 if ( eAdj == SvxAdjust::Right)
313 rSet.Put( SfxBoolItem( SID_ATTR_PARA_ADJUST_RIGHT, true ) );
316 bAttr = true;
318 Invalidate(nSlotId);
320 break;
321 case SID_ATTR_PARA_ADJUST_BLOCK:
323 SfxItemSet aAttrs( GetDoc()->GetPool() );
324 mpDrawView->GetAttributes( aAttrs );
326 SvxAdjust eAdj = aAttrs.Get( EE_PARA_JUST ).GetAdjust();
327 if ( eAdj == SvxAdjust::Block)
329 rSet.Put( SfxBoolItem( SID_ATTR_PARA_ADJUST_BLOCK, true ) );
332 bAttr = true;
334 Invalidate(nSlotId);
336 break;
337 case SID_ATTR_PARA_LRSPACE:
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);
347 break;
348 case SID_ATTR_PARA_LINESPACE:
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);
357 break;
358 case SID_ATTR_PARA_ULSPACE:
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);
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:
374 SfxItemSet aAttrs( GetDoc()->GetPool() );
375 mpDrawView->GetAttributes( aAttrs );
376 if( aAttrs.GetItemState( EE_CHAR_UNDERLINE ) >= SfxItemState::DEFAULT )
378 FontLineStyle eLineStyle = aAttrs.Get(EE_CHAR_UNDERLINE).GetLineStyle();
380 switch (nSlotId)
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;
397 bAttr = true;
399 Invalidate(nSlotId);
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:
443 bAttr = true;
445 break;
447 case SID_ATTR_TEXTCOLUMNS_NUMBER:
448 case SID_ATTR_TEXTCOLUMNS_SPACING:
450 SfxItemSet aAttrs(GetDoc()->GetPool());
451 mpDrawView->GetAttributes(aAttrs);
452 const sal_uInt16 nActWhich = nSlotId == SID_ATTR_TEXTCOLUMNS_NUMBER
453 ? SDRATTR_TEXTCOLUMNS_NUMBER
454 : SDRATTR_TEXTCOLUMNS_SPACING;
455 rSet.Put(aAttrs.Get(nActWhich).CloneSetWhich(nSlotId));
457 break;
459 case SID_HYPHENATION:
461 SfxItemSet aAttrs( GetDoc()->GetPool() );
462 mpDrawView->GetAttributes( aAttrs );
463 if( aAttrs.GetItemState( EE_PARA_HYPHENATE ) >= SfxItemState::DEFAULT )
465 bool bValue = aAttrs.Get( EE_PARA_HYPHENATE ).GetValue();
466 rSet.Put( SfxBoolItem( SID_HYPHENATION, bValue ) );
469 break;
471 case SID_STYLE_FAMILY2:
472 case SID_STYLE_FAMILY3:
473 case SID_STYLE_FAMILY5:
474 case SID_STYLE_APPLY: // StyleControl
476 SfxStyleSheet* pStyleSheet = mpDrawView->GetStyleSheet();
477 if( pStyleSheet )
479 if( nSlotId != SID_STYLE_APPLY && !mpDrawView->AreObjectsMarked() )
481 SfxTemplateItem aTmpItem( nWhich, OUString() );
482 aAllSet.Put( aTmpItem, aTmpItem.Which() );
484 else
486 if (pStyleSheet->GetFamily() == SfxStyleFamily::Page)
487 pStyleSheet = static_cast<SdStyleSheet*>(pStyleSheet)->GetPseudoStyleSheet();
489 if( pStyleSheet )
491 SfxStyleFamily eFamily = pStyleSheet->GetFamily();
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))
497 SfxTemplateItem aTmpItem ( nWhich, pStyleSheet->GetName() );
498 aAllSet.Put( aTmpItem, aTmpItem.Which() );
500 else
502 SfxTemplateItem aTmpItem(nWhich, OUString());
503 aAllSet.Put(aTmpItem,aTmpItem.Which() );
508 else
509 { SfxTemplateItem aItem( nWhich, OUString() );
510 aAllSet.Put( aItem, aItem.Which() );
513 break;
515 case SID_SET_DEFAULT:
517 if( !mpDrawView->GetMarkedObjectList().GetMarkCount() ||
518 ( !mpDrawView->IsTextEdit() && !mpDrawView->GetStyleSheet() )
520 rSet.DisableItem( nWhich );
522 break;
524 case SID_REMOVE_HYPERLINK:
526 if (!URLFieldHelper::IsCursorAtURLField(mpDrawView->GetTextEditOutlinerView()))
527 rSet.DisableItem(nWhich);
529 break;
531 case SID_STYLE_WATERCAN:
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
539 SfxBoolItem aItem(nWhich, SD_MOD()->GetWaterCan());
540 aAllSet.Put( aItem, aItem.Which());
543 break;
545 case SID_STYLE_NEW:
547 std::unique_ptr<SfxUInt16Item> pFamilyItem;
548 GetViewFrame()->GetBindings().QueryState(SID_STYLE_FAMILY, pFamilyItem);
549 if (pFamilyItem && static_cast<SfxStyleFamily>(pFamilyItem->GetValue()) == SfxStyleFamily::Pseudo)
551 rSet.DisableItem(nWhich);
554 break;
556 case SID_STYLE_DRAGHIERARCHIE:
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);
563 break;
565 case SID_STYLE_NEW_BY_EXAMPLE:
567 // It is not possible to create PseudoStyleSheets 'by Example';
568 // normal style sheets need a selected object for that
570 std::unique_ptr<SfxUInt16Item> pFamilyItem;
571 GetViewFrame()->GetBindings().QueryState(SID_STYLE_FAMILY, pFamilyItem);
572 if (pFamilyItem)
574 if (static_cast<SfxStyleFamily>(pFamilyItem->GetValue()) == SfxStyleFamily::Pseudo)
576 rSet.DisableItem(nWhich);
578 else if (static_cast<SfxStyleFamily>(pFamilyItem->GetValue()) == SfxStyleFamily::Para)
580 if (!mpDrawView->AreObjectsMarked())
582 rSet.DisableItem(nWhich);
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
590 if (!mpDrawView->AreObjectsMarked())
592 rSet.DisableItem(nWhich);
596 break;
598 case SID_STYLE_UPDATE_BY_EXAMPLE:
600 if (!mpDrawView->AreObjectsMarked())
602 rSet.DisableItem(nWhich);
605 break;
606 case FN_BUL_NUM_RULE_INDEX:
607 case FN_NUM_NUM_RULE_INDEX:
609 SfxItemSet aEditAttr( GetDoc()->GetPool() );
610 mpDrawView->GetAttributes( aEditAttr );
612 SfxItemSetFixed<EE_ITEMS_START, EE_ITEMS_END> aNewAttr( GetPool() );
613 aNewAttr.Put( aEditAttr, false );
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);
621 if (pTmpItem)
622 pNumRule.reset(new SvxNumRule(static_cast<const SvxNumBulletItem*>(pTmpItem)->GetNumRule()));
624 if ( pNumRule )
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++)
631 if(nActNumLvl & nMask)
633 nCount++;
634 nCurLevel = i;
636 nMask <<= 1;
638 if ( nCount == 1 )
640 const SvxNumberFormat* pNumFmt = pNumRule->Get(nCurLevel);
641 if ( pNumFmt )
643 bool bBullets = false;
644 switch(pNumFmt->GetNumberingType())
646 case SVX_NUM_CHAR_SPECIAL:
647 case SVX_NUM_BITMAP:
648 bBullets = true;
649 break;
651 default:
652 bBullets = false;
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 )
659 NBOTypeMgrBase* pBullets = NBOutlineTypeMgrFact::CreateInstance(NBOType::Bullets);
660 if ( pBullets )
662 sal_uInt16 nBulIndex = pBullets->GetNBOIndexForNumRule(*pNumRule,nActNumLvl);
663 rSet.Put(SfxUInt16Item(FN_BUL_NUM_RULE_INDEX,nBulIndex));
665 }else
667 NBOTypeMgrBase* pNumbering = NBOutlineTypeMgrFact::CreateInstance(NBOType::Numbering);
668 if ( pNumbering )
670 sal_uInt16 nBulIndex = pNumbering->GetNBOIndexForNumRule(*pNumRule,nActNumLvl);
671 rSet.Put(SfxUInt16Item(FN_NUM_NUM_RULE_INDEX,nBulIndex));
678 break;
679 case FN_NUM_BULLET_ON:
680 case FN_NUM_NUMBERING_ON:
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)
687 SdrTextObj* pTextObj = DynCastSdrTextObj(rMarkList.GetMark(nIndex)->GetMarkedSdrObj());
688 if (pTextObj && pTextObj->GetObjInventor() == SdrInventor::Default)
690 if (pTextObj->GetObjIdentifier() != SdrObjKind::OLE2)
692 bEnable = true;
693 break;
697 if (bEnable)
699 rSet.Put(SfxBoolItem(FN_NUM_BULLET_ON, false));
700 rSet.Put(SfxBoolItem(FN_NUM_NUMBERING_ON, false));
702 else
704 rSet.DisableItem(FN_NUM_BULLET_ON);
705 rSet.DisableItem(FN_NUM_NUMBERING_ON);
708 break;
710 nWhich = aIter.NextWhich();
713 std::optional<SfxItemSet> pSet;
715 if( bAttr )
717 pSet.emplace( GetDoc()->GetPool() );
718 mpDrawView->GetAttributes( *pSet );
719 rSet.Put( *pSet, false );
722 rSet.Put( aAllSet, false );
724 // there were changes at area and/or line attributes
725 if( !(bAttr && pSet) )
726 return;
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() )
732 SfxWhichIter aNewIter( *pSet );
733 nWhich = aNewIter.FirstWhich();
734 while( nWhich )
736 if (nWhich >= XATTR_LINE_FIRST && nWhich <= XATTR_LINE_LAST
737 && SfxItemState::DEFAULT == aNewIter.GetItemState() )
739 rSet.ClearItem( nWhich );
740 rSet.DisableItem( nWhich );
742 nWhich = aNewIter.NextWhich();
746 SfxItemState eState = pSet->GetItemState( EE_PARA_LRSPACE );
747 if ( eState == SfxItemState::DONTCARE )
749 rSet.InvalidateItem(EE_PARA_LRSPACE);
750 rSet.InvalidateItem(SID_ATTR_PARA_LRSPACE);
752 eState = pSet->GetItemState( EE_PARA_SBL );
753 if ( eState == SfxItemState::DONTCARE )
755 rSet.InvalidateItem(EE_PARA_SBL);
756 rSet.InvalidateItem(SID_ATTR_PARA_LINESPACE);
758 eState = pSet->GetItemState( EE_PARA_ULSPACE );
759 if ( eState == SfxItemState::DONTCARE )
761 rSet.InvalidateItem(EE_PARA_ULSPACE);
762 rSet.InvalidateItem(SID_ATTR_PARA_ULSPACE);
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));
769 eState = pSet->GetItemState( EE_CHAR_KERNING );
770 if ( eState == SfxItemState::DONTCARE )
772 rSet.InvalidateItem(EE_CHAR_KERNING);
773 rSet.InvalidateItem(SID_ATTR_CHAR_KERNING);
777 OUString DrawViewShell::GetSelectionText(bool bCompleteWords)
779 OUString aStrSelection;
780 ::Outliner* pOl = mpDrawView->GetTextEditOutliner();
781 OutlinerView* pOlView = mpDrawView->GetTextEditOutlinerView();
783 if (pOl && pOlView)
785 if (bCompleteWords)
787 ESelection aSel = pOlView->GetSelection();
788 OUString aStrCurrentDelimiters = pOl->GetWordDelimiters();
790 pOl->SetWordDelimiters(" .,;\"'");
791 aStrSelection = pOl->GetWord( aSel.nEndPara, aSel.nEndPos );
792 pOl->SetWordDelimiters( aStrCurrentDelimiters );
794 else
796 aStrSelection = pOlView->GetSelected();
800 return aStrSelection;
803 bool DrawViewShell::HasSelection(bool bText) const
805 bool bReturn = false;
807 if (bText)
809 OutlinerView* pOlView = mpDrawView->GetTextEditOutlinerView();
811 if (pOlView && !pOlView->GetSelected().isEmpty())
813 bReturn = true;
816 else if (mpDrawView->GetMarkedObjectList().GetMarkCount() != 0)
818 bReturn = true;
821 return bReturn;
824 } // end of namespace sd
826 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */