LCOV - code coverage report
Current view: top level - svtools/source/control - collatorres.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 0 39 0.0 %
Date: 2015-06-13 12:38:46 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/collatorres.hxx>
      24             : 
      25             : 
      26             : 
      27             : //  wrapper for locale specific translations data of collator algorithm
      28             : 
      29             : 
      30             : 
      31             : class CollatorResourceData
      32             : {
      33             :     friend class CollatorResource;
      34             :     private: /* data */
      35             :         OUString ma_Name;
      36             :         OUString ma_Translation;
      37             :     private: /* member functions */
      38           0 :         CollatorResourceData () {}
      39             :     public:
      40           0 :         CollatorResourceData ( 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 :         ~CollatorResourceData () {}
      48             : 
      49           0 :         CollatorResourceData& operator= (const CollatorResourceData& 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 collator-algorithm-name translation
      60             : 
      61             : 
      62             : 
      63             : #define COLLATOR_RESOURCE_COUNT (STR_SVT_COLLATE_END - STR_SVT_COLLATE_START + 1)
      64             : 
      65           0 : CollatorResource::CollatorResource()
      66             : {
      67           0 :     mp_Data = new CollatorResourceData[COLLATOR_RESOURCE_COUNT];
      68             : 
      69             :     #define RESSTR(rid) SvtResId(rid).toString()
      70             : 
      71           0 :     mp_Data[0] = CollatorResourceData ("alphanumeric", RESSTR(STR_SVT_COLLATE_ALPHANUMERIC));
      72           0 :     mp_Data[1] = CollatorResourceData ("charset", RESSTR(STR_SVT_COLLATE_CHARSET));
      73           0 :     mp_Data[2] = CollatorResourceData ("dict", RESSTR(STR_SVT_COLLATE_DICTIONARY));
      74           0 :     mp_Data[3] = CollatorResourceData ("normal", RESSTR(STR_SVT_COLLATE_NORMAL));
      75           0 :     mp_Data[4] = CollatorResourceData ("pinyin", RESSTR(STR_SVT_COLLATE_PINYIN));
      76           0 :     mp_Data[5] = CollatorResourceData ("radical", RESSTR(STR_SVT_COLLATE_RADICAL));
      77           0 :     mp_Data[6] = CollatorResourceData ("stroke", RESSTR(STR_SVT_COLLATE_STROKE));
      78           0 :     mp_Data[7] = CollatorResourceData ("unicode", RESSTR(STR_SVT_COLLATE_UNICODE));
      79           0 :     mp_Data[8] = CollatorResourceData ("zhuyin", RESSTR(STR_SVT_COLLATE_ZHUYIN));
      80           0 :     mp_Data[9] = CollatorResourceData ("phonebook", RESSTR(STR_SVT_COLLATE_PHONEBOOK));
      81           0 :     mp_Data[10] = CollatorResourceData ("phonetic (alphanumeric first)", RESSTR(STR_SVT_COLLATE_PHONETIC_F));
      82           0 :     mp_Data[11] = CollatorResourceData ("phonetic (alphanumeric last)", RESSTR(STR_SVT_COLLATE_PHONETIC_L));
      83           0 : }
      84             : 
      85           0 : CollatorResource::~CollatorResource()
      86             : {
      87           0 :     delete[] mp_Data;
      88           0 : }
      89             : 
      90             : const OUString&
      91           0 : CollatorResource::GetTranslation(const OUString &r_Algorithm)
      92             : {
      93           0 :     sal_Int32 nIndex = r_Algorithm.indexOf('.');
      94           0 :     OUString aLocaleFreeAlgorithm;
      95             : 
      96           0 :     if (nIndex == -1)
      97             :     {
      98           0 :         aLocaleFreeAlgorithm = r_Algorithm;
      99             :     }
     100             :     else
     101             :     {
     102           0 :         nIndex += 1;
     103           0 :         aLocaleFreeAlgorithm = r_Algorithm.copy(nIndex, r_Algorithm.getLength() - nIndex);
     104             :     }
     105             : 
     106           0 :     for (sal_uInt32 i = 0; i < COLLATOR_RESOURCE_COUNT; i++)
     107             :     {
     108           0 :         if (aLocaleFreeAlgorithm == mp_Data[i].GetAlgorithm())
     109           0 :             return mp_Data[i].GetTranslation();
     110             :     }
     111             : 
     112           0 :     return r_Algorithm;
     113             : }
     114             : 
     115             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11