LCOV - code coverage report
Current view: top level - sd/source/ui/view - drtxtob.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 21 258 8.1 %
Date: 2015-06-13 12:38:46 Functions: 9 16 56.2 %
Legend: Lines: hit not hit

          Line data    Source code
       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 "TextObjectBar.hxx"
      21             : 
      22             : #include <svx/svxids.hrc>
      23             : 
      24             : #include <i18nlangtag/mslangid.hxx>
      25             : #include <editeng/ulspitem.hxx>
      26             : #include <editeng/lspcitem.hxx>
      27             : #include <editeng/adjustitem.hxx>
      28             : #include <editeng/editview.hxx>
      29             : #include <editeng/editeng.hxx>
      30             : #include <editeng/outliner.hxx>
      31             : #include <editeng/unolingu.hxx>
      32             : #include <editeng/kernitem.hxx>
      33             : #include <vcl/vclenum.hxx>
      34             : #include <sfx2/app.hxx>
      35             : #include <sfx2/request.hxx>
      36             : #include <svl/whiter.hxx>
      37             : #include <svl/itempool.hxx>
      38             : #include <svl/stritem.hxx>
      39             : #include <svl/style.hxx>
      40             : #include <svl/languageoptions.hxx>
      41             : #include <sfx2/tplpitem.hxx>
      42             : #include <editeng/escapementitem.hxx>
      43             : #include <svx/svdoutl.hxx>
      44             : #include <svl/intitem.hxx>
      45             : #include <editeng/scripttypeitem.hxx>
      46             : #include <editeng/outlobj.hxx>
      47             : #include <editeng/writingmodeitem.hxx>
      48             : #include <editeng/frmdiritem.hxx>
      49             : #include <editeng/fhgtitem.hxx>
      50             : 
      51             : #include <sfx2/objface.hxx>
      52             : 
      53             : #include "app.hrc"
      54             : #include "glob.hrc"
      55             : #include "res_bmp.hrc"
      56             : 
      57             : #include "drawdoc.hxx"
      58             : #include "DrawViewShell.hxx"
      59             : #include "OutlineViewShell.hxx"
      60             : #include "ViewShellBase.hxx"
      61             : #include "ToolBarManager.hxx"
      62             : #include "futempl.hxx"
      63             : #include "sdresid.hxx"
      64             : #include "Window.hxx"
      65             : #include "OutlineView.hxx"
      66             : 
      67             : using namespace sd;
      68             : using namespace ::com::sun::star;
      69             : 
      70             : #define TextObjectBar
      71             : #include "sdslots.hxx"
      72             : 
      73             : namespace sd {
      74             : 
      75             : /**
      76             :  * Declare default interface (Slotmap must not be empty, therefore enter
      77             :  * something that (hopefully) never occurs.
      78             :  */
      79          60 : SFX_IMPL_INTERFACE(TextObjectBar, SfxShell)
      80             : 
      81          21 : void TextObjectBar::InitInterface_Impl()
      82             : {
      83          21 : }
      84             : 
      85           0 : TYPEINIT1( TextObjectBar, SfxShell );
      86             : 
      87           3 : TextObjectBar::TextObjectBar (
      88             :     ViewShell* pSdViewSh,
      89             :     SfxItemPool& rItemPool,
      90             :     ::sd::View* pSdView )
      91             :     : SfxShell(pSdViewSh->GetViewShell()),
      92             :       mpViewShell( pSdViewSh ),
      93           3 :       mpView( pSdView )
      94             : {
      95           3 :     SetPool(&rItemPool);
      96             : 
      97           3 :     if( mpView )
      98             :     {
      99           3 :         OutlineView* pOutlinerView = dynamic_cast< OutlineView* >( mpView );
     100           3 :         if( pOutlinerView )
     101             :         {
     102           0 :             SetUndoManager(&pOutlinerView->GetOutliner().GetUndoManager());
     103             :         }
     104             :         else
     105             :         {
     106           3 :             DrawDocShell* pDocShell = mpView->GetDoc().GetDocSh();
     107           3 :             if( pDocShell )
     108             :             {
     109           3 :                 SetUndoManager(pDocShell->GetUndoManager());
     110           3 :                 DrawViewShell* pDrawViewShell = dynamic_cast< DrawViewShell* >( pSdViewSh );
     111           3 :                 if ( pDrawViewShell )
     112           3 :                     SetRepeatTarget(pSdView);
     113             :             }
     114             :         }
     115             :     }
     116             : 
     117           3 :     SetName( OUString( "TextObjectBar" ));
     118             : 
     119             :     // SetHelpId( SD_IF_SDDRAWTEXTOBJECTBAR );
     120           3 : }
     121             : 
     122           9 : TextObjectBar::~TextObjectBar()
     123             : {
     124           3 :     SetRepeatTarget(NULL);
     125           6 : }
     126             : 
     127           0 : void TextObjectBar::GetCharState( SfxItemSet& rSet )
     128             : {
     129           0 :     SfxItemSet  aCharAttrSet( mpView->GetDoc().GetPool() );
     130           0 :     mpView->GetAttributes( aCharAttrSet );
     131             : 
     132           0 :     SfxItemSet aNewAttr( mpViewShell->GetPool(),EE_ITEMS_START,EE_ITEMS_END);
     133             : 
     134           0 :     aNewAttr.Put(aCharAttrSet, false);
     135           0 :     rSet.Put(aNewAttr, false);
     136             : 
     137           0 :     SvxKerningItem aKern = static_cast<const SvxKerningItem&>( aCharAttrSet.Get( EE_CHAR_KERNING ) );
     138             :     //aKern.SetWhich(SID_ATTR_CHAR_KERNING);
     139           0 :     rSet.Put(aKern);
     140             : 
     141           0 :     SfxItemState eState = aCharAttrSet.GetItemState( EE_CHAR_KERNING, true );
     142           0 :     if ( eState == SfxItemState::DONTCARE )
     143             :     {
     144           0 :         rSet.InvalidateItem(EE_CHAR_KERNING);
     145           0 :     }
     146           0 : }
     147             : 
     148             : /**
     149             :  * Status of attribute items.
     150             :  */
     151           0 : void TextObjectBar::GetAttrState( SfxItemSet& rSet )
     152             : {
     153           0 :     SfxWhichIter        aIter( rSet );
     154           0 :     sal_uInt16              nWhich = aIter.FirstWhich();
     155           0 :     SfxItemSet          aAttrSet( mpView->GetDoc().GetPool() );
     156           0 :     SvtLanguageOptions  aLangOpt;
     157           0 :     bool            bDisableParagraphTextDirection = !aLangOpt.IsCTLFontEnabled();
     158           0 :     bool            bDisableVerticalText = !aLangOpt.IsVerticalTextEnabled();
     159             : 
     160           0 :     mpView->GetAttributes( aAttrSet );
     161             : 
     162           0 :     while ( nWhich )
     163             :     {
     164           0 :         sal_uInt16 nSlotId = SfxItemPool::IsWhich(nWhich)
     165           0 :             ? GetPool().GetSlotId(nWhich)
     166           0 :             : nWhich;
     167             : 
     168           0 :         switch ( nSlotId )
     169             :         {
     170             :             case SID_ATTR_CHAR_FONT:
     171             :             case SID_ATTR_CHAR_FONTHEIGHT:
     172             :             case SID_ATTR_CHAR_WEIGHT:
     173             :             case SID_ATTR_CHAR_POSTURE:
     174             :             case SID_ATTR_CHAR_SHADOWED:
     175             :             case SID_ATTR_CHAR_STRIKEOUT:
     176             :             case SID_ATTR_CHAR_CASEMAP:
     177             :             {
     178           0 :                 sal_uInt16 stretchX = 100;
     179           0 :                 sal_uInt16 stretchY = 100;
     180           0 :                 SvxScriptSetItem aSetItem( nSlotId, GetPool() );
     181           0 :                 aSetItem.GetItemSet().Put( aAttrSet, false );
     182             : 
     183           0 :                 SvtScriptType nScriptType = mpView->GetScriptType();
     184             : 
     185           0 :                 if( (nSlotId == SID_ATTR_CHAR_FONT) || (nSlotId == SID_ATTR_CHAR_FONTHEIGHT) )
     186             :                 {
     187             :                     // input language should be preferred over
     188             :                     // current cursor position to detect script type
     189           0 :                     OutlinerView* pOLV = mpView->GetTextEditOutlinerView();
     190           0 :                     SdrOutliner *pOutliner = mpView->GetTextEditOutliner();
     191             : 
     192           0 :                     if (mpView->ISA(OutlineView))
     193             :                     {
     194             :                         pOLV = static_cast<OutlineView*>(mpView)->GetViewByWindow(
     195           0 :                             mpViewShell->GetActiveWindow());
     196             :                     }
     197             : 
     198           0 :                     if( pOutliner )
     199           0 :                         pOutliner->GetGlobalCharStretching( stretchX, stretchY );
     200             : 
     201           0 :                     if(pOLV && !pOLV->GetSelection().HasRange())
     202             :                     {
     203           0 :                         if( mpViewShell && mpViewShell->GetViewShell() && mpViewShell->GetViewShell()->GetWindow() )
     204             :                         {
     205           0 :                             LanguageType nInputLang = mpViewShell->GetViewShell()->GetWindow()->GetInputLanguage();
     206           0 :                             if(nInputLang != LANGUAGE_DONTKNOW && nInputLang != LANGUAGE_SYSTEM)
     207           0 :                                 nScriptType = SvtLanguageOptions::GetScriptTypeOfLanguage( nInputLang );
     208             :                         }
     209             :                     }
     210             :                 }
     211             : 
     212           0 :                 const SfxPoolItem* pI = aSetItem.GetItemOfScript( nScriptType );
     213           0 :                 if( pI )
     214             :                 {
     215           0 :                     if( nSlotId == SID_ATTR_CHAR_FONTHEIGHT )
     216             :                     {
     217           0 :                         SvxFontHeightItem aFontItem = dynamic_cast<const SvxFontHeightItem&>(*pI);
     218           0 :                         aFontItem.SetHeight(aFontItem.GetHeight(), stretchX, aFontItem.GetPropUnit());
     219           0 :                         aAttrSet.Put( aFontItem, nWhich );
     220             :                     }
     221             :                     else
     222             :                     {
     223           0 :                         aAttrSet.Put( *pI, nWhich );
     224             :                     }
     225             :                 }
     226             :                 else
     227             :                 {
     228           0 :                     aAttrSet.InvalidateItem( nWhich );
     229           0 :                 }
     230             :             }
     231           0 :             break;
     232             : 
     233             :             case SID_STYLE_APPLY:
     234             :             case SID_STYLE_FAMILY2:
     235             :             {
     236           0 :                 SfxStyleSheet* pStyleSheet = mpView->GetStyleSheetFromMarked();
     237           0 :                 if( pStyleSheet )
     238           0 :                     rSet.Put( SfxTemplateItem( nWhich, pStyleSheet->GetName() ) );
     239             :                 else
     240             :                 {
     241           0 :                     rSet.Put( SfxTemplateItem( nWhich, OUString() ) );
     242             :                 }
     243             :             }
     244           0 :             break;
     245             : 
     246             :             case SID_OUTLINE_LEFT:
     247             :             case SID_OUTLINE_RIGHT:
     248             :             case SID_OUTLINE_UP:
     249             :             case SID_OUTLINE_DOWN:
     250             :             {
     251           0 :                 bool bDisableLeft     = true;
     252           0 :                 bool bDisableRight    = true;
     253           0 :                 bool bDisableUp       = true;
     254           0 :                 bool bDisableDown     = true;
     255             : 
     256             :                 //fdo#78151 it doesn't make sense to promote or demote outline levels in master view.
     257           0 :                 const DrawViewShell* pDrawViewShell = dynamic_cast< DrawViewShell* >(mpViewShell);
     258           0 :                 const bool bInMasterView = pDrawViewShell && pDrawViewShell->GetEditMode() == EM_MASTERPAGE;
     259             : 
     260           0 :                 if (!bInMasterView)
     261             :                 {
     262           0 :                     OutlinerView* pOLV = mpView->GetTextEditOutlinerView();
     263             : 
     264           0 :                     if (mpView->ISA(OutlineView))
     265             :                     {
     266             :                         pOLV = static_cast<OutlineView*>(mpView)->GetViewByWindow(
     267           0 :                             mpViewShell->GetActiveWindow());
     268             :                     }
     269             : 
     270           0 :                     bool bOutlineViewSh = mpViewShell->ISA(OutlineViewShell);
     271             : 
     272           0 :                     if (pOLV &&
     273           0 :                         ( pOLV->GetOutliner()->GetMode() == OUTLINERMODE_OUTLINEOBJECT || bOutlineViewSh ) )
     274             :                     {
     275             :                         // Outliner at outline-mode
     276           0 :                         ::Outliner* pOutl = pOLV->GetOutliner();
     277             : 
     278           0 :                         std::vector<Paragraph*> aSelList;
     279           0 :                         pOLV->CreateSelectionList(aSelList);
     280           0 :                         Paragraph* pPara = aSelList.empty() ? NULL : *(aSelList.begin());
     281             : 
     282             :                         // find out if we are a OutlineView
     283           0 :                         bool bIsOutlineView(OUTLINERMODE_OUTLINEVIEW == pOLV->GetOutliner()->GetMode());
     284             : 
     285             :                         // This is ONLY for OutlineViews
     286           0 :                         if(bIsOutlineView)
     287             :                         {
     288             :                             // allow move up if position is 2 or greater OR it
     289             :                             // is a title object (and thus depth==1)
     290           0 :                             if(pOutl->GetAbsPos(pPara) > 1 || ( ::Outliner::HasParaFlag(pPara,ParaFlag::ISPAGE) && pOutl->GetAbsPos(pPara) > 0 ) )
     291             :                             {
     292             :                                 // not at top
     293           0 :                                 bDisableUp = false;
     294             :                             }
     295             :                         }
     296             :                         else
     297             :                         {
     298             :                             // old behaviour for OUTLINERMODE_OUTLINEOBJECT
     299           0 :                             if(pOutl->GetAbsPos(pPara) > 0)
     300             :                             {
     301             :                                 // not at top
     302           0 :                                 bDisableUp = false;
     303             :                             }
     304             :                         }
     305             : 
     306           0 :                         for (std::vector<Paragraph*>::const_iterator iter = aSelList.begin(); iter != aSelList.end(); ++iter)
     307             :                         {
     308           0 :                             pPara = *iter;
     309             : 
     310           0 :                             sal_Int16 nDepth = pOutl->GetDepth( pOutl->GetAbsPos( pPara ) );
     311             : 
     312           0 :                             if (nDepth > 0 || (bOutlineViewSh && (nDepth <= 0) && !::Outliner::HasParaFlag( pPara, ParaFlag::ISPAGE )) )
     313             :                             {
     314             :                                 // not minimum depth
     315           0 :                                 bDisableLeft = false;
     316             :                             }
     317             : 
     318           0 :                             if( (nDepth < pOLV->GetOutliner()->GetMaxDepth() && ( !bOutlineViewSh || pOutl->GetAbsPos(pPara) != 0 )) ||
     319           0 :                                 (bOutlineViewSh && (nDepth <= 0) && ::Outliner::HasParaFlag( pPara, ParaFlag::ISPAGE ) && pOutl->GetAbsPos(pPara) != 0) )
     320             :                             {
     321             :                                 // not maximum depth and not at top
     322           0 :                                 bDisableRight = false;
     323             :                             }
     324             :                         }
     325             : 
     326           0 :                         if ( ( pOutl->GetAbsPos(pPara) < pOutl->GetParagraphCount() - 1 ) &&
     327           0 :                              ( pOutl->GetParagraphCount() > 1 || !bOutlineViewSh) )
     328             :                         {
     329             :                             // not last paragraph
     330           0 :                             bDisableDown = false;
     331             :                         }
     332             : 
     333             :                         // disable when first para and 2nd is not a title
     334           0 :                         pPara = aSelList.empty() ? NULL : *(aSelList.begin());
     335             : 
     336           0 :                         if(!bDisableDown && bIsOutlineView
     337           0 :                             && pPara
     338           0 :                             && 0 == pOutl->GetAbsPos(pPara)
     339           0 :                             && pOutl->GetParagraphCount() > 1
     340           0 :                             && !::Outliner::HasParaFlag( pOutl->GetParagraph(1), ParaFlag::ISPAGE ) )
     341             :                         {
     342             :                             // Needs to be disabled
     343           0 :                             bDisableDown = true;
     344           0 :                         }
     345             :                     }
     346             :                 }
     347             : 
     348           0 :                 if (bDisableLeft)
     349           0 :                     rSet.DisableItem(SID_OUTLINE_LEFT);
     350           0 :                 if (bDisableRight)
     351           0 :                     rSet.DisableItem(SID_OUTLINE_RIGHT);
     352           0 :                 if (bDisableUp)
     353           0 :                     rSet.DisableItem(SID_OUTLINE_UP);
     354           0 :                 if (bDisableDown)
     355           0 :                     rSet.DisableItem(SID_OUTLINE_DOWN);
     356             :             }
     357           0 :             break;
     358             : 
     359             :             case SID_TEXTDIRECTION_LEFT_TO_RIGHT:
     360             :             case SID_TEXTDIRECTION_TOP_TO_BOTTOM:
     361             :             {
     362           0 :                 if ( bDisableVerticalText )
     363             :                 {
     364           0 :                     rSet.DisableItem( SID_TEXTDIRECTION_LEFT_TO_RIGHT );
     365           0 :                     rSet.DisableItem( SID_TEXTDIRECTION_TOP_TO_BOTTOM );
     366             :                 }
     367             :                 else
     368             :                 {
     369           0 :                     bool bLeftToRight = true;
     370             : 
     371           0 :                     SdrOutliner* pOutl = mpView->GetTextEditOutliner();
     372           0 :                     if( pOutl )
     373             :                     {
     374           0 :                         if( pOutl->IsVertical() )
     375           0 :                             bLeftToRight = false;
     376             :                     }
     377             :                     else
     378           0 :                         bLeftToRight = static_cast<const SvxWritingModeItem&>( aAttrSet.Get( SDRATTR_TEXTDIRECTION ) ).GetValue() == com::sun::star::text::WritingMode_LR_TB;
     379             : 
     380           0 :                     rSet.Put( SfxBoolItem( SID_TEXTDIRECTION_LEFT_TO_RIGHT, bLeftToRight ) );
     381           0 :                     rSet.Put( SfxBoolItem( SID_TEXTDIRECTION_TOP_TO_BOTTOM, !bLeftToRight ) );
     382             : 
     383           0 :                     if( !bLeftToRight )
     384           0 :                         bDisableParagraphTextDirection = true;
     385             :                 }
     386             :             }
     387           0 :             break;
     388             : 
     389             :             case SID_GROW_FONT_SIZE:
     390             :             case SID_SHRINK_FONT_SIZE:
     391             :             {
     392             :                 // todo
     393             :             }
     394           0 :             break;
     395             : 
     396             :             case SID_THES:
     397             :             {
     398           0 :                 if (mpView->GetTextEditOutlinerView())
     399             :                 {
     400           0 :                     EditView & rEditView = mpView->GetTextEditOutlinerView()->GetEditView();
     401           0 :                     OUString        aStatusVal;
     402           0 :                     LanguageType    nLang = LANGUAGE_NONE;
     403           0 :                     bool bIsLookUpWord = GetStatusValueForThesaurusFromContext( aStatusVal, nLang, rEditView );
     404           0 :                     rSet.Put( SfxStringItem( SID_THES, aStatusVal ) );
     405             : 
     406             :                     // disable "Thesaurus" context menu entry if there is nothing to look up
     407           0 :                     uno::Reference< linguistic2::XThesaurus > xThes( LinguMgr::GetThesaurus() );
     408           0 :                     if (!bIsLookUpWord ||
     409           0 :                         !xThes.is() || nLang == LANGUAGE_NONE || !xThes->hasLocale( LanguageTag( nLang). getLocale() ))
     410           0 :                         rSet.DisableItem( SID_THES );
     411             :                 }
     412             :                 else
     413             :                 {
     414           0 :                     rSet.DisableItem( SID_THES );
     415             :                 }
     416             :                 //! avoid putting the same item as SfxBoolItem at the end of this function
     417           0 :                 nSlotId = 0;
     418             :             }
     419           0 :             break;
     420             : 
     421             :             default:
     422           0 :             break;
     423             :         }
     424             : 
     425           0 :         nWhich = aIter.NextWhich();
     426             :     }
     427             : 
     428           0 :     rSet.Put( aAttrSet, false ); // <- sal_False, so DontCare-Status gets acquired
     429             : 
     430             :     // these are disabled in outline-mode
     431           0 :     if (!mpViewShell || !mpViewShell->ISA(DrawViewShell))
     432             :     {
     433           0 :         rSet.DisableItem( SID_ATTR_PARA_ADJUST_LEFT );
     434           0 :         rSet.DisableItem( SID_ATTR_PARA_ADJUST_RIGHT );
     435           0 :         rSet.DisableItem( SID_ATTR_PARA_ADJUST_CENTER );
     436           0 :         rSet.DisableItem( SID_ATTR_PARA_ADJUST_BLOCK );
     437           0 :         rSet.DisableItem( SID_ATTR_PARA_LINESPACE_10 );
     438           0 :         rSet.DisableItem( SID_ATTR_PARA_LINESPACE_15 );
     439           0 :         rSet.DisableItem( SID_ATTR_PARA_LINESPACE_20 );
     440           0 :         rSet.DisableItem( SID_PARASPACE_INCREASE );
     441           0 :         rSet.DisableItem( SID_PARASPACE_DECREASE );
     442           0 :         rSet.DisableItem( SID_TEXTDIRECTION_TOP_TO_BOTTOM );
     443           0 :         rSet.DisableItem( SID_TEXTDIRECTION_LEFT_TO_RIGHT );
     444           0 :         rSet.DisableItem( SID_ATTR_PARA_LEFT_TO_RIGHT );
     445           0 :         rSet.DisableItem( SID_ATTR_PARA_RIGHT_TO_LEFT );
     446             :     }
     447             :     else
     448             :     {
     449             :         // paragraph spacing
     450           0 :         OutlinerView* pOLV = mpView->GetTextEditOutlinerView();
     451           0 :         if( pOLV )
     452             :         {
     453           0 :             ESelection aSel = pOLV->GetSelection();
     454           0 :             aSel.Adjust();
     455           0 :             sal_Int32 nStartPara = aSel.nStartPara;
     456           0 :             sal_Int32 nEndPara = aSel.nEndPara;
     457           0 :             if( !aSel.HasRange() )
     458             :             {
     459           0 :                 nStartPara = 0;
     460           0 :                 nEndPara = pOLV->GetOutliner()->GetParagraphCount() - 1;
     461             :             }
     462           0 :             long nUpper = 0L;
     463           0 :             for( sal_Int32 nPara = nStartPara; nPara <= nEndPara; nPara++ )
     464             :             {
     465           0 :                 const SfxItemSet& rItems = pOLV->GetOutliner()->GetParaAttribs( nPara );
     466           0 :                 const SvxULSpaceItem& rItem = static_cast<const SvxULSpaceItem&>( rItems.Get( EE_PARA_ULSPACE ) );
     467           0 :                 nUpper = std::max( nUpper, (long)rItem.GetUpper() );
     468           0 :             }
     469           0 :             if( nUpper == 0L )
     470           0 :                 rSet.DisableItem( SID_PARASPACE_DECREASE );
     471             :         }
     472             :         else
     473             :         {
     474             :             // never disabled at the moment!
     475             :             //rSet.DisableItem( SID_PARASPACE_INCREASE );
     476             :             //rSet.DisableItem( SID_PARASPACE_DECREASE );
     477             :         }
     478             : 
     479             :         // paragraph justification
     480           0 :         SvxLRSpaceItem aLR = static_cast<const SvxLRSpaceItem&>( aAttrSet.Get( EE_PARA_LRSPACE ) );
     481           0 :         rSet.Put(aLR);
     482           0 :         SvxAdjust eAdj = static_cast<const SvxAdjustItem&>( aAttrSet.Get( EE_PARA_JUST ) ).GetAdjust();
     483           0 :         switch( eAdj )
     484             :         {
     485             :             case SVX_ADJUST_LEFT:
     486           0 :                 rSet.Put( SfxBoolItem( SID_ATTR_PARA_ADJUST_LEFT, true ) );
     487           0 :             break;
     488             :             case SVX_ADJUST_CENTER:
     489           0 :                 rSet.Put( SfxBoolItem( SID_ATTR_PARA_ADJUST_CENTER, true ) );
     490           0 :             break;
     491             :             case SVX_ADJUST_RIGHT:
     492           0 :                 rSet.Put( SfxBoolItem( SID_ATTR_PARA_ADJUST_RIGHT, true ) );
     493           0 :             break;
     494             :             case SVX_ADJUST_BLOCK:
     495           0 :                 rSet.Put( SfxBoolItem( SID_ATTR_PARA_ADJUST_BLOCK, true ) );
     496           0 :             break;
     497             :             default:
     498           0 :             break;
     499             :         }
     500             : 
     501           0 :         Invalidate(SID_ATTR_PARA_ADJUST_LEFT);
     502           0 :         Invalidate(SID_ATTR_PARA_ADJUST_CENTER);
     503           0 :         Invalidate(SID_ATTR_PARA_ADJUST_RIGHT);
     504           0 :         Invalidate(SID_ATTR_PARA_ADJUST_BLOCK);
     505           0 :         Invalidate(SID_ATTR_PARA_LINESPACE);
     506           0 :         Invalidate(SID_ATTR_PARA_ULSPACE);
     507             : 
     508             :         // paragraph text direction
     509           0 :         if( bDisableParagraphTextDirection )
     510             :         {
     511           0 :             rSet.DisableItem( SID_ATTR_PARA_LEFT_TO_RIGHT );
     512           0 :             rSet.DisableItem( SID_ATTR_PARA_RIGHT_TO_LEFT );
     513             :         }
     514             :         else
     515             :         {
     516           0 :             switch( static_cast<const SvxFrameDirectionItem&>( aAttrSet.Get( EE_PARA_WRITINGDIR ) ).GetValue() )
     517             :             {
     518             :                 case FRMDIR_VERT_TOP_LEFT:
     519             :                 case FRMDIR_VERT_TOP_RIGHT:
     520             :                 {
     521           0 :                     rSet.DisableItem( SID_ATTR_PARA_LEFT_TO_RIGHT );
     522           0 :                     rSet.DisableItem( SID_ATTR_PARA_RIGHT_TO_LEFT );
     523             :                 }
     524           0 :                 break;
     525             : 
     526             :                 case FRMDIR_HORI_LEFT_TOP:
     527           0 :                     rSet.Put( SfxBoolItem( SID_ATTR_PARA_LEFT_TO_RIGHT, true ) );
     528           0 :                     rSet.Put( SfxBoolItem( SID_ATTR_PARA_RIGHT_TO_LEFT, false ) );
     529           0 :                 break;
     530             : 
     531             :                 case FRMDIR_HORI_RIGHT_TOP:
     532           0 :                     rSet.Put( SfxBoolItem( SID_ATTR_PARA_LEFT_TO_RIGHT, false ) );
     533           0 :                     rSet.Put( SfxBoolItem( SID_ATTR_PARA_RIGHT_TO_LEFT, true ) );
     534           0 :                 break;
     535             : 
     536             :                 // The case for the superordinate object is missing.
     537             :                 case FRMDIR_ENVIRONMENT:
     538             :                 {
     539           0 :                     SdDrawDocument& rDoc = mpView->GetDoc();
     540           0 :                     ::com::sun::star::text::WritingMode eMode = rDoc.GetDefaultWritingMode();
     541           0 :                     bool bIsLeftToRight(false);
     542             : 
     543           0 :                     if(::com::sun::star::text::WritingMode_LR_TB == eMode
     544           0 :                         || ::com::sun::star::text::WritingMode_TB_RL == eMode)
     545             :                     {
     546           0 :                         bIsLeftToRight = true;
     547             :                     }
     548             : 
     549           0 :                     rSet.Put( SfxBoolItem( SID_ATTR_PARA_LEFT_TO_RIGHT, bIsLeftToRight ) );
     550           0 :                     rSet.Put( SfxBoolItem( SID_ATTR_PARA_RIGHT_TO_LEFT, !bIsLeftToRight ) );
     551             :                 }
     552           0 :                 break;
     553             :             }
     554             :         }
     555             : 
     556           0 :         SvxLRSpaceItem aLRSpace = static_cast<const SvxLRSpaceItem&>( aAttrSet.Get( EE_PARA_LRSPACE ) );
     557           0 :         aLRSpace.SetWhich(SID_ATTR_PARA_LRSPACE);
     558           0 :         rSet.Put(aLRSpace);
     559           0 :         Invalidate(SID_ATTR_PARA_LRSPACE);
     560             :         //Added by xuxu
     561           0 :         SfxItemState eState = aAttrSet.GetItemState( EE_PARA_LRSPACE );
     562           0 :         if ( eState == SfxItemState::DONTCARE )
     563             :         {
     564           0 :             rSet.InvalidateItem(EE_PARA_LRSPACE);
     565           0 :             rSet.InvalidateItem(SID_ATTR_PARA_LRSPACE);
     566             :         }
     567             :         sal_uInt16 nLineSpace = (sal_uInt16) static_cast<const SvxLineSpacingItem&>( aAttrSet.
     568           0 :                             Get( EE_PARA_SBL ) ).GetPropLineSpace();
     569           0 :         switch( nLineSpace )
     570             :         {
     571             :             case 100:
     572           0 :                 rSet.Put( SfxBoolItem( SID_ATTR_PARA_LINESPACE_10, true ) );
     573           0 :             break;
     574             :             case 150:
     575           0 :                 rSet.Put( SfxBoolItem( SID_ATTR_PARA_LINESPACE_15, true ) );
     576           0 :             break;
     577             :             case 200:
     578           0 :                 rSet.Put( SfxBoolItem( SID_ATTR_PARA_LINESPACE_20, true ) );
     579           0 :             break;
     580           0 :         }
     581             :     }
     582             : 
     583             :     // justification (superscript, subscript) is also needed in outline-mode
     584             :     SvxEscapement eEsc = (SvxEscapement ) static_cast<const SvxEscapementItem&>(
     585           0 :                     aAttrSet.Get( EE_CHAR_ESCAPEMENT ) ).GetEnumValue();
     586             : 
     587           0 :     if( eEsc == SVX_ESCAPEMENT_SUPERSCRIPT )
     588           0 :         rSet.Put( SfxBoolItem( SID_SET_SUPER_SCRIPT, true ) );
     589           0 :     else if( eEsc == SVX_ESCAPEMENT_SUBSCRIPT )
     590           0 :         rSet.Put( SfxBoolItem( SID_SET_SUB_SCRIPT, true ) );
     591           0 : }
     592             : 
     593          66 : } // end of namespace sd
     594             : 
     595             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11