LCOV - code coverage report
Current view: top level - cui/source/options - optaboutconfig.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 324 0.0 %
Date: 2014-04-14 Functions: 0 21 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             : 
      10             : #include "optaboutconfig.hxx"
      11             : #include "optHeaderTabListbox.hxx"
      12             : 
      13             : #include <svtools/svlbitm.hxx>
      14             : #include <svtools/treelistentry.hxx>
      15             : #include <comphelper/processfactory.hxx>
      16             : #include <comphelper/sequence.hxx>
      17             : #include <com/sun/star/configuration/theDefaultProvider.hpp>
      18             : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
      19             : #include <com/sun/star/beans/NamedValue.hpp>
      20             : #include <com/sun/star/beans/Property.hpp>
      21             : #include <com/sun/star/beans/XProperty.hpp>
      22             : #include <com/sun/star/container/XNameAccess.hpp>
      23             : #include <com/sun/star/container/XNameReplace.hpp>
      24             : #include <com/sun/star/container/XHierarchicalName.hpp>
      25             : #include <com/sun/star/container/XHierarchicalNameAccess.hpp>
      26             : #include <com/sun/star/util/XChangesBatch.hpp>
      27             : 
      28             : #include <vector>
      29             : #include <boost/shared_ptr.hpp>
      30             : #include <iostream>
      31             : 
      32             : using namespace svx;
      33             : using namespace ::com::sun::star;
      34             : using namespace com::sun::star::uno;
      35             : using namespace com::sun::star::container;
      36             : 
      37             : #define SHORT_LEN_LIMIT     7
      38             : #define LONG_LEN_LIMIT      11
      39             : #define HYPER_LEN_LIMIT     20
      40             : 
      41             : #define ITEMID_PREFNAME     1
      42             : #define ITEMID_PROPERTY     2
      43             : #define ITEMID_TYPE         3
      44             : #define ITEMID_VALUE        4
      45             : 
      46           0 : struct Prop_Impl
      47             : {
      48             :     OUString    Name;
      49             :     OUString    Property;
      50             :     Any         Value;
      51             : 
      52           0 :     Prop_Impl( const OUString& sName, const OUString& sProperty, const Any& aValue )
      53             :         : Name( sName )
      54             :         , Property( sProperty )
      55           0 :         , Value( aValue )
      56           0 :     {}
      57             : };
      58             : 
      59           0 : extern "C" SAL_DLLPUBLIC_EXPORT Window* SAL_CALL makeCuiCustomMultilineEdit(Window *pParent, VclBuilder::stringmap &)
      60             : {
      61           0 :     return new CuiCustomMultilineEdit(pParent, WB_LEFT|WB_VCENTER|WB_BORDER|WB_3DLOOK);
      62             : }
      63             : 
      64             : 
      65           0 : void CuiCustomMultilineEdit::KeyInput( const KeyEvent& rKeyEvent )
      66             : {
      67           0 :     bool bValid = false;
      68           0 :     bool bNonSpace = rKeyEvent.GetKeyCode().GetCode() != KEY_SPACE;
      69           0 :     if( bNumericOnly && bNonSpace )
      70             :     {
      71           0 :         const KeyCode& rKeyCode = rKeyEvent.GetKeyCode();
      72           0 :         sal_uInt16 nGroup = rKeyCode.GetGroup();
      73           0 :         sal_uInt16 nKey = rKeyCode.GetCode();
      74             : 
      75           0 :         switch ( nGroup ) {
      76             :             case KEYGROUP_NUM :
      77             :             case KEYGROUP_CURSOR :
      78             :             {
      79           0 :                 bValid = true;
      80           0 :                 break;
      81             :             }
      82             : 
      83             :             case KEYGROUP_MISC :
      84             :             {
      85           0 :                 switch ( nKey ) {
      86             :                     case KEY_SUBTRACT :
      87             :                     case KEY_COMMA :
      88             :                     case KEY_POINT :
      89             :                     {
      90           0 :                         bValid = true;
      91           0 :                         break;
      92             :                     }
      93             : 
      94             :                     default :
      95             :                     {
      96           0 :                         if( nKey < KEY_ADD || nKey > KEY_EQUAL )
      97           0 :                             bValid = true;
      98           0 :                         break;
      99             :                     }
     100             :                 }
     101           0 :                 break;
     102             :             }
     103             : 
     104             :             default :
     105             :             {
     106           0 :                 bValid = false;
     107           0 :                 break;
     108             :             }
     109             :         }
     110             : 
     111             :         //Select all, Copy, Paste, Cut, Undo Keys
     112           0 :         if ( !bValid && ( rKeyCode.IsMod1() && (
     113           0 :              KEY_A == nKey || KEY_C == nKey || KEY_V == nKey || KEY_X == nKey || KEY_Z == nKey ) ) )
     114           0 :             bValid = true;
     115             :     }
     116             :     else
     117           0 :         bValid = true;
     118           0 :     if( bValid )
     119           0 :         Edit::KeyInput( rKeyEvent );
     120           0 : }
     121             : 
     122           0 : Size CuiCustomMultilineEdit::GetOptimalSize() const
     123             : {
     124           0 :     return LogicToPixel(Size(150, GetTextHeight()), MAP_APPFONT);
     125             : }
     126             : 
     127           0 : Size CuiAboutConfigTabPage::GetOptimalSize() const
     128             : {
     129           0 :     return LogicToPixel(Size(1024,800),MAP_APPFONT);
     130             : }
     131             : 
     132           0 : CuiAboutConfigTabPage::CuiAboutConfigTabPage( Window* pParent/*, const SfxItemSet& rItemSet*/ ) :
     133             :     ModalDialog( pParent, "AboutConfig", "cui/ui/aboutconfigdialog.ui"),
     134           0 :     m_pPrefCtrl( get<SvSimpleTableContainer>("preferences") ),
     135           0 :     m_pResetBtn( get<PushButton>("reset") ),
     136           0 :     m_pEditBtn( get<PushButton>("edit") ),
     137             :     m_vectorOfModified(),
     138             :     m_pPrefBox( new OptHeaderTabListBox( *m_pPrefCtrl,
     139           0 :                                          WB_SCROLL | WB_HSCROLL | WB_VSCROLL ) )
     140             : {
     141           0 :     Size aControlSize(200,200);
     142           0 :     m_pPrefCtrl->set_width_request(aControlSize.Width());
     143           0 :     m_pPrefCtrl->set_height_request(aControlSize.Height());
     144             : 
     145           0 :     m_pEditBtn->SetClickHdl( LINK( this, CuiAboutConfigTabPage, StandardHdl_Impl ) );
     146           0 :     m_pResetBtn->SetClickHdl( LINK( this, CuiAboutConfigTabPage, ResetBtnHdl_Impl ) );
     147           0 :     m_pPrefBox->SetDoubleClickHdl( LINK(this, CuiAboutConfigTabPage, StandardHdl_Impl) );
     148             : 
     149           0 :     HeaderBar &rBar = m_pPrefBox->GetTheHeaderBar();
     150           0 :     rBar.InsertItem( ITEMID_PREFNAME, get<FixedText>("preference")->GetText(), 0, HIB_LEFT | HIB_VCENTER );
     151           0 :     rBar.InsertItem( ITEMID_PROPERTY, get<FixedText>("property")->GetText(), 0,  HIB_LEFT | HIB_VCENTER );
     152           0 :     rBar.InsertItem( ITEMID_TYPE, get<FixedText>("type")->GetText(), 0,  HIB_LEFT | HIB_VCENTER );
     153           0 :     rBar.InsertItem( ITEMID_VALUE, get<FixedText>("value")->GetText(), 0,  HIB_LEFT | HIB_VCENTER );
     154             : 
     155           0 :     long aTabs[] = {4,900,50,50,50};//TODO: Not works correctly hardcoded for now.
     156             : 
     157           0 :     aTabs[2] += aTabs[1] + rBar.GetTextWidth(rBar.GetItemText(1));
     158           0 :     aTabs[3] += aTabs[2] + 160; //rBar.GetTextWidth(rBar.GetItemText(2));
     159           0 :     aTabs[4] += aTabs[3] + 40; //rBar.GetTextWidth(rBar.GetItemText(3));
     160             : 
     161           0 :     m_pPrefBox->SetTabs(aTabs, MAP_PIXEL);
     162           0 : }
     163             : 
     164           0 : void CuiAboutConfigTabPage::InsertEntry(const OUString& rProp, const OUString& rStatus, const OUString& rType, const OUString& rValue)
     165             : {
     166           0 :     SvTreeListEntry* pEntry = new SvTreeListEntry;
     167             : 
     168           0 :     pEntry->AddItem( new SvLBoxContextBmp( pEntry, 0, Image(), Image(), false)); //It is needed, otherwise causes crash
     169           0 :     pEntry->AddItem( new SvLBoxString( pEntry, 0, rProp));
     170           0 :     pEntry->AddItem( new SvLBoxString( pEntry, 0, rStatus));
     171           0 :     pEntry->AddItem( new SvLBoxString( pEntry, 0, rType));
     172           0 :     pEntry->AddItem( new SvLBoxString( pEntry, 0, rValue));
     173             : 
     174           0 :     m_pPrefBox->Insert( pEntry );
     175           0 : }
     176             : 
     177           0 : void CuiAboutConfigTabPage::Reset(/* const SfxItemSet&*/ )
     178             : {
     179           0 :     m_pPrefBox->Clear();
     180             : 
     181           0 :     m_vectorOfModified.clear();
     182           0 :     m_pPrefBox->GetModel()->SetSortMode( SortNone );
     183             : 
     184           0 :     m_pPrefBox->SetUpdateMode(false);
     185           0 :     Reference< XNameAccess > xConfigAccess = getConfigAccess( "/", sal_False );
     186           0 :     FillItems( xConfigAccess );
     187           0 :     m_pPrefBox->SetUpdateMode(true);
     188           0 : }
     189             : 
     190           0 : bool CuiAboutConfigTabPage::FillItemSet(/* SfxItemSet&*/ )
     191             : {
     192           0 :     bool bModified = false;
     193             : 
     194           0 :     std::vector< boost::shared_ptr< Prop_Impl > >::iterator pIter;
     195           0 :     for( pIter = m_vectorOfModified.begin() ; pIter != m_vectorOfModified.end(); ++pIter )
     196             :     {
     197           0 :         Reference< XNameAccess > xUpdateAccess = getConfigAccess( (*pIter)->Name , sal_True );
     198           0 :         Reference< XNameReplace > xNameReplace( xUpdateAccess, UNO_QUERY_THROW );
     199             : 
     200           0 :         xNameReplace->replaceByName( (*pIter)->Property, (*pIter)->Value );
     201           0 :         bModified = true;
     202             : 
     203           0 :         Reference< util::XChangesBatch > xChangesBatch( xUpdateAccess, UNO_QUERY_THROW );
     204           0 :         xChangesBatch->commitChanges();
     205           0 :     }
     206             : 
     207           0 :     return bModified;
     208             : }
     209             : 
     210           0 : void CuiAboutConfigTabPage::FillItems(const Reference< XNameAccess >& xNameAccess)
     211             : {
     212             :     OUString sPath = Reference< XHierarchicalName >(
     213           0 :         xNameAccess, uno::UNO_QUERY_THROW )->getHierarchicalName();
     214           0 :     uno::Sequence< OUString > seqItems = xNameAccess->getElementNames();
     215           0 :     for( sal_Int32 i = 0; i < seqItems.getLength(); ++i )
     216             :     {
     217           0 :         Any aNode = xNameAccess->getByName( seqItems[i] );
     218             : 
     219           0 :         Reference< XNameAccess > xNextNameAccess( aNode, uno::UNO_QUERY );
     220           0 :         if( xNextNameAccess.is() )
     221             :         {
     222             :             // not leaf node
     223           0 :             FillItems( xNextNameAccess );
     224             :         }
     225             :         else
     226             :         {
     227             :             // leaf node
     228           0 :             OUString sType = aNode.getValueTypeName();
     229             : 
     230           0 :             OUString sValue;
     231           0 :             switch( aNode.getValueType().getTypeClass() )
     232             :             {
     233             :             case ::com::sun::star::uno::TypeClass_VOID:
     234           0 :                 break;
     235             : 
     236             :             case ::com::sun::star::uno::TypeClass_BOOLEAN:
     237           0 :                 sValue = OUString::boolean( aNode.get<bool>() );
     238           0 :                 break;
     239             : 
     240             :             case ::com::sun::star::uno::TypeClass_SHORT:
     241             :             case ::com::sun::star::uno::TypeClass_LONG:
     242             :             case ::com::sun::star::uno::TypeClass_HYPER:
     243           0 :                 sValue = OUString::number( aNode.get<sal_Int64>() );
     244           0 :                 break;
     245             : 
     246             :             case ::com::sun::star::uno::TypeClass_DOUBLE:
     247           0 :                 sValue = OUString::number( aNode.get<double>() );
     248           0 :                 break;
     249             : 
     250             :             case ::com::sun::star::uno::TypeClass_STRING:
     251           0 :                 sValue = aNode.get<OUString>();
     252           0 :                 break;
     253             : 
     254             :             case ::com::sun::star::uno::TypeClass_SEQUENCE:
     255           0 :                 if( sType == "[]boolean" )
     256             :                 {
     257           0 :                     uno::Sequence<sal_Bool> seq = aNode.get< uno::Sequence<sal_Bool> >();
     258           0 :                     for( sal_Int32 j = 0; j != seq.getLength(); ++j )
     259             :                     {
     260           0 :                         if( j != 0 )
     261             :                         {
     262           0 :                             sValue += ",";
     263             :                         }
     264           0 :                         sValue += OUString::boolean( seq[j] );
     265           0 :                     }
     266             :                 }
     267           0 :                 else if( sType == "[]byte" )
     268             :                 {
     269           0 :                     uno::Sequence<sal_Int8> seq = aNode.get< uno::Sequence<sal_Int8> >();
     270           0 :                     for( sal_Int32 j = 0; j != seq.getLength(); ++j )
     271             :                     {
     272             :                         OUString s = OUString::number(
     273           0 :                             static_cast<sal_uInt8>(seq[j]), 16 );
     274           0 :                         if( s.getLength() == 1 )
     275             :                         {
     276           0 :                             sValue += "0";
     277             :                         }
     278           0 :                         sValue += s.toAsciiUpperCase();
     279           0 :                     }
     280             :                 }
     281           0 :                 else if( sType == "[][]byte" )
     282             :                 {
     283           0 :                     uno::Sequence< uno::Sequence<sal_Int8> > seq = aNode.get< uno::Sequence< uno::Sequence<sal_Int8> > >();
     284           0 :                     for( sal_Int32 j = 0; j != seq.getLength(); ++j )
     285             :                     {
     286           0 :                         if( j != 0 )
     287             :                         {
     288           0 :                             sValue += ",";
     289             :                         }
     290           0 :                         for( sal_Int32 k = 0; k != seq[j].getLength(); ++k )
     291             :                         {
     292             :                             OUString s = OUString::number(
     293           0 :                                 static_cast<sal_uInt8>(seq[j][k]), 16 );
     294           0 :                             if( s.getLength() == 1 )
     295             :                             {
     296           0 :                                 sValue += "0";
     297             :                             }
     298           0 :                             sValue += s.toAsciiUpperCase();
     299           0 :                         }
     300           0 :                     }
     301             :                 }
     302           0 :                 else if( sType == "[]short" )
     303             :                 {
     304           0 :                     uno::Sequence<sal_Int16> seq = aNode.get< uno::Sequence<sal_Int16> >();
     305           0 :                     for( sal_Int32 j = 0; j != seq.getLength(); ++j )
     306             :                     {
     307           0 :                         if( j != 0 )
     308             :                         {
     309           0 :                             sValue += ",";
     310             :                         }
     311           0 :                         sValue += OUString::number( seq[j] );
     312           0 :                     }
     313             :                 }
     314           0 :                 else if( sType == "[]long" )
     315             :                 {
     316           0 :                     uno::Sequence<sal_Int32> seq = aNode.get< uno::Sequence<sal_Int32> >();
     317           0 :                     for( sal_Int32 j = 0; j != seq.getLength(); ++j )
     318             :                     {
     319           0 :                         if( j != 0 )
     320             :                         {
     321           0 :                             sValue += ",";
     322             :                         }
     323           0 :                         sValue += OUString::number( seq[j] );
     324           0 :                     }
     325             :                 }
     326           0 :                 else if( sType == "[]hyper" )
     327             :                 {
     328           0 :                     uno::Sequence<sal_Int64> seq = aNode.get< uno::Sequence<sal_Int64> >();
     329           0 :                     for( sal_Int32 j = 0; j != seq.getLength(); ++j )
     330             :                     {
     331           0 :                         if( j != 0 )
     332             :                         {
     333           0 :                             sValue += ",";
     334             :                         }
     335           0 :                         sValue += OUString::number( seq[j] );
     336           0 :                     }
     337             :                 }
     338           0 :                 else if( sType == "[]double" )
     339             :                 {
     340           0 :                     uno::Sequence<double> seq = aNode.get< uno::Sequence<double> >();
     341           0 :                     for( sal_Int32 j = 0; j != seq.getLength(); ++j )
     342             :                     {
     343           0 :                         if( j != 0 )
     344             :                         {
     345           0 :                             sValue += ",";
     346             :                         }
     347           0 :                         sValue += OUString::number( seq[j] );
     348           0 :                     }
     349             :                 }
     350           0 :                 else if( sType == "[]string" )
     351             :                 {
     352           0 :                     uno::Sequence<OUString> seq = aNode.get< uno::Sequence<OUString> >();
     353           0 :                     for( sal_Int32 j = 0; j != seq.getLength(); ++j )
     354             :                     {
     355           0 :                         if( j != 0 )
     356             :                         {
     357           0 :                             sValue += ",";
     358             :                         }
     359           0 :                         sValue += seq[j];
     360           0 :                     }
     361             :                 }
     362             :                 else
     363             :                 {
     364             :                     SAL_WARN(
     365             :                         "cui.options",
     366             :                         "path \"" << sPath << "\" member " << seqItems[i]
     367             :                             << " of unsupported type " << sType);
     368             :                 }
     369           0 :                 break;
     370             : 
     371             :             default:
     372             :                 SAL_WARN(
     373             :                     "cui.options",
     374             :                     "path \"" << sPath << "\" member " << seqItems[i]
     375             :                         << " of unsupported type " << sType);
     376           0 :                 break;
     377             :             }
     378             : 
     379           0 :             InsertEntry( sPath, seqItems[i], sType, sValue);
     380             :         }
     381           0 :     }
     382           0 : }
     383             : 
     384           0 : Reference< XNameAccess > CuiAboutConfigTabPage::getConfigAccess( const OUString& sNodePath, sal_Bool bUpdate )
     385             : {
     386           0 :     uno::Reference< uno::XComponentContext > xContext( ::comphelper::getProcessComponentContext() );
     387             : 
     388             :     uno::Reference< lang::XMultiServiceFactory > xConfigProvider(
     389           0 :                 com::sun::star::configuration::theDefaultProvider::get( xContext  ) );
     390             : 
     391           0 :     beans::NamedValue aProperty;
     392           0 :     aProperty.Name = "nodepath";
     393           0 :     aProperty.Value = uno::makeAny( sNodePath );
     394             : 
     395           0 :     uno::Sequence< uno::Any > aArgumentList( 1 );
     396           0 :     aArgumentList[0] = uno::makeAny( aProperty );
     397             : 
     398           0 :     OUString sAccessString;
     399             : 
     400           0 :     if( bUpdate )
     401           0 :         sAccessString = "com.sun.star.configuration.ConfigurationUpdateAccess";
     402             :     else
     403           0 :         sAccessString = "com.sun.star.configuration.ConfigurationAccess";
     404             : 
     405             :     uno::Reference< container::XNameAccess > xNameAccess(
     406           0 :                 xConfigProvider->createInstanceWithArguments(
     407           0 :                     sAccessString, aArgumentList ),
     408           0 :                 uno::UNO_QUERY_THROW );
     409             : 
     410           0 :     return xNameAccess;
     411             : }
     412             : 
     413           0 : void CuiAboutConfigTabPage::AddToModifiedVector( const boost::shared_ptr< Prop_Impl >& rProp )
     414             : {
     415           0 :     bool isModifiedBefore = false;
     416             :     //Check if value modified before
     417           0 :     for( size_t nInd = 0; nInd < m_vectorOfModified.size() ; ++nInd )
     418             :     {
     419           0 :         if( rProp->Name == m_vectorOfModified[nInd]->Name && rProp->Property == m_vectorOfModified[nInd]->Property )
     420             :         {
     421             :             //property modified before. assing reference to the modified value
     422             :             //do your changes on this object. They will be saved later.
     423           0 :             m_vectorOfModified[nInd] = rProp;
     424           0 :             isModifiedBefore = true;
     425           0 :             break;
     426             :         }
     427             :     }
     428             : 
     429           0 :     if( !isModifiedBefore )
     430           0 :         m_vectorOfModified.push_back( rProp );
     431             :     //property is not modified before
     432           0 : }
     433             : 
     434           0 : std::vector< OUString > CuiAboutConfigTabPage::commaStringToSequence( const OUString& rCommaSepString )
     435             : {
     436           0 :     std::vector<OUString> tempVector;
     437             : 
     438           0 :     sal_Int32 index = 0;
     439           0 :     do
     440             :     {
     441           0 :         OUString word = rCommaSepString.getToken(0, static_cast<sal_Unicode> (','), index);
     442           0 :         word = word.trim();
     443           0 :         if( !word.isEmpty())
     444           0 :             tempVector.push_back(word);
     445           0 :     }while( index >= 0 );
     446           0 :     return tempVector;
     447             : }
     448             : 
     449           0 : CuiAboutConfigValueDialog::CuiAboutConfigValueDialog( Window* pWindow,
     450             :                                                       const OUString& rValue,
     451             :                                                       int limit ) :
     452             :     ModalDialog( pWindow, "AboutConfigValueDialog", "cui/ui/aboutconfigvaluedialog.ui" ),
     453           0 :     m_pEDValue( get<CuiCustomMultilineEdit>("valuebox") )
     454             : {
     455           0 :     m_pEDValue->bNumericOnly = ( limit !=0 );
     456           0 :     m_pEDValue->SetMaxTextLen( limit == 0 ? EDIT_NOLIMIT : limit);
     457           0 :     m_pEDValue->SetText( rValue );
     458             : 
     459           0 : }
     460             : 
     461           0 : IMPL_LINK_NOARG( CuiAboutConfigTabPage, ResetBtnHdl_Impl )
     462             : {
     463           0 :     Reset();
     464           0 :     return 0;
     465             : }
     466             : 
     467           0 : IMPL_LINK_NOARG( CuiAboutConfigTabPage, StandardHdl_Impl )
     468             : {
     469           0 :     SvTreeListEntry* pEntry = m_pPrefBox->FirstSelected();
     470             : 
     471           0 :     OUString sPropertyPath = m_pPrefBox->GetEntryText( pEntry, 0 );
     472           0 :     OUString sPropertyName = m_pPrefBox->GetEntryText( pEntry, 1 );
     473           0 :     OUString sPropertyType = m_pPrefBox->GetEntryText( pEntry, 2 );
     474           0 :     OUString sPropertyValue = m_pPrefBox->GetEntryText( pEntry, 3 );
     475             : 
     476           0 :     boost::shared_ptr< Prop_Impl > pProperty (new Prop_Impl( sPropertyPath, sPropertyName, makeAny( sPropertyValue ) ) );
     477             : 
     478             :     bool bOpenDialog;
     479           0 :     OUString sDialogValue;
     480           0 :     OUString sNewValue;
     481             : 
     482           0 :     if( sPropertyType == "boolean" )
     483             :     {
     484             :         bool bValue;
     485           0 :         if( sPropertyValue == "true" )
     486             :         {
     487           0 :             sDialogValue = "false";
     488           0 :             bValue = false;
     489             :         }
     490             :         else
     491             :         {
     492           0 :             sDialogValue = "true";
     493           0 :             bValue = true;
     494             :         }
     495             : 
     496           0 :         pProperty->Value = uno::makeAny( bValue );
     497           0 :         bOpenDialog = false;
     498             :     }
     499           0 :     else if ( sPropertyType == "void" )
     500             :     {
     501           0 :         bOpenDialog = false;
     502             :     }
     503             :     else
     504             :     {
     505           0 :         sDialogValue = sPropertyValue;
     506           0 :         bOpenDialog = true;
     507             :     }
     508             : 
     509             :     try
     510             :     {
     511           0 :         if( bOpenDialog )
     512             :         {
     513             :             //Cosmetic length limit for integer values.
     514           0 :             int limit=0;
     515           0 :             if( sPropertyType == "short" )
     516           0 :                 limit = SHORT_LEN_LIMIT;
     517           0 :             else if( sPropertyType == "long" )
     518           0 :                 limit = LONG_LEN_LIMIT;
     519           0 :             else if( sPropertyType == "hyper" )
     520           0 :                 limit = HYPER_LEN_LIMIT;
     521             : 
     522           0 :             CuiAboutConfigValueDialog* pValueDialog = new CuiAboutConfigValueDialog(0, sDialogValue, limit);
     523             : 
     524           0 :             if( pValueDialog->Execute() == RET_OK )
     525             :             {
     526           0 :                 sNewValue = pValueDialog->getValue();
     527           0 :                 if ( sPropertyType == "short")
     528             :                 {
     529             :                     sal_Int16 nShort;
     530           0 :                     sal_Int32 nNumb = sNewValue.toInt32();
     531             : 
     532             :                     //if the value is 0 and length is not 1, there is something wrong
     533           0 :                     if( !( nNumb==0 && sNewValue.getLength()!=1 ) && nNumb < SAL_MAX_INT16 && nNumb > SAL_MIN_INT16)
     534           0 :                         nShort = (sal_Int16) nNumb;
     535             :                     else
     536           0 :                         throw uno::Exception();
     537           0 :                     pProperty->Value = uno::makeAny( nShort );
     538             :                 }
     539             :                 else
     540           0 :                     if( sPropertyType == "long" )
     541             :                     {
     542           0 :                         sal_Int32 nLong = sNewValue.toInt32();
     543           0 :                         if( !( nLong==0 && sNewValue.getLength()!=1 ) && nLong < SAL_MAX_INT32 && nLong > SAL_MIN_INT32)
     544           0 :                             pProperty->Value = uno::makeAny( nLong );
     545             :                         else
     546           0 :                             throw uno::Exception();
     547             :                     }
     548           0 :                     else if( sPropertyType == "hyper")
     549             :                     {
     550           0 :                         sal_Int64 nHyper = sNewValue.toInt64();
     551           0 :                         if( !( nHyper==0 && sNewValue.getLength()!=1 ) && nHyper < SAL_MAX_INT32 && nHyper > SAL_MIN_INT32)
     552           0 :                             pProperty->Value = uno::makeAny( nHyper );
     553             :                         else
     554           0 :                             throw uno::Exception();
     555             :                     }
     556           0 :                     else if( sPropertyType == "double")
     557             :                     {
     558           0 :                         double nDoub = sNewValue.toDouble();
     559           0 :                         if( !( nDoub ==0 && sNewValue.getLength()!=1 ) && nDoub < SAL_MAX_INT32 && nDoub > SAL_MIN_INT32)
     560           0 :                             pProperty->Value = uno::makeAny( nDoub );
     561             :                         else
     562           0 :                             throw uno::Exception();
     563             :                     }
     564           0 :                     else if( sPropertyType == "float")
     565             :                     {
     566           0 :                         float nFloat = sNewValue.toFloat();
     567           0 :                         if( !( nFloat ==0 && sNewValue.getLength()!=1 ) && nFloat < SAL_MAX_INT32 && nFloat > SAL_MIN_INT32)
     568           0 :                             pProperty->Value = uno::makeAny( nFloat );
     569             :                         else
     570           0 :                             throw uno::Exception();
     571             :                     }
     572           0 :                     else if( sPropertyType == "string" )
     573             :                     {
     574           0 :                         pProperty->Value = uno::makeAny( sNewValue );
     575             :                     }
     576           0 :                     else if( sPropertyType == "[]short" )
     577             :                     {
     578             :                         //create string sequence from comma seperated string
     579             :                         //uno::Sequence< OUString > seqStr;
     580           0 :                         std::vector< OUString > seqStr;
     581           0 :                         seqStr = commaStringToSequence( sNewValue );
     582             : 
     583             :                         //create appropriate sequence with same size as string sequence
     584           0 :                         uno::Sequence< sal_Int16 > seqShort( seqStr.size() );
     585             :                         //convert all strings to appropriate type
     586           0 :                         for( size_t i = 0; i < seqStr.size(); ++i )
     587             :                         {
     588           0 :                             seqShort[i] = (sal_Int16) seqStr[i].toInt32();
     589             :                         }
     590           0 :                         pProperty->Value = uno::makeAny( seqShort );
     591             :                     }
     592           0 :                     else if( sPropertyType == "[]long" )
     593             :                     {
     594           0 :                         std::vector< OUString > seqStrLong;
     595           0 :                         seqStrLong = commaStringToSequence( sNewValue );
     596             : 
     597           0 :                         uno::Sequence< sal_Int32 > seqLong( seqStrLong.size() );
     598           0 :                         for( size_t i = 0; i < seqStrLong.size(); ++i )
     599             :                         {
     600           0 :                             seqLong[i] = seqStrLong[i].toInt32();
     601             :                         }
     602           0 :                         pProperty->Value = uno::makeAny( seqLong );
     603             :                     }
     604           0 :                     else if( sPropertyType == "[]hyper" )
     605             :                     {
     606           0 :                         std::vector< OUString > seqStrHyper;
     607           0 :                         seqStrHyper = commaStringToSequence( sNewValue );
     608           0 :                         uno::Sequence< sal_Int64 > seqHyper( seqStrHyper.size() );
     609           0 :                         for( size_t i = 0; i < seqStrHyper.size(); ++i )
     610             :                         {
     611           0 :                             seqHyper[i] = seqStrHyper[i].toInt64();
     612             :                         }
     613           0 :                         pProperty->Value = uno::makeAny( seqHyper );
     614             :                     }
     615           0 :                     else if( sPropertyType == "[]double" )
     616             :                     {
     617           0 :                         std::vector< OUString > seqStrDoub;
     618           0 :                         seqStrDoub = commaStringToSequence( sNewValue );
     619           0 :                         uno::Sequence< double > seqDoub( seqStrDoub.size() );
     620           0 :                         for( size_t i = 0; i < seqStrDoub.size(); ++i )
     621             :                         {
     622           0 :                             seqDoub[i] = seqStrDoub[i].toDouble();
     623             :                         }
     624           0 :                         pProperty->Value = uno::makeAny( seqDoub );
     625             :                     }
     626           0 :                     else if( sPropertyType == "[]float" )
     627             :                     {
     628           0 :                         std::vector< OUString > seqStrFloat;
     629           0 :                         seqStrFloat = commaStringToSequence( sNewValue );
     630           0 :                         uno::Sequence< sal_Int16 > seqFloat( seqStrFloat.size() );
     631           0 :                         for( size_t i = 0; i < seqStrFloat.size(); ++i )
     632             :                         {
     633           0 :                             seqFloat[i] = seqStrFloat[i].toFloat();
     634             :                         }
     635           0 :                         pProperty->Value = uno::makeAny( seqFloat );
     636             :                     }
     637           0 :                     else if( sPropertyType == "[]string" )
     638             :                     {
     639           0 :                         pProperty->Value = uno::makeAny( comphelper::containerToSequence( commaStringToSequence( sNewValue )));
     640             :                     }
     641             :                     else //unknown
     642           0 :                         throw uno::Exception();
     643             : 
     644             : 
     645           0 :                 sDialogValue = sNewValue;
     646             :             }
     647             :         }
     648           0 :         AddToModifiedVector( pProperty );
     649             : 
     650             :         //update listbox value.
     651           0 :         m_pPrefBox->SetEntryText( sDialogValue,  pEntry, 3 );
     652             :     }
     653           0 :     catch( uno::Exception& )
     654             :     {
     655             :     }
     656             : 
     657           0 :     return 0;
     658           0 : }
     659             : 
     660             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10