LCOV - code coverage report
Current view: top level - libreoffice/basctl/source/basicide - localizationmgr.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 573 0.0 %
Date: 2012-12-27 Functions: 0 28 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 "localizationmgr.hxx"
      21             : 
      22             : #include "basidesh.hxx"
      23             : #include "baside3.hxx"
      24             : #include "basobj.hxx"
      25             : #include "iderdll.hxx"
      26             : #include "dlged.hxx"
      27             : 
      28             : #include <com/sun/star/resource/XStringResourceSupplier.hpp>
      29             : #include <com/sun/star/frame/XLayoutManager.hpp>
      30             : #include <sfx2/dispatch.hxx>
      31             : 
      32             : namespace basctl
      33             : {
      34             : 
      35             : using namespace ::com::sun::star;
      36             : using namespace ::com::sun::star::uno;
      37             : using namespace ::com::sun::star::lang;
      38             : using namespace ::com::sun::star::beans;
      39             : using namespace ::com::sun::star::resource;
      40             : 
      41             : namespace
      42             : {
      43             : 
      44           0 : OUString const aDot(".");
      45           0 : OUString const aEsc("&");
      46           0 : OUString const aSemi(";");
      47             : 
      48             : } // namespace
      49             : 
      50           0 : LocalizationMgr::LocalizationMgr(
      51             :     Shell* pShell,
      52             :     ScriptDocument const& rDocument,
      53             :     OUString const& aLibName,
      54             :     Reference<XStringResourceManager> const& xStringResourceManager
      55             : ) :
      56             :     m_xStringResourceManager(xStringResourceManager),
      57             :     m_pShell(pShell),
      58             :     m_aDocument(rDocument),
      59           0 :     m_aLibName(aLibName)
      60           0 : { }
      61             : 
      62           0 : bool LocalizationMgr::isLibraryLocalized ()
      63             : {
      64           0 :     if (m_xStringResourceManager.is())
      65           0 :         return m_xStringResourceManager->getLocales().getLength() > 0;
      66           0 :     return false;
      67             : }
      68             : 
      69           0 : void LocalizationMgr::handleTranslationbar ()
      70             : {
      71           0 :     static OUString const aLayoutManagerName("LayoutManager");
      72           0 :     static OUString const aToolBarResName("private:resource/toolbar/translationbar");
      73             : 
      74             :     Reference< beans::XPropertySet > xFrameProps
      75           0 :         ( m_pShell->GetViewFrame()->GetFrame().GetFrameInterface(), uno::UNO_QUERY );
      76           0 :     if ( xFrameProps.is() )
      77             :     {
      78           0 :         Reference< ::com::sun::star::frame::XLayoutManager > xLayoutManager;
      79           0 :         uno::Any a = xFrameProps->getPropertyValue( aLayoutManagerName );
      80           0 :         a >>= xLayoutManager;
      81           0 :         if ( xLayoutManager.is() )
      82             :         {
      83           0 :             if ( !isLibraryLocalized() )
      84             :             {
      85           0 :                 xLayoutManager->destroyElement( aToolBarResName );
      86             :             }
      87             :             else
      88             :             {
      89           0 :                 xLayoutManager->createElement( aToolBarResName );
      90           0 :                 xLayoutManager->requestElement( aToolBarResName );
      91             :             }
      92           0 :         }
      93           0 :     }
      94           0 : }
      95             : 
      96             : 
      97             : // TODO: -> export from toolkit
      98             : 
      99             : namespace
     100             : {
     101             : 
     102             : 
     103             : }
     104             : 
     105           0 : bool isLanguageDependentProperty( OUString aName )
     106             : {
     107             :     static struct Prop
     108             :     {
     109             :         const char* sName;
     110             :         sal_Int32 nNameLength;
     111             :     }
     112             :     const vProp[] =
     113             :     {
     114             :         { "Text",            4 },
     115             :         { "Label",           5 },
     116             :         { "Title",           5 },
     117             :         { "HelpText",        8 },
     118             :         { "CurrencySymbol", 14 },
     119             :         { "StringItemList", 14 },
     120             :         { 0, 0                 }
     121             :     };
     122             : 
     123           0 :     for (Prop const* pProp = vProp; pProp->sName; ++pProp)
     124           0 :         if (aName.equalsAsciiL(pProp->sName, pProp->nNameLength))
     125           0 :             return true;
     126           0 :     return false;
     127             : }
     128             : 
     129             : 
     130           0 : void LocalizationMgr::implEnableDisableResourceForAllLibraryDialogs( HandleResourceMode eMode )
     131             : {
     132           0 :     Sequence< OUString > aDlgNames = m_aDocument.getObjectNames( E_DIALOGS, m_aLibName );
     133           0 :     sal_Int32 nDlgCount = aDlgNames.getLength();
     134           0 :     const OUString* pDlgNames = aDlgNames.getConstArray();
     135             : 
     136           0 :     Reference< XStringResourceResolver > xDummyStringResolver;
     137           0 :     for( sal_Int32 i = 0 ; i < nDlgCount ; i++ )
     138             :     {
     139           0 :         String aDlgName = pDlgNames[ i ];
     140           0 :         if (DialogWindow* pWin = m_pShell->FindDlgWin(m_aDocument, m_aLibName, aDlgName))
     141             :         {
     142           0 :             Reference< container::XNameContainer > xDialog = pWin->GetDialog();
     143           0 :             if( xDialog.is() )
     144             :             {
     145             :                 // Handle dialog itself as control
     146           0 :                 Any aDialogCtrl;
     147           0 :                 aDialogCtrl <<= xDialog;
     148             :                 implHandleControlResourceProperties( aDialogCtrl, aDlgName,
     149           0 :                     OUString(), m_xStringResourceManager, xDummyStringResolver, eMode );
     150             : 
     151             :                 // Handle all controls
     152           0 :                 Sequence< OUString > aNames = xDialog->getElementNames();
     153           0 :                 const OUString* pNames = aNames.getConstArray();
     154           0 :                 sal_Int32 nCtrls = aNames.getLength();
     155           0 :                 for( sal_Int32 j = 0 ; j < nCtrls ; ++j )
     156             :                 {
     157           0 :                     OUString aCtrlName( pNames[j] );
     158           0 :                     Any aCtrl = xDialog->getByName( aCtrlName );
     159             :                     implHandleControlResourceProperties( aCtrl, aDlgName,
     160           0 :                         aCtrlName, m_xStringResourceManager, xDummyStringResolver, eMode );
     161           0 :                 }
     162           0 :             }
     163             :         }
     164           0 :     }
     165           0 : }
     166             : 
     167             : 
     168           0 : OUString implCreatePureResourceId
     169             :     ( const OUString& aDialogName, const OUString& aCtrlName,
     170             :       const OUString& aPropName,
     171             :       Reference< XStringResourceManager > xStringResourceManager )
     172             : {
     173           0 :     sal_Int32 nUniqueId = xStringResourceManager->getUniqueNumericId();
     174           0 :     OUString aPureIdStr = OUString::valueOf( nUniqueId );
     175           0 :     aPureIdStr += aDot;
     176           0 :     aPureIdStr += aDialogName;
     177           0 :     aPureIdStr += aDot;
     178           0 :     if( !aCtrlName.isEmpty() )
     179             :     {
     180           0 :         aPureIdStr += aCtrlName;
     181           0 :         aPureIdStr += aDot;
     182             :     }
     183           0 :     aPureIdStr += aPropName;
     184           0 :     return aPureIdStr;
     185             : }
     186             : 
     187             : extern bool localesAreEqual( const ::com::sun::star::lang::Locale& rLocaleLeft,
     188             :                              const ::com::sun::star::lang::Locale& rLocaleRight );
     189             : 
     190             : // Works on xStringResourceManager's current language for SET_IDS/RESET_IDS,
     191             : // anyway only one language should exist when calling this method then,
     192             : // either the first one for mode SET_IDS or the last one for mode RESET_IDS
     193           0 : sal_Int32 LocalizationMgr::implHandleControlResourceProperties
     194             :     ( Any aControlAny, const OUString& aDialogName, const OUString& aCtrlName,
     195             :         Reference< XStringResourceManager > xStringResourceManager,
     196             :         Reference< XStringResourceResolver > xSourceStringResolver, HandleResourceMode eMode )
     197             : {
     198           0 :     sal_Int32 nChangedCount = 0;
     199             : 
     200           0 :     Reference< XPropertySet > xPropertySet;
     201           0 :     aControlAny >>= xPropertySet;
     202           0 :     if( xPropertySet.is() )
     203             :     {
     204           0 :         Sequence< Locale > aLocaleSeq = xStringResourceManager->getLocales();
     205           0 :         sal_Int32 nLocaleCount = aLocaleSeq.getLength();
     206           0 :         if( nLocaleCount == 0 )
     207           0 :             return 0;
     208             : 
     209           0 :         Reference< XPropertySetInfo > xPropertySetInfo = xPropertySet->getPropertySetInfo();
     210           0 :         if( xPropertySetInfo.is() )
     211             :         {
     212             :             // get sequence of control properties
     213           0 :             Sequence< Property > aPropSeq = xPropertySetInfo->getProperties();
     214           0 :             const Property* pProps = aPropSeq.getConstArray();
     215           0 :             sal_Int32 nCtrlProps = aPropSeq.getLength();
     216             : 
     217             :             // create a map of tab indices and control names, sorted by tab index
     218           0 :             for( sal_Int32 j = 0 ; j < nCtrlProps ; ++j )
     219             :             {
     220           0 :                 const Property& rProp = pProps[j];
     221           0 :                 OUString aPropName = rProp.Name;
     222           0 :                 TypeClass eType = rProp.Type.getTypeClass();
     223             :                 bool bLanguageDependentProperty =
     224             :                     (eType == TypeClass_STRING || eType == TypeClass_SEQUENCE)
     225           0 :                     && isLanguageDependentProperty( aPropName );
     226           0 :                 if( !bLanguageDependentProperty )
     227           0 :                     continue;
     228             : 
     229           0 :                 if( eType == TypeClass_STRING )
     230             :                 {
     231           0 :                     Any aPropAny = xPropertySet->getPropertyValue( aPropName );
     232           0 :                     OUString aPropStr;
     233           0 :                     aPropAny >>= aPropStr;
     234             : 
     235             :                     // Replace string by id, add id+string to StringResource
     236           0 :                     if( eMode == SET_IDS )
     237             :                     {
     238           0 :                         bool bEscAlreadyExisting = (!aPropStr.isEmpty() && aPropStr.getStr()[0] == '&' );
     239           0 :                         if( bEscAlreadyExisting )
     240           0 :                             continue;
     241             : 
     242             :                         OUString aPureIdStr = implCreatePureResourceId
     243           0 :                             ( aDialogName, aCtrlName, aPropName, xStringResourceManager );
     244             : 
     245             :                         // Set Id for all locales
     246           0 :                         const Locale* pLocales = aLocaleSeq.getConstArray();
     247           0 :                         for( sal_Int32 i = 0 ; i < nLocaleCount ; i++ )
     248             :                         {
     249           0 :                             const Locale& rLocale = pLocales[ i ];
     250           0 :                             xStringResourceManager->setStringForLocale( aPureIdStr, aPropStr, rLocale );
     251             :                         }
     252             : 
     253           0 :                         OUString aPropIdStr = aEsc;
     254           0 :                         aPropIdStr += aPureIdStr;
     255             :                         // TODO?: Change here and in toolkit
     256             :                         (void)aSemi;
     257           0 :                         aPropAny <<= aPropIdStr;
     258           0 :                         xPropertySet->setPropertyValue( aPropName, aPropAny );
     259             :                     }
     260             :                     // Replace id by string from StringResource
     261           0 :                     else if( eMode == RESET_IDS )
     262             :                     {
     263           0 :                         if( aPropStr.getLength() > 1 )
     264             :                         {
     265           0 :                             OUString aPureIdStr = aPropStr.copy( 1 );
     266           0 :                             OUString aNewPropStr = aPropStr;
     267             :                             try
     268             :                             {
     269           0 :                                 aNewPropStr = xStringResourceManager->resolveString( aPureIdStr );
     270             :                             }
     271           0 :                             catch(const MissingResourceException&)
     272             :                             {
     273             :                             }
     274           0 :                             aPropAny <<= aNewPropStr;
     275           0 :                             xPropertySet->setPropertyValue( aPropName, aPropAny );
     276             :                         }
     277             :                     }
     278             :                     // Remove Id for all locales
     279           0 :                     else if( eMode == REMOVE_IDS_FROM_RESOURCE )
     280             :                     {
     281           0 :                         if( aPropStr.getLength() > 1 )
     282             :                         {
     283           0 :                             OUString aPureIdStr = aPropStr.copy( 1 );
     284             : 
     285           0 :                             const Locale* pLocales = aLocaleSeq.getConstArray();
     286           0 :                             for( sal_Int32 i = 0 ; i < nLocaleCount ; i++ )
     287             :                             {
     288           0 :                                 const Locale& rLocale = pLocales[ i ];
     289             :                                 try
     290             :                                 {
     291           0 :                                     xStringResourceManager->removeIdForLocale( aPureIdStr, rLocale );
     292             :                                 }
     293           0 :                                 catch(const MissingResourceException&)
     294             :                                 {
     295             :                                 }
     296           0 :                             }
     297             :                         }
     298             :                     }
     299             :                     // Rename resource id
     300           0 :                     else if( eMode == RENAME_DIALOG_IDS || eMode == RENAME_CONTROL_IDS )
     301             :                     {
     302           0 :                         OUString aSourceIdStr = aPropStr;
     303           0 :                         OUString aPureSourceIdStr = aSourceIdStr.copy( 1 );
     304             : 
     305             :                         OUString aPureIdStr = implCreatePureResourceId
     306           0 :                             ( aDialogName, aCtrlName, aPropName, xStringResourceManager );
     307             : 
     308             :                         // Set new Id and remove old one for all locales
     309           0 :                         const Locale* pLocales = aLocaleSeq.getConstArray();
     310           0 :                         for( sal_Int32 i = 0 ; i < nLocaleCount ; i++ )
     311             :                         {
     312           0 :                             const Locale& rLocale = pLocales[ i ];
     313           0 :                             OUString aResStr;
     314             :                             try
     315             :                             {
     316           0 :                                 aResStr = xStringResourceManager->resolveStringForLocale
     317           0 :                                     ( aPureSourceIdStr, rLocale );
     318           0 :                                 xStringResourceManager->removeIdForLocale( aPureSourceIdStr, rLocale );
     319           0 :                                 xStringResourceManager->setStringForLocale( aPureIdStr, aResStr, rLocale );
     320             :                             }
     321           0 :                             catch(const MissingResourceException&)
     322             :                             {}
     323           0 :                         }
     324             : 
     325           0 :                         OUString aPropIdStr = aEsc;
     326           0 :                         aPropIdStr += aPureIdStr;
     327             :                         // TODO?: Change here and in toolkit
     328             :                         (void)aSemi;
     329           0 :                         aPropAny <<= aPropIdStr;
     330           0 :                         xPropertySet->setPropertyValue( aPropName, aPropAny );
     331             :                     }
     332             :                     // Replace string by string from source StringResourceResolver
     333           0 :                     else if( eMode == MOVE_RESOURCES && xSourceStringResolver.is() )
     334             :                     {
     335           0 :                         OUString aSourceIdStr = aPropStr;
     336           0 :                         OUString aPureSourceIdStr = aSourceIdStr.copy( 1 );
     337             : 
     338             :                         OUString aPureIdStr = implCreatePureResourceId
     339           0 :                             ( aDialogName, aCtrlName, aPropName, xStringResourceManager );
     340             : 
     341           0 :                         const Locale& rDefaultLocale = xSourceStringResolver->getDefaultLocale();
     342             : 
     343             :                         // Set Id for all locales
     344           0 :                         const Locale* pLocales = aLocaleSeq.getConstArray();
     345           0 :                         for( sal_Int32 i = 0 ; i < nLocaleCount ; i++ )
     346             :                         {
     347           0 :                             const Locale& rLocale = pLocales[ i ];
     348           0 :                             OUString aResStr;
     349             :                             try
     350             :                             {
     351           0 :                                 aResStr = xSourceStringResolver->resolveStringForLocale
     352           0 :                                     ( aPureSourceIdStr, rLocale );
     353             :                             }
     354           0 :                             catch(const MissingResourceException&)
     355             :                             {
     356           0 :                                 aResStr = xSourceStringResolver->resolveStringForLocale
     357           0 :                                     ( aPureSourceIdStr, rDefaultLocale );
     358             :                             }
     359           0 :                             xStringResourceManager->setStringForLocale( aPureIdStr, aResStr, rLocale );
     360           0 :                         }
     361             : 
     362           0 :                         OUString aPropIdStr = aEsc;
     363           0 :                         aPropIdStr += aPureIdStr;
     364             :                         // TODO?: Change here and in toolkit
     365             :                         (void)aSemi;
     366           0 :                         aPropAny <<= aPropIdStr;
     367           0 :                         xPropertySet->setPropertyValue( aPropName, aPropAny );
     368             :                     }
     369             :                     // Copy string from source to target resource
     370           0 :                     else if( eMode == COPY_RESOURCES && xSourceStringResolver.is() )
     371             :                     {
     372           0 :                         OUString aSourceIdStr = aPropStr;
     373           0 :                         OUString aPureSourceIdStr = aSourceIdStr.copy( 1 );
     374             : 
     375           0 :                         const Locale& rDefaultLocale = xSourceStringResolver->getDefaultLocale();
     376             : 
     377             :                         // Copy Id for all locales
     378           0 :                         const Locale* pLocales = aLocaleSeq.getConstArray();
     379           0 :                         for( sal_Int32 i = 0 ; i < nLocaleCount ; i++ )
     380             :                         {
     381           0 :                             const Locale& rLocale = pLocales[ i ];
     382           0 :                             OUString aResStr;
     383             :                             try
     384             :                             {
     385           0 :                                 aResStr = xSourceStringResolver->resolveStringForLocale
     386           0 :                                     ( aPureSourceIdStr, rLocale );
     387             :                             }
     388           0 :                             catch(const MissingResourceException&)
     389             :                             {
     390           0 :                                 aResStr = xSourceStringResolver->resolveStringForLocale
     391           0 :                                     ( aPureSourceIdStr, rDefaultLocale );
     392             :                             }
     393           0 :                             xStringResourceManager->setStringForLocale( aPureSourceIdStr, aResStr, rLocale );
     394           0 :                         }
     395             :                     }
     396           0 :                     nChangedCount++;
     397             :                 }
     398             : 
     399             :                 // Listbox / Combobox
     400           0 :                 else if( eType == TypeClass_SEQUENCE )
     401             :                 {
     402           0 :                     Any aPropAny = xPropertySet->getPropertyValue( aPropName );
     403           0 :                     Sequence< OUString > aPropStrings;
     404           0 :                     aPropAny >>= aPropStrings;
     405             : 
     406           0 :                     const OUString* pPropStrings = aPropStrings.getConstArray();
     407           0 :                     sal_Int32 nPropStringCount = aPropStrings.getLength();
     408           0 :                     if( nPropStringCount == 0 )
     409           0 :                         continue;
     410             : 
     411             :                     // Replace string by id, add id+string to StringResource
     412           0 :                     if( eMode == SET_IDS )
     413             :                     {
     414           0 :                         Sequence< OUString > aIdStrings;
     415           0 :                         aIdStrings.realloc( nPropStringCount );
     416           0 :                         OUString* pIdStrings = aIdStrings.getArray();
     417             : 
     418           0 :                         OUString aIdStrBase = aDot;
     419           0 :                         aIdStrBase += aCtrlName;
     420           0 :                         aIdStrBase += aDot;
     421           0 :                         aIdStrBase += aPropName;
     422             : 
     423           0 :                         const Locale* pLocales = aLocaleSeq.getConstArray();
     424             :                         sal_Int32 i;
     425           0 :                         for ( i = 0; i < nPropStringCount; ++i )
     426             :                         {
     427           0 :                             OUString aPropStr = pPropStrings[i];
     428           0 :                             bool bEscAlreadyExisting = (!aPropStr.isEmpty() && aPropStr.getStr()[0] == '&' );
     429           0 :                             if( bEscAlreadyExisting )
     430             :                             {
     431           0 :                                 pIdStrings[i] = aPropStr;
     432           0 :                                 continue;
     433             :                             }
     434             : 
     435           0 :                             sal_Int32 nUniqueId = xStringResourceManager->getUniqueNumericId();
     436           0 :                             OUString aPureIdStr = OUString::valueOf( nUniqueId );
     437           0 :                             aPureIdStr += aIdStrBase;
     438             : 
     439             :                             // Set Id for all locales
     440           0 :                             for( sal_Int32 iLocale = 0 ; iLocale < nLocaleCount ; iLocale++ )
     441             :                             {
     442           0 :                                 const Locale& rLocale = pLocales[ iLocale ];
     443           0 :                                 xStringResourceManager->setStringForLocale( aPureIdStr, aPropStr, rLocale );
     444             :                             }
     445             : 
     446           0 :                             OUString aPropIdStr = aEsc;
     447           0 :                             aPropIdStr += aPureIdStr;
     448           0 :                             pIdStrings[i] = aPropIdStr;
     449           0 :                         }
     450           0 :                         aPropAny <<= aIdStrings;
     451           0 :                         xPropertySet->setPropertyValue( aPropName, aPropAny );
     452             :                     }
     453             :                     // Replace id by string from StringResource
     454           0 :                     else if( eMode == RESET_IDS )
     455             :                     {
     456           0 :                         Sequence< OUString > aNewPropStrings;
     457           0 :                         aNewPropStrings.realloc( nPropStringCount );
     458           0 :                         OUString* pNewPropStrings = aNewPropStrings.getArray();
     459             : 
     460             :                         sal_Int32 i;
     461           0 :                         for ( i = 0; i < nPropStringCount; ++i )
     462             :                         {
     463           0 :                             OUString aIdStr = pPropStrings[i];
     464           0 :                             OUString aNewPropStr = aIdStr;
     465           0 :                             if( aIdStr.getLength() > 1 )
     466             :                             {
     467           0 :                                 OUString aPureIdStr = aIdStr.copy( 1 );
     468             :                                 try
     469             :                                 {
     470           0 :                                     aNewPropStr = xStringResourceManager->resolveString( aPureIdStr );
     471             :                                 }
     472           0 :                                 catch(const MissingResourceException&)
     473             :                                 {
     474           0 :                                 }
     475             :                             }
     476           0 :                             pNewPropStrings[i] = aNewPropStr;
     477           0 :                         }
     478           0 :                         aPropAny <<= aNewPropStrings;
     479           0 :                         xPropertySet->setPropertyValue( aPropName, aPropAny );
     480             :                     }
     481             :                     // Remove Id for all locales
     482           0 :                     else if( eMode == REMOVE_IDS_FROM_RESOURCE )
     483             :                     {
     484           0 :                         Sequence< OUString > aNewPropStrings;
     485           0 :                         aNewPropStrings.realloc( nPropStringCount );
     486             : 
     487           0 :                         const Locale* pLocales = aLocaleSeq.getConstArray();
     488             :                         sal_Int32 i;
     489           0 :                         for ( i = 0; i < nPropStringCount; ++i )
     490             :                         {
     491           0 :                             OUString aIdStr = pPropStrings[i];
     492           0 :                             if( aIdStr.getLength() > 1 )
     493             :                             {
     494           0 :                                 OUString aPureIdStr = aIdStr.copy( 1 );
     495             : 
     496           0 :                                 for( sal_Int32 iLocale = 0 ; iLocale < nLocaleCount ; iLocale++ )
     497             :                                 {
     498           0 :                                     const Locale& rLocale = pLocales[iLocale];
     499             :                                     try
     500             :                                     {
     501           0 :                                         xStringResourceManager->removeIdForLocale( aPureIdStr, rLocale );
     502             :                                     }
     503           0 :                                     catch(const MissingResourceException&)
     504             :                                     {
     505             :                                     }
     506           0 :                                 }
     507             :                             }
     508           0 :                         }
     509             :                     }
     510             :                     // Rename resource id
     511           0 :                     else if( eMode == RENAME_CONTROL_IDS )
     512             :                     {
     513           0 :                         Sequence< OUString > aIdStrings;
     514           0 :                         aIdStrings.realloc( nPropStringCount );
     515           0 :                         OUString* pIdStrings = aIdStrings.getArray();
     516             : 
     517           0 :                         OUString aIdStrBase = aDot;
     518           0 :                         aIdStrBase += aCtrlName;
     519           0 :                         aIdStrBase += aDot;
     520           0 :                         aIdStrBase += aPropName;
     521             : 
     522           0 :                         const Locale* pLocales = aLocaleSeq.getConstArray();
     523             :                         sal_Int32 i;
     524           0 :                         for ( i = 0; i < nPropStringCount; ++i )
     525             :                         {
     526           0 :                             OUString aSourceIdStr = pPropStrings[i];
     527           0 :                             OUString aPureSourceIdStr = aSourceIdStr.copy( 1 );
     528             : 
     529           0 :                             sal_Int32 nUniqueId = xStringResourceManager->getUniqueNumericId();
     530           0 :                             OUString aPureIdStr = OUString::valueOf( nUniqueId );
     531           0 :                             aPureIdStr += aIdStrBase;
     532             : 
     533             :                             // Set Id for all locales
     534           0 :                             for( sal_Int32 iLocale = 0 ; iLocale < nLocaleCount ; iLocale++ )
     535             :                             {
     536           0 :                                 const Locale& rLocale = pLocales[ iLocale ];
     537             : 
     538           0 :                                 OUString aResStr;
     539             :                                 try
     540             :                                 {
     541           0 :                                     aResStr = xStringResourceManager->resolveStringForLocale
     542           0 :                                         ( aPureSourceIdStr, rLocale );
     543           0 :                                     xStringResourceManager->removeIdForLocale( aPureSourceIdStr, rLocale );
     544           0 :                                     xStringResourceManager->setStringForLocale( aPureIdStr, aResStr, rLocale );
     545             :                                 }
     546           0 :                                 catch(const MissingResourceException&)
     547             :                                 {}
     548           0 :                             }
     549             : 
     550           0 :                             OUString aPropIdStr = aEsc;
     551           0 :                             aPropIdStr += aPureIdStr;
     552           0 :                             pIdStrings[i] = aPropIdStr;
     553           0 :                         }
     554           0 :                         aPropAny <<= aIdStrings;
     555           0 :                         xPropertySet->setPropertyValue( aPropName, aPropAny );
     556             :                     }
     557             :                     // Replace string by string from source StringResourceResolver
     558           0 :                     else if( eMode == MOVE_RESOURCES && xSourceStringResolver.is() )
     559             :                     {
     560           0 :                         Sequence< OUString > aIdStrings;
     561           0 :                         aIdStrings.realloc( nPropStringCount );
     562           0 :                         OUString* pIdStrings = aIdStrings.getArray();
     563             : 
     564           0 :                         OUString aIdStrBase = aDot;
     565           0 :                         aIdStrBase += aCtrlName;
     566           0 :                         aIdStrBase += aDot;
     567           0 :                         aIdStrBase += aPropName;
     568             : 
     569           0 :                         const Locale& rDefaultLocale = xSourceStringResolver->getDefaultLocale();
     570             : 
     571           0 :                         const Locale* pLocales = aLocaleSeq.getConstArray();
     572             :                         sal_Int32 i;
     573           0 :                         for ( i = 0; i < nPropStringCount; ++i )
     574             :                         {
     575           0 :                             OUString aSourceIdStr = pPropStrings[i];
     576           0 :                             OUString aPureSourceIdStr = aSourceIdStr.copy( 1 );
     577             : 
     578           0 :                             sal_Int32 nUniqueId = xStringResourceManager->getUniqueNumericId();
     579           0 :                             OUString aPureIdStr = OUString::valueOf( nUniqueId );
     580           0 :                             aPureIdStr += aIdStrBase;
     581             : 
     582             :                             // Set Id for all locales
     583           0 :                             for( sal_Int32 iLocale = 0 ; iLocale < nLocaleCount ; iLocale++ )
     584             :                             {
     585           0 :                                 const Locale& rLocale = pLocales[ iLocale ];
     586             : 
     587           0 :                                 OUString aResStr;
     588             :                                 try
     589             :                                 {
     590           0 :                                     aResStr = xSourceStringResolver->resolveStringForLocale
     591           0 :                                         ( aPureSourceIdStr, rLocale );
     592             :                                 }
     593           0 :                                 catch(const MissingResourceException&)
     594             :                                 {
     595           0 :                                     aResStr = xSourceStringResolver->resolveStringForLocale
     596           0 :                                         ( aPureSourceIdStr, rDefaultLocale );
     597             :                                 }
     598           0 :                                 xStringResourceManager->setStringForLocale( aPureIdStr, aResStr, rLocale );
     599           0 :                             }
     600             : 
     601           0 :                             OUString aPropIdStr = aEsc;
     602           0 :                             aPropIdStr += aPureIdStr;
     603           0 :                             pIdStrings[i] = aPropIdStr;
     604           0 :                         }
     605           0 :                         aPropAny <<= aIdStrings;
     606           0 :                         xPropertySet->setPropertyValue( aPropName, aPropAny );
     607             :                     }
     608             :                     // Copy string from source to target resource
     609           0 :                     else if( eMode == COPY_RESOURCES && xSourceStringResolver.is() )
     610             :                     {
     611           0 :                         const Locale& rDefaultLocale = xSourceStringResolver->getDefaultLocale();
     612             : 
     613           0 :                         const Locale* pLocales = aLocaleSeq.getConstArray();
     614             :                         sal_Int32 i;
     615           0 :                         for ( i = 0; i < nPropStringCount; ++i )
     616             :                         {
     617           0 :                             OUString aSourceIdStr = pPropStrings[i];
     618           0 :                             OUString aPureSourceIdStr = aSourceIdStr.copy( 1 );
     619             : 
     620             :                             // Set Id for all locales
     621           0 :                             for( sal_Int32 iLocale = 0 ; iLocale < nLocaleCount ; iLocale++ )
     622             :                             {
     623           0 :                                 const Locale& rLocale = pLocales[ iLocale ];
     624             : 
     625           0 :                                 OUString aResStr;
     626             :                                 try
     627             :                                 {
     628           0 :                                     aResStr = xSourceStringResolver->resolveStringForLocale
     629           0 :                                         ( aPureSourceIdStr, rLocale );
     630             :                                 }
     631           0 :                                 catch(const MissingResourceException&)
     632             :                                 {
     633           0 :                                     aResStr = xSourceStringResolver->resolveStringForLocale
     634           0 :                                         ( aPureSourceIdStr, rDefaultLocale );
     635             :                                 }
     636           0 :                                 xStringResourceManager->setStringForLocale( aPureSourceIdStr, aResStr, rLocale );
     637           0 :                             }
     638           0 :                         }
     639             :                     }
     640           0 :                     nChangedCount++;
     641             :                 }
     642           0 :             }
     643           0 :         }
     644             :     }
     645           0 :     return nChangedCount;
     646             : }
     647             : 
     648             : 
     649           0 : void LocalizationMgr::handleAddLocales( Sequence< Locale > aLocaleSeq )
     650             : {
     651           0 :     const Locale* pLocales = aLocaleSeq.getConstArray();
     652           0 :     sal_Int32 nLocaleCount = aLocaleSeq.getLength();
     653             : 
     654           0 :     if( isLibraryLocalized() )
     655             :     {
     656           0 :         for( sal_Int32 i = 0 ; i < nLocaleCount ; i++ )
     657             :         {
     658           0 :             const Locale& rLocale = pLocales[ i ];
     659           0 :             m_xStringResourceManager->newLocale( rLocale );
     660             :         }
     661             :     }
     662             :     else
     663             :     {
     664             :         DBG_ASSERT( nLocaleCount==1, "LocalizationMgr::handleAddLocales(): Only one first locale allowed" );
     665             : 
     666           0 :         const Locale& rLocale = pLocales[ 0 ];
     667           0 :         m_xStringResourceManager->newLocale( rLocale );
     668           0 :         enableResourceForAllLibraryDialogs();
     669             :     }
     670             : 
     671           0 :     MarkDocumentModified( m_aDocument );
     672             : 
     673             :     // update locale toolbar
     674           0 :     if (SfxBindings* pBindings = GetBindingsPtr())
     675           0 :         pBindings->Invalidate( SID_BASICIDE_CURRENT_LANG );
     676             : 
     677           0 :     handleTranslationbar();
     678           0 : }
     679             : 
     680             : 
     681           0 : void LocalizationMgr::handleRemoveLocales( Sequence< Locale > aLocaleSeq )
     682             : {
     683           0 :     const Locale* pLocales = aLocaleSeq.getConstArray();
     684           0 :     sal_Int32 nLocaleCount = aLocaleSeq.getLength();
     685           0 :     bool bConsistant = true;
     686           0 :     bool bModified = false;
     687             : 
     688           0 :     for( sal_Int32 i = 0 ; i < nLocaleCount ; i++ )
     689             :     {
     690           0 :         const Locale& rLocale = pLocales[ i ];
     691           0 :         bool bRemove = true;
     692             : 
     693             :         // Check if last locale
     694           0 :         Sequence< Locale > aResLocaleSeq = m_xStringResourceManager->getLocales();
     695           0 :         if( aResLocaleSeq.getLength() == 1 )
     696             :         {
     697           0 :             const Locale& rLastResLocale = aResLocaleSeq.getConstArray()[ 0 ];
     698           0 :             if( localesAreEqual( rLocale, rLastResLocale ) )
     699             :             {
     700           0 :                 disableResourceForAllLibraryDialogs();
     701             :             }
     702             :             else
     703             :             {
     704             :                 // Inconsistancy, keep last locale
     705           0 :                 bConsistant = false;
     706           0 :                 bRemove = false;
     707             :             }
     708             :         }
     709             : 
     710           0 :         if( bRemove )
     711             :         {
     712             :             try
     713             :             {
     714           0 :                 m_xStringResourceManager->removeLocale( rLocale );
     715           0 :                 bModified = true;
     716             :             }
     717           0 :             catch(const IllegalArgumentException&)
     718             :             {
     719           0 :                 bConsistant = false;
     720             :             }
     721             :         }
     722           0 :     }
     723           0 :     if( bModified )
     724             :     {
     725           0 :         MarkDocumentModified( m_aDocument );
     726             : 
     727             :         // update slots
     728           0 :         if (SfxBindings* pBindings = GetBindingsPtr())
     729             :         {
     730           0 :             pBindings->Invalidate( SID_BASICIDE_CURRENT_LANG );
     731           0 :             pBindings->Invalidate( SID_BASICIDE_MANAGE_LANG );
     732             :         }
     733             : 
     734           0 :         handleTranslationbar();
     735             :     }
     736             : 
     737             :     DBG_ASSERT( bConsistant,
     738             :         "LocalizationMgr::handleRemoveLocales(): sequence contains unsupported locales" );
     739             :     (void)bConsistant;
     740           0 : }
     741             : 
     742           0 : void LocalizationMgr::handleSetDefaultLocale( Locale aLocale )
     743             : {
     744           0 :     if( m_xStringResourceManager.is() )
     745             :     {
     746             :         try
     747             :         {
     748           0 :             m_xStringResourceManager->setDefaultLocale( aLocale );
     749             :         }
     750           0 :         catch(const IllegalArgumentException&)
     751             :         {
     752             :             OSL_FAIL( "LocalizationMgr::handleSetDefaultLocale: Invalid locale" );
     753             :         }
     754             : 
     755             :         // update locale toolbar
     756           0 :         if (SfxBindings* pBindings = GetBindingsPtr())
     757           0 :             pBindings->Invalidate( SID_BASICIDE_CURRENT_LANG );
     758             :     }
     759           0 : }
     760             : 
     761           0 : void LocalizationMgr::handleSetCurrentLocale( ::com::sun::star::lang::Locale aLocale )
     762             : {
     763           0 :     if( m_xStringResourceManager.is() )
     764             :     {
     765             :         try
     766             :         {
     767           0 :             m_xStringResourceManager->setCurrentLocale( aLocale, false );
     768             :         }
     769           0 :         catch(const IllegalArgumentException&)
     770             :         {
     771             :             OSL_FAIL( "LocalizationMgr::handleSetCurrentLocale: Invalid locale" );
     772             :         }
     773             : 
     774             :         // update locale toolbar
     775           0 :         if (SfxBindings* pBindings = GetBindingsPtr())
     776           0 :             pBindings->Invalidate( SID_BASICIDE_CURRENT_LANG );
     777             : 
     778           0 :         if (DialogWindow* pDlgWin = dynamic_cast<DialogWindow*>(m_pShell->GetCurWindow()))
     779           0 :             if (!pDlgWin->IsSuspended())
     780           0 :                 pDlgWin->GetEditor().UpdatePropertyBrowserDelayed();
     781             :     }
     782           0 : }
     783             : 
     784           0 : void LocalizationMgr::handleBasicStarted( void )
     785             : {
     786           0 :     if( m_xStringResourceManager.is() )
     787           0 :         m_aLocaleBeforeBasicStart = m_xStringResourceManager->getCurrentLocale();
     788           0 : }
     789             : 
     790           0 : void LocalizationMgr::handleBasicStopped( void )
     791             : {
     792             :     try
     793             :     {
     794           0 :         if( m_xStringResourceManager.is() )
     795           0 :             m_xStringResourceManager->setCurrentLocale( m_aLocaleBeforeBasicStart, true );
     796             :     }
     797           0 :     catch(const IllegalArgumentException&)
     798             :     {
     799             :     }
     800           0 : }
     801             : 
     802             : 
     803           0 : DialogWindow* FindDialogWindowForEditor( DlgEditor* pEditor )
     804             : {
     805           0 :     Shell::WindowTable const& aWindowTable = GetShell()->GetWindowTable();
     806           0 :     for (Shell::WindowTableIt it = aWindowTable.begin(); it != aWindowTable.end(); ++it )
     807             :     {
     808           0 :         BaseWindow* pWin = it->second;
     809           0 :         if (!pWin->IsSuspended())
     810           0 :             if (DialogWindow* pDlgWin = dynamic_cast<DialogWindow*>(pWin))
     811             :             {
     812           0 :                 if (&pDlgWin->GetEditor() == pEditor)
     813           0 :                     return pDlgWin;
     814             :             }
     815             :     }
     816           0 :     return 0;
     817             : }
     818             : 
     819             : 
     820           0 : void LocalizationMgr::setControlResourceIDsForNewEditorObject( DlgEditor* pEditor,
     821             :     Any aControlAny, const OUString& aCtrlName )
     822             : {
     823             :     // Get library for DlgEditor
     824           0 :     DialogWindow* pDlgWin = FindDialogWindowForEditor( pEditor );
     825           0 :     if( !pDlgWin )
     826             :         return;
     827           0 :     ScriptDocument aDocument( pDlgWin->GetDocument() );
     828             :     DBG_ASSERT( aDocument.isValid(), "LocalizationMgr::setControlResourceIDsForNewEditorObject: invalid document!" );
     829           0 :     if ( !aDocument.isValid() )
     830             :         return;
     831           0 :     const String& rLibName = pDlgWin->GetLibName();
     832           0 :     Reference< container::XNameContainer > xDialogLib( aDocument.getLibrary( E_DIALOGS, rLibName, true ) );
     833             :     Reference< XStringResourceManager > xStringResourceManager =
     834           0 :         LocalizationMgr::getStringResourceFromDialogLibrary( xDialogLib );
     835             : 
     836             :     // Set resource property
     837           0 :     if( !xStringResourceManager.is() || xStringResourceManager->getLocales().getLength() == 0 )
     838             :         return;
     839             : 
     840           0 :     OUString aDialogName = pDlgWin->GetName();
     841           0 :     Reference< XStringResourceResolver > xDummyStringResolver;
     842             :     sal_Int32 nChangedCount = implHandleControlResourceProperties
     843             :         ( aControlAny, aDialogName, aCtrlName, xStringResourceManager,
     844           0 :           xDummyStringResolver, SET_IDS );
     845             : 
     846           0 :     if( nChangedCount )
     847           0 :         MarkDocumentModified( aDocument );
     848             : }
     849             : 
     850           0 : void LocalizationMgr::renameControlResourceIDsForEditorObject( DlgEditor* pEditor,
     851             :     ::com::sun::star::uno::Any aControlAny, const OUString& aNewCtrlName )
     852             : {
     853             :     // Get library for DlgEditor
     854           0 :     DialogWindow* pDlgWin = FindDialogWindowForEditor( pEditor );
     855           0 :     if( !pDlgWin )
     856             :         return;
     857           0 :     ScriptDocument aDocument( pDlgWin->GetDocument() );
     858             :     DBG_ASSERT( aDocument.isValid(), "LocalizationMgr::renameControlResourceIDsForEditorObject: invalid document!" );
     859           0 :     if ( !aDocument.isValid() )
     860             :         return;
     861           0 :     const String& rLibName = pDlgWin->GetLibName();
     862           0 :     Reference< container::XNameContainer > xDialogLib( aDocument.getLibrary( E_DIALOGS, rLibName, true ) );
     863             :     Reference< XStringResourceManager > xStringResourceManager =
     864           0 :         LocalizationMgr::getStringResourceFromDialogLibrary( xDialogLib );
     865             : 
     866             :     // Set resource property
     867           0 :     if( !xStringResourceManager.is() || xStringResourceManager->getLocales().getLength() == 0 )
     868             :         return;
     869             : 
     870           0 :     OUString aDialogName = pDlgWin->GetName();
     871           0 :     Reference< XStringResourceResolver > xDummyStringResolver;
     872             :     implHandleControlResourceProperties
     873             :         ( aControlAny, aDialogName, aNewCtrlName, xStringResourceManager,
     874           0 :           xDummyStringResolver, RENAME_CONTROL_IDS );
     875             : }
     876             : 
     877             : 
     878           0 : void LocalizationMgr::deleteControlResourceIDsForDeletedEditorObject( DlgEditor* pEditor,
     879             :     Any aControlAny, const OUString& aCtrlName )
     880             : {
     881             :     // Get library for DlgEditor
     882           0 :     DialogWindow* pDlgWin = FindDialogWindowForEditor( pEditor );
     883           0 :     if( !pDlgWin )
     884             :         return;
     885           0 :     ScriptDocument aDocument( pDlgWin->GetDocument() );
     886             :     DBG_ASSERT( aDocument.isValid(), "LocalizationMgr::deleteControlResourceIDsForDeletedEditorObject: invalid document!" );
     887           0 :     if ( !aDocument.isValid() )
     888             :         return;
     889           0 :     const String& rLibName = pDlgWin->GetLibName();
     890           0 :     Reference< container::XNameContainer > xDialogLib( aDocument.getLibrary( E_DIALOGS, rLibName, true ) );
     891             :     Reference< XStringResourceManager > xStringResourceManager =
     892           0 :         LocalizationMgr::getStringResourceFromDialogLibrary( xDialogLib );
     893             : 
     894           0 :     OUString aDialogName = pDlgWin->GetName();
     895           0 :     Reference< XStringResourceResolver > xDummyStringResolver;
     896             :     sal_Int32 nChangedCount = implHandleControlResourceProperties
     897             :         ( aControlAny, aDialogName, aCtrlName, xStringResourceManager,
     898           0 :           xDummyStringResolver, REMOVE_IDS_FROM_RESOURCE );
     899             : 
     900           0 :     if( nChangedCount )
     901           0 :         MarkDocumentModified( aDocument );
     902             : }
     903             : 
     904           0 : void LocalizationMgr::setStringResourceAtDialog( const ScriptDocument& rDocument, const OUString& aLibName,
     905             :     const OUString& aDlgName, Reference< container::XNameContainer > xDialogModel )
     906             : {
     907           0 :     static OUString aResourceResolverPropName( "ResourceResolver" );
     908             : 
     909             :     // Get library
     910           0 :     Reference< container::XNameContainer > xDialogLib( rDocument.getLibrary( E_DIALOGS, aLibName, true ) );
     911             :     Reference< XStringResourceManager > xStringResourceManager =
     912           0 :         LocalizationMgr::getStringResourceFromDialogLibrary( xDialogLib );
     913             : 
     914             :     // Set resource property
     915           0 :     if( xStringResourceManager.is() )
     916             :     {
     917             :         // Not very elegant as dialog may or may not be localized yet
     918             :         // TODO: Find better place, where dialog is created
     919           0 :         if( xStringResourceManager->getLocales().getLength() > 0 )
     920             :         {
     921           0 :             Any aDialogCtrl;
     922           0 :             aDialogCtrl <<= xDialogModel;
     923           0 :             Reference< XStringResourceResolver > xDummyStringResolver;
     924             :             implHandleControlResourceProperties( aDialogCtrl, aDlgName,
     925             :                 OUString(), xStringResourceManager,
     926           0 :                 xDummyStringResolver, SET_IDS );
     927             :         }
     928             : 
     929           0 :         Reference< beans::XPropertySet > xDlgPSet( xDialogModel, UNO_QUERY );
     930           0 :         Any aStringResourceManagerAny;
     931           0 :         aStringResourceManagerAny <<= xStringResourceManager;
     932           0 :         xDlgPSet->setPropertyValue( aResourceResolverPropName, aStringResourceManagerAny );
     933           0 :     }
     934           0 : }
     935             : 
     936           0 : void LocalizationMgr::renameStringResourceIDs( const ScriptDocument& rDocument, const OUString& aLibName,
     937             :     const OUString& aDlgName, Reference< container::XNameContainer > xDialogModel )
     938             : {
     939             :     // Get library
     940           0 :     Reference< container::XNameContainer > xDialogLib( rDocument.getLibrary( E_DIALOGS, aLibName, true ) );
     941             :     Reference< XStringResourceManager > xStringResourceManager =
     942           0 :         LocalizationMgr::getStringResourceFromDialogLibrary( xDialogLib );
     943           0 :     if( !xStringResourceManager.is() )
     944           0 :         return;
     945             : 
     946           0 :     Any aDialogCtrl;
     947           0 :     aDialogCtrl <<= xDialogModel;
     948           0 :     Reference< XStringResourceResolver > xDummyStringResolver;
     949             :     implHandleControlResourceProperties( aDialogCtrl, aDlgName,
     950             :         OUString(), xStringResourceManager,
     951           0 :         xDummyStringResolver, RENAME_DIALOG_IDS );
     952             : 
     953             :     // Handle all controls
     954           0 :     Sequence< OUString > aNames = xDialogModel->getElementNames();
     955           0 :     const OUString* pNames = aNames.getConstArray();
     956           0 :     sal_Int32 nCtrls = aNames.getLength();
     957           0 :     for( sal_Int32 i = 0 ; i < nCtrls ; ++i )
     958             :     {
     959           0 :         OUString aCtrlName( pNames[i] );
     960           0 :         Any aCtrl = xDialogModel->getByName( aCtrlName );
     961             :         implHandleControlResourceProperties( aCtrl, aDlgName,
     962             :             aCtrlName, xStringResourceManager,
     963           0 :             xDummyStringResolver, RENAME_DIALOG_IDS );
     964           0 :     }
     965             : }
     966             : 
     967           0 : void LocalizationMgr::removeResourceForDialog( const ScriptDocument& rDocument, const OUString& aLibName,
     968             :     const OUString& aDlgName, Reference< container::XNameContainer > xDialogModel )
     969             : {
     970             :     // Get library
     971           0 :     Reference< container::XNameContainer > xDialogLib( rDocument.getLibrary( E_DIALOGS, aLibName, true ) );
     972             :     Reference< XStringResourceManager > xStringResourceManager =
     973           0 :         LocalizationMgr::getStringResourceFromDialogLibrary( xDialogLib );
     974           0 :     if( !xStringResourceManager.is() )
     975           0 :         return;
     976             : 
     977           0 :     Any aDialogCtrl;
     978           0 :     aDialogCtrl <<= xDialogModel;
     979           0 :     Reference< XStringResourceResolver > xDummyStringResolver;
     980             :     implHandleControlResourceProperties( aDialogCtrl, aDlgName,
     981             :         OUString(), xStringResourceManager,
     982           0 :         xDummyStringResolver, REMOVE_IDS_FROM_RESOURCE );
     983             : 
     984             :     // Handle all controls
     985           0 :     Sequence< OUString > aNames = xDialogModel->getElementNames();
     986           0 :     const OUString* pNames = aNames.getConstArray();
     987           0 :     sal_Int32 nCtrls = aNames.getLength();
     988           0 :     for( sal_Int32 i = 0 ; i < nCtrls ; ++i )
     989             :     {
     990           0 :         OUString aCtrlName( pNames[i] );
     991           0 :         Any aCtrl = xDialogModel->getByName( aCtrlName );
     992             :         implHandleControlResourceProperties( aCtrl, aDlgName,
     993             :             aCtrlName, xStringResourceManager,
     994           0 :             xDummyStringResolver, REMOVE_IDS_FROM_RESOURCE );
     995           0 :     }
     996             : }
     997             : 
     998           0 : void LocalizationMgr::resetResourceForDialog( Reference< container::XNameContainer > xDialogModel,
     999             :     Reference< XStringResourceManager > xStringResourceManager )
    1000             : {
    1001           0 :     if( !xStringResourceManager.is() )
    1002           0 :         return;
    1003             : 
    1004             :     // Dialog as control
    1005           0 :     OUString aDummyName;
    1006           0 :     Any aDialogCtrl;
    1007           0 :     aDialogCtrl <<= xDialogModel;
    1008           0 :     Reference< XStringResourceResolver > xDummyStringResolver;
    1009             :     implHandleControlResourceProperties( aDialogCtrl, aDummyName,
    1010           0 :         aDummyName, xStringResourceManager, xDummyStringResolver, RESET_IDS );
    1011             : 
    1012             :     // Handle all controls
    1013           0 :     Sequence< OUString > aNames = xDialogModel->getElementNames();
    1014           0 :     const OUString* pNames = aNames.getConstArray();
    1015           0 :     sal_Int32 nCtrls = aNames.getLength();
    1016           0 :     for( sal_Int32 i = 0 ; i < nCtrls ; ++i )
    1017             :     {
    1018           0 :         OUString aCtrlName( pNames[i] );
    1019           0 :         Any aCtrl = xDialogModel->getByName( aCtrlName );
    1020             :         implHandleControlResourceProperties( aCtrl, aDummyName,
    1021           0 :             aCtrlName, xStringResourceManager, xDummyStringResolver, RESET_IDS );
    1022           0 :     }
    1023             : }
    1024             : 
    1025           0 : void LocalizationMgr::setResourceIDsForDialog( Reference< container::XNameContainer > xDialogModel,
    1026             :     Reference< XStringResourceManager > xStringResourceManager )
    1027             : {
    1028           0 :     if( !xStringResourceManager.is() )
    1029           0 :         return;
    1030             : 
    1031             :     // Dialog as control
    1032           0 :     OUString aDummyName;
    1033           0 :     Any aDialogCtrl;
    1034           0 :     aDialogCtrl <<= xDialogModel;
    1035           0 :     Reference< XStringResourceResolver > xDummyStringResolver;
    1036             :     implHandleControlResourceProperties( aDialogCtrl, aDummyName,
    1037           0 :         aDummyName, xStringResourceManager, xDummyStringResolver, SET_IDS );
    1038             : 
    1039             :     // Handle all controls
    1040           0 :     Sequence< OUString > aNames = xDialogModel->getElementNames();
    1041           0 :     const OUString* pNames = aNames.getConstArray();
    1042           0 :     sal_Int32 nCtrls = aNames.getLength();
    1043           0 :     for( sal_Int32 i = 0 ; i < nCtrls ; ++i )
    1044             :     {
    1045           0 :         OUString aCtrlName( pNames[i] );
    1046           0 :         Any aCtrl = xDialogModel->getByName( aCtrlName );
    1047             :         implHandleControlResourceProperties( aCtrl, aDummyName,
    1048           0 :             aCtrlName, xStringResourceManager, xDummyStringResolver, SET_IDS );
    1049           0 :     }
    1050             : }
    1051             : 
    1052           0 : void LocalizationMgr::copyResourcesForPastedEditorObject( DlgEditor* pEditor,
    1053             :     Any aControlAny, const OUString& aCtrlName,
    1054             :     Reference< XStringResourceResolver > xSourceStringResolver )
    1055             : {
    1056             :     // Get library for DlgEditor
    1057           0 :     DialogWindow* pDlgWin = FindDialogWindowForEditor( pEditor );
    1058           0 :     if( !pDlgWin )
    1059             :         return;
    1060           0 :     ScriptDocument aDocument( pDlgWin->GetDocument() );
    1061             :     DBG_ASSERT( aDocument.isValid(), "LocalizationMgr::copyResourcesForPastedEditorObject: invalid document!" );
    1062           0 :     if ( !aDocument.isValid() )
    1063             :         return;
    1064           0 :     const String& rLibName = pDlgWin->GetLibName();
    1065           0 :     Reference< container::XNameContainer > xDialogLib( aDocument.getLibrary( E_DIALOGS, rLibName, true ) );
    1066             :     Reference< XStringResourceManager > xStringResourceManager =
    1067           0 :         LocalizationMgr::getStringResourceFromDialogLibrary( xDialogLib );
    1068             : 
    1069             :     // Set resource property
    1070           0 :     if( !xStringResourceManager.is() || xStringResourceManager->getLocales().getLength() == 0 )
    1071             :         return;
    1072             : 
    1073           0 :     OUString aDialogName = pDlgWin->GetName();
    1074             :     implHandleControlResourceProperties
    1075             :         ( aControlAny, aDialogName, aCtrlName, xStringResourceManager,
    1076           0 :           xSourceStringResolver, MOVE_RESOURCES );
    1077             : }
    1078             : 
    1079           0 : void LocalizationMgr::copyResourceForDroppedDialog( Reference< container::XNameContainer > xDialogModel,
    1080             :     const OUString& aDialogName, Reference< XStringResourceManager > xStringResourceManager,
    1081             :     Reference< XStringResourceResolver > xSourceStringResolver )
    1082             : {
    1083           0 :     if( !xStringResourceManager.is() )
    1084           0 :         return;
    1085             : 
    1086             :     // Dialog as control
    1087           0 :     OUString aDummyName;
    1088           0 :     Any aDialogCtrl;
    1089           0 :     aDialogCtrl <<= xDialogModel;
    1090             :     implHandleControlResourceProperties( aDialogCtrl, aDialogName,
    1091           0 :         aDummyName, xStringResourceManager, xSourceStringResolver, MOVE_RESOURCES );
    1092             : 
    1093             :     // Handle all controls
    1094           0 :     Sequence< OUString > aNames = xDialogModel->getElementNames();
    1095           0 :     const OUString* pNames = aNames.getConstArray();
    1096           0 :     sal_Int32 nCtrls = aNames.getLength();
    1097           0 :     for( sal_Int32 i = 0 ; i < nCtrls ; ++i )
    1098             :     {
    1099           0 :         OUString aCtrlName( pNames[i] );
    1100           0 :         Any aCtrl = xDialogModel->getByName( aCtrlName );
    1101             :         implHandleControlResourceProperties( aCtrl, aDialogName,
    1102           0 :             aCtrlName, xStringResourceManager, xSourceStringResolver, MOVE_RESOURCES );
    1103           0 :     }
    1104             : }
    1105             : 
    1106           0 : void LocalizationMgr::copyResourceForDialog(
    1107             :     const Reference< container::XNameContainer >& xDialogModel,
    1108             :     const Reference< XStringResourceResolver >& xSourceStringResolver,
    1109             :     const Reference< XStringResourceManager >& xTargetStringResourceManager )
    1110             : {
    1111           0 :     if( !xDialogModel.is() || !xSourceStringResolver.is() || !xTargetStringResourceManager.is() )
    1112           0 :         return;
    1113             : 
    1114           0 :     OUString aDummyName;
    1115           0 :     Any aDialogCtrl;
    1116           0 :     aDialogCtrl <<= xDialogModel;
    1117             :     implHandleControlResourceProperties
    1118             :         ( aDialogCtrl, aDummyName, aDummyName, xTargetStringResourceManager,
    1119           0 :           xSourceStringResolver, COPY_RESOURCES );
    1120             : 
    1121             :     // Handle all controls
    1122           0 :     Sequence< OUString > aNames = xDialogModel->getElementNames();
    1123           0 :     const OUString* pNames = aNames.getConstArray();
    1124           0 :     sal_Int32 nCtrls = aNames.getLength();
    1125           0 :     for( sal_Int32 i = 0 ; i < nCtrls ; ++i )
    1126             :     {
    1127           0 :         OUString aCtrlName( pNames[i] );
    1128           0 :         Any aCtrl = xDialogModel->getByName( aCtrlName );
    1129             :         implHandleControlResourceProperties( aCtrl, aDummyName, aDummyName,
    1130           0 :             xTargetStringResourceManager, xSourceStringResolver, COPY_RESOURCES );
    1131           0 :     }
    1132             : }
    1133             : 
    1134           0 : Reference< XStringResourceManager > LocalizationMgr::getStringResourceFromDialogLibrary
    1135             :     ( Reference< container::XNameContainer > xDialogLib )
    1136             : {
    1137           0 :     Reference< XStringResourceManager > xStringResourceManager;
    1138           0 :     if( xDialogLib.is() )
    1139             :     {
    1140           0 :         Reference< resource::XStringResourceSupplier > xStringResourceSupplier( xDialogLib, UNO_QUERY );
    1141           0 :         if( xStringResourceSupplier.is() )
    1142             :         {
    1143             :             Reference< resource::XStringResourceResolver >
    1144           0 :                 xStringResourceResolver = xStringResourceSupplier->getStringResource();
    1145             : 
    1146             :             xStringResourceManager =
    1147           0 :                 Reference< resource::XStringResourceManager >( xStringResourceResolver, UNO_QUERY );
    1148           0 :         }
    1149             :     }
    1150           0 :     return xStringResourceManager;
    1151             : }
    1152             : 
    1153           0 : } // namespace basctl
    1154             : 
    1155             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10