xref: /AOO41X/main/sd/source/ui/view/drviewsf.cxx (revision ca62e2c2083b5d0995f1245bad6c2edfb455fbec)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_sd.hxx"
26 
27 #include "DrawViewShell.hxx"
28 #include <com/sun/star/form/FormButtonType.hpp>
29 #include <com/sun/star/beans/XPropertySet.hpp>
30 
31 #ifndef _SVXIDS_HRC
32 #include <svx/svxids.hrc>
33 #endif
34 #ifndef _GLOBL3D_HXX
35 #include <svx/globl3d.hxx>
36 #endif
37 #include <svx/hlnkitem.hxx>
38 #include <editeng/eeitem.hxx>
39 #ifndef _FLDITEM_HXX
40 #include <editeng/flditem.hxx>
41 #endif
42 #include <sfx2/viewfrm.hxx>
43 #include <svl/whiter.hxx>
44 #include <svl/eitem.hxx>
45 #include <svl/itempool.hxx>
46 #include <sfx2/tplpitem.hxx>
47 #ifndef _BINDING_HXX //autogen
48 #include <sfx2/bindings.hxx>
49 #endif
50 #include <sfx2/app.hxx>
51 #include <sfx2/templdlg.hxx>
52 #include <svx/xdef.hxx>
53 #include <svx/svddef.hxx>
54 #include <svx/fmglob.hxx>
55 #include <svx/svdouno.hxx>
56 #include <tools/urlobj.hxx>
57 #include <svx/fmshell.hxx>
58 #include <svl/cjkoptions.hxx>
59 
60 #ifndef SD_FRAME_VIEW
61 #include "FrameView.hxx"
62 #endif
63 #include "Outliner.hxx"
64 #include "app.hrc"
65 
66 #include "app.hxx"
67 #include "stlsheet.hxx"
68 #include "drawview.hxx"
69 #include "drawdoc.hxx"
70 #include "Window.hxx"
71 #include "ViewShellBase.hxx"
72 #include "FormShellManager.hxx"
73 #include "cfgids.hxx"
74 #include "anminfo.hxx"
75 
76 #include <editeng/lspcitem.hxx>
77 #include <editeng/ulspitem.hxx>
78 #include <editeng/lrspitem.hxx>
79 #include <editeng/escpitem.hxx>
80 #include <editeng/numitem.hxx>
81 #include <editeng/adjitem.hxx>
82 #include <svx/nbdtmgfact.hxx>
83 #include <svx/nbdtmg.hxx>
84 
85 using namespace svx::sidebar;
86 using ::rtl::OUString;
87 using namespace ::com::sun::star;
88 
89 namespace sd {
90 
91 /*************************************************************************
92 |*
93 |* Status von Controller-SfxSlots setzen
94 |*
95 \************************************************************************/
96 
GetCtrlState(SfxItemSet & rSet)97 void DrawViewShell::GetCtrlState(SfxItemSet &rSet)
98 {
99     if (rSet.GetItemState(SID_RELOAD) != SFX_ITEM_UNKNOWN)
100     {
101         // "Letzte Version" vom SFx en/disablen lassen
102         GetViewFrame()->GetSlotState (SID_RELOAD, NULL, &rSet);
103     }
104 
105     if (SFX_ITEM_AVAILABLE == rSet.GetItemState(SID_HYPERLINK_GETLINK))
106     {
107         SvxHyperlinkItem aHLinkItem;
108 
109         OutlinerView* pOLV = mpDrawView->GetTextEditOutlinerView();
110 
111         if (pOLV)
112         {
113             bool bField = false;
114             const SvxFieldItem* pFieldItem = pOLV->GetFieldAtSelection();
115             if (pFieldItem)
116             {
117                 ESelection aSel = pOLV->GetSelection();
118                 if ( abs( aSel.nEndPos - aSel.nStartPos ) == 1 )
119                 {
120                     const SvxFieldData* pField = pFieldItem->GetField();
121                     if (pField->ISA(SvxURLField))
122                     {
123                         aHLinkItem.SetName(((const SvxURLField*) pField)->GetRepresentation());
124                         aHLinkItem.SetURL(((const SvxURLField*) pField)->GetURL());
125                         aHLinkItem.SetTargetFrame(((const SvxURLField*) pField)->GetTargetFrame());
126                         bField = true;
127                     }
128                 }
129             }
130             if (!bField)
131             {
132                 // use selected text as name for urls
133                 String sReturn = pOLV->GetSelected();
134                 sReturn.Erase(255);
135                 sReturn.EraseTrailingChars();
136                 aHLinkItem.SetName(sReturn);
137             }
138         }
139         else
140         {
141             if (mpDrawView->GetMarkedObjectList().GetMarkCount() > 0)
142             {
143                 bool bFound = false;
144 
145                 SdrObject* pMarkedObj = mpDrawView->GetMarkedObjectList().GetMark(0)->GetMarkedSdrObj();
146                 if( pMarkedObj && (FmFormInventor == pMarkedObj->GetObjInventor()) )
147                 {
148                     SdrUnoObj* pUnoCtrl = dynamic_cast< SdrUnoObj* >( pMarkedObj );
149 
150                     if(pUnoCtrl) try
151                     {
152                         uno::Reference< awt::XControlModel > xControlModel( pUnoCtrl->GetUnoControlModel(), uno::UNO_QUERY_THROW );
153                         uno::Reference< beans::XPropertySet > xPropSet( xControlModel, uno::UNO_QUERY_THROW );
154                         uno::Reference< beans::XPropertySetInfo > xPropInfo( xPropSet->getPropertySetInfo(), uno::UNO_QUERY_THROW );
155 
156                         form::FormButtonType eButtonType = form::FormButtonType_URL;
157                         const OUString sButtonType( RTL_CONSTASCII_USTRINGPARAM( "ButtonType" ) );
158                         if(xPropInfo->hasPropertyByName( sButtonType ) && (xPropSet->getPropertyValue( sButtonType ) >>= eButtonType ) )
159                         {
160                             OUString aString;
161 
162                             // Label
163                             const OUString sLabel( RTL_CONSTASCII_USTRINGPARAM( "Label" ) );
164                             if(xPropInfo->hasPropertyByName(sLabel))
165                             {
166                                 if( xPropSet->getPropertyValue(sLabel) >>= aString )
167                                     aHLinkItem.SetName(String( aString ));
168                             }
169 
170                             // URL
171                             const OUString sTargetURL(RTL_CONSTASCII_USTRINGPARAM( "TargetURL" ));
172                             if(xPropInfo->hasPropertyByName(sTargetURL))
173                             {
174                                 if( xPropSet->getPropertyValue(sTargetURL) >>= aString )
175                                     aHLinkItem.SetURL(String( aString ));
176                             }
177 
178                             // Target
179                             const OUString sTargetFrame( RTL_CONSTASCII_USTRINGPARAM( "TargetFrame" ) );
180                             if(xPropInfo->hasPropertyByName(sTargetFrame) )
181                             {
182                                 if( xPropSet->getPropertyValue(sTargetFrame) >>= aString )
183                                     aHLinkItem.SetTargetFrame(String( aString ));
184                             }
185 
186                             aHLinkItem.SetInsertMode(HLINK_BUTTON);
187                             bFound = true;
188                         }
189                     }
190                     catch( uno::Exception& )
191                     {
192                     }
193                 }
194 
195                 // try interaction link
196                 if( !bFound && pMarkedObj )
197                 {
198                     SdAnimationInfo* pInfo = SdDrawDocument::GetShapeUserData(*pMarkedObj);
199                     if( pInfo && (pInfo->meClickAction == presentation::ClickAction_DOCUMENT) )
200                         aHLinkItem.SetURL( pInfo->GetBookmark());
201                     aHLinkItem.SetInsertMode(HLINK_BUTTON);
202                 }
203             }
204         }
205 
206         rSet.Put(aHLinkItem);
207     }
208     rSet.Put( SfxBoolItem( SID_READONLY_MODE, mbReadOnly ) );
209 
210     // Ausgabequalitaet
211     if( SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_OUTPUT_QUALITY_COLOR ) ||
212         SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_OUTPUT_QUALITY_GRAYSCALE ) ||
213         SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_OUTPUT_QUALITY_BLACKWHITE ) ||
214         SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_OUTPUT_QUALITY_CONTRAST ) )
215     {
216         const sal_uLong nMode = (sal_Int32)GetActiveWindow()->GetDrawMode();
217         rSet.Put( SfxBoolItem( SID_OUTPUT_QUALITY_COLOR, (sal_Bool)((sal_uLong)OUTPUT_DRAWMODE_COLOR == nMode) ) );
218         rSet.Put( SfxBoolItem( SID_OUTPUT_QUALITY_GRAYSCALE, (sal_Bool)((sal_uLong)OUTPUT_DRAWMODE_GRAYSCALE == nMode) ) );
219         rSet.Put( SfxBoolItem( SID_OUTPUT_QUALITY_BLACKWHITE, (sal_Bool)((sal_uLong)OUTPUT_DRAWMODE_BLACKWHITE == nMode) ) );
220         rSet.Put( SfxBoolItem( SID_OUTPUT_QUALITY_CONTRAST, (sal_Bool)((sal_uLong)OUTPUT_DRAWMODE_CONTRAST == nMode) ) );
221     }
222 
223     if ( SFX_ITEM_AVAILABLE == rSet.GetItemState(SID_MAIL_SCROLLBODY_PAGEDOWN) )
224     {
225         rSet.Put( SfxBoolItem( SID_MAIL_SCROLLBODY_PAGEDOWN, sal_True ) );
226     }
227 
228     if ( SFX_ITEM_AVAILABLE == rSet.GetItemState(SID_ATTR_YEAR2000) )
229     {
230         FmFormShell* pFormShell = GetViewShellBase().GetFormShellManager()->GetFormShell();
231         if (pFormShell != NULL)
232         {
233             sal_uInt16 nState = 0;
234             if (pFormShell->GetY2KState(nState))
235                 rSet.Put( SfxUInt16Item( SID_ATTR_YEAR2000, nState ) );
236             else
237                 rSet.DisableItem( SID_ATTR_YEAR2000 );
238         }
239     }
240 
241     if ( !GetView()->GetTextEditOutliner() )
242     {
243         SvtCJKOptions aCJKOptions;
244         if( !aCJKOptions.IsChangeCaseMapEnabled() )
245         {
246             GetViewFrame()->GetBindings().SetVisibleState( SID_TRANSLITERATE_HALFWIDTH, sal_False );
247             GetViewFrame()->GetBindings().SetVisibleState( SID_TRANSLITERATE_FULLWIDTH, sal_False );
248             GetViewFrame()->GetBindings().SetVisibleState( SID_TRANSLITERATE_HIRAGANA, sal_False );
249             GetViewFrame()->GetBindings().SetVisibleState( SID_TRANSLITERATE_KATAGANA, sal_False );
250         }
251         else
252         {
253             GetViewFrame()->GetBindings().SetVisibleState( SID_TRANSLITERATE_HALFWIDTH, sal_True );
254             GetViewFrame()->GetBindings().SetVisibleState( SID_TRANSLITERATE_FULLWIDTH, sal_True );
255             GetViewFrame()->GetBindings().SetVisibleState( SID_TRANSLITERATE_HIRAGANA, sal_True );
256             GetViewFrame()->GetBindings().SetVisibleState( SID_TRANSLITERATE_KATAGANA, sal_True );
257         }
258 
259         rSet.DisableItem( SID_TRANSLITERATE_SENTENCE_CASE );
260         rSet.DisableItem( SID_TRANSLITERATE_TITLE_CASE );
261         rSet.DisableItem( SID_TRANSLITERATE_TOGGLE_CASE );
262         rSet.DisableItem( SID_TRANSLITERATE_UPPER );
263         rSet.DisableItem( SID_TRANSLITERATE_LOWER );
264         rSet.DisableItem( SID_TRANSLITERATE_HALFWIDTH );
265         rSet.DisableItem( SID_TRANSLITERATE_FULLWIDTH );
266         rSet.DisableItem( SID_TRANSLITERATE_HIRAGANA );
267         rSet.DisableItem( SID_TRANSLITERATE_KATAGANA );
268     }
269     else
270     {
271         SvtCJKOptions aCJKOptions;
272         if( !aCJKOptions.IsChangeCaseMapEnabled() )
273         {
274             GetViewFrame()->GetBindings().SetVisibleState( SID_TRANSLITERATE_HALFWIDTH, sal_False );
275             GetViewFrame()->GetBindings().SetVisibleState( SID_TRANSLITERATE_FULLWIDTH, sal_False );
276             GetViewFrame()->GetBindings().SetVisibleState( SID_TRANSLITERATE_HIRAGANA, sal_False );
277             GetViewFrame()->GetBindings().SetVisibleState( SID_TRANSLITERATE_KATAGANA, sal_False );
278             rSet.DisableItem( SID_TRANSLITERATE_HALFWIDTH );
279             rSet.DisableItem( SID_TRANSLITERATE_FULLWIDTH );
280             rSet.DisableItem( SID_TRANSLITERATE_HIRAGANA );
281             rSet.DisableItem( SID_TRANSLITERATE_KATAGANA );
282         }
283         else
284         {
285             GetViewFrame()->GetBindings().SetVisibleState( SID_TRANSLITERATE_HALFWIDTH, sal_True );
286             GetViewFrame()->GetBindings().SetVisibleState( SID_TRANSLITERATE_FULLWIDTH, sal_True );
287             GetViewFrame()->GetBindings().SetVisibleState( SID_TRANSLITERATE_HIRAGANA, sal_True );
288             GetViewFrame()->GetBindings().SetVisibleState( SID_TRANSLITERATE_KATAGANA, sal_True );
289         }
290     }
291 }
292 
293 
294 /*************************************************************************
295 |*
296 |* Status der Attribut-Items
297 |*
298 \************************************************************************/
299 
GetAttrState(SfxItemSet & rSet)300 void DrawViewShell::GetAttrState( SfxItemSet& rSet )
301 {
302     SfxWhichIter    aIter( rSet );
303     sal_uInt16          nWhich = aIter.FirstWhich();
304 
305     sal_Bool    bAttr = sal_False;
306     SfxAllItemSet aAllSet( *rSet.GetPool() );
307 
308     while ( nWhich )
309     {
310         sal_uInt16 nSlotId = SfxItemPool::IsWhich(nWhich)
311             ? GetPool().GetSlotId(nWhich)
312             : nWhich;
313         switch ( nSlotId )
314         {
315             case SID_ATTR_PARA_ADJUST_LEFT:
316             {
317                 SfxItemSet aAttrs( GetDoc()->GetPool() );
318                 mpDrawView->GetAttributes( aAttrs );
319 
320                 SvxAdjustItem aItem= ( (const SvxAdjustItem&) aAttrs.Get( EE_PARA_JUST ) );
321                 SvxAdjust eAdj = aItem.GetAdjust();
322                 if ( eAdj == SVX_ADJUST_LEFT)
323                 {
324                     rSet.Put( SfxBoolItem( SID_ATTR_PARA_ADJUST_LEFT, sal_True ) );
325                 }
326 
327                 bAttr = sal_True;
328 
329                 Invalidate(nSlotId);
330             }
331             break;
332             case SID_ATTR_PARA_ADJUST_CENTER:
333             {
334                 SfxItemSet aAttrs( GetDoc()->GetPool() );
335                 mpDrawView->GetAttributes( aAttrs );
336 
337                 SvxAdjustItem aItem= ( (const SvxAdjustItem&) aAttrs.Get( EE_PARA_JUST ) );
338                 SvxAdjust eAdj = aItem.GetAdjust();
339                 if ( eAdj == SVX_ADJUST_CENTER)
340                 {
341                     rSet.Put( SfxBoolItem( SID_ATTR_PARA_ADJUST_CENTER, sal_True ) );
342                 }
343 
344                 bAttr = sal_True;
345 
346                 Invalidate(nSlotId);
347             }
348             break;
349             case SID_ATTR_PARA_ADJUST_RIGHT:
350             {
351                 SfxItemSet aAttrs( GetDoc()->GetPool() );
352                 mpDrawView->GetAttributes( aAttrs );
353 
354                 SvxAdjustItem aItem= ( (const SvxAdjustItem&) aAttrs.Get( EE_PARA_JUST ) );
355                 SvxAdjust eAdj = aItem.GetAdjust();
356                 if ( eAdj == SVX_ADJUST_RIGHT)
357                 {
358                     rSet.Put( SfxBoolItem( SID_ATTR_PARA_ADJUST_RIGHT, sal_True ) );
359                 }
360 
361                 bAttr = sal_True;
362 
363                 Invalidate(nSlotId);
364             }
365             break;
366             case SID_ATTR_PARA_ADJUST_BLOCK:
367             {
368                 SfxItemSet aAttrs( GetDoc()->GetPool() );
369                 mpDrawView->GetAttributes( aAttrs );
370 
371                 SvxAdjustItem aItem= ( (const SvxAdjustItem&) aAttrs.Get( EE_PARA_JUST ) );
372                 SvxAdjust eAdj = aItem.GetAdjust();
373                 if ( eAdj == SVX_ADJUST_BLOCK)
374                 {
375                     rSet.Put( SfxBoolItem( SID_ATTR_PARA_ADJUST_BLOCK, sal_True ) );
376                 }
377 
378                 bAttr = sal_True;
379 
380                 Invalidate(nSlotId);
381             }
382             break;
383             case SID_ATTR_PARA_LRSPACE:
384             {
385                 SfxItemSet aAttrs( GetDoc()->GetPool() );
386                 mpDrawView->GetAttributes( aAttrs );
387                 SvxLRSpaceItem aLRSpace = ( (const SvxLRSpaceItem&) aAttrs.Get( EE_PARA_LRSPACE ) );
388                 aLRSpace.SetWhich(SID_ATTR_PARA_LRSPACE);
389                 rSet.Put(aLRSpace);
390                 bAttr = sal_True;
391                 Invalidate(SID_ATTR_PARA_LRSPACE);
392             }
393             break;
394             case SID_ATTR_PARA_LINESPACE:
395             {
396                 SfxItemSet aAttrs( GetDoc()->GetPool() );
397                 mpDrawView->GetAttributes( aAttrs );
398                 SvxLineSpacingItem aLineLR = ( (const SvxLineSpacingItem&) aAttrs.Get( EE_PARA_SBL ) );
399                 rSet.Put(aLineLR);
400                 bAttr = sal_True;
401                 Invalidate(SID_ATTR_PARA_LINESPACE);
402             }
403             break;
404             case SID_ATTR_PARA_ULSPACE:
405             {
406                 SfxItemSet aAttrs( GetDoc()->GetPool() );
407                 mpDrawView->GetAttributes( aAttrs );
408                 SvxULSpaceItem aULSP = ( (const SvxULSpaceItem&) aAttrs.Get( EE_PARA_ULSPACE ) );
409                 aULSP.SetWhich(SID_ATTR_PARA_ULSPACE);
410                 rSet.Put(aULSP);
411                 bAttr = sal_True;
412                 Invalidate(SID_ATTR_PARA_ULSPACE);
413             }
414             break;
415             case SID_ATTR_FILL_STYLE:
416             case SID_ATTR_FILL_COLOR:
417             case SID_ATTR_FILL_GRADIENT:
418             case SID_ATTR_FILL_HATCH:
419             case SID_ATTR_FILL_BITMAP:
420             case SID_ATTR_FILL_SHADOW:
421             case SID_ATTR_FILL_TRANSPARENCE:
422             case SID_ATTR_FILL_FLOATTRANSPARENCE:
423             case SID_ATTR_LINE_STYLE:
424             case SID_ATTR_LINE_DASH:
425             case SID_ATTR_LINE_WIDTH:
426             case SID_ATTR_LINE_COLOR:
427             case SID_ATTR_LINE_TRANSPARENCE:
428             case SID_ATTR_LINE_JOINT:
429             case SID_ATTR_LINE_CAP:
430             case SID_ATTR_TEXT_FITTOSIZE:
431             case SID_ATTR_CHAR_FONT:
432             case SID_ATTR_CHAR_FONTHEIGHT:
433             case SID_ATTR_CHAR_SHADOWED:
434             case SID_ATTR_CHAR_POSTURE:
435             case SID_ATTR_CHAR_UNDERLINE:
436             case SID_ATTR_CHAR_STRIKEOUT:
437             case SID_ATTR_CHAR_WEIGHT:
438             case SID_ATTR_CHAR_COLOR:
439             case SID_ATTR_CHAR_KERNING:
440             case SID_SET_SUB_SCRIPT:
441             case SID_SET_SUPER_SCRIPT:
442             {
443                 bAttr = sal_True;
444             }
445             break;
446 
447             case SID_HYPHENATION:
448             {
449                 SfxItemSet aAttrs( GetDoc()->GetPool() );
450                 mpDrawView->GetAttributes( aAttrs );
451                 if( aAttrs.GetItemState( EE_PARA_HYPHENATE ) >= SFX_ITEM_AVAILABLE )
452                 {
453                     sal_Bool bValue = ( (const SfxBoolItem&) aAttrs.Get( EE_PARA_HYPHENATE ) ).GetValue();
454                     rSet.Put( SfxBoolItem( SID_HYPHENATION, bValue ) );
455                 }
456             }
457             break;
458 
459             case SID_STYLE_FAMILY2:
460             case SID_STYLE_FAMILY3:
461             case SID_STYLE_FAMILY5:
462             case SID_STYLE_APPLY: // StyleControl
463             {
464                 SfxStyleSheet* pStyleSheet = mpDrawView->GetStyleSheet();
465                 if( pStyleSheet )
466                 {
467                     if( nSlotId != SID_STYLE_APPLY && !mpDrawView->AreObjectsMarked() )
468                     {
469                         SfxTemplateItem aTmpItem( nWhich, String() );
470                         aAllSet.Put( aTmpItem, aTmpItem.Which()  );
471                     }
472                     else
473                     {
474                         if (pStyleSheet->GetFamily() == SD_STYLE_FAMILY_MASTERPAGE)
475                             pStyleSheet = ((SdStyleSheet*)pStyleSheet)->GetPseudoStyleSheet();
476 
477                         if( pStyleSheet )
478                         {
479                             SfxStyleFamily eFamily = pStyleSheet->GetFamily();
480 
481                             if ((eFamily == SD_STYLE_FAMILY_GRAPHICS &&     nSlotId == SID_STYLE_FAMILY2)       ||
482                                 (eFamily == SD_STYLE_FAMILY_CELL     && nSlotId == SID_STYLE_FAMILY3)       ||
483                                 (eFamily == SD_STYLE_FAMILY_PSEUDO &&   nSlotId == SID_STYLE_FAMILY5))
484                             {
485                                 SfxTemplateItem aTmpItem ( nWhich, pStyleSheet->GetName() );
486                                 aAllSet.Put( aTmpItem, aTmpItem.Which()  );
487                             }
488                             else
489                             {
490                                 SfxTemplateItem aTmpItem(nWhich, String());
491                                 aAllSet.Put(aTmpItem,aTmpItem.Which()  );
492                             }
493                         }
494                     }
495                 }
496                 else
497                 {   SfxTemplateItem aItem( nWhich, String() );
498                     aAllSet.Put( aItem, aItem.Which() );
499                     // rSet.DisableItem( nWhich );
500                 }
501             }
502             break;
503 
504             case SID_SET_DEFAULT:
505             {
506                 if( !mpDrawView->GetMarkedObjectList().GetMarkCount() ||
507                     ( !mpDrawView->IsTextEdit() && !mpDrawView->GetStyleSheet() )
508                   )
509                     rSet.DisableItem( nWhich );
510             }
511             break;
512 
513             case SID_STYLE_WATERCAN:
514             {
515                 ISfxTemplateCommon* pTemplateCommon = SFX_APP()->GetCurrentTemplateCommon(GetViewFrame()->GetBindings());
516                 if (pTemplateCommon && pTemplateCommon->GetActualFamily() == SD_STYLE_FAMILY_PSEUDO)
517                     rSet.Put(SfxBoolItem(nWhich,sal_False));
518                 else
519                 {
520                     SfxBoolItem aItem(nWhich, SD_MOD()->GetWaterCan());
521                     aAllSet.Put( aItem, aItem.Which());
522                 }
523             }
524             break;
525 
526             case SID_STYLE_NEW:
527             {
528                 ISfxTemplateCommon* pTemplateCommon = SFX_APP()->GetCurrentTemplateCommon(GetViewFrame()->GetBindings());
529                 if (pTemplateCommon && pTemplateCommon->GetActualFamily() == SD_STYLE_FAMILY_PSEUDO)
530                     rSet.DisableItem(nWhich);
531             }
532             break;
533 
534             case SID_STYLE_DRAGHIERARCHIE:
535             {
536                 ISfxTemplateCommon* pTemplateCommon = SFX_APP()->GetCurrentTemplateCommon(GetViewFrame()->GetBindings());
537                 if (pTemplateCommon && pTemplateCommon->GetActualFamily() == SD_STYLE_FAMILY_PSEUDO)
538                     rSet.DisableItem(nWhich);
539             }
540             break;
541 
542             case SID_STYLE_NEW_BY_EXAMPLE:
543             {
544                 // PseudoStyleSheets koennen nicht 'by Example' erzeugt werden;
545                 // normale StyleSheets brauchen dafuer ein selektiertes Objekt
546                 ISfxTemplateCommon* pTemplCommon = SFX_APP()->GetCurrentTemplateCommon(GetViewFrame()->GetBindings());
547                 if (pTemplCommon)
548                 {
549                     if (pTemplCommon->GetActualFamily() == SD_STYLE_FAMILY_PSEUDO)
550                     {
551                         rSet.DisableItem(nWhich);
552                     }
553                     else if (pTemplCommon->GetActualFamily() == SD_STYLE_FAMILY_GRAPHICS)
554                     {
555                         if (!mpDrawView->AreObjectsMarked())
556                         {
557                             rSet.DisableItem(nWhich);
558                         }
559                     }
560                 }
561                 // falls (noch) kein Gestalter da ist, muessen wir uns auf den
562                 // View-Zustand zurueckziehen; eine aktuell eingestellte Familie
563                 // kann nicht beruecksichtigt werden
564                 else
565                 {
566                     if (!mpDrawView->AreObjectsMarked())
567                     {
568                         rSet.DisableItem(nWhich);
569                     }
570                 }
571 
572             }
573             break;
574 
575             case SID_STYLE_UPDATE_BY_EXAMPLE:
576             {
577                 if (!mpDrawView->AreObjectsMarked())
578                 {
579                     rSet.DisableItem(nWhich);
580                 }
581             }
582             break;
583             case FN_BUL_NUM_RULE_INDEX:
584             case FN_NUM_NUM_RULE_INDEX:
585             {
586                 SfxItemSet aEditAttr( GetDoc()->GetPool() );
587                 mpDrawView->GetAttributes( aEditAttr );
588 
589                 SfxItemSet aNewAttr( GetPool(), EE_ITEMS_START, EE_ITEMS_END );
590                 aNewAttr.Put( aEditAttr, sal_False );
591 
592 
593                 sal_uInt16 nActNumLvl = (sal_uInt16)0xFFFF;
594                 SvxNumRule* pNumRule = NULL;
595                 const SfxPoolItem* pTmpItem=NULL;
596                 sal_uInt16 nNumItemId = SID_ATTR_NUMBERING_RULE;
597 
598                 //if(SFX_ITEM_SET == aNewAttr.GetItemState(SID_PARAM_CUR_NUM_LEVEL, sal_False, &pTmpItem))
599                 //  nActNumLvl = ((const SfxUInt16Item*)pTmpItem)->GetValue();
600                 rSet.Put(SfxUInt16Item(FN_NUM_NUM_RULE_INDEX,DEFAULT_NONE));
601                 rSet.Put(SfxUInt16Item(FN_BUL_NUM_RULE_INDEX,DEFAULT_NONE));
602                 nActNumLvl = mpDrawView->GetSelectionLevel();
603                 pTmpItem=GetNumBulletItem(aNewAttr, nNumItemId);
604 
605                 if (pTmpItem)
606                     pNumRule = new SvxNumRule(*((SvxNumBulletItem*)pTmpItem)->GetNumRule());
607 
608                 if ( pNumRule )
609                 {
610                     sal_uInt16 nMask = 1;
611                     sal_uInt16 nCount = 0;
612                     sal_uInt16 nCurLevel = (sal_uInt16)0xFFFF;
613                     for(sal_uInt16 i = 0; i < pNumRule->GetLevelCount(); i++)
614                     {
615                         if(nActNumLvl & nMask)
616                         {
617                             nCount++;
618                             nCurLevel = i;
619                         }
620                         nMask <<= 1;
621                     }
622                     if ( nCount == 1 )
623                     {
624                         sal_Bool bBullets = sal_False;
625                         const SvxNumberFormat* pNumFmt = pNumRule->Get(nCurLevel);
626                         if ( pNumFmt )
627                         {
628                             switch(pNumFmt->GetNumberingType())
629                             {
630                                 case SVX_NUM_CHAR_SPECIAL:
631                                 case SVX_NUM_BITMAP:
632                                     bBullets = sal_True;
633                                     break;
634 
635                                 default:
636                                     bBullets = sal_False;
637                             }
638 
639                             rSet.Put(SfxUInt16Item(FN_BUL_NUM_RULE_INDEX,(sal_uInt16)0xFFFF));
640                             rSet.Put(SfxUInt16Item(FN_NUM_NUM_RULE_INDEX,(sal_uInt16)0xFFFF));
641                             if ( bBullets )
642                             {
643                                 NBOTypeMgrBase* pBullets = NBOutlineTypeMgrFact::CreateInstance(eNBOType::MIXBULLETS);
644                                 if ( pBullets )
645                                 {
646                                     sal_uInt16 nBulIndex = pBullets->GetNBOIndexForNumRule(*pNumRule,nActNumLvl);
647                                      rSet.Put(SfxUInt16Item(FN_BUL_NUM_RULE_INDEX,nBulIndex));
648                                 }
649                             }else
650                             {
651                                 NBOTypeMgrBase* pNumbering = NBOutlineTypeMgrFact::CreateInstance(eNBOType::NUMBERING);
652                                 if ( pNumbering )
653                                 {
654                                     sal_uInt16 nBulIndex = pNumbering->GetNBOIndexForNumRule(*pNumRule,nActNumLvl);
655                                      rSet.Put(SfxUInt16Item(FN_NUM_NUM_RULE_INDEX,nBulIndex));
656                                 }
657                             }
658                         }
659                     }
660                 }
661             }
662                     break;
663             //End
664             // Added by Li Hui for story 179.
665             case FN_NUM_BULLET_ON:
666             case FN_NUM_NUMBERING_ON:
667             {
668                 sal_Bool bEnable = sal_False;
669                 const SdrMarkList& rMarkList = mpDrawView->GetMarkedObjectList();
670                 const sal_uInt32 nMarkCount = rMarkList.GetMarkCount();
671                 for (sal_uInt32 nIndex = 0; nIndex < nMarkCount; nIndex++)
672                 {
673                     SdrTextObj* pTextObj = dynamic_cast< SdrTextObj* >(rMarkList.GetMark(nIndex)->GetMarkedSdrObj());
674                     if (pTextObj && pTextObj->GetObjInventor() == SdrInventor)
675                     {
676                         if (pTextObj->GetObjIdentifier() != OBJ_OLE2)
677                         {
678                             bEnable = sal_True;
679                             break;
680                         }
681                     }
682                 }
683                 if (bEnable)
684                 {
685                     rSet.Put(SfxBoolItem(FN_NUM_BULLET_ON, sal_False));
686                     rSet.Put(SfxBoolItem(FN_NUM_NUMBERING_ON, sal_False));
687                 }
688                 else
689                 {
690                     rSet.DisableItem(FN_NUM_BULLET_ON);
691                     rSet.DisableItem(FN_NUM_NUMBERING_ON);
692                 }
693             }
694             break;
695         }
696         nWhich = aIter.NextWhich();
697     }
698 
699     SfxItemSet* pSet = NULL;
700 
701     if( bAttr )
702     {
703         pSet = new SfxItemSet( GetDoc()->GetPool() );
704         mpDrawView->GetAttributes( *pSet );
705         rSet.Put( *pSet, sal_False );
706     }
707 
708     rSet.Put( aAllSet, sal_False );
709 
710     // Flaechen und/oder Linienattribute wurden geaendert
711     if( bAttr && pSet )
712     {
713         // Wenn die View selektierte Objekte besitzt, muessen entspr. Items
714         // von SFX_ITEM_DEFAULT (_ON) auf SFX_ITEM_DISABLED geaendert werden
715         if( mpDrawView->AreObjectsMarked() )
716         {
717             SfxWhichIter aNewIter( *pSet, XATTR_LINE_FIRST, XATTR_FILL_LAST );
718             nWhich = aNewIter.FirstWhich();
719             while( nWhich )
720             {
721                 if( SFX_ITEM_DEFAULT == pSet->GetItemState( nWhich ) )
722                 {
723                     rSet.ClearItem( nWhich );
724                     rSet.DisableItem( nWhich );
725                 }
726                 nWhich = aNewIter.NextWhich();
727             }
728         }
729 
730         SfxItemState eState = pSet->GetItemState( EE_PARA_LRSPACE );
731         if ( eState == SFX_ITEM_DONTCARE )
732         {
733             rSet.InvalidateItem(EE_PARA_LRSPACE);
734             rSet.InvalidateItem(SID_ATTR_PARA_LRSPACE);
735         }
736         eState = pSet->GetItemState( EE_PARA_SBL );
737         if ( eState == SFX_ITEM_DONTCARE )
738         {
739             rSet.InvalidateItem(EE_PARA_SBL);
740             rSet.InvalidateItem(SID_ATTR_PARA_LINESPACE);
741         }
742         eState = pSet->GetItemState( EE_PARA_ULSPACE );
743         if ( eState == SFX_ITEM_DONTCARE )
744         {
745             rSet.InvalidateItem(EE_PARA_ULSPACE);
746             rSet.InvalidateItem(SID_ATTR_PARA_ULSPACE);
747         }
748 
749         SvxEscapement eEsc = (SvxEscapement) ( (const SvxEscapementItem&)
750                         pSet->Get( EE_CHAR_ESCAPEMENT ) ).GetEnumValue();
751         if( eEsc == SVX_ESCAPEMENT_SUPERSCRIPT )
752         {
753             rSet.Put( SfxBoolItem( SID_SET_SUPER_SCRIPT, sal_True ) );
754         }
755         else if( eEsc == SVX_ESCAPEMENT_SUBSCRIPT )
756         {
757             rSet.Put( SfxBoolItem( SID_SET_SUB_SCRIPT, sal_True ) );
758         }
759 
760         eState = pSet->GetItemState( EE_CHAR_KERNING, sal_True );
761         if ( eState == SFX_ITEM_DONTCARE )
762         {
763             rSet.InvalidateItem(EE_CHAR_KERNING);
764             rSet.InvalidateItem(SID_ATTR_CHAR_KERNING);
765         }
766         delete pSet;
767     }
768 }
769 
770 
771 /*************************************************************************
772 |*
773 |* Text der Selektion zurueckgeben
774 |*
775 \************************************************************************/
776 
GetSelectionText(sal_Bool bCompleteWords)777 String DrawViewShell::GetSelectionText(sal_Bool bCompleteWords)
778 {
779     String 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             String aStrCurrentDelimiters = pOl->GetWordDelimiters();
789 
790             pOl->SetWordDelimiters( String( RTL_CONSTASCII_USTRINGPARAM( " .,;\"'" )));
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 
803 /*************************************************************************
804 |*
805 |* Ist etwas selektiert?
806 |*
807 \************************************************************************/
808 
HasSelection(sal_Bool bText) const809 sal_Bool DrawViewShell::HasSelection(sal_Bool bText) const
810 {
811     sal_Bool bReturn = sal_False;
812 
813     if (bText)
814     {
815         OutlinerView* pOlView = mpDrawView->GetTextEditOutlinerView();
816 
817         if (pOlView && pOlView->GetSelected().Len() != 0)
818         {
819             bReturn = sal_True;
820         }
821     }
822     else if (mpDrawView->GetMarkedObjectList().GetMarkCount() != 0)
823     {
824         bReturn = sal_True;
825     }
826 
827     return bReturn;
828 }
829 
830 } // end of namespace sd
831