LCOV - code coverage report
Current view: top level - dbaccess/source/filter/xml - xmlHelper.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 26 26 100.0 %
Date: 2015-06-13 12:38:46 Functions: 8 8 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include "xmlHelper.hxx"
      21             : #include <xmloff/XMLConstantsPropertyHandler.hxx>
      22             : #include <xmloff/contextid.hxx>
      23             : #include <xmloff/xmlement.hxx>
      24             : #include <xmloff/xmlnmspe.hxx>
      25             : #include <xmloff/xmltoken.hxx>
      26             : #include <xmloff/xmltypes.hxx>
      27             : #include <xmloff/maptype.hxx>
      28             : 
      29             : #include <com/sun/star/awt/TextAlign.hpp>
      30             : #include "xmlstrings.hrc"
      31             : #include "xmlEnums.hxx"
      32             : #include <tools/debug.hxx>
      33             : 
      34             : namespace dbaxml
      35             : {
      36             :     using namespace ::xmloff::token;
      37             :     using namespace ::com::sun::star::awt;
      38             : 
      39         398 : OPropertyHandlerFactory::OPropertyHandlerFactory()
      40             : {
      41         398 : }
      42             : 
      43         796 : OPropertyHandlerFactory::~OPropertyHandlerFactory()
      44             : {
      45             : 
      46         796 : }
      47             : 
      48         804 : const XMLPropertyHandler* OPropertyHandlerFactory::GetPropertyHandler(sal_Int32 _nType) const
      49             : {
      50         804 :     const XMLPropertyHandler* pHandler = NULL;
      51             : 
      52         804 :     switch (_nType)
      53             :     {
      54             :         case XML_DB_TYPE_EQUAL:
      55         203 :             if ( !m_pDisplayHandler.get() )
      56             :             {
      57             :                 static const SvXMLEnumMapEntry aDisplayMap[] =
      58             :                 {
      59             :                     { XML_VISIBLE,      sal_uInt16(true) },
      60             :                     { XML_COLLAPSE,     sal_uInt16(false) },
      61             :                     { XML_TOKEN_INVALID, 0 }
      62             :                 };
      63         203 :                 m_pDisplayHandler.reset(new XMLConstantsPropertyHandler(aDisplayMap, XML_TOKEN_INVALID ));
      64             :             }
      65         203 :             pHandler = m_pDisplayHandler.get();
      66         203 :             break;
      67             :     }
      68         804 :     if ( !pHandler )
      69         601 :         pHandler = OControlPropertyHandlerFactory::GetPropertyHandler(_nType);
      70         804 :     return pHandler;
      71             : }
      72             : 
      73             : #define MAP_END() { NULL, 0, 0, XML_TOKEN_INVALID, 0 , 0, SvtSaveOptions::ODFVER_010, false}
      74         195 : rtl::Reference < XMLPropertySetMapper > OXMLHelper::GetTableStylesPropertySetMapper( bool bForExport )
      75             : {
      76             :     static const XMLPropertyMapEntry s_aTableStylesProperties[] =
      77             :     {
      78             :         MAP_END()
      79             :     };
      80         195 :     rtl::Reference < XMLPropertyHandlerFactory> xFac = new ::xmloff::OControlPropertyHandlerFactory();
      81         195 :     return new XMLPropertySetMapper(s_aTableStylesProperties, xFac, bForExport);
      82             : }
      83             : 
      84         203 : rtl::Reference < XMLPropertySetMapper > OXMLHelper::GetColumnStylesPropertySetMapper( bool bForExport )
      85             : {
      86             : #define MAP_CONST_COLUMN( name, prefix, token, type, context )  { name, sizeof(name)-1,  prefix, token, type|XML_TYPE_PROP_TABLE_COLUMN, context, SvtSaveOptions::ODFVER_010, false }
      87             :     static const XMLPropertyMapEntry s_aColumnStylesProperties[] =
      88             :     {
      89             :         MAP_CONST_COLUMN( PROPERTY_WIDTH,           XML_NAMESPACE_STYLE,    XML_COLUMN_WIDTH,       XML_TYPE_MEASURE, 0),
      90             :         MAP_CONST_COLUMN( PROPERTY_HIDDEN,          XML_NAMESPACE_TABLE,    XML_DISPLAY,            XML_DB_TYPE_EQUAL|MID_FLAG_SPECIAL_ITEM, CTF_DB_ISVISIBLE ),
      91             :         MAP_CONST_COLUMN( PROPERTY_NUMBERFORMAT,    XML_NAMESPACE_STYLE,    XML_DATA_STYLE_NAME,    XML_TYPE_NUMBER|MID_FLAG_SPECIAL_ITEM, CTF_DB_NUMBERFORMAT),
      92             :         MAP_END()
      93             :     };
      94         203 :     rtl::Reference < XMLPropertyHandlerFactory> xFac = new OPropertyHandlerFactory();
      95         203 :     return new XMLPropertySetMapper(s_aColumnStylesProperties, xFac, bForExport);
      96             : }
      97             : 
      98         203 : rtl::Reference < XMLPropertySetMapper > OXMLHelper::GetCellStylesPropertySetMapper( bool bForExport )
      99             : {
     100             : #define MAP_CONST_CELL( name, prefix, token, type, context ) { name, sizeof(name)-1,  prefix, token, type|XML_TYPE_PROP_PARAGRAPH, context, SvtSaveOptions::ODFVER_010, false }
     101             : #define MAP_CONST_TEXT( name, prefix, token, type, context ) { name, sizeof(name)-1,  prefix, token, type|XML_TYPE_PROP_TEXT, context, SvtSaveOptions::ODFVER_010, false }
     102             :     static const XMLPropertyMapEntry s_aCellStylesProperties[] =
     103             :     {
     104             :         MAP_CONST_CELL( PROPERTY_ALIGN,             XML_NAMESPACE_FO,       XML_TEXT_ALIGN,             XML_TYPE_TEXT_ALIGN, CTF_DB_COLUMN_TEXT_ALIGN),
     105             :         MAP_CONST_TEXT( PROPERTY_FONTNAME,          XML_NAMESPACE_STYLE,    XML_FONT_NAME,              XML_TYPE_STRING, 0 ),
     106             :         MAP_CONST_TEXT( PROPERTY_TEXTCOLOR,         XML_NAMESPACE_FO,       XML_COLOR,                  XML_TYPE_COLOR, 0 ),
     107             :         MAP_CONST_TEXT( PROPERTY_TEXTLINECOLOR,     XML_NAMESPACE_STYLE,    XML_TEXT_UNDERLINE_COLOR,   XML_TYPE_TEXT_UNDERLINE_COLOR|MID_FLAG_MULTI_PROPERTY, 0 ),
     108             : 
     109             :         MAP_CONST_TEXT( PROPERTY_TEXTRELIEF,        XML_NAMESPACE_STYLE,    XML_FONT_RELIEF,                XML_TYPE_TEXT_FONT_RELIEF|MID_FLAG_MULTI_PROPERTY, 0 ),
     110             :         MAP_CONST_TEXT( PROPERTY_TEXTEMPHASIS,      XML_NAMESPACE_STYLE,    XML_TEXT_EMPHASIZE,             XML_TYPE_CONTROL_TEXT_EMPHASIZE, 0 ),
     111             :         MAP_CONST_TEXT( PROPERTY_FONTCHARWIDTH,     XML_NAMESPACE_STYLE,    XML_FONT_CHAR_WIDTH,            XML_TYPE_NUMBER16, 0 ),
     112             :         MAP_CONST_TEXT( PROPERTY_FONTCHARSET,       XML_NAMESPACE_STYLE,    XML_FONT_CHARSET,               XML_TYPE_TEXT_FONTENCODING, 0 ),
     113             :         MAP_CONST_TEXT( PROPERTY_FONTFAMILY,        XML_NAMESPACE_STYLE,    XML_FONT_FAMILY_GENERIC,        XML_TYPE_TEXT_FONTFAMILY, 0 ),
     114             :         MAP_CONST_TEXT( PROPERTY_FONTHEIGHT,        XML_NAMESPACE_FO,       XML_FONT_SIZE,                  XML_TYPE_MEASURE16, 0 ),
     115             :         MAP_CONST_TEXT( PROPERTY_FONTKERNING,       XML_NAMESPACE_STYLE,    XML_LETTER_KERNING,             XML_TYPE_BOOL, 0 ),
     116             : 
     117             :         MAP_CONST_TEXT( PROPERTY_FONTORIENTATION,   XML_NAMESPACE_STYLE,    XML_ROTATION_ANGLE,             XML_TYPE_ROTATION_ANGLE, 0 ),
     118             :         MAP_CONST_TEXT( PROPERTY_FONTPITCH,         XML_NAMESPACE_STYLE,    XML_FONT_PITCH,                 XML_TYPE_TEXT_FONTPITCH, 0 ),
     119             :         MAP_CONST_TEXT( PROPERTY_FONTSLANT,         XML_NAMESPACE_FO,       XML_FONT_STYLE,                 XML_TYPE_TEXT_POSTURE, 0 ),
     120             :         MAP_CONST_TEXT( "CharStrikeout",            XML_NAMESPACE_STYLE,    XML_TEXT_LINE_THROUGH_STYLE,    XML_TYPE_TEXT_CROSSEDOUT_STYLE|MID_FLAG_MERGE_PROPERTY, 0),
     121             :         MAP_CONST_TEXT( "CharStrikeout",            XML_NAMESPACE_STYLE,    XML_TEXT_LINE_THROUGH_TYPE,     XML_TYPE_TEXT_CROSSEDOUT_TYPE|MID_FLAG_MERGE_PROPERTY,  0),
     122             :         MAP_CONST_TEXT( "CharStrikeout",            XML_NAMESPACE_STYLE,    XML_TEXT_LINE_THROUGH_WIDTH,    XML_TYPE_TEXT_CROSSEDOUT_WIDTH|MID_FLAG_MERGE_PROPERTY, 0),
     123             :         MAP_CONST_TEXT( "CharStrikeout",            XML_NAMESPACE_STYLE,    XML_TEXT_LINE_THROUGH_TEXT,     XML_TYPE_TEXT_CROSSEDOUT_TEXT|MID_FLAG_MERGE_PROPERTY,  0),
     124             :         MAP_CONST_TEXT( PROPERTY_FONTSTYLENAME,     XML_NAMESPACE_STYLE,    XML_FONT_STYLE_NAME,            XML_TYPE_STRING, 0 ),
     125             :         MAP_CONST_TEXT( "CharUnderline",            XML_NAMESPACE_STYLE,    XML_TEXT_UNDERLINE_STYLE,       XML_TYPE_TEXT_UNDERLINE_STYLE|MID_FLAG_MERGE_PROPERTY, 0 ),
     126             :         MAP_CONST_TEXT( "CharUnderline",            XML_NAMESPACE_STYLE,    XML_TEXT_UNDERLINE_TYPE,        XML_TYPE_TEXT_UNDERLINE_TYPE|MID_FLAG_MERGE_PROPERTY, 0 ),
     127             :         MAP_CONST_TEXT( "CharUnderline",            XML_NAMESPACE_STYLE,    XML_TEXT_UNDERLINE_WIDTH,       XML_TYPE_TEXT_UNDERLINE_WIDTH|MID_FLAG_MERGE_PROPERTY, 0 ),
     128             :         MAP_CONST_TEXT( "CharUnderlineColor",       XML_NAMESPACE_STYLE,    XML_TEXT_UNDERLINE_COLOR,       XML_TYPE_TEXT_UNDERLINE_COLOR|MID_FLAG_MULTI_PROPERTY, 0    ),
     129             :         MAP_CONST_TEXT( "CharUnderlineHasColor",    XML_NAMESPACE_STYLE,  XML_TEXT_UNDERLINE_COLOR,       XML_TYPE_TEXT_UNDERLINE_HASCOLOR|MID_FLAG_MERGE_ATTRIBUTE, 0    ),
     130             :         MAP_CONST_TEXT( PROPERTY_FONTWEIGHT,        XML_NAMESPACE_FO,       XML_FONT_WEIGHT,                XML_TYPE_TEXT_WEIGHT, 0 ),
     131             :         MAP_CONST_TEXT( PROPERTY_FONTWIDTH,         XML_NAMESPACE_STYLE,    XML_FONT_WIDTH,                 XML_TYPE_FONT_WIDTH, 0 ),
     132             :         MAP_CONST_TEXT( PROPERTY_FONTWORDLINEMODE,  XML_NAMESPACE_STYLE,    XML_TEXT_UNDERLINE_MODE,        XML_TYPE_TEXT_LINE_MODE|MID_FLAG_MERGE_PROPERTY, 0 ),
     133             :         MAP_END()
     134             :     };
     135         203 :     rtl::Reference < XMLPropertyHandlerFactory> xFac = new /*OPropertyHandlerFactory*/::xmloff::OControlPropertyHandlerFactory();
     136         203 :     return new XMLPropertySetMapper(s_aCellStylesProperties, xFac, bForExport);
     137             : }
     138             : 
     139         195 : rtl::Reference < XMLPropertySetMapper > OXMLHelper::GetRowStylesPropertySetMapper( bool bForExport )
     140             : {
     141             : #define MAP_CONST_ROW( name, prefix, token, type, context )  { name, sizeof(name)-1, prefix, token, type|XML_TYPE_PROP_TABLE_ROW, context, SvtSaveOptions::ODFVER_010, false }
     142             :     static const XMLPropertyMapEntry s_aStylesProperties[] =
     143             :     {
     144             :         MAP_CONST_ROW( PROPERTY_ROW_HEIGHT,         XML_NAMESPACE_STYLE,    XML_ROW_HEIGHT,             XML_TYPE_MEASURE, 0),
     145             :         MAP_END()
     146             :     };
     147         195 :     rtl::Reference < XMLPropertyHandlerFactory> xFac = new OPropertyHandlerFactory();
     148         195 :     return new XMLPropertySetMapper(s_aStylesProperties, xFac, bForExport);
     149             : }
     150             : 
     151             : }
     152             : 
     153             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11