LCOV - code coverage report
Current view: top level - registry/source - reflwrit.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 407 570 71.4 %
Date: 2012-08-25 Functions: 33 51 64.7 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 200 370 54.1 %

           Branch data     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 <new>
      22                 :            : #include <sal/types.h>
      23                 :            : #include <sal/macros.h>
      24                 :            : #include <osl/endian.h>
      25                 :            : #include <rtl/alloc.h>
      26                 :            : #include "rtl/string.hxx"
      27                 :            : #include "rtl/ustring.hxx"
      28                 :            : 
      29                 :            : #include "registry/reflwrit.hxx"
      30                 :            : #include "registry/version.h"
      31                 :            : #include "registry/writer.h"
      32                 :            : 
      33                 :            : #include "reflcnst.hxx"
      34                 :            : 
      35                 :            : using ::rtl::OString;
      36                 :            : 
      37                 :            : 
      38                 :            : namespace {
      39                 :            : 
      40                 :     249235 : inline rtl::OString toByteString(rtl_uString const * str) {
      41                 :            :     return rtl::OString(
      42                 :            :         str->buffer, str->length, RTL_TEXTENCODING_UTF8,
      43                 :     249235 :         OUSTRING_TO_OSTRING_CVTFLAGS);
      44                 :            : }
      45                 :            : 
      46                 :            : }
      47                 :            : 
      48                 :            : static sal_Unicode NULL_WSTRING[1] = { 0 };
      49                 :            : 
      50                 :            : #define BLOP_OFFSET_MAGIC       0
      51                 :            : #define BLOP_OFFSET_SIZE        (BLOP_OFFSET_MAGIC + sizeof(sal_uInt32))
      52                 :            : #define BLOP_OFFSET_MINOR       (BLOP_OFFSET_SIZE + sizeof(sal_uInt32))
      53                 :            : #define BLOP_OFFSET_MAJOR       (BLOP_OFFSET_MINOR + sizeof(sal_uInt16))
      54                 :            : #define BLOP_OFFSET_N_ENTRIES   (BLOP_OFFSET_MAJOR + sizeof(sal_uInt16))
      55                 :            : #define BLOP_OFFSET_TYPE_SOURCE (BLOP_OFFSET_N_ENTRIES + sizeof(sal_uInt16))
      56                 :            : #define BLOP_OFFSET_TYPE_CLASS  (BLOP_OFFSET_TYPE_SOURCE + sizeof(sal_uInt16))
      57                 :            : #define BLOP_OFFSET_THIS        (BLOP_OFFSET_TYPE_CLASS + sizeof(sal_uInt16))
      58                 :            : #define BLOP_OFFSET_UIK         (BLOP_OFFSET_THIS + sizeof(sal_uInt16))
      59                 :            : #define BLOP_OFFSET_DOKU        (BLOP_OFFSET_UIK + sizeof(sal_uInt16))
      60                 :            : #define BLOP_OFFSET_FILENAME    (BLOP_OFFSET_DOKU + sizeof(sal_uInt16))
      61                 :            : #define BLOP_HEADER_N_ENTRIES   6
      62                 :            : 
      63                 :            : #define BLOP_OFFSET_N_SUPERTYPES    0
      64                 :            : #define BLOP_OFFSET_SUPERTYPES      (BLOP_OFFSET_N_SUPERTYPES + sizeof(sal_uInt16))
      65                 :            : 
      66                 :            : #define BLOP_FIELD_ENTRY_ACCESS     0
      67                 :            : #define BLOP_FIELD_ENTRY_NAME       (BLOP_FIELD_ENTRY_ACCESS + sizeof(sal_uInt16))
      68                 :            : #define BLOP_FIELD_ENTRY_TYPE       (BLOP_FIELD_ENTRY_NAME + sizeof(sal_uInt16))
      69                 :            : #define BLOP_FIELD_ENTRY_VALUE      (BLOP_FIELD_ENTRY_TYPE + sizeof(sal_uInt16))
      70                 :            : #define BLOP_FIELD_ENTRY_DOKU       (BLOP_FIELD_ENTRY_VALUE + sizeof(sal_uInt16))
      71                 :            : #define BLOP_FIELD_ENTRY_FILENAME   (BLOP_FIELD_ENTRY_DOKU + sizeof(sal_uInt16))
      72                 :            : #define BLOP_FIELD_N_ENTRIES        6
      73                 :            : 
      74                 :            : #define BLOP_METHOD_SIZE        0
      75                 :            : #define BLOP_METHOD_MODE        (BLOP_METHOD_SIZE + sizeof(sal_uInt16))
      76                 :            : #define BLOP_METHOD_NAME        (BLOP_METHOD_MODE + sizeof(sal_uInt16))
      77                 :            : #define BLOP_METHOD_RETURN      (BLOP_METHOD_NAME + sizeof(sal_uInt16))
      78                 :            : #define BLOP_METHOD_DOKU        (BLOP_METHOD_RETURN + sizeof(sal_uInt16))
      79                 :            : #define BLOP_METHOD_N_ENTRIES   5
      80                 :            : 
      81                 :            : #define BLOP_PARAM_TYPE         0
      82                 :            : #define BLOP_PARAM_MODE         (BLOP_PARAM_TYPE + sizeof(sal_uInt16))
      83                 :            : #define BLOP_PARAM_NAME         (BLOP_PARAM_MODE + sizeof(sal_uInt16))
      84                 :            : #define BLOP_PARAM_N_ENTRIES    3
      85                 :            : 
      86                 :            : #define BLOP_REFERENCE_TYPE         0
      87                 :            : #define BLOP_REFERENCE_NAME         (BLOP_REFERENCE_TYPE + sizeof(sal_uInt16))
      88                 :            : #define BLOP_REFERENCE_DOKU         (BLOP_REFERENCE_NAME + sizeof(sal_uInt16))
      89                 :            : #define BLOP_REFERENCE_ACCESS       (BLOP_REFERENCE_DOKU + sizeof(sal_uInt16))
      90                 :            : #define BLOP_REFERENCE_N_ENTRIES    4
      91                 :            : 
      92                 :          0 : sal_uInt32 UINT16StringLen(const sal_uInt8* wstring)
      93                 :            : {
      94         [ #  # ]:          0 :     if (!wstring) return 0;
      95                 :            : 
      96                 :          0 :     const sal_uInt8* b = wstring;
      97                 :            : 
      98 [ #  # ][ #  # ]:          0 :     while (b[0] || b[1]) b += sizeof(sal_uInt16);
                 [ #  # ]
      99                 :            : 
     100                 :          0 :     return ((b - wstring) / sizeof(sal_uInt16));
     101                 :            : }
     102                 :            : 
     103                 :          0 : sal_uInt32 writeString(sal_uInt8* buffer, const sal_Unicode* v)
     104                 :            : {
     105                 :          0 :     sal_uInt32 len = rtl_ustr_getLength(v) + 1;
     106                 :            :     sal_uInt32 i;
     107                 :          0 :     sal_uInt8* buff = buffer;
     108                 :            : 
     109         [ #  # ]:          0 :     for (i = 0; i < len; i++)
     110                 :            :     {
     111                 :          0 :         buff += writeUINT16(buff, (sal_uInt16) v[i]);
     112                 :            :     }
     113                 :            : 
     114                 :          0 :     return (buff - buffer);
     115                 :            : }
     116                 :            : 
     117                 :          0 : sal_uInt32 readString(const sal_uInt8* buffer, sal_Unicode* v, sal_uInt32 maxSize)
     118                 :            : {
     119         [ #  # ]:          0 :     sal_uInt32 len = SAL_MIN(UINT16StringLen(buffer) + 1, maxSize / 2);
     120                 :            :     sal_uInt32 i;
     121                 :          0 :     sal_uInt8* buff = (sal_uInt8*)buffer;
     122                 :            : 
     123         [ #  # ]:          0 :     for (i = 0; i < (len - 1); i++)
     124                 :            :     {
     125                 :            :         sal_uInt16 aChar;
     126                 :            : 
     127                 :          0 :         buff += readUINT16(buff, aChar);
     128                 :            : 
     129                 :          0 :         v[i] = (sal_Unicode) aChar;
     130                 :            :     }
     131                 :            : 
     132                 :          0 :     v[len - 1] = L'\0';
     133                 :            : 
     134                 :          0 :     return (buff - ((sal_uInt8*)buffer));
     135                 :            : }
     136                 :            : 
     137                 :         20 : sal_uInt32 writeFloat(sal_uInt8* buffer, float v)
     138                 :            : {
     139                 :            :     union
     140                 :            :     {
     141                 :            :         float   v;
     142                 :            :         sal_uInt32  b;
     143                 :            :     } x;
     144                 :            : 
     145                 :         20 :     x.v = v;
     146                 :            : 
     147                 :            : #ifdef REGTYPE_IEEE_NATIVE
     148                 :         20 :     writeUINT32(buffer, x.b);
     149                 :            : #else
     150                 :            : #   error no IEEE
     151                 :            : #endif
     152                 :            : 
     153                 :         20 :     return sizeof(sal_uInt32);
     154                 :            : }
     155                 :            : 
     156                 :          0 : sal_uInt32 writeDouble(sal_uInt8* buffer, double v)
     157                 :            : {
     158                 :            :     union
     159                 :            :     {
     160                 :            :         double v;
     161                 :            :         struct
     162                 :            :         {
     163                 :            :             sal_uInt32  b1;
     164                 :            :             sal_uInt32  b2;
     165                 :            :         } b;
     166                 :            :     } x;
     167                 :            : 
     168                 :          0 :     x.v = v;
     169                 :            : 
     170                 :            : #ifdef REGTYPE_IEEE_NATIVE
     171                 :            : #   ifdef OSL_BIGENDIAN
     172                 :            :     writeUINT32(buffer, x.b.b1);
     173                 :            :     writeUINT32(buffer + sizeof(sal_uInt32), x.b.b2);
     174                 :            : #   else
     175                 :          0 :     writeUINT32(buffer, x.b.b2);
     176                 :          0 :     writeUINT32(buffer + sizeof(sal_uInt32), x.b.b1);
     177                 :            : #   endif
     178                 :            : #else
     179                 :            : #   error no IEEE
     180                 :            : #endif
     181                 :            : 
     182                 :          0 :     return (sizeof(sal_uInt32) + sizeof(sal_uInt32));
     183                 :            : }
     184                 :            : 
     185                 :            : /**************************************************************************
     186                 :            : 
     187                 :            :     buffer write functions
     188                 :            : 
     189                 :            : **************************************************************************/
     190                 :            : 
     191                 :            : 
     192                 :            : /**************************************************************************
     193                 :            : 
     194                 :            :     struct CPInfo
     195                 :            : 
     196                 :            : **************************************************************************/
     197                 :            : 
     198                 :            : struct CPInfo
     199                 :            : {
     200                 :            :     CPInfoTag   m_tag;
     201                 :            :     union
     202                 :            :     {
     203                 :            :         const sal_Char*     aUtf8;
     204                 :            :         RTUik*              aUik;
     205                 :            :         RTConstValueUnion   aConst;
     206                 :            :     } m_value;
     207                 :            : 
     208                 :            :     sal_uInt16      m_index;
     209                 :            :     struct CPInfo*  m_next;
     210                 :            : 
     211                 :            :     CPInfo(CPInfoTag tag, struct CPInfo* prev);
     212                 :            : 
     213                 :            :     sal_uInt32 getBlopSize();
     214                 :            : 
     215                 :            :     sal_uInt32 toBlop(sal_uInt8* buffer);
     216                 :            : };
     217                 :            : 
     218                 :     171361 : CPInfo::CPInfo(CPInfoTag tag, struct CPInfo* prev)
     219                 :            :     : m_tag(tag)
     220                 :            :     , m_index(0)
     221                 :     171361 :     , m_next(NULL)
     222                 :            : {
     223         [ +  + ]:     171361 :     if (prev)
     224                 :            :     {
     225                 :     135093 :         m_index = prev->m_index + 1;
     226                 :     135093 :         prev->m_next = this;
     227                 :            :     }
     228                 :     171361 : }
     229                 :            : 
     230                 :     270186 : sal_uInt32 CPInfo::getBlopSize()
     231                 :            : {
     232                 :     270186 :     sal_uInt32 size = sizeof(sal_uInt32) /* size */ + sizeof(sal_uInt16) /* tag */;
     233                 :            : 
     234   [ -  +  +  +  :     270186 :     switch (m_tag)
          +  +  +  +  +  
             -  -  +  -  
                      - ]
     235                 :            :     {
     236                 :            :         case CP_TAG_CONST_BOOL:
     237                 :          0 :             size += sizeof(sal_uInt8);
     238                 :          0 :             break;
     239                 :            :         case CP_TAG_CONST_BYTE:
     240                 :        500 :             size += sizeof(sal_uInt8);
     241                 :        500 :             break;
     242                 :            :         case CP_TAG_CONST_INT16:
     243                 :       4900 :             size += sizeof(sal_Int16);
     244                 :       4900 :             break;
     245                 :            :         case CP_TAG_CONST_UINT16:
     246                 :          4 :             size += sizeof(sal_uInt16);
     247                 :          4 :             break;
     248                 :            :         case CP_TAG_CONST_INT32:
     249                 :      22654 :             size += sizeof(sal_Int32);
     250                 :      22654 :             break;
     251                 :            :         case CP_TAG_CONST_UINT32:
     252                 :         82 :             size += sizeof(sal_uInt32);
     253                 :         82 :             break;
     254                 :            :         case CP_TAG_CONST_INT64:
     255                 :         62 :               size += sizeof(sal_Int64);
     256                 :         62 :             break;
     257                 :            :         case CP_TAG_CONST_UINT64:
     258                 :          4 :             size += sizeof(sal_uInt64);
     259                 :          4 :             break;
     260                 :            :         case CP_TAG_CONST_FLOAT:
     261                 :         40 :             size += sizeof(sal_uInt32);
     262                 :         40 :             break;
     263                 :            :         case CP_TAG_CONST_DOUBLE:
     264                 :          0 :             size += sizeof(sal_uInt32) + sizeof(sal_uInt32);
     265                 :          0 :             break;
     266                 :            :         case CP_TAG_CONST_STRING:
     267                 :          0 :             size += (rtl_ustr_getLength(m_value.aConst.aString) + 1) * sizeof(sal_uInt16);
     268                 :          0 :             break;
     269                 :            :         case CP_TAG_UTF8_NAME:
     270                 :     241940 :             size += strlen(m_value.aUtf8) + 1;
     271                 :     241940 :             break;
     272                 :            :         case CP_TAG_UIK:
     273                 :          0 :             size += sizeof(sal_uInt32) + sizeof(sal_uInt16) + sizeof(sal_uInt16) + sizeof(sal_uInt32) + sizeof(sal_uInt32);
     274                 :          0 :             break;
     275                 :            :         default:
     276                 :          0 :             break;
     277                 :            :     }
     278                 :            : 
     279                 :     270186 :     return size;
     280                 :            : }
     281                 :            : 
     282                 :            : 
     283                 :     135093 : sal_uInt32 CPInfo::toBlop(sal_uInt8* buffer)
     284                 :            : {
     285                 :     135093 :     sal_uInt8* buff = buffer;
     286                 :            : 
     287                 :     135093 :     buff += writeUINT32(buff, getBlopSize());
     288                 :     135093 :     buff += writeUINT16(buff, (sal_uInt16) m_tag);
     289                 :            : 
     290   [ -  +  +  +  :     135093 :     switch (m_tag)
          +  +  +  +  +  
             -  -  +  -  
                      - ]
     291                 :            :     {
     292                 :            :         case CP_TAG_CONST_BOOL:
     293                 :          0 :             buff += writeBYTE(buff, (sal_uInt8) m_value.aConst.aBool);
     294                 :          0 :             break;
     295                 :            :         case CP_TAG_CONST_BYTE:
     296                 :            :             buff += writeBYTE(
     297                 :        250 :                 buff, static_cast< sal_uInt8 >(m_value.aConst.aByte));
     298                 :        250 :             break;
     299                 :            :         case CP_TAG_CONST_INT16:
     300                 :       2450 :             buff += writeINT16(buff, m_value.aConst.aShort);
     301                 :       2450 :             break;
     302                 :            :         case CP_TAG_CONST_UINT16:
     303                 :          2 :             buff += writeINT16(buff, m_value.aConst.aUShort);
     304                 :          2 :             break;
     305                 :            :         case CP_TAG_CONST_INT32:
     306                 :      11327 :             buff += writeINT32(buff, m_value.aConst.aLong);
     307                 :      11327 :             break;
     308                 :            :         case CP_TAG_CONST_UINT32:
     309                 :         41 :             buff += writeUINT32(buff, m_value.aConst.aULong);
     310                 :         41 :             break;
     311                 :            :         case CP_TAG_CONST_INT64:
     312                 :         31 :             buff += writeUINT64(buff, m_value.aConst.aHyper);
     313                 :         31 :             break;
     314                 :            :         case CP_TAG_CONST_UINT64:
     315                 :          2 :             buff += writeUINT64(buff, m_value.aConst.aUHyper);
     316                 :          2 :             break;
     317                 :            :         case CP_TAG_CONST_FLOAT:
     318                 :         20 :             buff += writeFloat(buff, m_value.aConst.aFloat);
     319                 :         20 :             break;
     320                 :            :         case CP_TAG_CONST_DOUBLE:
     321                 :          0 :             buff += writeDouble(buff, m_value.aConst.aDouble);
     322                 :          0 :             break;
     323                 :            :         case CP_TAG_CONST_STRING:
     324                 :          0 :             buff += writeString(buff, m_value.aConst.aString);
     325                 :          0 :             break;
     326                 :            :         case CP_TAG_UTF8_NAME:
     327                 :     120970 :             buff += writeUtf8(buff, m_value.aUtf8);
     328                 :     120970 :             break;
     329                 :            :         case CP_TAG_UIK:
     330                 :          0 :             buff += writeUINT32(buff, m_value.aUik->m_Data1);
     331                 :          0 :             buff += writeUINT16(buff, m_value.aUik->m_Data2);
     332                 :          0 :             buff += writeUINT16(buff, m_value.aUik->m_Data3);
     333                 :          0 :             buff += writeUINT32(buff, m_value.aUik->m_Data4);
     334                 :          0 :             buff += writeUINT32(buff, m_value.aUik->m_Data5);
     335                 :          0 :             break;
     336                 :            :         default:
     337                 :          0 :             break;
     338                 :            :     }
     339                 :            : 
     340                 :     135093 :     return (buff - buffer);
     341                 :            : }
     342                 :            : 
     343                 :            : 
     344                 :            : /**************************************************************************
     345                 :            : 
     346                 :            :     class FieldEntry
     347                 :            : 
     348                 :            : **************************************************************************/
     349                 :            : 
     350                 :            : class FieldEntry
     351                 :            : {
     352                 :            : 
     353                 :            : public:
     354                 :            : 
     355                 :            :     OString           m_name;
     356                 :            :     OString           m_typeName;
     357                 :            :     OString           m_doku;
     358                 :            :     OString           m_fileName;
     359                 :            :     RTFieldAccess     m_access;
     360                 :            :     RTValueType       m_constValueType;
     361                 :            :     RTConstValueUnion m_constValue;
     362                 :            : 
     363                 :            :     FieldEntry();
     364                 :            :     ~FieldEntry();
     365                 :            : 
     366                 :            :     void setData(const OString&    name,
     367                 :            :                  const OString&    typeName,
     368                 :            :                  const OString&    doku,
     369                 :            :                  const OString&    fileName,
     370                 :            :                  RTFieldAccess     access,
     371                 :            :                  RTValueType       constValueType,
     372                 :            :                  RTConstValueUnion constValue);
     373                 :            :         // throws std::bad_alloc
     374                 :            : };
     375                 :            : 
     376                 :      21164 : FieldEntry::FieldEntry()
     377                 :            :     : m_access(RT_ACCESS_INVALID)
     378                 :      21164 :     , m_constValueType(RT_TYPE_NONE)
     379                 :            : {
     380                 :      21164 : }
     381                 :            : 
     382                 :      21164 : FieldEntry::~FieldEntry()
     383                 :            : {
     384 [ -  + ][ #  # ]:      21164 :     if (
                 [ #  # ]
     385                 :            :         (m_constValueType == RT_TYPE_STRING) &&
     386                 :            :         m_constValue.aString &&
     387                 :            :         (m_constValue.aString != NULL_WSTRING)
     388                 :            :        )
     389                 :            :     {
     390         [ #  # ]:          0 :         delete[] (sal_Unicode*)m_constValue.aString;
     391                 :            :     }
     392                 :      21164 : }
     393                 :            : 
     394                 :      21164 : void FieldEntry::setData(const OString&    name,
     395                 :            :                          const OString&    typeName,
     396                 :            :                          const OString&    doku,
     397                 :            :                          const OString&    fileName,
     398                 :            :                          RTFieldAccess      access,
     399                 :            :                          RTValueType        constValueType,
     400                 :            :                          RTConstValueUnion  constValue)
     401                 :            : {
     402                 :      21164 :     sal_Unicode * newValue = 0;
     403 [ -  + ][ #  # ]:      21164 :     if (constValueType == RT_TYPE_STRING && constValue.aString != 0) {
     404                 :          0 :         sal_Int32 n = rtl_ustr_getLength(constValue.aString) + 1;
     405                 :          0 :         newValue = new sal_Unicode[n];
     406                 :          0 :         memcpy(newValue, constValue.aString, n * sizeof (sal_Unicode));
     407                 :            :     }
     408                 :            : 
     409                 :      21164 :     m_name = name;
     410                 :      21164 :     m_typeName = typeName;
     411                 :      21164 :     m_doku = doku;
     412                 :      21164 :     m_fileName = fileName;
     413                 :            : 
     414 [ #  # ][ #  # ]:      21164 :     if (
                 [ -  + ]
     415                 :            :         (m_constValueType == RT_TYPE_STRING) &&
     416                 :            :         m_constValue.aString &&
     417                 :            :         (m_constValue.aString != NULL_WSTRING)
     418                 :            :        )
     419                 :            :     {
     420         [ #  # ]:          0 :         delete[] (sal_Unicode*)m_constValue.aString;
     421                 :            :     }
     422                 :            : 
     423                 :      21164 :     m_access = access;
     424                 :      21164 :     m_constValueType = constValueType;
     425                 :            : 
     426         [ -  + ]:      21164 :     if (m_constValueType == RT_TYPE_STRING)
     427                 :            :     {
     428         [ #  # ]:          0 :         if (constValue.aString == NULL)
     429                 :          0 :             m_constValue.aString = NULL_WSTRING;
     430                 :            :         else
     431                 :            :         {
     432                 :          0 :             m_constValue.aString = newValue;
     433                 :            :         }
     434                 :            :     }
     435                 :            :     else
     436                 :            :     {
     437                 :      21164 :         m_constValue = constValue;
     438                 :            :     }
     439                 :      21164 : }
     440                 :            : 
     441                 :            : /**************************************************************************
     442                 :            : 
     443                 :            :     class ParamEntry
     444                 :            : 
     445                 :            : **************************************************************************/
     446                 :            : 
     447                 :            : class ParamEntry
     448                 :            : {
     449                 :            : public:
     450                 :            : 
     451                 :            :     OString     m_typeName;
     452                 :            :     OString     m_name;
     453                 :            :     RTParamMode m_mode;
     454                 :            : 
     455                 :            :     ParamEntry();
     456                 :            :     ~ParamEntry();
     457                 :            : 
     458                 :            :     void setData(const OString& typeName,
     459                 :            :                  const OString& name,
     460                 :            :                  RTParamMode    mode);
     461                 :            : };
     462                 :            : 
     463                 :       8858 : ParamEntry::ParamEntry()
     464                 :       8858 :     : m_mode(RT_PARAM_INVALID)
     465                 :            : {
     466                 :       8858 : }
     467                 :            : 
     468                 :       8858 : ParamEntry::~ParamEntry()
     469                 :            : {
     470                 :       8858 : }
     471                 :            : 
     472                 :       8858 : void ParamEntry::setData(const OString& typeName,
     473                 :            :                          const OString& name,
     474                 :            :                          RTParamMode    mode)
     475                 :            : {
     476                 :       8858 :     m_name = name;
     477                 :       8858 :     m_typeName = typeName;
     478                 :       8858 :     m_mode = mode;
     479                 :       8858 : }
     480                 :            : 
     481                 :            : /**************************************************************************
     482                 :            : 
     483                 :            :     class ReferenceEntry
     484                 :            : 
     485                 :            : **************************************************************************/
     486                 :            : 
     487                 :            : class ReferenceEntry
     488                 :            : {
     489                 :            : public:
     490                 :            : 
     491                 :            :     OString         m_name;
     492                 :            :     OString         m_doku;
     493                 :            :     RTReferenceType m_type;
     494                 :            :     RTFieldAccess   m_access;
     495                 :            : 
     496                 :            :     ReferenceEntry();
     497                 :            :     ~ReferenceEntry();
     498                 :            : 
     499                 :            :     void setData(const OString&     name,
     500                 :            :                  RTReferenceType    refType,
     501                 :            :                  const OString&     doku,
     502                 :            :                  RTFieldAccess      access);
     503                 :            : };
     504                 :            : 
     505                 :       3429 : ReferenceEntry::ReferenceEntry()
     506                 :            :     : m_type(RT_REF_INVALID)
     507                 :       3429 :     , m_access(RT_ACCESS_INVALID)
     508                 :            : {
     509                 :       3429 : }
     510                 :            : 
     511                 :       3429 : ReferenceEntry::~ReferenceEntry()
     512                 :            : {
     513                 :       3429 : }
     514                 :            : 
     515                 :       3429 : void ReferenceEntry::setData(const OString&    name,
     516                 :            :                              RTReferenceType   refType,
     517                 :            :                              const OString&    doku,
     518                 :            :                              RTFieldAccess     access)
     519                 :            : {
     520                 :       3429 :     m_name = name;
     521                 :       3429 :     m_doku = doku;
     522                 :       3429 :     m_type = refType;
     523                 :       3429 :     m_access = access;
     524                 :       3429 : }
     525                 :            : 
     526                 :            : /**************************************************************************
     527                 :            : 
     528                 :            :     class MethodEntry
     529                 :            : 
     530                 :            : **************************************************************************/
     531                 :            : 
     532                 :            : class MethodEntry
     533                 :            : {
     534                 :            : public:
     535                 :            : 
     536                 :            :     OString         m_name;
     537                 :            :     OString         m_returnTypeName;
     538                 :            :     RTMethodMode    m_mode;
     539                 :            :     sal_uInt16      m_paramCount;
     540                 :            :     ParamEntry*     m_params;
     541                 :            :     sal_uInt16      m_excCount;
     542                 :            :     OString*        m_excNames;
     543                 :            :     OString         m_doku;
     544                 :            : 
     545                 :            :     MethodEntry();
     546                 :            :     ~MethodEntry();
     547                 :            : 
     548                 :            :     void setData(const OString&    name,
     549                 :            :                  const OString&    returnTypeName,
     550                 :            :                  RTMethodMode      mode,
     551                 :            :                  sal_uInt16        paramCount,
     552                 :            :                  sal_uInt16        excCount,
     553                 :            :                  const OString&    doku);
     554                 :            : 
     555                 :            :     void setExcName(sal_uInt16 excIndex, const OString& name);
     556                 :            : 
     557                 :            : protected:
     558                 :            : 
     559                 :            :     void reallocParams(sal_uInt16 size);
     560                 :            :     void reallocExcs(sal_uInt16 size);
     561                 :            : };
     562                 :            : 
     563                 :       8143 : MethodEntry::MethodEntry()
     564                 :            :     : m_mode(RT_MODE_INVALID)
     565                 :            :     , m_paramCount(0)
     566                 :            :     , m_params(NULL)
     567                 :            :     , m_excCount(0)
     568                 :       8143 :     , m_excNames(NULL)
     569                 :            : {
     570                 :       8143 : }
     571                 :            : 
     572                 :       8143 : MethodEntry::~MethodEntry()
     573                 :            : {
     574         [ +  + ]:       8143 :     if (m_params)
     575 [ +  - ][ +  + ]:      13920 :         delete[] m_params;
     576                 :            : 
     577         [ +  + ]:       8143 :     if (m_excNames)
     578 [ +  - ][ +  + ]:       5939 :         delete[] m_excNames;
     579                 :       8143 : }
     580                 :            : 
     581                 :       8143 : void MethodEntry::setData(const OString&    name,
     582                 :            :                           const OString&    returnTypeName,
     583                 :            :                           RTMethodMode      mode,
     584                 :            :                           sal_uInt16        paramCount,
     585                 :            :                           sal_uInt16        excCount,
     586                 :            :                           const OString&    doku)
     587                 :            : {
     588                 :       8143 :     m_name = name;
     589                 :       8143 :     m_returnTypeName = returnTypeName;
     590                 :       8143 :     m_doku = doku;
     591                 :            : 
     592                 :       8143 :     m_mode = mode;
     593                 :            : 
     594                 :       8143 :     reallocParams(paramCount);
     595                 :       8143 :     reallocExcs(excCount);
     596                 :       8143 : }
     597                 :            : 
     598                 :       3404 : void MethodEntry::setExcName(sal_uInt16 excIndex, const OString& name)
     599                 :            : {
     600         [ +  - ]:       3404 :     if (excIndex < m_excCount)
     601                 :            :     {
     602                 :       3404 :         m_excNames[excIndex] = name;
     603                 :            :     }
     604                 :       3404 : }
     605                 :            : 
     606                 :       8143 : void MethodEntry::reallocParams(sal_uInt16 size)
     607                 :            : {
     608                 :            :     ParamEntry* newParams;
     609                 :            : 
     610         [ +  + ]:       8143 :     if (size)
     611         [ +  + ]:      13920 :         newParams = new ParamEntry[size];
     612                 :            :     else
     613                 :       3081 :         newParams = NULL;
     614                 :            : 
     615         [ -  + ]:       8143 :     if (m_paramCount)
     616                 :            :     {
     617                 :            :         sal_uInt16 i;
     618                 :            : 
     619 [ #  # ][ #  # ]:          0 :         for (i = 0; i < SAL_MIN(size, m_paramCount); i++)
     620                 :            :         {
     621                 :          0 :             newParams[i].setData(m_params[i].m_typeName, m_params[i].m_name, m_params[i].m_mode);
     622                 :            :         }
     623                 :            : 
     624 [ #  # ][ #  # ]:          0 :         delete[] m_params;
     625                 :            :     }
     626                 :            : 
     627                 :       8143 :     m_paramCount = size;
     628                 :       8143 :     m_params = newParams;
     629                 :       8143 : }
     630                 :            : 
     631                 :       8143 : void MethodEntry::reallocExcs(sal_uInt16 size)
     632                 :            : {
     633                 :            :     OString* newExcNames;
     634                 :            : 
     635         [ +  + ]:       8143 :     if (size)
     636         [ +  + ]:       5939 :         newExcNames = new OString[size];
     637                 :            :     else
     638                 :       5608 :         newExcNames = NULL;
     639                 :            : 
     640                 :            :     sal_uInt16 i;
     641                 :            : 
     642 [ +  - ][ -  + ]:       8143 :     for (i = 0; i < SAL_MIN(size, m_excCount); i++)
     643                 :            :     {
     644                 :          0 :         newExcNames[i] = m_excNames[i];
     645                 :            :     }
     646                 :            : 
     647 [ -  + ][ #  # ]:       8143 :     delete[] m_excNames;
     648                 :            : 
     649                 :       8143 :     m_excCount = size;
     650                 :       8143 :     m_excNames = newExcNames;
     651                 :       8143 : }
     652                 :            : 
     653                 :            : 
     654                 :            : /**************************************************************************
     655                 :            : 
     656                 :            :     class TypeRegistryEntry
     657                 :            : 
     658                 :            : **************************************************************************/
     659                 :            : 
     660                 :            : class TypeWriter
     661                 :            : {
     662                 :            : 
     663                 :            : public:
     664                 :            : 
     665                 :            :     sal_uInt32          m_refCount;
     666                 :            :     typereg_Version     m_version;
     667                 :            :     RTTypeClass         m_typeClass;
     668                 :            :     OString             m_typeName;
     669                 :            :     sal_uInt16          m_nSuperTypes;
     670                 :            :     OString*            m_superTypeNames;
     671                 :            :     RTUik*              m_pUik;
     672                 :            :     OString             m_doku;
     673                 :            :     OString             m_fileName;
     674                 :            :     sal_uInt16          m_fieldCount;
     675                 :            :     FieldEntry*         m_fields;
     676                 :            :     sal_uInt16          m_methodCount;
     677                 :            :     MethodEntry*        m_methods;
     678                 :            :     sal_uInt16          m_referenceCount;
     679                 :            :     ReferenceEntry*     m_references;
     680                 :            : 
     681                 :            :     sal_uInt8*          m_blop;
     682                 :            :     sal_uInt32          m_blopSize;
     683                 :            : 
     684                 :            :     TypeWriter(typereg_Version version,
     685                 :            :                rtl::OString const & documentation,
     686                 :            :                rtl::OString const & fileName,
     687                 :            :                RTTypeClass      RTTypeClass,
     688                 :            :                bool             published,
     689                 :            :                const OString&   typeName,
     690                 :            :                sal_uInt16       superTypeCount,
     691                 :            :                sal_uInt16       FieldCount,
     692                 :            :                sal_uInt16       methodCount,
     693                 :            :                sal_uInt16       referenceCount);
     694                 :            : 
     695                 :            :     ~TypeWriter();
     696                 :            : 
     697                 :            :     void setSuperType(sal_uInt16 index, OString const & name);
     698                 :            : 
     699                 :            :     void createBlop(); // throws std::bad_alloc
     700                 :            : };
     701                 :            : 
     702                 :      36268 : TypeWriter::TypeWriter(typereg_Version version,
     703                 :            :                        rtl::OString const & documentation,
     704                 :            :                        rtl::OString const & fileName,
     705                 :            :                        RTTypeClass      RTTypeClass,
     706                 :            :                        bool             published,
     707                 :            :                        const OString&   typeName,
     708                 :            :                        sal_uInt16       superTypeCount,
     709                 :            :                        sal_uInt16       fieldCount,
     710                 :            :                        sal_uInt16       methodCount,
     711                 :            :                        sal_uInt16       referenceCount)
     712                 :            :     : m_refCount(1)
     713                 :            :     , m_version(version)
     714                 :            :     , m_typeClass(
     715                 :            :         static_cast< enum RTTypeClass >(
     716                 :            :             RTTypeClass | (published ? RT_TYPE_PUBLISHED : 0)))
     717                 :            :      , m_typeName(typeName)
     718                 :            :     , m_nSuperTypes(superTypeCount)
     719                 :            :     , m_pUik(NULL)
     720                 :            :     , m_doku(documentation)
     721                 :            :     , m_fileName(fileName)
     722                 :            :     , m_fieldCount(fieldCount)
     723                 :            :     , m_methodCount(methodCount)
     724                 :            :     , m_referenceCount(referenceCount)
     725                 :            :     , m_blop(NULL)
     726         [ +  + ]:      36268 :     , m_blopSize(0)
     727                 :            : {
     728         [ +  + ]:      36268 :     if (m_nSuperTypes > 0)
     729                 :            :     {
     730 [ +  - ][ +  + ]:       6568 :         m_superTypeNames = new OString[m_nSuperTypes];
     731                 :            :     } else
     732                 :            :     {
     733                 :      33068 :         m_superTypeNames = NULL;
     734                 :            :     }
     735                 :            : 
     736         [ +  + ]:      36268 :     if (m_fieldCount)
     737 [ +  - ][ +  + ]:      24019 :         m_fields = new FieldEntry[fieldCount];
     738                 :            : 
     739         [ +  + ]:      36268 :     if (m_methodCount)
     740 [ +  - ][ +  + ]:      10510 :         m_methods = new MethodEntry[methodCount];
     741                 :            : 
     742         [ +  + ]:      36268 :     if (m_referenceCount)
     743 [ +  - ][ +  + ]:       4668 :         m_references = new ReferenceEntry[referenceCount];
     744                 :      36268 : }
     745                 :            : 
     746                 :      36268 : TypeWriter::~TypeWriter()
     747                 :            : {
     748         [ +  + ]:      36268 :     if (m_superTypeNames)
     749 [ +  - ][ +  + ]:       6568 :         delete[] m_superTypeNames;
     750                 :            : 
     751         [ +  - ]:      36268 :     if (m_blop)
     752         [ +  - ]:      36268 :         delete[] m_blop;
     753                 :            : 
     754         [ +  + ]:      36268 :     if (m_fieldCount)
     755 [ +  - ][ +  + ]:      24019 :         delete[] m_fields;
     756                 :            : 
     757         [ +  + ]:      36268 :     if (m_methodCount)
     758 [ +  - ][ +  + ]:      10510 :         delete[] m_methods;
     759                 :            : 
     760         [ +  + ]:      36268 :     if (m_referenceCount)
     761 [ +  - ][ +  + ]:       4668 :         delete[] m_references;
     762                 :            : 
     763         [ -  + ]:      36268 :     if (m_pUik)
     764                 :          0 :         delete m_pUik;
     765                 :      36268 : }
     766                 :            : 
     767                 :       3368 : void TypeWriter::setSuperType(sal_uInt16 index, OString const & name)
     768                 :            : {
     769                 :       3368 :     m_superTypeNames[index] = name;
     770                 :       3368 : }
     771                 :            : 
     772                 :      36268 : void TypeWriter::createBlop()
     773                 :            : {
     774                 :            :     //TODO: Fix memory leaks that occur when std::bad_alloc is thrown
     775                 :            : 
     776                 :      36268 :     sal_uInt8*  pBlopFields         = NULL;
     777                 :      36268 :     sal_uInt8*  pBlopMethods        = NULL;
     778                 :      36268 :     sal_uInt8*  pBlopReferences     = NULL;
     779                 :      36268 :     sal_uInt8*  pBuffer             = NULL;
     780                 :      36268 :     sal_uInt32  blopFieldsSize      = 0;
     781                 :      36268 :     sal_uInt32  blopMethodsSize     = 0;
     782                 :      36268 :     sal_uInt32  blopReferenceSize   = 0;
     783                 :            : 
     784                 :      36268 :     CPInfo  root(CP_TAG_INVALID, NULL);
     785                 :      36268 :     sal_uInt16  cpIndexThisName = 0;
     786                 :      36268 :     sal_uInt16* cpIndexSuperNames = NULL;
     787                 :      36268 :     sal_uInt16  cpIndexUik = 0;
     788                 :      36268 :     sal_uInt16  cpIndexDoku = 0;
     789                 :      36268 :     sal_uInt16  cpIndexFileName = 0;
     790                 :      36268 :     CPInfo* pInfo = NULL;
     791                 :            : 
     792                 :      36268 :     sal_uInt16  entrySize = sizeof(sal_uInt16);
     793                 :      36268 :     sal_uInt32  blopHeaderEntrySize = BLOP_OFFSET_N_ENTRIES + entrySize + (BLOP_HEADER_N_ENTRIES * entrySize);
     794                 :      36268 :     sal_uInt32  blopFieldEntrySize = BLOP_FIELD_N_ENTRIES * entrySize;
     795                 :      36268 :     sal_uInt32  blopMethodEntrySize = BLOP_METHOD_N_ENTRIES * entrySize;
     796                 :      36268 :     sal_uInt32  blopParamEntrySize = BLOP_PARAM_N_ENTRIES * entrySize;
     797                 :      36268 :     sal_uInt32  blopReferenceEntrySize = BLOP_REFERENCE_N_ENTRIES * entrySize;
     798                 :            : 
     799                 :      36268 :     sal_uInt32 blopSize = blopHeaderEntrySize;
     800                 :            : 
     801                 :            :     // create CP entry for this name
     802         [ +  - ]:      36268 :     pInfo = new CPInfo(CP_TAG_UTF8_NAME, &root);
     803                 :      36268 :     pInfo->m_value.aUtf8 = m_typeName.getStr();
     804                 :      36268 :     cpIndexThisName = pInfo->m_index;
     805                 :            : 
     806                 :            :     // nSuperTypes
     807                 :      36268 :     blopSize += entrySize;
     808                 :            : 
     809                 :            :     // create CP entry for super names
     810         [ +  + ]:      36268 :     if (m_nSuperTypes)
     811                 :            :     {
     812                 :       3200 :         blopSize += m_nSuperTypes * entrySize;
     813                 :            : 
     814         [ +  - ]:       3200 :         cpIndexSuperNames = new sal_uInt16[m_nSuperTypes];
     815                 :            : 
     816         [ +  + ]:       6568 :         for (sal_uInt32 i=0; i < m_nSuperTypes; i++)
     817                 :            :         {
     818         [ +  - ]:       3368 :             pInfo = new CPInfo(CP_TAG_UTF8_NAME, pInfo);
     819                 :       3368 :             pInfo->m_value.aUtf8 = m_superTypeNames[i].getStr();
     820                 :       3368 :             cpIndexSuperNames[i] = pInfo->m_index;
     821                 :            :         }
     822                 :            :     }
     823                 :            : 
     824                 :            :     // create CP entry for uik
     825         [ -  + ]:      36268 :     if (m_pUik != NULL)
     826                 :            :     {
     827         [ #  # ]:          0 :         pInfo = new CPInfo(CP_TAG_UIK, pInfo);
     828                 :          0 :         pInfo->m_value.aUik = m_pUik;
     829                 :          0 :         cpIndexUik = pInfo->m_index;
     830                 :            :     }
     831                 :            : 
     832                 :            :     // create CP entry for doku
     833         [ -  + ]:      36268 :     if (!m_doku.isEmpty())
     834                 :            :     {
     835         [ #  # ]:          0 :         pInfo = new CPInfo(CP_TAG_UTF8_NAME, pInfo);
     836                 :          0 :         pInfo->m_value.aUtf8 = m_doku.getStr();
     837                 :          0 :         cpIndexDoku = pInfo->m_index;
     838                 :            :     }
     839                 :            : 
     840                 :            :     // create CP entry for idl source filename
     841         [ -  + ]:      36268 :     if (!m_fileName.isEmpty())
     842                 :            :     {
     843         [ #  # ]:          0 :         pInfo = new CPInfo(CP_TAG_UTF8_NAME, pInfo);
     844                 :          0 :         pInfo->m_value.aUtf8 = m_fileName.getStr();
     845                 :          0 :         cpIndexFileName = pInfo->m_index;
     846                 :            :     }
     847                 :            : 
     848                 :            :     // fields blop
     849                 :      36268 :     blopSize += sizeof(sal_uInt16); // fieldCount + nFieldEntries
     850                 :            : 
     851         [ +  + ]:      36268 :     if (m_fieldCount)
     852                 :            :     {
     853                 :       2855 :         sal_uInt16 cpIndexName = 0;
     854                 :       2855 :         sal_uInt16 cpIndexTypeName = 0;
     855                 :       2855 :         sal_uInt16 cpIndexValue = 0;
     856                 :       2855 :         sal_uInt16 cpIndexDoku2 = 0;
     857                 :       2855 :         sal_uInt16 cpIndexFileName2 = 0;
     858                 :            : 
     859                 :            :         // nFieldEntries + n fields
     860                 :       2855 :         blopFieldsSize = sizeof(sal_uInt16) + (m_fieldCount * blopFieldEntrySize);
     861                 :            : 
     862                 :       2855 :         blopSize += blopFieldsSize;
     863                 :            : 
     864         [ +  - ]:       2855 :         pBlopFields = new sal_uInt8[blopFieldsSize];
     865                 :       2855 :         pBuffer = pBlopFields;
     866                 :            : 
     867                 :       2855 :         pBuffer += writeUINT16(pBuffer, BLOP_FIELD_N_ENTRIES);
     868                 :            : 
     869         [ +  + ]:      24019 :         for (sal_uInt16 i = 0; i < m_fieldCount; i++)
     870                 :            :         {
     871                 :      21164 :             cpIndexName = 0;
     872                 :      21164 :             cpIndexTypeName = 0;
     873                 :      21164 :             cpIndexValue = 0;
     874                 :      21164 :             cpIndexDoku2 = 0;
     875                 :      21164 :             cpIndexFileName2 = 0;
     876                 :            : 
     877                 :      21164 :             pBuffer += writeUINT16(pBuffer, m_fields[i].m_access);
     878                 :            : 
     879         [ +  - ]:      21164 :             if (!m_fields[i].m_name.isEmpty())
     880                 :            :             {
     881         [ +  - ]:      21164 :                 pInfo = new CPInfo(CP_TAG_UTF8_NAME, pInfo);
     882                 :      21164 :                 pInfo->m_value.aUtf8 = m_fields[i].m_name.getStr();
     883                 :      21164 :                 cpIndexName = pInfo->m_index;
     884                 :            :             }
     885                 :      21164 :             pBuffer += writeUINT16(pBuffer, cpIndexName);
     886                 :            : 
     887         [ +  + ]:      21164 :             if (!m_fields[i].m_typeName.isEmpty())
     888                 :            :             {
     889         [ +  - ]:      19243 :                 pInfo = new CPInfo(CP_TAG_UTF8_NAME, pInfo);
     890                 :      19243 :                 pInfo->m_value.aUtf8 = m_fields[i].m_typeName.getStr();
     891                 :      19243 :                 cpIndexTypeName = pInfo->m_index;
     892                 :            :             }
     893                 :      21164 :             pBuffer += writeUINT16(pBuffer, cpIndexTypeName);
     894                 :            : 
     895         [ +  + ]:      21164 :             if (m_fields[i].m_constValueType != RT_TYPE_NONE)
     896                 :            :             {
     897         [ +  - ]:      14123 :                 pInfo = new CPInfo((CPInfoTag)m_fields[i].m_constValueType, pInfo);
     898                 :      14123 :                 pInfo->m_value.aConst = m_fields[i].m_constValue;
     899                 :      14123 :                 cpIndexValue = pInfo->m_index;
     900                 :            :             }
     901                 :      21164 :             pBuffer += writeUINT16(pBuffer, cpIndexValue);
     902                 :            : 
     903         [ -  + ]:      21164 :             if (!m_fields[i].m_doku.isEmpty())
     904                 :            :             {
     905         [ #  # ]:          0 :                 pInfo = new CPInfo(CP_TAG_UTF8_NAME, pInfo);
     906                 :          0 :                 pInfo->m_value.aUtf8 = m_fields[i].m_doku.getStr();
     907                 :          0 :                 cpIndexDoku2 = pInfo->m_index;
     908                 :            :             }
     909                 :      21164 :             pBuffer += writeUINT16(pBuffer, cpIndexDoku2);
     910                 :            : 
     911         [ -  + ]:      21164 :             if (!m_fields[i].m_fileName.isEmpty())
     912                 :            :             {
     913         [ #  # ]:          0 :                 pInfo = new CPInfo(CP_TAG_UTF8_NAME, pInfo);
     914                 :          0 :                 pInfo->m_value.aUtf8 = m_fields[i].m_fileName.getStr();
     915                 :          0 :                 cpIndexFileName2 = pInfo->m_index;
     916                 :            :             }
     917                 :      21164 :             pBuffer += writeUINT16(pBuffer, cpIndexFileName2);
     918                 :            :         }
     919                 :            :     }
     920                 :            : 
     921                 :            :     // methods blop
     922                 :      36268 :     blopSize += sizeof(sal_uInt16); // methodCount
     923                 :            : 
     924         [ +  + ]:      36268 :     if (m_methodCount)
     925                 :            :     {
     926         [ +  - ]:       2367 :         sal_uInt16* pMethodEntrySize = new sal_uInt16[m_methodCount];
     927                 :       2367 :         sal_uInt16  cpIndexName = 0;
     928                 :       2367 :         sal_uInt16  cpIndexReturn = 0;
     929                 :       2367 :         sal_uInt16  cpIndexDoku2 = 0;
     930                 :            : 
     931                 :            :         // nMethodEntries + nParamEntries
     932                 :       2367 :         blopMethodsSize = (2 * sizeof(sal_uInt16));
     933                 :            : 
     934         [ +  + ]:      10510 :         for (sal_uInt16 i = 0; i < m_methodCount; i++)
     935                 :            :         {
     936                 :       8143 :             pMethodEntrySize[i] = (sal_uInt16)
     937                 :            :                 ( blopMethodEntrySize +                                 // header
     938                 :            :                   sizeof(sal_uInt16) +                                  // parameterCount
     939                 :       8143 :                   (m_methods[i].m_paramCount * blopParamEntrySize) +    // exceptions
     940                 :            :                   sizeof(sal_uInt16) +                                  // exceptionCount
     941                 :       8143 :                   (m_methods[i].m_excCount * sizeof(sal_uInt16)) );     // exceptions
     942                 :            : 
     943                 :       8143 :             blopMethodsSize += pMethodEntrySize[i];
     944                 :            :         }
     945                 :            : 
     946         [ +  - ]:       2367 :         pBlopMethods = new sal_uInt8[blopMethodsSize];
     947                 :            : 
     948                 :       2367 :         blopSize += blopMethodsSize;
     949                 :            : 
     950                 :       2367 :         pBuffer = pBlopMethods;
     951                 :            : 
     952                 :       2367 :         pBuffer += writeUINT16(pBuffer, BLOP_METHOD_N_ENTRIES);
     953                 :       2367 :         pBuffer += writeUINT16(pBuffer, BLOP_PARAM_N_ENTRIES );
     954                 :            : 
     955         [ +  + ]:      10510 :         for (sal_uInt16 i = 0; i < m_methodCount; i++)
     956                 :            :         {
     957                 :       8143 :             cpIndexReturn = 0;
     958                 :       8143 :             cpIndexDoku2 = 0;
     959                 :            : 
     960                 :       8143 :             pBuffer += writeUINT16(pBuffer, pMethodEntrySize[i]);
     961                 :            :             pBuffer += writeUINT16(
     962                 :            :                 pBuffer,
     963                 :       8143 :                 sal::static_int_cast< sal_uInt16 >(m_methods[i].m_mode));
     964                 :            : 
     965         [ +  + ]:       8143 :             if (!m_methods[i].m_name.isEmpty())
     966                 :            :             {
     967         [ +  - ]:       8036 :                 pInfo = new CPInfo(CP_TAG_UTF8_NAME, pInfo);
     968                 :       8036 :                 pInfo->m_value.aUtf8 = m_methods[i].m_name.getStr();
     969                 :       8036 :                 cpIndexName = pInfo->m_index;
     970                 :            :             }
     971                 :       8143 :             pBuffer += writeUINT16(pBuffer, cpIndexName);
     972                 :       8143 :             cpIndexName = 0;
     973                 :            : 
     974         [ +  - ]:       8143 :             if (!m_methods[i].m_returnTypeName.isEmpty())
     975                 :            :             {
     976         [ +  - ]:       8143 :                 pInfo = new CPInfo(CP_TAG_UTF8_NAME, pInfo);
     977                 :       8143 :                 pInfo->m_value.aUtf8 = m_methods[i].m_returnTypeName.getStr();
     978                 :       8143 :                 cpIndexReturn = pInfo->m_index;
     979                 :            :             }
     980                 :       8143 :             pBuffer += writeUINT16(pBuffer, cpIndexReturn);
     981                 :            : 
     982         [ +  + ]:       8143 :             if (!m_methods[i].m_doku.isEmpty())
     983                 :            :             {
     984         [ +  - ]:        193 :                 pInfo = new CPInfo(CP_TAG_UTF8_NAME, pInfo);
     985                 :        193 :                 pInfo->m_value.aUtf8 = m_methods[i].m_doku.getStr();
     986                 :        193 :                 cpIndexDoku2 = pInfo->m_index;
     987                 :            :             }
     988                 :       8143 :             pBuffer += writeUINT16(pBuffer, cpIndexDoku2);
     989                 :            : 
     990                 :            :             sal_uInt16 j;
     991                 :            : 
     992                 :       8143 :             pBuffer += writeUINT16(pBuffer, m_methods[i].m_paramCount);
     993                 :            : 
     994         [ +  + ]:      17001 :             for (j = 0; j < m_methods[i].m_paramCount; j++)
     995                 :            :             {
     996         [ +  - ]:       8858 :                 if (!m_methods[i].m_params[j].m_typeName.isEmpty())
     997                 :            :                 {
     998         [ +  - ]:       8858 :                     pInfo = new CPInfo(CP_TAG_UTF8_NAME, pInfo);
     999                 :       8858 :                     pInfo->m_value.aUtf8 = m_methods[i].m_params[j].m_typeName.getStr();
    1000                 :       8858 :                     cpIndexName = pInfo->m_index;
    1001                 :            :                 }
    1002                 :       8858 :                 pBuffer += writeUINT16(pBuffer, cpIndexName);
    1003                 :       8858 :                 cpIndexName = 0;
    1004                 :            : 
    1005                 :            :                 pBuffer += writeUINT16(
    1006                 :            :                     pBuffer,
    1007                 :            :                     sal::static_int_cast< sal_uInt16 >(
    1008                 :       8858 :                         m_methods[i].m_params[j].m_mode));
    1009                 :            : 
    1010         [ +  - ]:       8858 :                 if (!m_methods[i].m_params[j].m_name.isEmpty())
    1011                 :            :                 {
    1012         [ +  - ]:       8858 :                     pInfo = new CPInfo(CP_TAG_UTF8_NAME, pInfo);
    1013                 :       8858 :                     pInfo->m_value.aUtf8 = m_methods[i].m_params[j].m_name.getStr();
    1014                 :       8858 :                     cpIndexName = pInfo->m_index;
    1015                 :            :                 }
    1016                 :       8858 :                 pBuffer += writeUINT16(pBuffer, cpIndexName);
    1017                 :       8858 :                 cpIndexName = 0;
    1018                 :            :             }
    1019                 :            : 
    1020                 :       8143 :             pBuffer += writeUINT16(pBuffer, m_methods[i].m_excCount);
    1021                 :            : 
    1022         [ +  + ]:      11547 :             for (j = 0; j < m_methods[i].m_excCount; j++)
    1023                 :            :             {
    1024         [ +  - ]:       3404 :                 if (!m_methods[i].m_excNames[j].isEmpty())
    1025                 :            :                 {
    1026         [ +  - ]:       3404 :                     pInfo = new CPInfo(CP_TAG_UTF8_NAME, pInfo);
    1027                 :       3404 :                     pInfo->m_value.aUtf8 = m_methods[i].m_excNames[j].getStr();
    1028                 :       3404 :                     cpIndexName = pInfo->m_index;
    1029                 :            :                 }
    1030                 :       3404 :                 pBuffer += writeUINT16(pBuffer, cpIndexName);
    1031                 :       3404 :                 cpIndexName = 0;
    1032                 :            :             }
    1033                 :            :         }
    1034                 :            : 
    1035         [ +  - ]:       2367 :         delete[] pMethodEntrySize;
    1036                 :            :     }
    1037                 :            : 
    1038                 :            :     // reference blop
    1039                 :      36268 :     blopSize += entrySize; // referenceCount
    1040                 :            : 
    1041         [ +  + ]:      36268 :     if (m_referenceCount)
    1042                 :            :     {
    1043                 :       1239 :         sal_uInt16 cpIndexName = 0;
    1044                 :       1239 :         sal_uInt16 cpIndexDoku2 = 0;
    1045                 :            : 
    1046                 :            :         // nReferenceEntries + n references
    1047                 :       1239 :         blopReferenceSize = entrySize + (m_referenceCount * blopReferenceEntrySize);
    1048                 :            : 
    1049                 :       1239 :         blopSize += blopReferenceSize;
    1050                 :            : 
    1051         [ +  - ]:       1239 :         pBlopReferences = new sal_uInt8[blopReferenceSize];
    1052                 :       1239 :         pBuffer = pBlopReferences;
    1053                 :            : 
    1054                 :       1239 :         pBuffer += writeUINT16(pBuffer, BLOP_REFERENCE_N_ENTRIES);
    1055                 :            : 
    1056         [ +  + ]:       4668 :         for (sal_uInt16 i = 0; i < m_referenceCount; i++)
    1057                 :            :         {
    1058                 :            :             pBuffer += writeUINT16(
    1059                 :            :                 pBuffer,
    1060                 :       3429 :                 sal::static_int_cast< sal_uInt16 >(m_references[i].m_type));
    1061                 :            : 
    1062                 :       3429 :             cpIndexName = 0;
    1063                 :       3429 :             cpIndexDoku2 = 0;
    1064                 :            : 
    1065         [ +  - ]:       3429 :             if (!m_references[i].m_name.isEmpty())
    1066                 :            :             {
    1067         [ +  - ]:       3429 :                 pInfo = new CPInfo(CP_TAG_UTF8_NAME, pInfo);
    1068                 :       3429 :                 pInfo->m_value.aUtf8 = m_references[i].m_name.getStr();
    1069                 :       3429 :                 cpIndexName = pInfo->m_index;
    1070                 :            :             }
    1071                 :       3429 :             pBuffer += writeUINT16(pBuffer, cpIndexName);
    1072                 :            : 
    1073         [ +  + ]:       3429 :             if (!m_references[i].m_doku.isEmpty())
    1074                 :            :             {
    1075         [ +  - ]:          6 :                 pInfo = new CPInfo(CP_TAG_UTF8_NAME, pInfo);
    1076                 :          6 :                 pInfo->m_value.aUtf8 = m_references[i].m_doku.getStr();
    1077                 :          6 :                 cpIndexDoku2 = pInfo->m_index;
    1078                 :            :             }
    1079                 :       3429 :             pBuffer += writeUINT16(pBuffer, cpIndexDoku2);
    1080                 :            : 
    1081                 :       3429 :             pBuffer += writeUINT16(pBuffer, m_references[i].m_access);
    1082                 :            :         }
    1083                 :            :     }
    1084                 :            : 
    1085                 :            : 
    1086                 :            :     // get CP infos blop-length
    1087                 :      36268 :     pInfo = root.m_next;
    1088                 :      36268 :     sal_uInt32 cpBlopSize = 0;
    1089                 :      36268 :     sal_uInt16 cpCount = 0;
    1090                 :            : 
    1091         [ +  + ]:     171361 :     while (pInfo)
    1092                 :            :     {
    1093                 :     135093 :         cpBlopSize += pInfo->getBlopSize();
    1094                 :     135093 :         cpCount++;
    1095                 :     135093 :         pInfo = pInfo->m_next;
    1096                 :            :     }
    1097                 :            : 
    1098                 :      36268 :     blopSize += cpBlopSize;
    1099                 :      36268 :     blopSize += sizeof(sal_uInt16);   // constantPoolCount
    1100                 :            : 
    1101                 :            :     // write all in flat buffer
    1102                 :            : 
    1103         [ +  - ]:      36268 :     sal_uInt8 * blop = new sal_uInt8[blopSize];
    1104                 :            : 
    1105                 :      36268 :     pBuffer = blop;
    1106                 :            : 
    1107                 :            :     // Assumes two's complement arithmetic with modulo-semantics:
    1108                 :      36268 :     pBuffer += writeUINT32(pBuffer, magic + m_version);
    1109                 :      36268 :     pBuffer += writeUINT32(pBuffer, blopSize);
    1110                 :      36268 :     pBuffer += writeUINT16(pBuffer, minorVersion);
    1111                 :      36268 :     pBuffer += writeUINT16(pBuffer, majorVersion);
    1112                 :      36268 :     pBuffer += writeUINT16(pBuffer, BLOP_HEADER_N_ENTRIES);
    1113                 :            : 
    1114                 :      36268 :     pBuffer += writeUINT16(pBuffer, (sal_uInt16)RT_UNO_IDL);
    1115                 :      36268 :     pBuffer += writeUINT16(pBuffer, (sal_uInt16)m_typeClass);
    1116                 :      36268 :     pBuffer += writeUINT16(pBuffer, cpIndexThisName);
    1117                 :      36268 :     pBuffer += writeUINT16(pBuffer, cpIndexUik);
    1118                 :      36268 :     pBuffer += writeUINT16(pBuffer, cpIndexDoku);
    1119                 :      36268 :     pBuffer += writeUINT16(pBuffer, cpIndexFileName);
    1120                 :            : 
    1121                 :            :     // write supertypes
    1122                 :      36268 :     pBuffer += writeUINT16(pBuffer, m_nSuperTypes);
    1123         [ +  + ]:      36268 :     if (m_nSuperTypes)
    1124                 :            :     {
    1125         [ +  + ]:       6568 :         for (sal_uInt32 i=0; i < m_nSuperTypes; i++)
    1126                 :            :         {
    1127                 :       3368 :             pBuffer += writeUINT16(pBuffer, cpIndexSuperNames[i]);
    1128                 :            :         }
    1129         [ +  - ]:       3200 :         delete[] cpIndexSuperNames;
    1130                 :            :     }
    1131                 :            : 
    1132                 :      36268 :     pBuffer += writeUINT16(pBuffer, cpCount);
    1133                 :            : 
    1134                 :            :     // write and delete CP infos
    1135                 :      36268 :     pInfo = root.m_next;
    1136                 :            : 
    1137         [ +  + ]:     171361 :     while (pInfo)
    1138                 :            :     {
    1139                 :     135093 :         CPInfo* pNextInfo = pInfo->m_next;
    1140                 :            : 
    1141                 :     135093 :         pBuffer += pInfo->toBlop(pBuffer);
    1142                 :     135093 :         delete pInfo;
    1143                 :            : 
    1144                 :     135093 :         pInfo = pNextInfo;
    1145                 :            :     }
    1146                 :            : 
    1147                 :            :     // write fields
    1148                 :      36268 :     pBuffer += writeUINT16(pBuffer, m_fieldCount);
    1149         [ +  + ]:      36268 :     if (blopFieldsSize)
    1150                 :            :     {
    1151                 :       2855 :         memcpy(pBuffer, pBlopFields, blopFieldsSize);
    1152                 :       2855 :         pBuffer += blopFieldsSize;
    1153                 :            :     }
    1154                 :            : 
    1155                 :            :     // write methods
    1156                 :      36268 :     pBuffer += writeUINT16(pBuffer, m_methodCount);
    1157         [ +  + ]:      36268 :     if (blopMethodsSize)
    1158                 :            :     {
    1159                 :       2367 :         memcpy(pBuffer, pBlopMethods, blopMethodsSize);
    1160                 :       2367 :         pBuffer += blopMethodsSize;
    1161                 :            :     }
    1162                 :            : 
    1163                 :            :     // write references
    1164                 :      36268 :     pBuffer += writeUINT16(pBuffer, m_referenceCount);
    1165         [ +  + ]:      36268 :     if (blopReferenceSize)
    1166                 :            :     {
    1167                 :       1239 :         memcpy(pBuffer, pBlopReferences, blopReferenceSize);
    1168                 :       1239 :         pBuffer += blopReferenceSize;
    1169                 :            :     }
    1170                 :            : 
    1171         [ +  + ]:      36268 :     delete[] pBlopFields;
    1172         [ +  + ]:      36268 :     delete[] pBlopMethods;
    1173         [ +  + ]:      36268 :     delete[] pBlopReferences;
    1174                 :            : 
    1175         [ -  + ]:      36268 :     delete[] m_blop;
    1176                 :      36268 :     m_blop = blop;
    1177                 :      36268 :     m_blopSize = blopSize;
    1178                 :      36268 : }
    1179                 :            : 
    1180                 :            : 
    1181                 :            : /**************************************************************************
    1182                 :            : 
    1183                 :            :     C-API
    1184                 :            : 
    1185                 :            : **************************************************************************/
    1186                 :            : 
    1187                 :            : extern "C" {
    1188                 :            : 
    1189                 :          0 : static void TYPEREG_CALLTYPE acquire(TypeWriterImpl hEntry)
    1190                 :            : {
    1191                 :          0 :     TypeWriter* pEntry = (TypeWriter*) hEntry;
    1192                 :            : 
    1193         [ #  # ]:          0 :     if (pEntry != NULL)
    1194                 :          0 :         pEntry->m_refCount++;
    1195                 :          0 : }
    1196                 :            : 
    1197                 :          0 : static void TYPEREG_CALLTYPE release(TypeWriterImpl hEntry)
    1198                 :            : {
    1199                 :          0 :     TypeWriter* pEntry = (TypeWriter*) hEntry;
    1200                 :            : 
    1201         [ #  # ]:          0 :     if (pEntry != NULL)
    1202                 :            :     {
    1203         [ #  # ]:          0 :         if (--pEntry->m_refCount == 0)
    1204         [ #  # ]:          0 :             delete pEntry;
    1205                 :            :     }
    1206                 :          0 : }
    1207                 :            : 
    1208                 :          0 : static void TYPEREG_CALLTYPE setUik(TypeWriterImpl  hEntry, const RTUik* uik)
    1209                 :            : {
    1210                 :          0 :     TypeWriter* pEntry = (TypeWriter*) hEntry;
    1211                 :            : 
    1212         [ #  # ]:          0 :     if (pEntry != NULL)
    1213                 :            :     {
    1214         [ #  # ]:          0 :         if (pEntry->m_pUik)
    1215                 :            :         {
    1216                 :          0 :             pEntry->m_pUik->m_Data1 = uik->m_Data1;
    1217                 :          0 :             pEntry->m_pUik->m_Data2 = uik->m_Data2;
    1218                 :          0 :             pEntry->m_pUik->m_Data3 = uik->m_Data3;
    1219                 :          0 :             pEntry->m_pUik->m_Data4 = uik->m_Data4;
    1220                 :          0 :             pEntry->m_pUik->m_Data5 = uik->m_Data5;
    1221                 :            :         }
    1222                 :            :         else
    1223                 :          0 :             pEntry->m_pUik = new RTUik(*uik);
    1224                 :            :     }
    1225                 :          0 : }
    1226                 :            : 
    1227                 :          0 : static void TYPEREG_CALLTYPE setDoku(TypeWriterImpl hEntry, rtl_uString* doku)
    1228                 :            : {
    1229                 :          0 :     static_cast< TypeWriter * >(hEntry)->m_doku = toByteString(doku);
    1230                 :          0 : }
    1231                 :            : 
    1232                 :          0 : static void TYPEREG_CALLTYPE setFileName(TypeWriterImpl hEntry, rtl_uString* fileName)
    1233                 :            : {
    1234                 :          0 :     static_cast< TypeWriter * >(hEntry)->m_fileName = toByteString(fileName);
    1235                 :          0 : }
    1236                 :            : 
    1237                 :      21164 : REG_DLLPUBLIC sal_Bool TYPEREG_CALLTYPE typereg_writer_setFieldData(
    1238                 :            :     void * handle, sal_uInt16 index, rtl_uString const * documentation,
    1239                 :            :     rtl_uString const * fileName, RTFieldAccess flags, rtl_uString const * name,
    1240                 :            :     rtl_uString const * typeName, RTValueType valueType,
    1241                 :            :     RTConstValueUnion valueValue)
    1242                 :            :     SAL_THROW_EXTERN_C()
    1243                 :            : {
    1244                 :            :     try {
    1245                 :            :         static_cast< TypeWriter * >(handle)->m_fields[index].setData(
    1246                 :            :             toByteString(name), toByteString(typeName),
    1247                 :            :             toByteString(documentation), toByteString(fileName), flags,
    1248 [ +  - ][ +  - ]:      21164 :             valueType, valueValue);
         [ +  - ][ +  - ]
         [ +  - ][ #  # ]
    1249                 :          0 :     } catch (std::bad_alloc &) {
    1250                 :          0 :         return false;
    1251                 :            :     }
    1252                 :      21164 :     return true;
    1253                 :            : }
    1254                 :            : 
    1255                 :          0 : static void TYPEREG_CALLTYPE setFieldData(TypeWriterImpl    hEntry,
    1256                 :            :                                           sal_uInt16        index,
    1257                 :            :                                           rtl_uString*      name,
    1258                 :            :                                           rtl_uString*      typeName,
    1259                 :            :                                           rtl_uString*      doku,
    1260                 :            :                                           rtl_uString*      fileName,
    1261                 :            :                                           RTFieldAccess     access,
    1262                 :            :                                           RTValueType       valueType,
    1263                 :            :                                           RTConstValueUnion constValue)
    1264                 :            : {
    1265                 :            :     typereg_writer_setFieldData(
    1266                 :            :         hEntry, index, doku, fileName, access, name, typeName, valueType,
    1267                 :          0 :         constValue);
    1268                 :          0 : }
    1269                 :            : 
    1270                 :       8143 : REG_DLLPUBLIC sal_Bool TYPEREG_CALLTYPE typereg_writer_setMethodData(
    1271                 :            :     void * handle, sal_uInt16 index, rtl_uString const * documentation,
    1272                 :            :     RTMethodMode flags, rtl_uString const * name,
    1273                 :            :     rtl_uString const * returnTypeName, sal_uInt16 parameterCount,
    1274                 :            :     sal_uInt16 exceptionCount)
    1275                 :            :     SAL_THROW_EXTERN_C()
    1276                 :            : {
    1277                 :            :     try {
    1278                 :            :         static_cast< TypeWriter * >(handle)->m_methods[index].setData(
    1279                 :            :             toByteString(name), toByteString(returnTypeName), flags,
    1280 [ +  - ][ +  - ]:       8143 :             parameterCount, exceptionCount, toByteString(documentation));
         [ +  - ][ +  - ]
                 [ #  # ]
    1281                 :          0 :     } catch (std::bad_alloc &) {
    1282                 :          0 :         return false;
    1283                 :            :     }
    1284                 :       8143 :     return true;
    1285                 :            : }
    1286                 :            : 
    1287                 :          0 : static void TYPEREG_CALLTYPE setMethodData(TypeWriterImpl   hEntry,
    1288                 :            :                                            sal_uInt16       index,
    1289                 :            :                                            rtl_uString*     name,
    1290                 :            :                                            rtl_uString*     returnTypeName,
    1291                 :            :                                            RTMethodMode     mode,
    1292                 :            :                                            sal_uInt16       paramCount,
    1293                 :            :                                            sal_uInt16       excCount,
    1294                 :            :                                            rtl_uString*     doku)
    1295                 :            : {
    1296                 :            :     typereg_writer_setMethodData(
    1297                 :          0 :         hEntry, index, doku, mode, name, returnTypeName, paramCount, excCount);
    1298                 :          0 : }
    1299                 :            : 
    1300                 :       8858 : REG_DLLPUBLIC sal_Bool TYPEREG_CALLTYPE typereg_writer_setMethodParameterData(
    1301                 :            :     void * handle, sal_uInt16 methodIndex, sal_uInt16 parameterIndex,
    1302                 :            :     RTParamMode flags, rtl_uString const * name, rtl_uString const * typeName)
    1303                 :            :     SAL_THROW_EXTERN_C()
    1304                 :            : {
    1305                 :            :     try {
    1306                 :            :         static_cast< TypeWriter * >(handle)->
    1307                 :       8858 :             m_methods[methodIndex].m_params[parameterIndex].setData(
    1308 [ +  - ][ +  - ]:       8858 :                 toByteString(typeName), toByteString(name), flags);
                 [ #  # ]
    1309                 :          0 :     } catch (std::bad_alloc &) {
    1310                 :          0 :         return false;
    1311                 :            :     }
    1312                 :       8858 :     return true;
    1313                 :            : }
    1314                 :            : 
    1315                 :          0 : static void TYPEREG_CALLTYPE setParamData(TypeWriterImpl    hEntry,
    1316                 :            :                                           sal_uInt16        index,
    1317                 :            :                                           sal_uInt16        paramIndex,
    1318                 :            :                                           rtl_uString*      type,
    1319                 :            :                                           rtl_uString*      name,
    1320                 :            :                                           RTParamMode       mode)
    1321                 :            : {
    1322                 :            :     typereg_writer_setMethodParameterData(
    1323                 :          0 :         hEntry, index, paramIndex, mode, name, type);
    1324                 :          0 : }
    1325                 :            : 
    1326                 :       3404 : REG_DLLPUBLIC sal_Bool TYPEREG_CALLTYPE typereg_writer_setMethodExceptionTypeName(
    1327                 :            :     void * handle, sal_uInt16 methodIndex, sal_uInt16 exceptionIndex,
    1328                 :            :     rtl_uString const * typeName)
    1329                 :            :     SAL_THROW_EXTERN_C()
    1330                 :            : {
    1331                 :            :     try {
    1332                 :            :         static_cast< TypeWriter * >(handle)->m_methods[methodIndex].setExcName(
    1333         [ +  - ]:       3404 :             exceptionIndex, toByteString(typeName));
    1334                 :          0 :     } catch (std::bad_alloc &) {
    1335                 :          0 :         return false;
    1336                 :            :     }
    1337         [ #  # ]:       3404 :     return true;
    1338                 :            : }
    1339                 :            : 
    1340                 :          0 : static void TYPEREG_CALLTYPE setExcData(TypeWriterImpl  hEntry,
    1341                 :            :                                         sal_uInt16      index,
    1342                 :            :                                         sal_uInt16      excIndex,
    1343                 :            :                                         rtl_uString*    type)
    1344                 :            : {
    1345                 :          0 :     typereg_writer_setMethodExceptionTypeName(hEntry, index, excIndex, type);
    1346                 :          0 : }
    1347                 :            : 
    1348                 :      36268 : REG_DLLPUBLIC void const * TYPEREG_CALLTYPE typereg_writer_getBlob(void * handle, sal_uInt32 * size)
    1349                 :            :     SAL_THROW_EXTERN_C()
    1350                 :            : {
    1351                 :      36268 :     TypeWriter * writer = static_cast< TypeWriter * >(handle);
    1352         [ +  - ]:      36268 :     if (writer->m_blop == 0) {
    1353                 :            :         try {
    1354         [ +  - ]:      36268 :             writer->createBlop();
    1355                 :          0 :         } catch (std::bad_alloc &) {
    1356                 :          0 :             return 0;
    1357                 :            :         }
    1358                 :            :     }
    1359                 :      36268 :     *size = writer->m_blopSize;
    1360         [ #  # ]:      36268 :     return writer->m_blop;
    1361                 :            : }
    1362                 :            : 
    1363                 :          0 : static const sal_uInt8* TYPEREG_CALLTYPE getBlop(TypeWriterImpl hEntry)
    1364                 :            : {
    1365                 :            :     sal_uInt32 size;
    1366                 :            :     return static_cast< sal_uInt8 const * >(
    1367                 :          0 :         typereg_writer_getBlob(hEntry, &size));
    1368                 :            : }
    1369                 :            : 
    1370                 :          0 : static sal_uInt32 TYPEREG_CALLTYPE getBlopSize(TypeWriterImpl hEntry)
    1371                 :            : {
    1372                 :            :     sal_uInt32 size;
    1373                 :          0 :     typereg_writer_getBlob(hEntry, &size);
    1374                 :          0 :     return size;
    1375                 :            : }
    1376                 :            : 
    1377                 :       3429 : REG_DLLPUBLIC sal_Bool TYPEREG_CALLTYPE typereg_writer_setReferenceData(
    1378                 :            :     void * handle, sal_uInt16 index, rtl_uString const * documentation,
    1379                 :            :     RTReferenceType sort, RTFieldAccess flags, rtl_uString const * typeName)
    1380                 :            :     SAL_THROW_EXTERN_C()
    1381                 :            : {
    1382                 :            :     try {
    1383                 :            :         static_cast< TypeWriter * >(handle)->m_references[index].setData(
    1384 [ +  - ][ +  - ]:       3429 :             toByteString(typeName), sort, toByteString(documentation), flags);
                 [ #  # ]
    1385                 :          0 :     } catch (std::bad_alloc &) {
    1386                 :          0 :         return false;
    1387                 :            :     }
    1388                 :       3429 :     return true;
    1389                 :            : }
    1390                 :            : 
    1391                 :          0 : static void TYPEREG_CALLTYPE setReferenceData(TypeWriterImpl    hEntry,
    1392                 :            :                                               sal_uInt16        index,
    1393                 :            :                                               rtl_uString*      name,
    1394                 :            :                                               RTReferenceType   refType,
    1395                 :            :                                               rtl_uString*      doku,
    1396                 :            :                                               RTFieldAccess     access)
    1397                 :            : {
    1398                 :          0 :     typereg_writer_setReferenceData(hEntry, index, doku, refType, access, name);
    1399                 :          0 : }
    1400                 :            : 
    1401                 :      36268 : REG_DLLPUBLIC void * TYPEREG_CALLTYPE typereg_writer_create(
    1402                 :            :     typereg_Version version, rtl_uString const * documentation,
    1403                 :            :     rtl_uString const * fileName, RTTypeClass typeClass, sal_Bool published,
    1404                 :            :     rtl_uString const * typeName, sal_uInt16 superTypeCount,
    1405                 :            :     sal_uInt16 fieldCount, sal_uInt16 methodCount, sal_uInt16 referenceCount)
    1406                 :            :     SAL_THROW_EXTERN_C()
    1407                 :            : {
    1408                 :            :     try {
    1409                 :            :         return new TypeWriter(
    1410                 :            :             version, toByteString(documentation), toByteString(fileName),
    1411                 :            :             typeClass, published, toByteString(typeName), superTypeCount,
    1412 [ +  - ][ +  - ]:      36268 :             fieldCount, methodCount, referenceCount);
         [ +  - ][ +  - ]
         [ +  - ][ #  # ]
    1413                 :          0 :     } catch (std::bad_alloc &) {
    1414                 :          0 :         return 0;
    1415                 :            :     }
    1416                 :            : }
    1417                 :            : 
    1418                 :      36268 : REG_DLLPUBLIC void TYPEREG_CALLTYPE typereg_writer_destroy(void * handle) SAL_THROW_EXTERN_C() {
    1419         [ +  - ]:      36268 :     delete static_cast< TypeWriter * >(handle);
    1420                 :      36268 : }
    1421                 :            : 
    1422                 :       3368 : REG_DLLPUBLIC sal_Bool TYPEREG_CALLTYPE typereg_writer_setSuperTypeName(
    1423                 :            :     void * handle, sal_uInt16 index, rtl_uString const * typeName)
    1424                 :            :     SAL_THROW_EXTERN_C()
    1425                 :            : {
    1426                 :            :     try {
    1427                 :            :         static_cast< TypeWriter * >(handle)->setSuperType(
    1428         [ +  - ]:       3368 :             index, toByteString(typeName));
    1429                 :          0 :     } catch (std::bad_alloc &) {
    1430                 :          0 :         return false;
    1431                 :            :     }
    1432         [ #  # ]:       3368 :     return true;
    1433                 :            : }
    1434                 :            : 
    1435                 :          0 : static TypeWriterImpl TYPEREG_CALLTYPE createEntry(
    1436                 :            :     RTTypeClass typeClass, rtl_uString * typeName, rtl_uString * superTypeName,
    1437                 :            :     sal_uInt16 fieldCount, sal_uInt16 methodCount, sal_uInt16 referenceCount)
    1438                 :            : {
    1439                 :          0 :     rtl::OUString empty;
    1440                 :          0 :     sal_uInt16 superTypeCount = rtl_uString_getLength(superTypeName) == 0
    1441                 :          0 :         ? 0 : 1;
    1442                 :            :     TypeWriterImpl t = typereg_writer_create(
    1443                 :            :         TYPEREG_VERSION_0, empty.pData, empty.pData, typeClass, false, typeName,
    1444                 :          0 :         superTypeCount, fieldCount, methodCount, referenceCount);
    1445         [ #  # ]:          0 :     if (superTypeCount > 0) {
    1446                 :          0 :         typereg_writer_setSuperTypeName(t, 0, superTypeName);
    1447                 :            :     }
    1448                 :          0 :     return t;
    1449                 :            : }
    1450                 :            : 
    1451                 :          0 : REG_DLLPUBLIC RegistryTypeWriter_Api* TYPEREG_CALLTYPE initRegistryTypeWriter_Api(void)
    1452                 :            : {
    1453                 :            :     static RegistryTypeWriter_Api aApi= {0,0,0,0,0,0,0,0,0,0,0,0,0};
    1454         [ #  # ]:          0 :     if (!aApi.acquire)
    1455                 :            :     {
    1456                 :          0 :         aApi.createEntry        = &createEntry;
    1457                 :          0 :         aApi.acquire            = &acquire;
    1458                 :          0 :         aApi.release            = &release;
    1459                 :          0 :         aApi.setUik             = &setUik;
    1460                 :          0 :         aApi.setDoku            = &setDoku;
    1461                 :          0 :         aApi.setFileName        = &setFileName;
    1462                 :          0 :         aApi.setFieldData       = &setFieldData;
    1463                 :          0 :         aApi.setMethodData      = &setMethodData;
    1464                 :          0 :         aApi.setParamData       = &setParamData;
    1465                 :          0 :         aApi.setExcData         = &setExcData;
    1466                 :          0 :         aApi.getBlop            = &getBlop;
    1467                 :          0 :         aApi.getBlopSize        = &getBlopSize;
    1468                 :          0 :         aApi.setReferenceData   = &setReferenceData;
    1469                 :            : 
    1470                 :          0 :         return (&aApi);
    1471                 :            :     }
    1472                 :            :     else
    1473                 :            :     {
    1474                 :          0 :         return (&aApi);
    1475                 :            :     }
    1476                 :            : }
    1477                 :            : 
    1478                 :            : }
    1479                 :            : 
    1480                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10