LCOV - code coverage report
Current view: top level - sw/source/core/sw3io - sw3convert.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 1 51 2.0 %
Date: 2014-11-03 Functions: 2 3 66.7 %
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 "hintids.hxx"
      21             : #include "sw3convert.hxx"
      22             : #include <tools/resid.hxx>
      23             : #include <svl/macitem.hxx>
      24             : #include <svl/zforlist.hxx>
      25             : #include <svl/zformat.hxx>
      26             : #include <svl/urihelper.hxx>
      27             : #include <sfx2/linkmgr.hxx>
      28             : 
      29             : #include <editeng/lrspitem.hxx>
      30             : #include <editeng/tstpitem.hxx>
      31             : #include <fmtinfmt.hxx>
      32             : #include <fmtfld.hxx>
      33             : #include <frmatr.hxx>
      34             : #include "doc.hxx"
      35             : #include "docary.hxx"
      36             : #include "fldbas.hxx"
      37             : #include "flddat.hxx"
      38             : #include "docufld.hxx"
      39             : #include "chpfld.hxx"
      40             : #include "ddefld.hxx"
      41             : #include "expfld.hxx"
      42             : #include "reffld.hxx"
      43             : #include "usrfld.hxx"
      44             : #include "dbfld.hxx"
      45             : #include "txtfld.hxx"
      46             : #include "ndtxt.hxx"
      47             : 
      48             : //really used ids from old sw3ids.hxx
      49             : #define SWG_INETBROWSER 0x000e      // URL graph nodes, browse flag, formatter
      50             : #define SWG_NEWFIELDS   0x0200      // Fields with Numberformatter numberformat
      51             : 
      52             : using namespace nsSwDocInfoSubType;
      53             : 
      54             : struct OldFormats
      55             : {
      56             :     NfIndexTableOffset  eFormatIdx;
      57             :     sal_uInt16              nOldFormat;
      58             : };
      59             : 
      60             : static const OldFormats aOldDateFmt40[] =
      61             : {
      62             :     // Date fields
      63             :     { NF_DATE_SYSTEM_SHORT,         DFF_SSYS },     // Short system date
      64             :     { NF_DATE_SYSTEM_LONG,          DFF_LSYS },     // Long system date
      65             :     { NF_DATE_SYS_DDMMYY,           DFF_DMY },      // 06.10.64
      66             :     { NF_DATE_SYS_DDMMYYYY,         DFF_DMYY },     // 06.10.1964
      67             :     { NF_DATE_SYS_DMMMYY,           DFF_DMMY },     // 06. Oct 64
      68             :     { NF_DATE_SYS_DMMMYYYY,         DFF_DMMYY },    // 06. Oct 1964
      69             :     { NF_DATE_DIN_DMMMMYYYY,        DFF_DMMMYY },   // 06. October 1964
      70             :     { NF_DATE_DIN_DMMMMYYYY,        DFF_DMMMY },    // 06. October 64
      71             :     { NF_DATE_SYS_NNDMMMYY,         DFF_DDMMY },    // Tue, 06. Oct 64
      72             :     { NF_DATE_SYS_NNDMMMMYYYY,      DFF_DDMMMY },   // Tue, 06. October 64
      73             :     { NF_DATE_SYS_NNDMMMMYYYY,      DFF_DDMMMYY },  // Tue, 06. October 1964
      74             :     { NF_DATE_SYS_NNNNDMMMMYYYY,    DFF_DDDMMMYY }, // Tuesday, 06. October 1964
      75             :     { NF_DATE_SYS_NNNNDMMMMYYYY,    DFF_DDDMMMY },  // Tuesday, 06. October 64
      76             :     { NF_DATE_SYS_MMYY,             DFF_MY },       // 10.64
      77             :     { NF_DATE_DIN_MMDD,             DFF_MD },       // 10-06
      78             :     { NF_DATE_DIN_YYMMDD,           DFF_YMD },      // 64-10-06
      79             :     { NF_DATE_DIN_YYYYMMDD,         DFF_YYMD },     // 1964-10-06
      80             : 
      81             :     { NF_NUMERIC_START,             0  }            // End of table
      82             : };
      83             : 
      84             : static const OldFormats aOldDateFmt30[] =
      85             : {
      86             :     // Date fields
      87             :     { NF_DATE_SYSTEM_SHORT,         DFF_SSYS },     // Short system date
      88             :     { NF_DATE_SYSTEM_LONG,          DFF_LSYS },     // Long system date
      89             :     { NF_DATE_SYS_DDMMYY,           DFF_DMY },      // 06.10.64
      90             :     { NF_DATE_SYS_DDMMYYYY,         DFF_DMYY },     // 06.10.1964
      91             :     { NF_DATE_SYS_DMMMYY,           DFF_DMMY },     // 06. Oct 64
      92             :     { NF_DATE_SYS_DMMMYYYY,         4 /*DFF_DMMYY*/ },  // 06. Oct 1964
      93             :     { NF_DATE_DIN_DMMMMYYYY,        5 /*DFF_DMMMYY*/ }, // 06. October 1964
      94             :     { NF_DATE_DIN_DMMMMYYYY,        5 /*DFF_DMMMY*/ },  // 06. October 64
      95             :     { NF_DATE_SYS_NNDMMMMYYYY,      6 /*DFF_DDMMMYY*/ },// Tue, 06. October 1964
      96             :     { NF_DATE_SYS_NNDMMMYY,         6 /*DFF_DDMMY*/ },  // Tue, 06. Oct 64
      97             :     { NF_DATE_SYS_NNDMMMMYYYY,      6 /*DFF_DDMMMY*/ }, // Tue, 06. October 64
      98             :     { NF_DATE_SYS_NNNNDMMMMYYYY,    7 /*DFF_DDDMMMYY*/ }, // Tuesday, 06. October 1964
      99             :     { NF_DATE_SYS_NNNNDMMMMYYYY,    7 /*DFF_DDDMMMY*/ },  // Tuesday, 06. October 64
     100             :     { NF_DATE_SYS_MMYY,             2 /*DFF_MY*/ },     // 10.64
     101             :     { NF_DATE_DIN_MMDD,             DFF_MD },           // 10-06
     102             :     { NF_DATE_DIN_YYMMDD,           DFF_YMD },      // 64-10-06
     103             :     { NF_DATE_DIN_YYYYMMDD,         DFF_YYMD },     // 1964-10-06
     104             : 
     105             :     { NF_NUMERIC_START,             0  }            // End of table
     106             : };
     107             : 
     108             : static const OldFormats aOldTimeFmt[] =
     109             : {
     110             :     // Time fields
     111             :     { NF_TIME_HHMMSS,               TF_SYSTEM },    // System time
     112             :     { NF_TIME_HHMM,                 TF_SSMM_24 },   // 23:25
     113             :     { NF_TIME_HHMMAMPM,             TF_SSMM_12 },   // 11:25 PM
     114             : 
     115             :     { NF_NUMERIC_START,             0 }             // End of table
     116             : };
     117             : 
     118             : static const OldFormats aOldGetSetExpFmt40[] =
     119             : {
     120             :     { NF_TEXT,                      VVF_CMD },      // Show command
     121             :     { NF_TEXT,                      VVF_INVISIBLE },// Invisible
     122             :     { NF_PERCENT_INT,               VVF_XXP },      // 1234%
     123             :     { NF_PERCENT_DEC2,              VVF_XX_XXP },   // 1.234,56%
     124             :     { NF_TEXT,                      VVF_CLEAR },    // ???
     125             : 
     126             :     { NF_NUMBER_SYSTEM,             VVF_SYS },      // Number format from system preferences
     127             :     { NF_NUMBER_INT,                VVF_X },        // 1234
     128             :     { NF_NUMBER_DEC2,               VVF_X_X },      // 1234,5
     129             :     { NF_NUMBER_DEC2,               VVF_X_XX },     // 1245,56
     130             :     { NF_NUMBER_1000DEC2,           VVF_XX_XX },    // 1.234,56
     131             :     { NF_NUMBER_1000DEC2,           VVF_XX_X },     // 1.234,5
     132             :     { NF_NUMBER_1000DEC2,           VVF_XX_XXX },   // 1.234,567
     133             :     { NF_CURRENCY_1000DEC2,         VVF_SYS_CUR },  // Currency format from system settings
     134             :                                                     // (1.234,00 EUR)
     135             :     { NF_CURRENCY_1000INT,          VVF_X_CUR },    // 1234 EUR
     136             :     { NF_CURRENCY_1000DEC2,         VVF_XX_XX_CUR },// 1234,56 EUR 1234,00 EUR
     137             :     { NF_CURRENCY_1000DEC2_DASHED,  VVF_XX_X0_CUR },// 1234,56 EUR 1234,-- EUR
     138             :     { NF_CURRENCY_1000INT,          VVF_CUR_X },    // EUR 1234
     139             :     { NF_CURRENCY_1000DEC2,         VVF_CUR_XX_XX },// EUR 1234,56 EUR 1234,00
     140             :     { NF_CURRENCY_1000DEC2_DASHED,  VVF_CUR_XX_X0 },// EUR 1234,56 EUR 1234,--
     141             : 
     142             :     { NF_NUMERIC_START,                 0  }        // End of table
     143             : };
     144             : 
     145             : static const OldFormats aOldGetSetExpFmt30[] =
     146             : {
     147             :     { NF_TEXT,                      VVF_CMD },      // Show command
     148             :     { NF_TEXT,                      VVF_INVISIBLE },// Invisible
     149             :     { NF_PERCENT_INT,                   VVF_XXP },  // 1234%
     150             :     { NF_PERCENT_DEC2,              VVF_XX_XXP },   // 1.234,56%
     151             :     { NF_TEXT,                      VVF_CLEAR },    // ???
     152             : 
     153             :     { NF_NUMBER_SYSTEM,             0x0020 },       // Number format from system preferences
     154             :     { NF_NUMBER_INT,                    0x0080 },   // 1234
     155             :     { NF_NUMBER_1000DEC2,               0x0100 },   // 1.234,56
     156             :     { NF_NUMBER_DEC2,                   0x0100 },   // 1234,5
     157             :     { NF_NUMBER_DEC2,                   0x0100 },   // 1245,56
     158             :     { NF_NUMBER_1000DEC2,               0x0100 },   // 1.234,5
     159             :     { NF_NUMBER_1000DEC2,               0x0100 },   // 1.234,567
     160             :     { NF_CURRENCY_1000DEC2,         0x0200 },       // Currency format from system settings
     161             :                                                     // (1.234,00 EUR)
     162             :     { NF_CURRENCY_1000INT,          0x1000 },       // 1234 EUR
     163             :     { NF_CURRENCY_1000DEC2,         0x1000 },       // 1234,56 EUR 1234,00 EUR
     164             :     { NF_CURRENCY_1000DEC2_DASHED,  0x1000 },       // 1234,56 EUR 1234,-- EUR
     165             :     { NF_CURRENCY_1000INT,          0x1000 },       // EUR 1234
     166             :     { NF_CURRENCY_1000DEC2,         0x1000 },       // EUR 1234,56 EUR 1234,00
     167             :     { NF_CURRENCY_1000DEC2_DASHED,  0x1000 },       // EUR 1234,56 EUR 1234,--
     168             : 
     169             :     { NF_NUMERIC_START,                 0  }        // End of table
     170             : };
     171             : 
     172           0 : SW_DLLPUBLIC void sw3io_ConvertFromOldField( SwDoc& rDoc, sal_uInt16& rWhich,
     173             :                                 sal_uInt16& rSubType, sal_uLong &rFmt,
     174             :                                 sal_uInt16 nVersion )
     175             : {
     176           0 :     const OldFormats *pOldFmt = 0L;
     177             : 
     178           0 :     switch( rWhich )
     179             :     {
     180             :         case RES_DATEFLD:
     181             :         case RES_FIXDATEFLD:
     182           0 :             if( nVersion < SWG_NEWFIELDS )
     183             :             {
     184           0 :                 rSubType = DATEFLD;
     185           0 :                 if( RES_FIXDATEFLD == rWhich )
     186           0 :                     rSubType |= FIXEDFLD;
     187           0 :                 rWhich = RES_DATETIMEFLD;
     188             :                 pOldFmt = nVersion<SWG_INETBROWSER ? aOldDateFmt30
     189           0 :                                                    : aOldDateFmt40;
     190             :             }
     191           0 :             break;
     192             : 
     193             :         case RES_TIMEFLD:
     194             :         case RES_FIXTIMEFLD:
     195           0 :             if( nVersion < SWG_NEWFIELDS )
     196             :             {
     197           0 :                 rSubType = TIMEFLD;
     198           0 :                 if( RES_FIXTIMEFLD == rWhich )
     199           0 :                     rSubType |= FIXEDFLD;
     200           0 :                 rWhich = RES_DATETIMEFLD;
     201           0 :                 pOldFmt = aOldTimeFmt;
     202             :             }
     203           0 :             break;
     204             : 
     205             :         case RES_DBFLD:
     206           0 :             if( nVersion < SWG_NEWFIELDS )
     207             :             {
     208           0 :                 rSubType = nsSwExtendedSubType::SUB_OWN_FMT;
     209             :                 pOldFmt = nVersion<SWG_INETBROWSER ? aOldGetSetExpFmt30
     210           0 :                                                     : aOldGetSetExpFmt40;
     211             :             }
     212           0 :             break;
     213             : 
     214             :         case RES_TABLEFLD:
     215             :         case RES_GETEXPFLD:
     216             :         case RES_SETEXPFLD:
     217             :         case RES_USERFLD:
     218           0 :             if( nVersion < SWG_NEWFIELDS )
     219             :             {
     220           0 :                 if( rFmt == VVF_INVISIBLE )
     221             :                 {
     222           0 :                     rSubType = nsSwExtendedSubType::SUB_INVISIBLE;
     223           0 :                     rFmt = 0;
     224             :                 }
     225           0 :                 else if( rFmt == VVF_CMD )
     226             :                 {
     227           0 :                     rSubType = nsSwExtendedSubType::SUB_CMD;
     228           0 :                     rFmt = 0;
     229             :                 }
     230             :                 else
     231             :                 {
     232             :                     // Small hack: We still need the unconverted format
     233             :                     // when handling number groups. We keep it temporarily
     234             :                     // in the subtype; if it's a valid format in the first
     235             :                     // place.
     236           0 :                     if( RES_SETEXPFLD==rWhich &&
     237             :                         /*rFmt >= (sal_uInt16)SVX_NUM_CHARS_UPPER_LETTER && always true*/
     238           0 :                         rFmt <= (sal_uInt16)SVX_NUM_BITMAP )
     239             :                     {
     240           0 :                         rSubType = (sal_uInt16)rFmt;
     241             :                     }
     242             :                     pOldFmt = nVersion<SWG_INETBROWSER ? aOldGetSetExpFmt30
     243           0 :                                                        : aOldGetSetExpFmt40;
     244             :                 }
     245             :             }
     246           0 :             break;
     247             :         case RES_DOCINFOFLD:
     248           0 :             if( nVersion < SWG_NEWFIELDS )
     249             :             {
     250           0 :                 switch( rFmt )
     251             :                 {
     252           0 :                 case RF_AUTHOR: rSubType = DI_SUB_AUTHOR;   break;
     253           0 :                 case RF_TIME:   rSubType = DI_SUB_TIME; break;
     254           0 :                 case RF_DATE:   rSubType = DI_SUB_DATE; break;
     255           0 :                 case RF_ALL:    rSubType = DI_SUB_DATE; break;
     256             :                 }
     257           0 :                 rFmt = 0;
     258             :             }
     259           0 :             break;
     260             :     }
     261             : 
     262           0 :     if( pOldFmt )
     263             :     {
     264           0 :         SvNumberFormatter *pFormatter = rDoc.GetNumberFormatter();
     265           0 :         sal_uInt16 i = 0;
     266             : 
     267           0 :         while( pOldFmt[i].eFormatIdx != NF_NUMERIC_START ||
     268           0 :                pOldFmt[i].nOldFormat)
     269             :         {
     270           0 :             if( rFmt == pOldFmt[i].nOldFormat )
     271             :             {
     272           0 :                 rFmt = pFormatter->GetFormatIndex(pOldFmt[i].eFormatIdx, LANGUAGE_SYSTEM);
     273           0 :                 break;
     274             :             }
     275           0 :             i++;
     276             :         }
     277             :     }
     278         270 : }
     279             : 
     280             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10