LCOV - code coverage report
Current view: top level - sw/source/core/uibase/config - barcfg.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 52 0.0 %
Date: 2014-04-14 Functions: 0 8 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include <osl/diagnose.h>
      21             : #include <com/sun/star/uno/Any.hxx>
      22             : #include <com/sun/star/uno/Sequence.hxx>
      23             : #include <wrtsh.hxx>
      24             : #include "barcfg.hxx"
      25             : 
      26             : #include <unomid.h>
      27             : 
      28             : using namespace utl;
      29             : using namespace com::sun::star::uno;
      30             : 
      31             : #define SEL_TYPE_TABLE_TEXT     0
      32             : #define SEL_TYPE_LIST_TEXT      1
      33             : #define SEL_TYPE_TABLE_LIST     2
      34             : #define SEL_TYPE_BEZIER         3
      35             : #define SEL_TYPE_GRAPHIC        4
      36             : 
      37           0 : SwToolbarConfigItem::SwToolbarConfigItem( bool bWeb ) :
      38             :     ConfigItem(bWeb ? OUString("Office.WriterWeb/ObjectBar") : OUString("Office.Writer/ObjectBar"),
      39           0 :         CONFIG_MODE_DELAYED_UPDATE|CONFIG_MODE_RELEASE_TREE)
      40             : {
      41           0 :     for(sal_uInt16 i = 0; i <= SEL_TYPE_GRAPHIC; i++ )
      42           0 :         aTbxIdArray[i] = -1;
      43             : 
      44           0 :     Sequence<OUString> aNames = GetPropertyNames();
      45           0 :     Sequence<Any> aValues = GetProperties(aNames);
      46           0 :     const Any* pValues = aValues.getConstArray();
      47             :     OSL_ENSURE(aValues.getLength() == aNames.getLength(), "GetProperties failed");
      48           0 :     if(aValues.getLength() == aNames.getLength())
      49             :     {
      50           0 :         for(int nProp = 0; nProp < aNames.getLength(); nProp++)
      51             :         {
      52           0 :             if(pValues[nProp].hasValue())
      53             :             {
      54           0 :                 sal_Int32 nVal = 0;
      55           0 :                 pValues[nProp] >>= nVal;
      56           0 :                 aTbxIdArray[nProp] = nVal;
      57             :             }
      58             :         }
      59           0 :     }
      60           0 : }
      61             : 
      62           0 : SwToolbarConfigItem::~SwToolbarConfigItem()
      63             : {
      64           0 : }
      65             : 
      66           0 : static sal_Int32 lcl_getArrayIndex(int nSelType)
      67             : {
      68           0 :     sal_Int32 nRet = -1;
      69           0 :     if(nSelType & nsSelectionType::SEL_NUM)
      70             :     {
      71           0 :         if(nSelType & nsSelectionType::SEL_TBL)
      72           0 :             nRet = SEL_TYPE_TABLE_LIST;
      73             :         else
      74           0 :             nRet = SEL_TYPE_LIST_TEXT;
      75             :     }
      76           0 :     else if(nSelType & nsSelectionType::SEL_TBL)
      77           0 :         nRet = SEL_TYPE_TABLE_TEXT;
      78           0 :     else if(nSelType & nsSelectionType::SEL_BEZ)
      79           0 :         nRet = SEL_TYPE_BEZIER;
      80           0 :     else if(nSelType & nsSelectionType::SEL_GRF)
      81           0 :         nRet = SEL_TYPE_GRAPHIC;
      82           0 :     return nRet;
      83             : }
      84             : 
      85           0 : void SwToolbarConfigItem::SetTopToolbar( sal_Int32 nSelType, sal_Int32 nBarId )
      86             : {
      87           0 :     sal_Int32 nProp = lcl_getArrayIndex(nSelType);
      88           0 :     if(nProp >= 0)
      89             :     {
      90           0 :         aTbxIdArray[nProp] = nBarId;
      91           0 :         SetModified();
      92             :     }
      93           0 : }
      94             : 
      95           0 : Sequence<OUString> SwToolbarConfigItem::GetPropertyNames()
      96             : {
      97             :     static const char* aPropNames[] =
      98             :     {
      99             :         "Selection/Table",                   //  SEL_TYPE_TABLE_TEXT
     100             :         "Selection/NumberedList",            //  SEL_TYPE_LIST_TEXT
     101             :         "Selection/NumberedList_InTable",     //  SEL_TYPE_TABLE_LIST
     102             :         "Selection/BezierObject",           //  SEL_TYPE_BEZIER
     103             :         "Selection/Graphic"                 //SEL_TYPE_GRAPHIC
     104             :     };
     105           0 :     const int nCount = 5;
     106           0 :     Sequence<OUString> aNames(nCount);
     107           0 :     OUString* pNames = aNames.getArray();
     108           0 :     for(int i = 0; i < nCount; i++)
     109           0 :         pNames[i] = OUString::createFromAscii(aPropNames[i]);
     110           0 :     return aNames;
     111             : }
     112             : 
     113           0 : void SwToolbarConfigItem::Commit()
     114             : {
     115           0 :     Sequence<OUString> aNames = GetPropertyNames();
     116             : 
     117           0 :     Sequence<Any> aValues(aNames.getLength());
     118           0 :     Any* pValues = aValues.getArray();
     119             : 
     120           0 :     for(int nProp = 0; nProp < aNames.getLength(); nProp++)
     121           0 :         pValues[nProp] <<= aTbxIdArray[nProp];
     122           0 :     PutProperties(aNames, aValues);
     123           0 : }
     124             : 
     125           0 : void SwToolbarConfigItem::Notify( const ::com::sun::star::uno::Sequence< OUString >& ) {}
     126             : 
     127             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10