LCOV - code coverage report
Current view: top level - libreoffice/writerfilter/source/rtftok - rtffly.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 38 58 65.5 %
Date: 2012-12-27 Functions: 10 10 100.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             :  * Version: MPL 1.1 / GPLv3+ / LGPLv3+
       4             :  *
       5             :  * The contents of this file are subject to the Mozilla Public License Version
       6             :  * 1.1 (the "License"); you may not use this file except in compliance with
       7             :  * the License. You may obtain a copy of the License at
       8             :  * http://www.mozilla.org/MPL/
       9             :  *
      10             :  * Software distributed under the License is distributed on an "AS IS" basis,
      11             :  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
      12             :  * for the specific language governing rights and limitations under the
      13             :  * License.
      14             :  *
      15             :  * The Initial Developer of the Original Code is
      16             :  *       Miklos Vajna <vmiklos@frugalware.org>
      17             :  * Portions created by the Initial Developer are Copyright (C) 2011 the
      18             :  * Initial Developer. All Rights Reserved.
      19             :  *
      20             :  * Contributor(s):
      21             :  *
      22             :  * Alternatively, the contents of this file may be used under the terms of
      23             :  * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
      24             :  * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
      25             :  * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
      26             :  * instead of those above.
      27             :  */
      28             : 
      29             : #ifndef _RTFFLY_HXX_
      30             : #define _RTFFLY_HXX_
      31             : 
      32             : namespace writerfilter {
      33             :     namespace rtftok {
      34             :         /// Stores the vertical orientation properties of an RTF fly frame.
      35             :         class RTFVertOrient
      36             :         {
      37             :             public:
      38           3 :                 RTFVertOrient(sal_uInt16 nValue)
      39             :                 {
      40           3 :                     Value.nVal = nValue;
      41           3 :                 }
      42             : 
      43           3 :                 sal_uInt16 GetOrient() const
      44             :                 {
      45           3 :                     return Value.Flags.nOrient;
      46             :                 }
      47             : 
      48           3 :                 sal_uInt16 GetRelation() const
      49             :                 {
      50           3 :                     return Value.Flags.nRelOrient;
      51             :                 }
      52             : 
      53           3 :                 sal_Int32 GetAlign() const
      54             :                 {
      55           3 :                     sal_Int32 nAlign = 0;
      56           3 :                     switch( GetOrient( ) )
      57             :                     {
      58             :                         case text::VertOrientation::CENTER:
      59           0 :                             nAlign = NS_ooxml::LN_Value_wordprocessingml_ST_YAlign_center;
      60           0 :                             break;
      61             :                         case text::VertOrientation::TOP:
      62           2 :                             nAlign = NS_ooxml::LN_Value_wordprocessingml_ST_YAlign_top;
      63           2 :                             break;
      64             :                         case text::VertOrientation::BOTTOM:
      65           0 :                             nAlign = NS_ooxml::LN_Value_wordprocessingml_ST_YAlign_bottom;
      66           0 :                             break;
      67             :                     }
      68             : 
      69           3 :                     return nAlign;
      70             :                 }
      71             : 
      72           3 :                 sal_Int32 GetAnchor() const
      73             :                 {
      74           3 :                     sal_Int32 nAnchor = 0;
      75           3 :                     switch( GetRelation( ) )
      76             :                     {
      77             :                         case text::RelOrientation::FRAME:
      78           1 :                             nAnchor = NS_ooxml::LN_Value_wordprocessingml_ST_VAnchor_text;
      79           1 :                             break;
      80             :                         case text::RelOrientation::PAGE_FRAME:
      81           0 :                             nAnchor = NS_ooxml::LN_Value_wordprocessingml_ST_VAnchor_page;
      82           0 :                             break;
      83             :                         case text::RelOrientation::PAGE_PRINT_AREA:
      84           0 :                             nAnchor = NS_ooxml::LN_Value_wordprocessingml_ST_VAnchor_margin;
      85           0 :                             break;
      86             :                     }
      87             : 
      88           3 :                     return nAnchor;
      89             :                 }
      90             : 
      91             :                 sal_uInt16 GetValue() const
      92             :                 {
      93             :                     return Value.nVal;
      94             :                 }
      95             : 
      96             :             private:
      97             :                 union
      98             :                 {
      99             :                     struct
     100             :                     {
     101             :                         sal_uInt16 nOrient : 4;
     102             :                         sal_uInt16 nRelOrient : 1;
     103             :                     } Flags;
     104             :                     sal_uInt16 nVal;
     105             :                 } Value;
     106             :         };
     107             : 
     108             :         /// Stores the horizontal orientation properties of an RTF fly frame.
     109             :         class RTFHoriOrient
     110             :         {
     111             :             public:
     112           3 :                 RTFHoriOrient(sal_uInt16 nValue)
     113             :                 {
     114           3 :                     Value.nVal = nValue;
     115           3 :                 }
     116             : 
     117           3 :                 sal_uInt16 GetOrient() const
     118             :                 {
     119           3 :                     return Value.Flags.nOrient;
     120             :                 }
     121             : 
     122           3 :                 sal_uInt16 GetRelation() const
     123             :                 {
     124           3 :                     return Value.Flags.nRelOrient;
     125             :                 }
     126             : 
     127           3 :                 sal_Int32 GetAlign() const
     128             :                 {
     129           3 :                     sal_Int32 nAlign = 0;
     130           3 :                     switch( GetOrient( ) )
     131             :                     {
     132             :                         case text::HoriOrientation::CENTER:
     133           2 :                             nAlign = NS_ooxml::LN_Value_wordprocessingml_ST_XAlign_center;
     134           2 :                             break;
     135             :                         case text::HoriOrientation::RIGHT:
     136           0 :                             nAlign = NS_ooxml::LN_Value_wordprocessingml_ST_XAlign_right;
     137           0 :                             break;
     138             :                         case text::HoriOrientation::LEFT:
     139           0 :                             nAlign = NS_ooxml::LN_Value_wordprocessingml_ST_XAlign_left;
     140           0 :                             break;
     141             :                         case text::HoriOrientation::INSIDE:
     142           0 :                             nAlign = NS_ooxml::LN_Value_wordprocessingml_ST_XAlign_inside;
     143           0 :                             break;
     144             :                         case text::HoriOrientation::OUTSIDE:
     145           0 :                             nAlign = NS_ooxml::LN_Value_wordprocessingml_ST_XAlign_outside;
     146           0 :                             break;
     147             :                     }
     148             : 
     149           3 :                     return nAlign;
     150             :                 }
     151             : 
     152           3 :                 sal_Int32 GetAnchor() const
     153             :                 {
     154           3 :                     sal_Int32 nAnchor = 0;
     155           3 :                     switch( GetRelation( ) )
     156             :                     {
     157             :                         case text::RelOrientation::FRAME:
     158           2 :                             nAnchor = NS_ooxml::LN_Value_wordprocessingml_ST_HAnchor_text;
     159           2 :                             break;
     160             :                         case text::RelOrientation::PAGE_FRAME:
     161           0 :                             nAnchor = NS_ooxml::LN_Value_wordprocessingml_ST_HAnchor_page;
     162           0 :                             break;
     163             :                         case text::RelOrientation::PAGE_PRINT_AREA:
     164           0 :                             nAnchor = NS_ooxml::LN_Value_wordprocessingml_ST_HAnchor_margin;
     165           0 :                             break;
     166             :                     }
     167             : 
     168           3 :                     return nAnchor;
     169             :                 }
     170             : 
     171             :                 sal_uInt16 GetValue() const
     172             :                 {
     173             :                     return Value.nVal;
     174             :                 }
     175             : 
     176             :             private:
     177             :                 union
     178             :                 {
     179             :                     struct
     180             :                     {
     181             :                         sal_uInt16 nOrient : 4;
     182             :                         sal_uInt16 nRelAnchor : 4;
     183             :                         sal_uInt16 nRelOrient : 1;
     184             :                     } Flags;
     185             :                     sal_uInt16 nVal;
     186             :                 } Value;
     187             :         };
     188             :     } // namespace rtftok
     189             : } // namespace writerfilter
     190             : 
     191             : #endif // _RTFFLY_HXX_
     192             : 
     193             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10