LCOV - code coverage report
Current view: top level - svtools/source/control - indexentryres.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 47 0.0 %
Date: 2014-04-14 Functions: 0 9 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             : 
      21             : #include <svtools/svtresid.hxx>
      22             : #include <svtools/svtools.hrc>
      23             : #include <svtools/indexentryres.hxx>
      24             : 
      25             : 
      26             : 
      27             : //  wrapper for locale specific translations data of indexentry algorithm
      28             : 
      29             : 
      30             : 
      31             : class IndexEntryResourceData
      32             : {
      33             :     friend class IndexEntryResource;
      34             :     private: /* data */
      35             :         OUString  ma_Name;
      36             :         OUString  ma_Translation;
      37             :     private: /* member functions */
      38           0 :         IndexEntryResourceData () {}
      39             :     public:
      40           0 :         IndexEntryResourceData ( const OUString &r_Algorithm, const OUString &r_Translation)
      41           0 :                 : ma_Name (r_Algorithm), ma_Translation (r_Translation) {}
      42             : 
      43           0 :         const OUString& GetAlgorithm () const { return ma_Name; }
      44             : 
      45           0 :         const OUString& GetTranslation () const { return ma_Translation; }
      46             : 
      47           0 :         ~IndexEntryResourceData () {}
      48             : 
      49           0 :         IndexEntryResourceData& operator= (const IndexEntryResourceData& r_From)
      50             :         {
      51           0 :             ma_Name         = r_From.GetAlgorithm();
      52           0 :             ma_Translation  = r_From.GetTranslation();
      53           0 :             return *this;
      54             :         }
      55             : };
      56             : 
      57             : 
      58             : 
      59             : //  implementation of the indexentry-algorithm-name translation
      60             : 
      61             : 
      62             : 
      63             : #define INDEXENTRY_RESOURCE_COUNT (STR_SVT_INDEXENTRY_END - STR_SVT_INDEXENTRY_START + 1)
      64             : 
      65           0 : IndexEntryResource::IndexEntryResource()
      66             : {
      67           0 :         mp_Data = new IndexEntryResourceData[INDEXENTRY_RESOURCE_COUNT];
      68             : 
      69             :         #define RESSTR(rid) SvtResId(rid).toString()
      70             : 
      71           0 :         mp_Data[STR_SVT_INDEXENTRY_ALPHANUMERIC - STR_SVT_INDEXENTRY_START] =
      72           0 :         IndexEntryResourceData ("alphanumeric", RESSTR(STR_SVT_INDEXENTRY_ALPHANUMERIC));
      73           0 :         mp_Data[STR_SVT_INDEXENTRY_DICTIONARY - STR_SVT_INDEXENTRY_START] =
      74           0 :         IndexEntryResourceData ("dict", RESSTR(STR_SVT_INDEXENTRY_DICTIONARY));
      75           0 :         mp_Data[STR_SVT_INDEXENTRY_PINYIN - STR_SVT_INDEXENTRY_START] =
      76           0 :         IndexEntryResourceData ("pinyin", RESSTR(STR_SVT_INDEXENTRY_PINYIN));
      77           0 :         mp_Data[STR_SVT_INDEXENTRY_PINYIN - STR_SVT_INDEXENTRY_START] =
      78           0 :         IndexEntryResourceData ("radical", RESSTR(STR_SVT_INDEXENTRY_RADICAL));
      79           0 :         mp_Data[STR_SVT_INDEXENTRY_STROKE - STR_SVT_INDEXENTRY_START] =
      80           0 :         IndexEntryResourceData ("stroke", RESSTR(STR_SVT_INDEXENTRY_STROKE));
      81           0 :         mp_Data[STR_SVT_INDEXENTRY_STROKE - STR_SVT_INDEXENTRY_START] =
      82           0 :         IndexEntryResourceData ("zhuyin", RESSTR(STR_SVT_INDEXENTRY_ZHUYIN));
      83           0 :         mp_Data[STR_SVT_INDEXENTRY_ZHUYIN - STR_SVT_INDEXENTRY_START] =
      84             :         IndexEntryResourceData ("phonetic (alphanumeric first) (grouped by syllable)",
      85           0 :                     RESSTR(STR_SVT_INDEXENTRY_PHONETIC_FS));
      86           0 :         mp_Data[STR_SVT_INDEXENTRY_PHONETIC_FS - STR_SVT_INDEXENTRY_START] =
      87             :         IndexEntryResourceData ("phonetic (alphanumeric first) (grouped by consonant)",
      88           0 :                     RESSTR(STR_SVT_INDEXENTRY_PHONETIC_FC));
      89           0 :         mp_Data[STR_SVT_INDEXENTRY_PHONETIC_FC - STR_SVT_INDEXENTRY_START] =
      90             :         IndexEntryResourceData ("phonetic (alphanumeric last) (grouped by syllable)",
      91           0 :                     RESSTR(STR_SVT_INDEXENTRY_PHONETIC_LS));
      92           0 :         mp_Data[STR_SVT_INDEXENTRY_PHONETIC_LS - STR_SVT_INDEXENTRY_START] =
      93             :         IndexEntryResourceData ("phonetic (alphanumeric last) (grouped by consonant)",
      94           0 :                     RESSTR(STR_SVT_INDEXENTRY_PHONETIC_LC));
      95           0 : }
      96             : 
      97           0 : IndexEntryResource::~IndexEntryResource()
      98             : {
      99           0 :     delete[] mp_Data;
     100           0 : }
     101             : 
     102           0 : const OUString& IndexEntryResource::GetTranslation(const OUString &r_Algorithm)
     103             : {
     104           0 :     sal_Int32 nIndex = r_Algorithm.indexOf('.');
     105           0 :     OUString aLocaleFreeAlgorithm;
     106             : 
     107           0 :     if (nIndex == -1)
     108           0 :         aLocaleFreeAlgorithm = r_Algorithm;
     109             :     else {
     110           0 :         nIndex += 1;
     111           0 :         aLocaleFreeAlgorithm = r_Algorithm.copy(nIndex, r_Algorithm.getLength() - nIndex);
     112             :     }
     113             : 
     114           0 :     for (sal_uInt32 i = 0; i < INDEXENTRY_RESOURCE_COUNT; i++)
     115           0 :         if (aLocaleFreeAlgorithm == mp_Data[i].GetAlgorithm())
     116           0 :             return mp_Data[i].GetTranslation();
     117           0 :     return r_Algorithm;
     118             : }
     119             : 
     120             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10