LCOV - code coverage report
Current view: top level - editeng/source/items - justifyitem.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 183 0.0 %
Date: 2014-04-14 Functions: 0 37 0.0 %
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 "editeng/justifyitem.hxx"
      21             : #include "editeng/memberids.hrc"
      22             : #include "editeng/editrids.hrc"
      23             : #include "editeng/eerdll.hxx"
      24             : 
      25             : #include <tools/stream.hxx>
      26             : 
      27             : #include <com/sun/star/table/CellHoriJustify.hpp>
      28             : #include <com/sun/star/style/ParagraphAdjust.hpp>
      29             : #include <com/sun/star/table/CellJustifyMethod.hpp>
      30             : #include <com/sun/star/table/CellVertJustify2.hpp>
      31             : #include <com/sun/star/style/VerticalAlignment.hpp>
      32             : 
      33             : 
      34           0 : TYPEINIT1_FACTORY( SvxHorJustifyItem, SfxEnumItem, new SvxHorJustifyItem(SVX_HOR_JUSTIFY_STANDARD, 0) );
      35           0 : TYPEINIT1_FACTORY( SvxVerJustifyItem, SfxEnumItem, new SvxVerJustifyItem(SVX_VER_JUSTIFY_STANDARD, 0) );
      36             : 
      37             : using namespace ::com::sun::star;
      38             : 
      39             : 
      40             : 
      41           0 : SvxHorJustifyItem::SvxHorJustifyItem( const sal_uInt16 nId ) :
      42           0 :     SfxEnumItem( nId, (sal_uInt16)SVX_HOR_JUSTIFY_STANDARD )
      43             : {
      44           0 : }
      45             : 
      46           0 : SvxHorJustifyItem::SvxHorJustifyItem( const SvxCellHorJustify eJustify,
      47             :                                       const sal_uInt16 nId ) :
      48           0 :     SfxEnumItem( nId, (sal_uInt16)eJustify )
      49             : {
      50           0 : }
      51             : 
      52             : 
      53           0 : SfxItemPresentation SvxHorJustifyItem::GetPresentation
      54             : (
      55             :     SfxItemPresentation ePres,
      56             :     SfxMapUnit          /*eCoreUnit*/,
      57             :     SfxMapUnit          /*ePresUnit*/,
      58             :     OUString&           rText, const IntlWrapper *)    const
      59             : {
      60           0 :     switch ( ePres )
      61             :     {
      62             :         case SFX_ITEM_PRESENTATION_NONE:
      63           0 :             rText = OUString();
      64           0 :             return SFX_ITEM_PRESENTATION_NONE;
      65             :         case SFX_ITEM_PRESENTATION_NAMELESS:
      66             :         case SFX_ITEM_PRESENTATION_COMPLETE:
      67           0 :             rText = GetValueText( GetValue() );
      68           0 :             return SFX_ITEM_PRESENTATION_COMPLETE;
      69             :         default: ; //prevent warning
      70             :     }
      71           0 :     return SFX_ITEM_PRESENTATION_NONE;
      72             : }
      73             : 
      74             : 
      75           0 : bool SvxHorJustifyItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const
      76             : {
      77           0 :     nMemberId &= ~CONVERT_TWIPS;
      78           0 :     switch ( nMemberId )
      79             :     {
      80             :         case MID_HORJUST_HORJUST:
      81             :             {
      82           0 :                 table::CellHoriJustify eUno = table::CellHoriJustify_STANDARD;
      83           0 :                 switch ( (SvxCellHorJustify)GetValue() )
      84             :                 {
      85           0 :                     case SVX_HOR_JUSTIFY_STANDARD: eUno = table::CellHoriJustify_STANDARD; break;
      86           0 :                     case SVX_HOR_JUSTIFY_LEFT:     eUno = table::CellHoriJustify_LEFT;     break;
      87           0 :                     case SVX_HOR_JUSTIFY_CENTER:   eUno = table::CellHoriJustify_CENTER;   break;
      88           0 :                     case SVX_HOR_JUSTIFY_RIGHT:    eUno = table::CellHoriJustify_RIGHT;    break;
      89           0 :                     case SVX_HOR_JUSTIFY_BLOCK:    eUno = table::CellHoriJustify_BLOCK;    break;
      90           0 :                     case SVX_HOR_JUSTIFY_REPEAT:   eUno = table::CellHoriJustify_REPEAT;   break;
      91             :                 }
      92           0 :                 rVal <<= eUno;
      93             :             }
      94           0 :             break;
      95             :         case MID_HORJUST_ADJUST:
      96             :             {
      97             :                 //  ParagraphAdjust values, as in SvxAdjustItem
      98             :                 //  (same value for ParaAdjust and ParaLastLineAdjust)
      99             : 
     100           0 :                 sal_Int16 nAdjust = style::ParagraphAdjust_LEFT;
     101           0 :                 switch ( (SvxCellHorJustify)GetValue() )
     102             :                 {
     103             :                     // ParagraphAdjust_LEFT is used for STANDARD and REPEAT
     104             :                     case SVX_HOR_JUSTIFY_STANDARD:
     105             :                     case SVX_HOR_JUSTIFY_REPEAT:
     106           0 :                     case SVX_HOR_JUSTIFY_LEFT:   nAdjust = style::ParagraphAdjust_LEFT;   break;
     107           0 :                     case SVX_HOR_JUSTIFY_CENTER: nAdjust = style::ParagraphAdjust_CENTER; break;
     108           0 :                     case SVX_HOR_JUSTIFY_RIGHT:  nAdjust = style::ParagraphAdjust_RIGHT;  break;
     109           0 :                     case SVX_HOR_JUSTIFY_BLOCK:  nAdjust = style::ParagraphAdjust_BLOCK;  break;
     110             :                 }
     111           0 :                 rVal <<= nAdjust;       // as sal_Int16
     112             :             }
     113           0 :             break;
     114             :     }
     115           0 :     return true;
     116             : }
     117             : 
     118           0 : bool SvxHorJustifyItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId )
     119             : {
     120           0 :     nMemberId &= ~CONVERT_TWIPS;
     121           0 :     switch ( nMemberId )
     122             :     {
     123             :         case MID_HORJUST_HORJUST:
     124             :             {
     125             :                 table::CellHoriJustify eUno;
     126           0 :                 if(!(rVal >>= eUno))
     127             :                 {
     128           0 :                     sal_Int32 nValue = 0;
     129           0 :                     if(!(rVal >>= nValue))
     130           0 :                         return false;
     131           0 :                     eUno = (table::CellHoriJustify)nValue;
     132             :                 }
     133           0 :                 SvxCellHorJustify eSvx = SVX_HOR_JUSTIFY_STANDARD;
     134           0 :                 switch (eUno)
     135             :                 {
     136           0 :                     case table::CellHoriJustify_STANDARD: eSvx = SVX_HOR_JUSTIFY_STANDARD; break;
     137           0 :                     case table::CellHoriJustify_LEFT:     eSvx = SVX_HOR_JUSTIFY_LEFT;     break;
     138           0 :                     case table::CellHoriJustify_CENTER:   eSvx = SVX_HOR_JUSTIFY_CENTER;   break;
     139           0 :                     case table::CellHoriJustify_RIGHT:    eSvx = SVX_HOR_JUSTIFY_RIGHT;    break;
     140           0 :                     case table::CellHoriJustify_BLOCK:    eSvx = SVX_HOR_JUSTIFY_BLOCK;    break;
     141           0 :                     case table::CellHoriJustify_REPEAT:   eSvx = SVX_HOR_JUSTIFY_REPEAT;   break;
     142             :                     default: ; //prevent warning
     143             :                 }
     144           0 :                 SetValue( (sal_uInt16)eSvx );
     145             :             }
     146           0 :             break;
     147             :         case MID_HORJUST_ADJUST:
     148             :             {
     149             :                 //  property contains ParagraphAdjust values as sal_Int16
     150           0 :                 sal_Int16 nVal = sal_Int16();
     151           0 :                 if(!(rVal >>= nVal))
     152           0 :                     return false;
     153             : 
     154           0 :                 SvxCellHorJustify eSvx = SVX_HOR_JUSTIFY_STANDARD;
     155           0 :                 switch (nVal)
     156             :                 {
     157             :                     //  STRETCH is treated as BLOCK
     158           0 :                     case style::ParagraphAdjust_LEFT:    eSvx = SVX_HOR_JUSTIFY_LEFT;   break;
     159           0 :                     case style::ParagraphAdjust_RIGHT:   eSvx = SVX_HOR_JUSTIFY_RIGHT;  break;
     160             :                     case style::ParagraphAdjust_STRETCH:
     161           0 :                     case style::ParagraphAdjust_BLOCK:   eSvx = SVX_HOR_JUSTIFY_BLOCK;  break;
     162           0 :                     case style::ParagraphAdjust_CENTER:  eSvx = SVX_HOR_JUSTIFY_CENTER; break;
     163             :                 }
     164           0 :                 SetValue( (sal_uInt16)eSvx );
     165             :             }
     166             :     }
     167           0 :     return true;
     168             : }
     169             : 
     170             : 
     171           0 : OUString SvxHorJustifyItem::GetValueText( sal_uInt16 nVal ) const
     172             : {
     173             :     DBG_ASSERT( nVal <= SVX_HOR_JUSTIFY_REPEAT, "enum overflow!" );
     174           0 :     return EE_RESSTR(RID_SVXITEMS_HORJUST_STANDARD + nVal);
     175             : }
     176             : 
     177             : 
     178           0 : SfxPoolItem* SvxHorJustifyItem::Clone( SfxItemPool* ) const
     179             : {
     180           0 :     return new SvxHorJustifyItem( *this );
     181             : }
     182             : 
     183             : 
     184           0 : SfxPoolItem* SvxHorJustifyItem::Create( SvStream& rStream, sal_uInt16 ) const
     185             : {
     186             :     sal_uInt16 nVal;
     187           0 :     rStream.ReadUInt16( nVal );
     188           0 :     return new SvxHorJustifyItem( (SvxCellHorJustify)nVal, Which() );
     189             : }
     190             : 
     191             : 
     192           0 : sal_uInt16 SvxHorJustifyItem::GetValueCount() const
     193             : {
     194           0 :     return SVX_HOR_JUSTIFY_REPEAT + 1;  // Last Enum value + 1
     195             : }
     196             : 
     197             : 
     198           0 : SvxVerJustifyItem::SvxVerJustifyItem( const sal_uInt16 nId ) :
     199           0 :     SfxEnumItem( nId, (sal_uInt16)SVX_VER_JUSTIFY_STANDARD )
     200             : {
     201           0 : }
     202             : 
     203           0 : SvxVerJustifyItem::SvxVerJustifyItem( const SvxCellVerJustify eJustify,
     204             :                                       const sal_uInt16 nId ) :
     205           0 :     SfxEnumItem( nId, (sal_uInt16)eJustify )
     206             : {
     207           0 : }
     208             : 
     209             : 
     210           0 : SfxItemPresentation SvxVerJustifyItem::GetPresentation
     211             : (
     212             :     SfxItemPresentation ePres,
     213             :     SfxMapUnit          /*eCoreUnit*/,
     214             :     SfxMapUnit          /*ePresUnit*/,
     215             :     OUString&           rText,
     216             :     const IntlWrapper * )    const
     217             : {
     218           0 :     switch ( ePres )
     219             :     {
     220             :         case SFX_ITEM_PRESENTATION_NONE:
     221           0 :             rText = OUString();
     222           0 :             return SFX_ITEM_PRESENTATION_NONE;
     223             :         case SFX_ITEM_PRESENTATION_NAMELESS:
     224             :         case SFX_ITEM_PRESENTATION_COMPLETE:
     225           0 :             rText = GetValueText( GetValue() );
     226           0 :             return SFX_ITEM_PRESENTATION_COMPLETE;
     227             :         default: ; //prevent warning
     228             :     }
     229           0 :     return SFX_ITEM_PRESENTATION_NONE;
     230             : }
     231             : 
     232             : 
     233           0 : bool SvxVerJustifyItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const
     234             : {
     235           0 :     nMemberId &= ~CONVERT_TWIPS;
     236           0 :     switch ( nMemberId )
     237             :     {
     238             :         case MID_HORJUST_ADJUST:
     239             :             {
     240           0 :                 style::VerticalAlignment eUno = style::VerticalAlignment_TOP;
     241           0 :                 switch ( (SvxCellVerJustify)GetValue() )
     242             :                 {
     243           0 :                     case SVX_VER_JUSTIFY_TOP:      eUno = style::VerticalAlignment_TOP;     break;
     244           0 :                     case SVX_VER_JUSTIFY_CENTER:   eUno = style::VerticalAlignment_MIDDLE;  break;
     245           0 :                     case SVX_VER_JUSTIFY_BOTTOM:   eUno = style::VerticalAlignment_BOTTOM;  break;
     246             :                     default: ; //prevent warning
     247             :                 }
     248           0 :                 rVal <<= eUno;
     249           0 :                 break;
     250             :             }
     251             :         default:
     252             :             {
     253           0 :                 sal_Int32 nUno = table::CellVertJustify2::STANDARD;
     254           0 :                 switch ( (SvxCellVerJustify)GetValue() )
     255             :                 {
     256           0 :                     case SVX_VER_JUSTIFY_STANDARD: nUno = table::CellVertJustify2::STANDARD; break;
     257           0 :                     case SVX_VER_JUSTIFY_TOP:      nUno = table::CellVertJustify2::TOP;     break;
     258           0 :                     case SVX_VER_JUSTIFY_CENTER:   nUno = table::CellVertJustify2::CENTER;  break;
     259           0 :                     case SVX_VER_JUSTIFY_BOTTOM:   nUno = table::CellVertJustify2::BOTTOM;  break;
     260           0 :                     case SVX_VER_JUSTIFY_BLOCK:    nUno = table::CellVertJustify2::BLOCK;  break;
     261             :                     default: ; //prevent warning
     262             :                 }
     263           0 :                 rVal <<= nUno;
     264           0 :                 break;
     265             :             }
     266             :     }
     267           0 :     return true;
     268             : }
     269             : 
     270           0 : bool SvxVerJustifyItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId )
     271             : {
     272           0 :     nMemberId &= ~CONVERT_TWIPS;
     273           0 :     switch ( nMemberId )
     274             :     {
     275             :         case MID_HORJUST_ADJUST:
     276             :             {
     277             :                 //  property contains ParagraphAdjust values as sal_Int16
     278           0 :                 style::VerticalAlignment nVal = style::VerticalAlignment_TOP;
     279           0 :                 if(!(rVal >>= nVal))
     280           0 :                     return false;
     281             : 
     282           0 :                 SvxCellVerJustify eSvx = SVX_VER_JUSTIFY_STANDARD;
     283           0 :                 switch (nVal)
     284             :                 {
     285           0 :                     case style::VerticalAlignment_TOP:      eSvx = SVX_VER_JUSTIFY_TOP;     break;
     286           0 :                     case style::VerticalAlignment_MIDDLE:   eSvx = SVX_VER_JUSTIFY_CENTER;  break;
     287           0 :                     case style::VerticalAlignment_BOTTOM:   eSvx = SVX_VER_JUSTIFY_BOTTOM;  break;
     288             :                     default:;
     289             :                 }
     290           0 :                 SetValue( (sal_uInt16)eSvx );
     291           0 :                 break;
     292             :             }
     293             :         default:
     294             :             {
     295           0 :                 sal_Int32 eUno = table::CellVertJustify2::STANDARD;
     296           0 :                 rVal >>= eUno;
     297             : 
     298           0 :                 SvxCellVerJustify eSvx = SVX_VER_JUSTIFY_STANDARD;
     299           0 :                 switch (eUno)
     300             :                 {
     301           0 :                     case table::CellVertJustify2::STANDARD: eSvx = SVX_VER_JUSTIFY_STANDARD;  break;
     302           0 :                     case table::CellVertJustify2::TOP:      eSvx = SVX_VER_JUSTIFY_TOP;       break;
     303           0 :                     case table::CellVertJustify2::CENTER:   eSvx = SVX_VER_JUSTIFY_CENTER;    break;
     304           0 :                     case table::CellVertJustify2::BOTTOM:   eSvx = SVX_VER_JUSTIFY_BOTTOM;    break;
     305           0 :                     case table::CellVertJustify2::BLOCK:    eSvx = SVX_VER_JUSTIFY_BLOCK;     break;
     306             :                     default: ; //prevent warning
     307             :                 }
     308           0 :                 SetValue( (sal_uInt16)eSvx );
     309           0 :                 break;
     310             :             }
     311             :     }
     312             : 
     313           0 :     return true;
     314             : }
     315             : 
     316             : 
     317           0 : OUString SvxVerJustifyItem::GetValueText( sal_uInt16 nVal ) const
     318             : {
     319             :     DBG_ASSERT( nVal <= SVX_VER_JUSTIFY_BOTTOM, "enum overflow!" );
     320           0 :     return EE_RESSTR(RID_SVXITEMS_VERJUST_STANDARD + nVal);
     321             : }
     322             : 
     323             : 
     324           0 : SfxPoolItem* SvxVerJustifyItem::Clone( SfxItemPool* ) const
     325             : {
     326           0 :     return new SvxVerJustifyItem( *this );
     327             : }
     328             : 
     329             : 
     330           0 : SfxPoolItem* SvxVerJustifyItem::Create( SvStream& rStream, sal_uInt16 ) const
     331             : {
     332             :     sal_uInt16 nVal;
     333           0 :     rStream.ReadUInt16( nVal );
     334           0 :     return new SvxVerJustifyItem( (SvxCellVerJustify)nVal, Which() );
     335             : }
     336             : 
     337             : 
     338           0 : sal_uInt16 SvxVerJustifyItem::GetValueCount() const
     339             : {
     340           0 :     return SVX_VER_JUSTIFY_BOTTOM + 1;  // Last Enum value + 1
     341             : }
     342             : 
     343             : 
     344           0 : SvxJustifyMethodItem::SvxJustifyMethodItem( const SvxCellJustifyMethod eJustify,
     345             :                                       const sal_uInt16 nId ) :
     346           0 :     SfxEnumItem( nId, (sal_uInt16)eJustify )
     347             : {
     348           0 : }
     349             : 
     350             : 
     351           0 : SfxItemPresentation SvxJustifyMethodItem::GetPresentation
     352             : (
     353             :     SfxItemPresentation ePres,
     354             :     SfxMapUnit          /*eCoreUnit*/,
     355             :     SfxMapUnit          /*ePresUnit*/,
     356             :     OUString&           rText,
     357             :     const IntlWrapper * )    const
     358             : {
     359           0 :     switch ( ePres )
     360             :     {
     361             :         case SFX_ITEM_PRESENTATION_NONE:
     362           0 :             rText = OUString();
     363           0 :             return SFX_ITEM_PRESENTATION_NONE;
     364             :         case SFX_ITEM_PRESENTATION_NAMELESS:
     365             :         case SFX_ITEM_PRESENTATION_COMPLETE:
     366           0 :             rText = GetValueText( GetValue() );
     367           0 :             return SFX_ITEM_PRESENTATION_COMPLETE;
     368             :         default: ; //prevent warning
     369             :     }
     370           0 :     return SFX_ITEM_PRESENTATION_NONE;
     371             : }
     372             : 
     373             : 
     374           0 : bool SvxJustifyMethodItem::QueryValue( uno::Any& rVal, sal_uInt8 /*nMemberId*/ ) const
     375             : {
     376           0 :     sal_Int32 nUno = table::CellJustifyMethod::AUTO;
     377           0 :     switch (static_cast<SvxCellJustifyMethod>(GetValue()))
     378             :     {
     379           0 :         case SVX_JUSTIFY_METHOD_AUTO:       nUno = table::CellJustifyMethod::AUTO;       break;
     380           0 :         case SVX_JUSTIFY_METHOD_DISTRIBUTE: nUno = table::CellJustifyMethod::DISTRIBUTE; break;
     381             :         default:;
     382             :     }
     383           0 :     rVal <<= nUno;
     384           0 :     return true;
     385             : }
     386             : 
     387           0 : bool SvxJustifyMethodItem::PutValue( const uno::Any& rVal, sal_uInt8 /*nMemberId*/ )
     388             : {
     389           0 :     sal_Int32 nVal = table::CellJustifyMethod::AUTO;
     390           0 :     if (!(rVal >>= nVal))
     391           0 :         return false;
     392             : 
     393           0 :     SvxCellJustifyMethod eSvx = SVX_JUSTIFY_METHOD_AUTO;
     394           0 :     switch (nVal)
     395             :     {
     396             :         case table::CellJustifyMethod::AUTO:
     397           0 :             eSvx = SVX_JUSTIFY_METHOD_AUTO;
     398           0 :         break;
     399             :         case table::CellJustifyMethod::DISTRIBUTE:
     400           0 :             eSvx = SVX_JUSTIFY_METHOD_DISTRIBUTE;
     401           0 :         break;
     402             :         default:;
     403             :     }
     404           0 :     SetValue(static_cast<sal_uInt16>(eSvx));
     405           0 :     return true;
     406             : }
     407             : 
     408             : 
     409           0 : OUString SvxJustifyMethodItem::GetValueText( sal_uInt16 nVal ) const
     410             : {
     411             :     DBG_ASSERT( nVal <= SVX_VER_JUSTIFY_BOTTOM, "enum overflow!" );
     412           0 :     return EE_RESSTR(RID_SVXITEMS_JUSTMETHOD_AUTO + nVal);
     413             : }
     414             : 
     415             : 
     416           0 : SfxPoolItem* SvxJustifyMethodItem::Clone( SfxItemPool* ) const
     417             : {
     418           0 :     return new SvxJustifyMethodItem( *this );
     419             : }
     420             : 
     421             : 
     422           0 : SfxPoolItem* SvxJustifyMethodItem::Create( SvStream& rStream, sal_uInt16 ) const
     423             : {
     424             :     sal_uInt16 nVal;
     425           0 :     rStream.ReadUInt16( nVal );
     426           0 :     return new SvxJustifyMethodItem( (SvxCellJustifyMethod)nVal, Which() );
     427             : }
     428             : 
     429             : 
     430           0 : sal_uInt16 SvxJustifyMethodItem::GetValueCount() const
     431             : {
     432           0 :     return SVX_JUSTIFY_METHOD_DISTRIBUTE + 1;   // Last Enum value + 1
     433             : }
     434             : 
     435           0 : SvxJustifyMethodItem& SvxJustifyMethodItem::operator=(const SvxJustifyMethodItem& r)
     436             : {
     437           0 :     SetValue( r.GetValue() );
     438           0 :     return *this;
     439             : }
     440             : 
     441             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10