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

Generated by: LCOV version 1.11