LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/oox/source/ppt - pptfilterhelpers.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 13 52 25.0 %
Date: 2013-07-09 Functions: 2 2 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             :  * 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 <com/sun/star/animations/TransitionType.hpp>
      21             : #include <com/sun/star/animations/TransitionSubType.hpp>
      22             : #include <rtl/ustrbuf.hxx>
      23             : #include "pptfilterhelpers.hxx"
      24             : 
      25             : namespace oox { namespace ppt {
      26             : 
      27             :     // BEGIN CUT&PASTE from sd pptanimations.hxx
      28             : 
      29             : 
      30             :     static const transition gTransitions[] =
      31             :     {
      32             :         { "wipe(up)", ::com::sun::star::animations::TransitionType::BARWIPE, ::com::sun::star::animations::TransitionSubType::TOPTOBOTTOM, sal_True },
      33             :         { "wipe(right)", ::com::sun::star::animations::TransitionType::BARWIPE, ::com::sun::star::animations::TransitionSubType::LEFTTORIGHT, sal_False },
      34             :         { "wipe(left)", ::com::sun::star::animations::TransitionType::BARWIPE, ::com::sun::star::animations::TransitionSubType::LEFTTORIGHT, sal_True },
      35             :         { "wipe(down)", ::com::sun::star::animations::TransitionType::BARWIPE, ::com::sun::star::animations::TransitionSubType::TOPTOBOTTOM, sal_False },
      36             :         { "wheel(1)", ::com::sun::star::animations::TransitionType::PINWHEELWIPE, ::com::sun::star::animations::TransitionSubType::ONEBLADE, sal_True },
      37             :         { "wheel(2)", ::com::sun::star::animations::TransitionType::PINWHEELWIPE, ::com::sun::star::animations::TransitionSubType::TWOBLADEVERTICAL, sal_True },
      38             :         { "wheel(3)", ::com::sun::star::animations::TransitionType::PINWHEELWIPE, ::com::sun::star::animations::TransitionSubType::THREEBLADE, sal_True },
      39             :         { "wheel(4)", ::com::sun::star::animations::TransitionType::PINWHEELWIPE, ::com::sun::star::animations::TransitionSubType::FOURBLADE, sal_True },
      40             :         { "wheel(8)", ::com::sun::star::animations::TransitionType::PINWHEELWIPE, ::com::sun::star::animations::TransitionSubType::EIGHTBLADE, sal_True },
      41             :         { "strips(downLeft)", ::com::sun::star::animations::TransitionType::WATERFALLWIPE, ::com::sun::star::animations::TransitionSubType::HORIZONTALRIGHT, sal_True },
      42             :         { "strips(upLeft)", ::com::sun::star::animations::TransitionType::WATERFALLWIPE, ::com::sun::star::animations::TransitionSubType::HORIZONTALLEFT, sal_False },
      43             :         { "strips(downRight)", ::com::sun::star::animations::TransitionType::WATERFALLWIPE, ::com::sun::star::animations::TransitionSubType::HORIZONTALLEFT, sal_True },
      44             :         { "strips(upRight)", ::com::sun::star::animations::TransitionType::WATERFALLWIPE, ::com::sun::star::animations::TransitionSubType::HORIZONTALRIGHT, sal_False },
      45             :         { "barn(inVertical)", ::com::sun::star::animations::TransitionType::BARNDOORWIPE, ::com::sun::star::animations::TransitionSubType::VERTICAL, sal_False },
      46             :         { "barn(outVertical)", ::com::sun::star::animations::TransitionType::BARNDOORWIPE, ::com::sun::star::animations::TransitionSubType::VERTICAL, sal_True },
      47             :         { "barn(inHorizontal)", ::com::sun::star::animations::TransitionType::BARNDOORWIPE, ::com::sun::star::animations::TransitionSubType::HORIZONTAL, sal_False },
      48             :         { "barn(outHorizontal)", ::com::sun::star::animations::TransitionType::BARNDOORWIPE, ::com::sun::star::animations::TransitionSubType::HORIZONTAL, sal_True },
      49             :         { "randombar(vertical)", ::com::sun::star::animations::TransitionType::RANDOMBARWIPE, ::com::sun::star::animations::TransitionSubType::VERTICAL, sal_True},
      50             :         { "randombar(horizontal)", ::com::sun::star::animations::TransitionType::RANDOMBARWIPE, ::com::sun::star::animations::TransitionSubType::HORIZONTAL, sal_True },
      51             :         { "checkerboard(down)", ::com::sun::star::animations::TransitionType::CHECKERBOARDWIPE, ::com::sun::star::animations::TransitionSubType::DOWN, sal_True},
      52             :         { "checkerboard(across)", ::com::sun::star::animations::TransitionType::CHECKERBOARDWIPE, ::com::sun::star::animations::TransitionSubType::ACROSS, sal_True },
      53             :         { "plus(out)", ::com::sun::star::animations::TransitionType::FOURBOXWIPE, ::com::sun::star::animations::TransitionSubType::CORNERSIN, sal_False },
      54             :         { "plus(in)", ::com::sun::star::animations::TransitionType::FOURBOXWIPE, ::com::sun::star::animations::TransitionSubType::CORNERSIN, sal_True },
      55             :         { "diamond(out)", ::com::sun::star::animations::TransitionType::IRISWIPE, ::com::sun::star::animations::TransitionSubType::DIAMOND, sal_True },
      56             :         { "diamond(in)", ::com::sun::star::animations::TransitionType::IRISWIPE, ::com::sun::star::animations::TransitionSubType::DIAMOND, sal_False },
      57             :         { "circle(out)", ::com::sun::star::animations::TransitionType::ELLIPSEWIPE, ::com::sun::star::animations::TransitionSubType::HORIZONTAL, sal_True },
      58             :         { "circle(in)", ::com::sun::star::animations::TransitionType::ELLIPSEWIPE, ::com::sun::star::animations::TransitionSubType::HORIZONTAL, sal_False },
      59             :         { "box(out)", ::com::sun::star::animations::TransitionType::IRISWIPE, ::com::sun::star::animations::TransitionSubType::RECTANGLE, sal_True },
      60             :         { "box(in)", ::com::sun::star::animations::TransitionType::IRISWIPE, ::com::sun::star::animations::TransitionSubType::RECTANGLE, sal_False },
      61             :         { "wedge", ::com::sun::star::animations::TransitionType::FANWIPE, ::com::sun::star::animations::TransitionSubType::CENTERTOP, sal_True },
      62             :         { "blinds(vertical)", ::com::sun::star::animations::TransitionType::BLINDSWIPE, ::com::sun::star::animations::TransitionSubType::VERTICAL, sal_True },
      63             :         { "blinds(horizontal)", ::com::sun::star::animations::TransitionType::BLINDSWIPE, ::com::sun::star::animations::TransitionSubType::HORIZONTAL, sal_True },
      64             :         { "fade", ::com::sun::star::animations::TransitionType::FADE, ::com::sun::star::animations::TransitionSubType::CROSSFADE, sal_True },
      65             :         { "slide(fromTop)", ::com::sun::star::animations::TransitionType::SLIDEWIPE, ::com::sun::star::animations::TransitionSubType::FROMTOP, sal_True },
      66             :         { "slide(fromRight)", ::com::sun::star::animations::TransitionType::SLIDEWIPE, ::com::sun::star::animations::TransitionSubType::FROMRIGHT, sal_True },
      67             :         { "slide(fromLeft)", ::com::sun::star::animations::TransitionType::SLIDEWIPE, ::com::sun::star::animations::TransitionSubType::FROMLEFT, sal_True },
      68             :         { "slide(fromBottom)", ::com::sun::star::animations::TransitionType::SLIDEWIPE, ::com::sun::star::animations::TransitionSubType::FROMBOTTOM, sal_True },
      69             :         { "dissolve", ::com::sun::star::animations::TransitionType::DISSOLVE, ::com::sun::star::animations::TransitionSubType::DEFAULT, sal_True },
      70             :         { "image", ::com::sun::star::animations::TransitionType::DISSOLVE, ::com::sun::star::animations::TransitionSubType::DEFAULT, sal_True }, // TODO
      71             :         { NULL, 0, 0, sal_False }
      72             :     };
      73             : 
      74           4 :     const transition* transition::find( const OUString& rName )
      75             :     {
      76           4 :         const transition* p = gTransitions;
      77             : 
      78          13 :         while( p->mpName )
      79             :         {
      80           9 :             if( rName.compareToAscii( p->mpName ) == 0 )
      81           4 :                 return p;
      82             : 
      83           5 :             p++;
      84             :         }
      85             : 
      86           0 :         return NULL;
      87             :     }
      88             : 
      89             : 
      90           4 :     bool convertMeasure( OUString& rString )
      91             :     {
      92           4 :         bool bRet = false;
      93             : 
      94             :         /* here we want to substitute all occurance of
      95             :          * [#]ppt_[xyhw] with
      96             :          * x,y,height and width respectively
      97             :          */
      98           4 :         sal_Int32 nIndex = 0;
      99           4 :         sal_Int32 nLastIndex = 0;
     100             : 
     101           4 :         nIndex = rString.indexOf("ppt_");
     102             :         // bail out early if there is no substitution to be made
     103           4 :         if(nIndex >= 0)
     104             :         {
     105           0 :             OUStringBuffer sRes(rString.getLength());
     106             : 
     107           0 :             do
     108             :             {
     109             :                 // copy the non matching inverval verbatim
     110           0 :                 if(nIndex > nLastIndex)
     111             :                 {
     112           0 :                     sRes.append(rString.getStr() + nLastIndex, (nIndex - nLastIndex));
     113             :                 }
     114             :                 // we are searching for ppt_[xywh] so we need and extra char behind the match
     115           0 :                 if(nIndex + 4 < rString.getLength())
     116             :                 {
     117           0 :                     switch(rString[nIndex + 4])
     118             :                     {
     119             :                     case (sal_Unicode)'h': // we found ppt_h
     120             :                         // if it was #ppt_h we already copied the #
     121             :                         // which we do not want in the target, so remove it
     122           0 :                         if(nIndex && (rString[nIndex - 1] == (sal_Unicode)'#'))
     123             :                         {
     124           0 :                             sRes.remove(sRes.getLength() - 1, 1);
     125             :                         }
     126           0 :                         sRes.append("height");
     127           0 :                         bRet = true;
     128           0 :                         break;
     129             :                     case (sal_Unicode)'w':
     130           0 :                         if(nIndex && (rString[nIndex - 1] == (sal_Unicode)'#'))
     131             :                         {
     132           0 :                             sRes.remove(sRes.getLength() - 1, 1);
     133             :                         }
     134           0 :                         sRes.append("width");
     135           0 :                         bRet = true;
     136           0 :                         break;
     137             :                     case (sal_Unicode)'x':
     138           0 :                         if(nIndex && (rString[nIndex - 1] == (sal_Unicode)'#'))
     139             :                         {
     140           0 :                             sRes[sRes.getLength() - 1] = (sal_Unicode)'x';
     141             :                         }
     142             :                         else
     143             :                         {
     144           0 :                             sRes.append((sal_Unicode)'x');
     145             :                         }
     146           0 :                         bRet = true;
     147           0 :                         break;
     148             :                     case (sal_Unicode)'y':
     149           0 :                         if(nIndex && (rString[nIndex - 1] == (sal_Unicode)'#'))
     150             :                         {
     151           0 :                             sRes[sRes.getLength() - 1] = (sal_Unicode)'y';
     152             :                         }
     153             :                         else
     154             :                         {
     155           0 :                             sRes.append((sal_Unicode)'y');
     156             :                         }
     157           0 :                         bRet = true;
     158           0 :                         break;
     159             :                     default:
     160             :                         // this was ppt_ without an interesting thing after that
     161             :                         // just copy it verbatim
     162           0 :                         sRes.append("ppt_");
     163             :                         // we are going to ajust for ppt_@ after the swtich
     164             :                         // so compensate for the fact we did not really process
     165             :                         // an extra character after ppt_
     166           0 :                         nIndex -= 1;
     167           0 :                         break;
     168             :                     }
     169             :                 }
     170             :                 else
     171             :                 {
     172           0 :                     sRes.append("ppt_");
     173           0 :                     nIndex += 4;
     174           0 :                     nLastIndex = nIndex;
     175           0 :                     break;
     176             :                 }
     177           0 :                 nIndex += 5;
     178           0 :                 nLastIndex = nIndex;
     179             :             }
     180             :             while((nIndex = rString.indexOf("ppt_", nIndex)) > 0);
     181             :             // copy the non matching tail if any
     182           0 :             if(nLastIndex < rString.getLength())
     183             :             {
     184           0 :                 sRes.append(rString.getStr() + nLastIndex, rString.getLength() - nLastIndex );
     185             :             }
     186           0 :             rString = sRes.makeStringAndClear();
     187             :         }
     188           4 :         return bRet;
     189             :     }
     190             : 
     191             : 
     192             : } }
     193             : 
     194             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10