2000-10-24 10:56:40 +00:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
|
|
|
* $RCSfile: moduleoptions.cxx,v $
|
|
|
|
*
|
2001-08-22 12:06:35 +00:00
|
|
|
* $Revision: 1.8 $
|
2000-10-24 10:56:40 +00:00
|
|
|
*
|
2001-08-22 12:06:35 +00:00
|
|
|
* last change: $Author: as $ $Date: 2001-08-22 13:00:34 $
|
2000-10-24 10:56:40 +00:00
|
|
|
*
|
|
|
|
* The Contents of this file are made available subject to the terms of
|
|
|
|
* either of the following licenses
|
|
|
|
*
|
|
|
|
* - GNU Lesser General Public License Version 2.1
|
|
|
|
* - Sun Industry Standards Source License Version 1.1
|
|
|
|
*
|
|
|
|
* Sun Microsystems Inc., October, 2000
|
|
|
|
*
|
|
|
|
* GNU Lesser General Public License Version 2.1
|
|
|
|
* =============================================
|
|
|
|
* Copyright 2000 by Sun Microsystems, Inc.
|
|
|
|
* 901 San Antonio Road, Palo Alto, CA 94303, USA
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License version 2.1, as published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
|
|
|
* MA 02111-1307 USA
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* Sun Industry Standards Source License Version 1.1
|
|
|
|
* =================================================
|
|
|
|
* The contents of this file are subject to the Sun Industry Standards
|
|
|
|
* Source License Version 1.1 (the "License"); You may not use this file
|
|
|
|
* except in compliance with the License. You may obtain a copy of the
|
|
|
|
* License at http://www.openoffice.org/license.html.
|
|
|
|
*
|
|
|
|
* Software provided under this License is provided on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
|
|
|
|
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
|
|
|
|
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
|
|
|
|
* See the License for the specific provisions governing your rights and
|
|
|
|
* obligations concerning the Software.
|
|
|
|
*
|
|
|
|
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
|
|
|
|
*
|
|
|
|
* Copyright: 2000 by Sun Microsystems, Inc.
|
|
|
|
*
|
|
|
|
* All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Contributor(s): _______________________________________
|
|
|
|
*
|
|
|
|
*
|
|
|
|
************************************************************************/
|
|
|
|
|
|
|
|
#pragma hdrstop
|
|
|
|
|
|
|
|
//_________________________________________________________________________________________________________________
|
|
|
|
// includes
|
|
|
|
//_________________________________________________________________________________________________________________
|
|
|
|
|
|
|
|
#include "moduleoptions.hxx"
|
|
|
|
|
|
|
|
#ifndef _UTL_CONFIGMGR_HXX_
|
|
|
|
#include <unotools/configmgr.hxx>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef _UTL_CONFIGITEM_HXX_
|
|
|
|
#include <unotools/configitem.hxx>
|
|
|
|
#endif
|
|
|
|
|
2001-08-22 12:06:35 +00:00
|
|
|
#ifndef _OSL_DIAGNOSE_H_
|
|
|
|
#include <osl/diagnose.h>
|
2000-10-24 10:56:40 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef _COM_SUN_STAR_UNO_ANY_HXX_
|
|
|
|
#include <com/sun/star/uno/Any.hxx>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef _COM_SUN_STAR_UNO_SEQUENCE_HXX_
|
|
|
|
#include <com/sun/star/uno/Sequence.hxx>
|
|
|
|
#endif
|
|
|
|
|
2001-08-22 12:06:35 +00:00
|
|
|
#ifndef _COM_SUN_STAR_BEANS_PROPERTYVALUE_HPP_
|
|
|
|
#include <com/sun/star/beans/PropertyValue.hpp>
|
2000-11-01 11:01:31 +00:00
|
|
|
#endif
|
|
|
|
|
2000-10-24 10:56:40 +00:00
|
|
|
//_________________________________________________________________________________________________________________
|
|
|
|
// namespaces
|
|
|
|
//_________________________________________________________________________________________________________________
|
|
|
|
|
2001-08-22 12:06:35 +00:00
|
|
|
#ifdef css
|
|
|
|
#error "Who defined css? I use it as namespace value ...!"
|
|
|
|
#else
|
|
|
|
#define css ::com::sun::star
|
|
|
|
#endif
|
2000-10-24 10:56:40 +00:00
|
|
|
|
|
|
|
//_________________________________________________________________________________________________________________
|
|
|
|
// const
|
|
|
|
//_________________________________________________________________________________________________________________
|
|
|
|
|
2000-11-01 11:01:31 +00:00
|
|
|
/*-************************************************************************************************************//**
|
2001-08-22 12:06:35 +00:00
|
|
|
@descr These values are used to define neccessary keys from our configuration management to support
|
|
|
|
all functionality of these implementation.
|
2000-11-01 11:01:31 +00:00
|
|
|
It's a fast way to make changes if some keys change his name or location!
|
|
|
|
|
2001-08-22 12:06:35 +00:00
|
|
|
Property handle are neccessary to specify right position in return list of configuration
|
2000-11-01 11:01:31 +00:00
|
|
|
for asked values. We ask it with a list of properties to get his values. The returned list
|
2001-08-22 12:06:35 +00:00
|
|
|
has the same order like our given name list!
|
|
|
|
e.g.:
|
|
|
|
NAMELIST[ PROPERTYHANDLE_xxx ] => VALUELIST[ PROPERTYHANDLE_xxx ]
|
2000-11-01 11:01:31 +00:00
|
|
|
*//*-*************************************************************************************************************/
|
2001-08-22 12:06:35 +00:00
|
|
|
#define ROOTNODE_FACTORIES ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Setup/Office/Factories" ))
|
|
|
|
#define PATHSEPERATOR ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/" ))
|
|
|
|
|
|
|
|
#define PROPERTYNAME_SHORTNAME ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ooSetupFactoryShortName" ))
|
|
|
|
#define PROPERTYNAME_TEMPLATEFILE ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ooSetupFactoryTemplateFile" ))
|
|
|
|
#define PROPERTYNAME_WINDOWATTRIBUTES ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ooSetupFactoryWindowAttributes"))
|
|
|
|
#define PROPERTYNAME_EMPTYDOCUMENTURL ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ooSetupFactoryEmptyDocumentURL"))
|
|
|
|
#define PROPERTYNAME_ICON ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ooSetupFactoryIcon" ))
|
|
|
|
|
|
|
|
#define PROPERTYHANDLE_SHORTNAME 0
|
|
|
|
#define PROPERTYHANDLE_TEMPLATEFILE 1
|
|
|
|
#define PROPERTYHANDLE_WINDOWATTRIBUTES 2
|
|
|
|
#define PROPERTYHANDLE_EMPTYDOCUMENTURL 3
|
|
|
|
#define PROPERTYHANDLE_ICON 4
|
|
|
|
|
|
|
|
#define PROPERTYCOUNT 5
|
|
|
|
|
|
|
|
#define FACTORYNAME_WRITER ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.TextDocument" ))
|
|
|
|
#define FACTORYNAME_WRITERWEB ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.WebDocument" ))
|
|
|
|
#define FACTORYNAME_WRITERGLOBAL ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.GlobalDocument" ))
|
|
|
|
#define FACTORYNAME_CALC ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sheet.SpreadsheetDocument" ))
|
|
|
|
#define FACTORYNAME_DRAW ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.DrawingDocument" ))
|
|
|
|
#define FACTORYNAME_IMPRESS ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.PresentationDocument"))
|
|
|
|
#define FACTORYNAME_MATH ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.formula.FormulaProperties" ))
|
|
|
|
#define FACTORYNAME_CHART ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.chart.ChartDocument" ))
|
|
|
|
|
|
|
|
#define FACTORYCOUNT 8
|
2000-11-01 11:01:31 +00:00
|
|
|
|
|
|
|
/*-************************************************************************************************************//**
|
2001-08-22 12:06:35 +00:00
|
|
|
@descr This struct hold information about one factory. We declare a complete array which can hold infos
|
|
|
|
for all well known factories. Values of enum "EFactory" (see header!) are directly used as index!
|
|
|
|
So we can support a fast access on these informations.
|
2000-11-01 11:01:31 +00:00
|
|
|
*//*-*************************************************************************************************************/
|
2001-08-22 12:06:35 +00:00
|
|
|
struct FactoryInfo
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
// initialize empty struct
|
|
|
|
FactoryInfo()
|
|
|
|
{
|
|
|
|
free();
|
|
|
|
}
|
2000-11-01 11:01:31 +00:00
|
|
|
|
2001-08-22 12:06:35 +00:00
|
|
|
// easy way to reset struct member!
|
|
|
|
void free()
|
|
|
|
{
|
|
|
|
bInstalled = sal_False ;
|
|
|
|
sFactory = ::rtl::OUString() ;
|
|
|
|
sShortName = ::rtl::OUString() ;
|
|
|
|
sTemplateFile = ::rtl::OUString() ;
|
|
|
|
sWindowAttributes = ::rtl::OUString() ;
|
|
|
|
sEmptyDocumentURL = ::rtl::OUString() ;
|
|
|
|
nIcon = 0 ;
|
|
|
|
}
|
2000-11-01 11:01:31 +00:00
|
|
|
|
2001-08-22 12:06:35 +00:00
|
|
|
public:
|
|
|
|
sal_Bool bInstalled ;
|
|
|
|
::rtl::OUString sFactory ;
|
|
|
|
::rtl::OUString sShortName ;
|
|
|
|
::rtl::OUString sTemplateFile ;
|
|
|
|
::rtl::OUString sWindowAttributes ;
|
|
|
|
::rtl::OUString sEmptyDocumentURL ;
|
|
|
|
sal_Int32 nIcon ;
|
|
|
|
};
|
2000-11-01 11:01:31 +00:00
|
|
|
|
2001-08-22 12:06:35 +00:00
|
|
|
typedef FactoryInfo FactoryInfoList[FACTORYCOUNT];
|
2000-11-01 11:01:31 +00:00
|
|
|
|
|
|
|
/*-************************************************************************************************************//**
|
2001-08-22 12:06:35 +00:00
|
|
|
@short IMPL data container for wrapper class SvtModulOptions!
|
|
|
|
@descr These class is used as a static data container of class SvtModuleOptions. The hold it by using
|
|
|
|
a refcount and make it threadsafe by using an osl mutex. So we don't must do anything for that.
|
|
|
|
We can implement pure functionality to read/write configuration data only.
|
2000-11-01 11:01:31 +00:00
|
|
|
|
2001-08-22 12:06:35 +00:00
|
|
|
@implements -
|
|
|
|
@base ConfigItem
|
2000-10-24 10:56:40 +00:00
|
|
|
|
2001-08-22 12:06:35 +00:00
|
|
|
@devstatus ready to use
|
|
|
|
@threadsafe no
|
|
|
|
*//*-*************************************************************************************************************/
|
|
|
|
class SvtModuleOptions_Impl : public ::utl::ConfigItem
|
2000-10-24 10:56:40 +00:00
|
|
|
{
|
|
|
|
//-------------------------------------------------------------------------------------------------------------
|
|
|
|
// public methods
|
|
|
|
//-------------------------------------------------------------------------------------------------------------
|
|
|
|
public:
|
|
|
|
//---------------------------------------------------------------------------------------------------------
|
|
|
|
// constructor / destructor
|
|
|
|
//---------------------------------------------------------------------------------------------------------
|
|
|
|
SvtModuleOptions_Impl();
|
|
|
|
~SvtModuleOptions_Impl();
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------
|
|
|
|
// overloaded methods of baseclass
|
|
|
|
//---------------------------------------------------------------------------------------------------------
|
2001-08-22 12:06:35 +00:00
|
|
|
virtual void Notify( const css::uno::Sequence< ::rtl::OUString >& lPropertyNames );
|
|
|
|
virtual void Commit( );
|
2000-10-24 10:56:40 +00:00
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------
|
|
|
|
// public interface
|
|
|
|
//---------------------------------------------------------------------------------------------------------
|
2001-08-22 12:06:35 +00:00
|
|
|
sal_Bool IsModuleInstalled ( SvtModuleOptions::EModule eModule ) const;
|
|
|
|
::rtl::OUString GetFactoryName ( SvtModuleOptions::EFactory eFactory ) const;
|
|
|
|
::rtl::OUString GetFactoryShortName ( SvtModuleOptions::EFactory eFactory ) const;
|
|
|
|
::rtl::OUString GetFactoryStandardTemplate( SvtModuleOptions::EFactory eFactory ) const;
|
|
|
|
::rtl::OUString GetFactoryWindowAttributes( SvtModuleOptions::EFactory eFactory ) const;
|
|
|
|
::rtl::OUString GetFactoryEmptyDocumentURL( SvtModuleOptions::EFactory eFactory ) const;
|
|
|
|
sal_Int32 GetFactoryIcon ( SvtModuleOptions::EFactory eFactory ) const;
|
|
|
|
static sal_Bool ClassifyFactoryByName ( const ::rtl::OUString& sName ,
|
|
|
|
SvtModuleOptions::EFactory& eFactory );
|
|
|
|
void SetFactoryStandardTemplate( SvtModuleOptions::EFactory eFactory ,
|
|
|
|
const ::rtl::OUString& sTemplate );
|
|
|
|
void SetFactoryWindowAttributes( SvtModuleOptions::EFactory eFactory ,
|
|
|
|
const ::rtl::OUString& sAttributes);
|
2000-10-24 10:56:40 +00:00
|
|
|
|
|
|
|
//-------------------------------------------------------------------------------------------------------------
|
|
|
|
// private methods
|
|
|
|
//-------------------------------------------------------------------------------------------------------------
|
|
|
|
private:
|
2001-08-22 12:06:35 +00:00
|
|
|
static css::uno::Sequence< ::rtl::OUString > impl_ExpandSetNames ( const css::uno::Sequence< ::rtl::OUString >& lSetNames );
|
|
|
|
void impl_Read ( const css::uno::Sequence< ::rtl::OUString >& lSetNames );
|
2000-10-24 10:56:40 +00:00
|
|
|
|
2001-08-22 12:06:35 +00:00
|
|
|
//-------------------------------------------------------------------------------------------------------------
|
|
|
|
// private types
|
|
|
|
//-------------------------------------------------------------------------------------------------------------
|
|
|
|
private:
|
2000-10-24 10:56:40 +00:00
|
|
|
|
|
|
|
//-------------------------------------------------------------------------------------------------------------
|
|
|
|
// private member
|
|
|
|
//-------------------------------------------------------------------------------------------------------------
|
|
|
|
private:
|
2001-08-22 12:06:35 +00:00
|
|
|
FactoryInfoList m_lFactories;
|
2000-10-24 10:56:40 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
//_________________________________________________________________________________________________________________
|
|
|
|
// definitions
|
|
|
|
//_________________________________________________________________________________________________________________
|
|
|
|
|
2001-08-22 12:06:35 +00:00
|
|
|
/*-************************************************************************************************************//**
|
|
|
|
@short default ctor
|
|
|
|
@descr We open our configuration here and read all neccessary values from it.
|
|
|
|
These values are cached till everyone call Commit(). Then we write changed ones back to cfg.
|
|
|
|
|
|
|
|
@seealso baseclass ConfigItem
|
|
|
|
@seealso method impl_Read()
|
|
|
|
|
|
|
|
@param -
|
|
|
|
@return -
|
|
|
|
|
|
|
|
@onerror -
|
|
|
|
@threadsafe no
|
|
|
|
*//*-*************************************************************************************************************/
|
2000-10-24 10:56:40 +00:00
|
|
|
SvtModuleOptions_Impl::SvtModuleOptions_Impl()
|
2001-08-22 12:06:35 +00:00
|
|
|
: ::utl::ConfigItem( ROOTNODE_FACTORIES )
|
2000-10-24 10:56:40 +00:00
|
|
|
{
|
2001-08-22 12:06:35 +00:00
|
|
|
// First initialize list of factory infos! Otherwise we couldnt gurantee right working of these class.
|
|
|
|
for( sal_Int32 nFactory=0; nFactory<FACTORYCOUNT; ++nFactory )
|
2001-06-22 12:06:16 +00:00
|
|
|
{
|
2001-08-22 12:06:35 +00:00
|
|
|
m_lFactories[nFactory].free();
|
|
|
|
}
|
2001-06-22 12:06:16 +00:00
|
|
|
|
2001-08-22 12:06:35 +00:00
|
|
|
// Get name list of all existing set node names in configuration to read her properties in impl_Read().
|
|
|
|
// These list is a list of long names of our factories.
|
|
|
|
const css::uno::Sequence< ::rtl::OUString > lFactories = GetNodeNames( ::rtl::OUString() );
|
|
|
|
impl_Read( lFactories );
|
2001-06-22 12:06:16 +00:00
|
|
|
|
2001-08-22 12:06:35 +00:00
|
|
|
// Enable notification for changes by using configuration directly.
|
|
|
|
// So we can update our internal values immediatly.
|
|
|
|
EnableNotification( lFactories );
|
|
|
|
}
|
2001-06-22 12:06:16 +00:00
|
|
|
|
2001-08-22 12:06:35 +00:00
|
|
|
/*-************************************************************************************************************//**
|
|
|
|
@short default dtor
|
|
|
|
@descr If any values of our cache was modified we should write it back to configuration.
|
2001-06-22 12:06:16 +00:00
|
|
|
|
2001-08-22 12:06:35 +00:00
|
|
|
@attention Don't forget to call "SetModified()" method of base class ConfigItem if any interface method
|
|
|
|
of this class modify internal member list m_lFactories! Otherwise Commit() will never be called!!!
|
2001-06-22 12:06:16 +00:00
|
|
|
|
2001-08-22 12:06:35 +00:00
|
|
|
@seealso baseclass ConfigItem
|
2001-06-22 12:06:16 +00:00
|
|
|
|
2001-08-22 12:06:35 +00:00
|
|
|
@param -
|
|
|
|
@return -
|
|
|
|
|
|
|
|
@onerror -
|
|
|
|
@threadsafe no
|
|
|
|
*//*-*************************************************************************************************************/
|
|
|
|
SvtModuleOptions_Impl::~SvtModuleOptions_Impl()
|
|
|
|
{
|
|
|
|
if( IsModified() == sal_True )
|
|
|
|
{
|
|
|
|
Commit();
|
2001-06-22 12:06:16 +00:00
|
|
|
}
|
2001-08-22 12:06:35 +00:00
|
|
|
}
|
2001-06-22 12:06:16 +00:00
|
|
|
|
2001-08-22 12:06:35 +00:00
|
|
|
/*-************************************************************************************************************//**
|
|
|
|
@short called for notify of configmanager
|
|
|
|
@descr These method is called from the ConfigManager before application ends or from the
|
|
|
|
PropertyChangeListener if the sub tree broadcasts changes. You must update our
|
|
|
|
internal values.
|
2000-10-24 10:56:40 +00:00
|
|
|
|
2001-08-22 12:06:35 +00:00
|
|
|
@attention We are registered for pure set node names only. So we can use our internal method "impl_Read()" to
|
|
|
|
update our info list. Because - these method expand given name list to full qualified property list
|
|
|
|
and use it to read the values. These values are filled into our internal member list m_lFactories
|
|
|
|
at right position.
|
|
|
|
|
|
|
|
@seealso method impl_Read()
|
|
|
|
|
|
|
|
@param "lNames" is the list of set node entries which should be updated.
|
|
|
|
@return -
|
|
|
|
|
|
|
|
@onerror -
|
|
|
|
@threadsafe no
|
|
|
|
*//*-*************************************************************************************************************/
|
|
|
|
void SvtModuleOptions_Impl::Notify( const css::uno::Sequence< ::rtl::OUString >& lNames )
|
|
|
|
{
|
|
|
|
impl_Read( lNames );
|
|
|
|
}
|
|
|
|
|
|
|
|
/*-****************************************************************************************************//**
|
|
|
|
@short write changes to configuration
|
|
|
|
@descr These method writes the changed values into the sub tree
|
|
|
|
and should always called in our destructor to guarantee consistency of config data.
|
|
|
|
|
|
|
|
@attention We clear complete set in configuration first and write it completly new! So we don't must
|
|
|
|
distinguish between existing, added or removed elements. Our internal cached values
|
|
|
|
are the only and right ones.
|
|
|
|
|
|
|
|
@seealso baseclass ConfigItem
|
|
|
|
|
|
|
|
@param -
|
|
|
|
@return -
|
2000-10-24 10:56:40 +00:00
|
|
|
|
2001-08-22 12:06:35 +00:00
|
|
|
@onerror -
|
|
|
|
@threadsafe no
|
|
|
|
*//*-*****************************************************************************************************/
|
|
|
|
void SvtModuleOptions_Impl::Commit()
|
|
|
|
{
|
|
|
|
// Clear whole cfg list.
|
|
|
|
ClearNodeSet( ::rtl::OUString() );
|
|
|
|
// Build complete list of all factories, her properties and values.
|
|
|
|
css::uno::Sequence< css::beans::PropertyValue > lProperties ( FACTORYCOUNT*PROPERTYCOUNT );
|
|
|
|
FactoryInfo* pInfo = NULL ;
|
|
|
|
sal_Int32 nPropertyStart = 0 ;
|
|
|
|
for( sal_Int32 nFactory=0; nFactory<FACTORYCOUNT; ++nFactory )
|
2000-10-24 10:56:40 +00:00
|
|
|
{
|
2001-08-22 12:06:35 +00:00
|
|
|
pInfo = &(m_lFactories[nFactory]);
|
|
|
|
|
|
|
|
if( pInfo->bInstalled == sal_True )
|
2000-10-24 10:56:40 +00:00
|
|
|
{
|
2001-08-22 12:06:35 +00:00
|
|
|
lProperties[nPropertyStart+PROPERTYHANDLE_SHORTNAME ].Name = PATHSEPERATOR + pInfo->sFactory + PATHSEPERATOR + PROPERTYNAME_SHORTNAME ;
|
|
|
|
lProperties[nPropertyStart+PROPERTYHANDLE_TEMPLATEFILE ].Name = PATHSEPERATOR + pInfo->sFactory + PATHSEPERATOR + PROPERTYNAME_TEMPLATEFILE ;
|
|
|
|
lProperties[nPropertyStart+PROPERTYHANDLE_WINDOWATTRIBUTES].Name = PATHSEPERATOR + pInfo->sFactory + PATHSEPERATOR + PROPERTYNAME_WINDOWATTRIBUTES;
|
|
|
|
lProperties[nPropertyStart+PROPERTYHANDLE_EMPTYDOCUMENTURL].Name = PATHSEPERATOR + pInfo->sFactory + PATHSEPERATOR + PROPERTYNAME_EMPTYDOCUMENTURL;
|
|
|
|
lProperties[nPropertyStart+PROPERTYHANDLE_ICON ].Name = PATHSEPERATOR + pInfo->sFactory + PATHSEPERATOR + PROPERTYNAME_ICON ;
|
|
|
|
|
|
|
|
lProperties[nPropertyStart+PROPERTYHANDLE_SHORTNAME ].Value <<= pInfo->sShortName ;
|
|
|
|
lProperties[nPropertyStart+PROPERTYHANDLE_TEMPLATEFILE ].Value <<= pInfo->sTemplateFile ;
|
|
|
|
lProperties[nPropertyStart+PROPERTYHANDLE_WINDOWATTRIBUTES].Value <<= pInfo->sWindowAttributes ;
|
|
|
|
lProperties[nPropertyStart+PROPERTYHANDLE_EMPTYDOCUMENTURL].Value <<= pInfo->sEmptyDocumentURL ;
|
|
|
|
lProperties[nPropertyStart+PROPERTYHANDLE_ICON ].Value <<= pInfo->nIcon ;
|
2000-10-24 10:56:40 +00:00
|
|
|
}
|
2001-08-22 12:06:35 +00:00
|
|
|
nPropertyStart += PROPERTYCOUNT;
|
2000-10-24 10:56:40 +00:00
|
|
|
}
|
2001-08-22 12:06:35 +00:00
|
|
|
// Write list to cfg.
|
|
|
|
SetSetProperties( ::rtl::OUString(), lProperties );
|
|
|
|
}
|
2000-11-01 11:01:31 +00:00
|
|
|
|
2001-08-22 12:06:35 +00:00
|
|
|
/*-****************************************************************************************************//**
|
|
|
|
@short access method to get internal values
|
|
|
|
@descr These methods implement easy access to our internal values.
|
|
|
|
You give us right enum value to specify which module interest you ... we return right information.
|
2000-11-03 08:45:51 +00:00
|
|
|
|
2001-08-22 12:06:35 +00:00
|
|
|
@attention Some poeple use any value as enum ... but we support in header specified values only!
|
|
|
|
We use it directly as index in our internal list. If enum value isn't right - we crash with an
|
|
|
|
"index out of range"!!! Please use me right - otherwise there is no guarantee.
|
2000-11-01 11:01:31 +00:00
|
|
|
|
2001-08-22 12:06:35 +00:00
|
|
|
@seealso -
|
2000-11-01 11:01:31 +00:00
|
|
|
|
2001-08-22 12:06:35 +00:00
|
|
|
@param "eModule" , index in list - specify module
|
|
|
|
@param "eFactory" , index in list - specify factory
|
|
|
|
@param "sTemplate", set new standard template for these factory
|
|
|
|
@return Queried information.
|
2001-05-25 09:44:06 +00:00
|
|
|
|
2001-08-22 12:06:35 +00:00
|
|
|
@onerror We return default values. (mostly "not installed"!)
|
|
|
|
@threadsafe no
|
|
|
|
*//*-*****************************************************************************************************/
|
|
|
|
sal_Bool SvtModuleOptions_Impl::IsModuleInstalled( SvtModuleOptions::EModule eModule ) const
|
|
|
|
{
|
|
|
|
sal_Bool bInstalled = sal_False;
|
|
|
|
switch( eModule )
|
|
|
|
{
|
|
|
|
case SvtModuleOptions::E_SWRITER : {
|
|
|
|
// Module writer knows more then one factory!
|
|
|
|
bInstalled = (
|
|
|
|
( m_lFactories[SvtModuleOptions::E_WRITER ].bInstalled == sal_True ) ||
|
|
|
|
( m_lFactories[SvtModuleOptions::E_WRITERWEB ].bInstalled == sal_True ) ||
|
|
|
|
( m_lFactories[SvtModuleOptions::E_WRITERGLOBAL].bInstalled == sal_True )
|
|
|
|
);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case SvtModuleOptions::E_SCALC : bInstalled = m_lFactories[SvtModuleOptions::E_CALC].bInstalled;
|
|
|
|
break;
|
|
|
|
case SvtModuleOptions::E_SDRAW : bInstalled = m_lFactories[SvtModuleOptions::E_DRAW].bInstalled;
|
|
|
|
break;
|
|
|
|
case SvtModuleOptions::E_SIMPRESS : bInstalled = m_lFactories[SvtModuleOptions::E_IMPRESS].bInstalled;
|
|
|
|
break;
|
|
|
|
case SvtModuleOptions::E_SMATH : bInstalled = m_lFactories[SvtModuleOptions::E_MATH].bInstalled;
|
|
|
|
break;
|
|
|
|
case SvtModuleOptions::E_SCHART : bInstalled = m_lFactories[SvtModuleOptions::E_CHART].bInstalled;
|
|
|
|
break;
|
|
|
|
case SvtModuleOptions::E_SBASIC : bInstalled = sal_True; // Couldn't be deselected by setup yet!
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return bInstalled;
|
2000-10-24 10:56:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//*****************************************************************************************************************
|
2001-08-22 12:06:35 +00:00
|
|
|
::rtl::OUString SvtModuleOptions_Impl::GetFactoryName( SvtModuleOptions::EFactory eFactory ) const
|
2000-10-24 10:56:40 +00:00
|
|
|
{
|
2001-08-22 12:06:35 +00:00
|
|
|
::rtl::OUString sName;
|
2000-11-01 11:01:31 +00:00
|
|
|
|
2001-08-22 12:06:35 +00:00
|
|
|
if( eFactory>=0 && eFactory<FACTORYCOUNT )
|
2000-11-01 11:01:31 +00:00
|
|
|
{
|
2001-08-22 12:06:35 +00:00
|
|
|
sName = m_lFactories[eFactory].sFactory;
|
2000-11-01 11:01:31 +00:00
|
|
|
}
|
|
|
|
|
2001-08-22 12:06:35 +00:00
|
|
|
return sName;
|
2000-11-01 11:01:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//*****************************************************************************************************************
|
2001-08-22 12:06:35 +00:00
|
|
|
::rtl::OUString SvtModuleOptions_Impl::GetFactoryShortName( SvtModuleOptions::EFactory eFactory ) const
|
|
|
|
{
|
|
|
|
// Attention: Hard configured yet ... because it's not fine to make changes possible by xml file yet.
|
|
|
|
// But it's good to plan further possibilities!
|
|
|
|
|
|
|
|
//return m_lFactories[eFactory].sShortName;
|
|
|
|
|
|
|
|
::rtl::OUString sShortName;
|
|
|
|
switch( eFactory )
|
|
|
|
{
|
|
|
|
case SvtModuleOptions::E_WRITER : sShortName = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("swriter"));
|
|
|
|
break;
|
|
|
|
case SvtModuleOptions::E_WRITERWEB : sShortName = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("swriter/web"));
|
|
|
|
break;
|
|
|
|
case SvtModuleOptions::E_WRITERGLOBAL : sShortName = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("swriter/GlobalDocument"));
|
|
|
|
break;
|
|
|
|
case SvtModuleOptions::E_CALC : sShortName = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("scalc"));
|
|
|
|
break;
|
|
|
|
case SvtModuleOptions::E_DRAW : sShortName = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("sdraw"));
|
|
|
|
break;
|
|
|
|
case SvtModuleOptions::E_IMPRESS : sShortName = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("simpress"));
|
|
|
|
break;
|
|
|
|
case SvtModuleOptions::E_MATH : sShortName = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("smath"));
|
|
|
|
break;
|
|
|
|
case SvtModuleOptions::E_CHART : sShortName = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("schart"));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return sShortName;
|
|
|
|
}
|
|
|
|
|
2000-11-01 11:01:31 +00:00
|
|
|
//*****************************************************************************************************************
|
2001-08-22 12:06:35 +00:00
|
|
|
::rtl::OUString SvtModuleOptions_Impl::GetFactoryStandardTemplate( SvtModuleOptions::EFactory eFactory ) const
|
2000-11-01 11:01:31 +00:00
|
|
|
{
|
2001-08-22 12:06:35 +00:00
|
|
|
::rtl::OUString sFile;
|
|
|
|
|
|
|
|
if( eFactory>=0 && eFactory<FACTORYCOUNT )
|
2000-11-01 11:01:31 +00:00
|
|
|
{
|
2001-08-22 12:06:35 +00:00
|
|
|
sFile = m_lFactories[eFactory].sTemplateFile;
|
2000-11-01 11:01:31 +00:00
|
|
|
}
|
2001-08-22 12:06:35 +00:00
|
|
|
|
|
|
|
return sFile;
|
2000-11-01 11:01:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//*****************************************************************************************************************
|
2001-08-22 12:06:35 +00:00
|
|
|
::rtl::OUString SvtModuleOptions_Impl::GetFactoryWindowAttributes( SvtModuleOptions::EFactory eFactory ) const
|
2000-11-01 11:01:31 +00:00
|
|
|
{
|
2001-08-22 12:06:35 +00:00
|
|
|
::rtl::OUString sAttributes;
|
|
|
|
|
|
|
|
if( eFactory>=0 && eFactory<FACTORYCOUNT )
|
2000-11-01 11:01:31 +00:00
|
|
|
{
|
2001-08-22 12:06:35 +00:00
|
|
|
sAttributes = m_lFactories[eFactory].sWindowAttributes;
|
2000-11-01 11:01:31 +00:00
|
|
|
}
|
2001-08-22 12:06:35 +00:00
|
|
|
|
|
|
|
return sAttributes;
|
2000-11-01 11:01:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//*****************************************************************************************************************
|
2001-08-22 12:06:35 +00:00
|
|
|
::rtl::OUString SvtModuleOptions_Impl::GetFactoryEmptyDocumentURL( SvtModuleOptions::EFactory eFactory ) const
|
|
|
|
{
|
|
|
|
// Attention: Hard configured yet ... because it's not fine to make changes possible by xml file yet.
|
|
|
|
// But it's good to plan further possibilities!
|
|
|
|
|
|
|
|
//return m_lFactories[eFactory].sEmptyDocumentURL;
|
|
|
|
|
|
|
|
::rtl::OUString sURL;
|
|
|
|
switch( eFactory )
|
|
|
|
{
|
|
|
|
case SvtModuleOptions::E_WRITER : sURL = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("private:factory/swriter"));
|
|
|
|
break;
|
|
|
|
case SvtModuleOptions::E_WRITERWEB : sURL = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("private:factory/swriter/web"));
|
|
|
|
break;
|
|
|
|
case SvtModuleOptions::E_WRITERGLOBAL : sURL = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("private:factory/swriter/GlobalDocument"));
|
|
|
|
break;
|
|
|
|
case SvtModuleOptions::E_CALC : sURL = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("private:factory/scalc"));
|
|
|
|
break;
|
|
|
|
case SvtModuleOptions::E_DRAW : sURL = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("private:factory/sdraw"));
|
|
|
|
break;
|
|
|
|
case SvtModuleOptions::E_IMPRESS : sURL = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("private:factory/simpress"));
|
|
|
|
break;
|
|
|
|
case SvtModuleOptions::E_MATH : sURL = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("private:factory/smath"));
|
|
|
|
break;
|
|
|
|
case SvtModuleOptions::E_CHART : sURL = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("private:factory/schart"));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return sURL;
|
|
|
|
}
|
|
|
|
|
2000-11-01 11:01:31 +00:00
|
|
|
//*****************************************************************************************************************
|
2001-08-22 12:06:35 +00:00
|
|
|
sal_Int32 SvtModuleOptions_Impl::GetFactoryIcon( SvtModuleOptions::EFactory eFactory ) const
|
2000-11-01 11:01:31 +00:00
|
|
|
{
|
2001-08-22 12:06:35 +00:00
|
|
|
sal_Int32 nIcon = 0;
|
|
|
|
|
|
|
|
if( eFactory>=0 && eFactory<FACTORYCOUNT )
|
2000-11-01 11:01:31 +00:00
|
|
|
{
|
2001-08-22 12:06:35 +00:00
|
|
|
nIcon = m_lFactories[eFactory].nIcon;
|
2000-11-01 11:01:31 +00:00
|
|
|
}
|
2001-08-22 12:06:35 +00:00
|
|
|
|
|
|
|
return nIcon;
|
2000-11-01 11:01:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//*****************************************************************************************************************
|
2001-08-22 12:06:35 +00:00
|
|
|
void SvtModuleOptions_Impl::SetFactoryStandardTemplate( SvtModuleOptions::EFactory eFactory ,
|
|
|
|
const ::rtl::OUString& sTemplate )
|
2000-11-01 11:01:31 +00:00
|
|
|
{
|
2001-08-22 12:06:35 +00:00
|
|
|
if( eFactory>=0 && eFactory<FACTORYCOUNT )
|
2000-11-01 11:01:31 +00:00
|
|
|
{
|
2001-08-22 12:06:35 +00:00
|
|
|
m_lFactories[eFactory].sTemplateFile = sTemplate;
|
|
|
|
SetModified();
|
2000-11-01 11:01:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//*****************************************************************************************************************
|
2001-08-22 12:06:35 +00:00
|
|
|
void SvtModuleOptions_Impl::SetFactoryWindowAttributes( SvtModuleOptions::EFactory eFactory ,
|
|
|
|
const ::rtl::OUString& sAttributes)
|
2000-11-01 11:01:31 +00:00
|
|
|
{
|
2001-08-22 12:06:35 +00:00
|
|
|
if( eFactory>=0 && eFactory<FACTORYCOUNT )
|
2000-11-01 11:01:31 +00:00
|
|
|
{
|
2001-08-22 12:06:35 +00:00
|
|
|
m_lFactories[eFactory].sWindowAttributes = sAttributes;
|
|
|
|
SetModified();
|
2000-11-01 11:01:31 +00:00
|
|
|
}
|
2001-08-22 12:06:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*-************************************************************************************************************//**
|
|
|
|
@short return list of key names of ouer configuration management which represent our module tree
|
|
|
|
@descr You give use a list of current existing set node names .. and we expand it for all
|
|
|
|
well known properties which are neccessary for this implementation.
|
|
|
|
These full expanded list should be used to get values of this properties.
|
|
|
|
|
|
|
|
@seealso ctor
|
|
|
|
|
|
|
|
@param -
|
|
|
|
@return List of all relative addressed properties of given set entry names.
|
|
|
|
|
|
|
|
@onerror List will be empty.
|
|
|
|
@threadsafe no
|
|
|
|
*//*-*************************************************************************************************************/
|
|
|
|
css::uno::Sequence< ::rtl::OUString > SvtModuleOptions_Impl::impl_ExpandSetNames( const css::uno::Sequence< ::rtl::OUString >& lSetNames )
|
|
|
|
{
|
|
|
|
sal_Int32 nCount = lSetNames.getLength() ;
|
|
|
|
css::uno::Sequence< ::rtl::OUString > lPropNames ( nCount*PROPERTYCOUNT );
|
|
|
|
sal_Int32 nPropStart = 0 ;
|
|
|
|
|
|
|
|
for( sal_Int32 nName=0; nName<nCount; ++nName )
|
2000-11-01 11:01:31 +00:00
|
|
|
{
|
2001-08-22 12:06:35 +00:00
|
|
|
lPropNames[nPropStart+PROPERTYHANDLE_SHORTNAME ] = lSetNames[nName] + PATHSEPERATOR + PROPERTYNAME_SHORTNAME ;
|
|
|
|
lPropNames[nPropStart+PROPERTYHANDLE_TEMPLATEFILE ] = lSetNames[nName] + PATHSEPERATOR + PROPERTYNAME_TEMPLATEFILE ;
|
|
|
|
lPropNames[nPropStart+PROPERTYHANDLE_WINDOWATTRIBUTES] = lSetNames[nName] + PATHSEPERATOR + PROPERTYNAME_WINDOWATTRIBUTES;
|
|
|
|
lPropNames[nPropStart+PROPERTYHANDLE_EMPTYDOCUMENTURL] = lSetNames[nName] + PATHSEPERATOR + PROPERTYNAME_EMPTYDOCUMENTURL;
|
|
|
|
lPropNames[nPropStart+PROPERTYHANDLE_ICON ] = lSetNames[nName] + PATHSEPERATOR + PROPERTYNAME_ICON ;
|
|
|
|
nPropStart += PROPERTYCOUNT;
|
2000-11-01 11:01:31 +00:00
|
|
|
}
|
2001-08-22 12:06:35 +00:00
|
|
|
|
|
|
|
return lPropNames;
|
2000-11-01 11:01:31 +00:00
|
|
|
}
|
|
|
|
|
2001-08-22 12:06:35 +00:00
|
|
|
/*-************************************************************************************************************//**
|
|
|
|
@short helper to classify given factory by name
|
|
|
|
@descr Every factory has his own long and short name. So we can match right enum value for internal using.
|
|
|
|
|
|
|
|
@attention We change in/out parameter "eFactory" in every case! But you should use it only, if return value is TRUE!
|
|
|
|
Algorithm: Set out-parameter to propably value ... and check the longname.
|
|
|
|
If it match with these factory - break operation and return true AND right set parameter.
|
|
|
|
Otherwise try next one and so on. If no factory was found return false. Out parameter eFactory
|
|
|
|
is set to last tried value but shouldn't be used! Because our return value is false!
|
|
|
|
|
|
|
|
@seealso -
|
|
|
|
|
|
|
|
@param "sLongName" , long name of factory, which should be classified
|
|
|
|
@return "eFactory" , right enum value, which match given long name
|
|
|
|
and true for successfully classification, false otherwise
|
|
|
|
|
|
|
|
@onerror We return false.
|
|
|
|
@threadsafe no
|
|
|
|
*//*-*************************************************************************************************************/
|
|
|
|
sal_Bool SvtModuleOptions_Impl::ClassifyFactoryByName( const ::rtl::OUString& sName, SvtModuleOptions::EFactory& eFactory )
|
2000-11-01 11:01:31 +00:00
|
|
|
{
|
2001-08-22 12:06:35 +00:00
|
|
|
sal_Bool bState;
|
|
|
|
|
|
|
|
eFactory = SvtModuleOptions::E_WRITER ;
|
|
|
|
bState = ( sName == FACTORYNAME_WRITER );
|
|
|
|
|
|
|
|
if( bState == sal_False )
|
2000-11-01 11:01:31 +00:00
|
|
|
{
|
2001-08-22 12:06:35 +00:00
|
|
|
eFactory = SvtModuleOptions::E_WRITERWEB ;
|
|
|
|
bState = ( sName == FACTORYNAME_WRITERWEB );
|
2000-11-01 11:01:31 +00:00
|
|
|
}
|
2001-08-22 12:06:35 +00:00
|
|
|
// no else!
|
|
|
|
if( bState == sal_False )
|
2000-11-01 11:01:31 +00:00
|
|
|
{
|
2001-08-22 12:06:35 +00:00
|
|
|
eFactory = SvtModuleOptions::E_WRITERGLOBAL ;
|
|
|
|
bState = ( sName == FACTORYNAME_WRITERGLOBAL );
|
2000-11-01 11:01:31 +00:00
|
|
|
}
|
2001-08-22 12:06:35 +00:00
|
|
|
// no else!
|
|
|
|
if( bState == sal_False )
|
2000-11-03 08:45:51 +00:00
|
|
|
{
|
2001-08-22 12:06:35 +00:00
|
|
|
eFactory = SvtModuleOptions::E_CALC ;
|
|
|
|
bState = ( sName == FACTORYNAME_CALC );
|
2000-11-03 08:45:51 +00:00
|
|
|
}
|
2001-08-22 12:06:35 +00:00
|
|
|
// no else!
|
|
|
|
if( bState == sal_False )
|
2000-11-03 08:45:51 +00:00
|
|
|
{
|
2001-08-22 12:06:35 +00:00
|
|
|
eFactory = SvtModuleOptions::E_DRAW ;
|
|
|
|
bState = ( sName == FACTORYNAME_DRAW );
|
2000-11-03 08:45:51 +00:00
|
|
|
}
|
2001-08-22 12:06:35 +00:00
|
|
|
// no else!
|
|
|
|
if( bState == sal_False )
|
2000-11-01 11:01:31 +00:00
|
|
|
{
|
2001-08-22 12:06:35 +00:00
|
|
|
eFactory = SvtModuleOptions::E_IMPRESS ;
|
|
|
|
bState = ( sName == FACTORYNAME_IMPRESS );
|
2000-11-01 11:01:31 +00:00
|
|
|
}
|
2001-08-22 12:06:35 +00:00
|
|
|
// no else!
|
|
|
|
if( bState == sal_False )
|
2000-11-01 11:01:31 +00:00
|
|
|
{
|
2001-08-22 12:06:35 +00:00
|
|
|
eFactory = SvtModuleOptions::E_MATH ;
|
|
|
|
bState = ( sName == FACTORYNAME_MATH );
|
2000-11-01 11:01:31 +00:00
|
|
|
}
|
2001-08-22 12:06:35 +00:00
|
|
|
// no else!
|
|
|
|
if( bState == sal_False )
|
|
|
|
{
|
|
|
|
eFactory = SvtModuleOptions::E_CHART ;
|
|
|
|
bState = ( sName == FACTORYNAME_CHART );
|
|
|
|
}
|
|
|
|
|
|
|
|
return bState;
|
2000-10-24 10:56:40 +00:00
|
|
|
}
|
|
|
|
|
2001-08-22 12:06:35 +00:00
|
|
|
/*-************************************************************************************************************//**
|
|
|
|
@short read factory configuration
|
|
|
|
@descr Give us a list of pure factory names (long names!) which can be used as
|
|
|
|
direct set node names ... and we read her property values and fill internal list.
|
|
|
|
These method can be used by initial reading at ctor and later updating by "Notify()".
|
|
|
|
|
|
|
|
@seealso ctor
|
|
|
|
@seealso method Notify()
|
|
|
|
|
|
|
|
@param "lFactories" is the list of set node entries which should be readed.
|
|
|
|
@return -
|
|
|
|
|
|
|
|
@onerror We do nothing.
|
|
|
|
@threadsafe no
|
|
|
|
*//*-*************************************************************************************************************/
|
|
|
|
void SvtModuleOptions_Impl::impl_Read( const css::uno::Sequence< ::rtl::OUString >& lFactories )
|
2000-10-24 10:56:40 +00:00
|
|
|
{
|
2001-08-22 12:06:35 +00:00
|
|
|
// Expand every set node name in lFactories to full qualified pathes to his properties
|
|
|
|
// and get right values from configuration.
|
|
|
|
const css::uno::Sequence< ::rtl::OUString > lProperties = impl_ExpandSetNames( lFactories );
|
|
|
|
const css::uno::Sequence< css::uno::Any > lValues = GetProperties ( lProperties );
|
|
|
|
|
|
|
|
// Safe impossible cases.
|
|
|
|
// We need values from ALL configuration keys.
|
|
|
|
// Follow assignment use order of values in relation to our list of key names!
|
|
|
|
OSL_ENSURE( !(lProperties.getLength()!=lValues.getLength()), "SvtModuleOptions_Impl::impl_Read()\nI miss some values of configuration keys!\n" );
|
|
|
|
|
|
|
|
// Algorithm: We step over all given factory names and classify it. These enum value can be used as direct index
|
|
|
|
// in our member list m_lFactories! VAriable nPropertyStart marks start position of every factory
|
|
|
|
// and her properties in expanded property/value list. The defines PROPERTHANDLE_xxx are used as offset values
|
|
|
|
// added to nPropertyStart. So we can address every property relative in these lists.
|
|
|
|
// If we found any valid values ... we reset all existing informations for corresponding m_lFactories-entry and
|
|
|
|
// use a pointer to these struct in memory directly to set new values.
|
|
|
|
// But we set it only, if bInstalled is true. Otherwise all other values of a factory can be undeclared .. They
|
|
|
|
// shouldn't be used then.
|
|
|
|
// Attention: If a propertyset of a factory will be ignored we must step to next start position of next factory infos!
|
|
|
|
// see "nPropertyStart += PROPERTYCOUNT" ...
|
|
|
|
|
|
|
|
sal_Int32 nPropertyStart = 0 ;
|
|
|
|
sal_Int32 nNodeCount = lFactories.getLength();
|
|
|
|
FactoryInfo* pInfo = NULL ;
|
|
|
|
SvtModuleOptions::EFactory eFactory ;
|
|
|
|
::rtl::OUString sFactoryName ;
|
|
|
|
for( sal_Int32 nSetNode=0; nSetNode<nNodeCount; ++nSetNode )
|
|
|
|
{
|
|
|
|
sFactoryName = lFactories[nSetNode];
|
|
|
|
if( ClassifyFactoryByName( sFactoryName, eFactory ) == sal_True )
|
|
|
|
{
|
|
|
|
pInfo = &(m_lFactories[eFactory]);
|
|
|
|
pInfo->free();
|
|
|
|
|
|
|
|
pInfo->bInstalled = sal_True ;
|
|
|
|
pInfo->sFactory = sFactoryName ;
|
|
|
|
lValues[nPropertyStart+PROPERTYHANDLE_SHORTNAME ] >>= pInfo->sShortName ;
|
|
|
|
lValues[nPropertyStart+PROPERTYHANDLE_TEMPLATEFILE ] >>= pInfo->sTemplateFile ;
|
|
|
|
lValues[nPropertyStart+PROPERTYHANDLE_WINDOWATTRIBUTES] >>= pInfo->sWindowAttributes;
|
|
|
|
lValues[nPropertyStart+PROPERTYHANDLE_EMPTYDOCUMENTURL] >>= pInfo->sEmptyDocumentURL;
|
|
|
|
lValues[nPropertyStart+PROPERTYHANDLE_ICON ] >>= pInfo->nIcon ;
|
|
|
|
}
|
|
|
|
nPropertyStart += PROPERTYCOUNT;
|
|
|
|
}
|
2000-10-24 10:56:40 +00:00
|
|
|
}
|
|
|
|
|
2001-08-22 12:06:35 +00:00
|
|
|
|
2000-10-24 10:56:40 +00:00
|
|
|
//*****************************************************************************************************************
|
|
|
|
// initialize static member
|
|
|
|
// DON'T DO IT IN YOUR HEADER!
|
|
|
|
// see definition for further informations
|
|
|
|
//*****************************************************************************************************************
|
|
|
|
SvtModuleOptions_Impl* SvtModuleOptions::m_pDataContainer = NULL ;
|
|
|
|
sal_Int32 SvtModuleOptions::m_nRefCount = 0 ;
|
|
|
|
|
2001-08-22 12:06:35 +00:00
|
|
|
/*-************************************************************************************************************//**
|
|
|
|
@short standard constructor and destructor
|
|
|
|
@descr This will initialize an instance with default values. We initialize/deinitialize our static data
|
|
|
|
container and create a static mutex, which is used for threadsafe code in further time of this object.
|
|
|
|
|
|
|
|
@seealso method impl_GetOwnStaticMutex()
|
|
|
|
|
|
|
|
@param -
|
|
|
|
@return -
|
|
|
|
|
|
|
|
@onerror -
|
|
|
|
@threadsafe yes
|
|
|
|
*//*-*************************************************************************************************************/
|
2000-10-24 10:56:40 +00:00
|
|
|
SvtModuleOptions::SvtModuleOptions()
|
|
|
|
{
|
2001-08-22 12:06:35 +00:00
|
|
|
::osl::MutexGuard aGuard( impl_GetOwnStaticMutex() );
|
2000-10-24 10:56:40 +00:00
|
|
|
++m_nRefCount;
|
2001-08-22 12:06:35 +00:00
|
|
|
if( m_nRefCount == 1 )
|
2000-10-24 10:56:40 +00:00
|
|
|
{
|
|
|
|
m_pDataContainer = new SvtModuleOptions_Impl;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//*****************************************************************************************************************
|
|
|
|
SvtModuleOptions::~SvtModuleOptions()
|
|
|
|
{
|
2001-08-22 12:06:35 +00:00
|
|
|
::osl::MutexGuard aGuard( impl_GetOwnStaticMutex() );
|
2000-10-24 10:56:40 +00:00
|
|
|
--m_nRefCount;
|
2001-08-22 12:06:35 +00:00
|
|
|
if( m_nRefCount == 0 )
|
2000-10-24 10:56:40 +00:00
|
|
|
{
|
|
|
|
delete m_pDataContainer;
|
|
|
|
m_pDataContainer = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-08-22 12:06:35 +00:00
|
|
|
/*-************************************************************************************************************//**
|
|
|
|
@short access to configuration data
|
|
|
|
@descr This methods allow read/write access to configuration values.
|
|
|
|
They are threadsafe. All calls are forwarded to impl-data-container. See there for further informations!
|
|
|
|
|
|
|
|
@seealso method impl_GetOwnStaticMutex()
|
|
|
|
|
|
|
|
@param -
|
|
|
|
@return -
|
|
|
|
|
|
|
|
@onerror -
|
|
|
|
@threadsafe yes
|
|
|
|
*//*-*************************************************************************************************************/
|
|
|
|
sal_Bool SvtModuleOptions::IsModuleInstalled( EModule eModule ) const
|
|
|
|
{
|
|
|
|
::osl::MutexGuard aGuard( impl_GetOwnStaticMutex() );
|
|
|
|
return m_pDataContainer->IsModuleInstalled( eModule );
|
|
|
|
}
|
|
|
|
|
2000-10-24 10:56:40 +00:00
|
|
|
//*****************************************************************************************************************
|
2001-08-22 12:06:35 +00:00
|
|
|
::rtl::OUString SvtModuleOptions::GetFactoryName( EFactory eFactory ) const
|
2000-10-24 10:56:40 +00:00
|
|
|
{
|
2001-08-22 12:06:35 +00:00
|
|
|
::osl::MutexGuard aGuard( impl_GetOwnStaticMutex() );
|
|
|
|
return m_pDataContainer->GetFactoryName( eFactory );
|
2000-10-24 10:56:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//*****************************************************************************************************************
|
2001-08-22 12:06:35 +00:00
|
|
|
::rtl::OUString SvtModuleOptions::GetFactoryShortName( EFactory eFactory ) const
|
|
|
|
{
|
|
|
|
::osl::MutexGuard aGuard( impl_GetOwnStaticMutex() );
|
|
|
|
return m_pDataContainer->GetFactoryShortName( eFactory );
|
|
|
|
}
|
|
|
|
|
2000-10-24 10:56:40 +00:00
|
|
|
//*****************************************************************************************************************
|
2001-08-22 12:06:35 +00:00
|
|
|
::rtl::OUString SvtModuleOptions::GetFactoryStandardTemplate( EFactory eFactory ) const
|
2000-10-24 10:56:40 +00:00
|
|
|
{
|
2001-08-22 12:06:35 +00:00
|
|
|
::osl::MutexGuard aGuard( impl_GetOwnStaticMutex() );
|
|
|
|
return m_pDataContainer->GetFactoryStandardTemplate( eFactory );
|
2000-10-24 10:56:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//*****************************************************************************************************************
|
2001-08-22 12:06:35 +00:00
|
|
|
::rtl::OUString SvtModuleOptions::GetFactoryWindowAttributes( EFactory eFactory ) const
|
|
|
|
{
|
|
|
|
::osl::MutexGuard aGuard( impl_GetOwnStaticMutex() );
|
|
|
|
return m_pDataContainer->GetFactoryWindowAttributes( eFactory );
|
|
|
|
}
|
|
|
|
|
2000-10-24 10:56:40 +00:00
|
|
|
//*****************************************************************************************************************
|
2001-08-22 12:06:35 +00:00
|
|
|
::rtl::OUString SvtModuleOptions::GetFactoryEmptyDocumentURL( EFactory eFactory ) const
|
2000-10-24 10:56:40 +00:00
|
|
|
{
|
2001-08-22 12:06:35 +00:00
|
|
|
::osl::MutexGuard aGuard( impl_GetOwnStaticMutex() );
|
|
|
|
return m_pDataContainer->GetFactoryEmptyDocumentURL( eFactory );
|
2000-10-24 10:56:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//*****************************************************************************************************************
|
2001-08-22 12:06:35 +00:00
|
|
|
sal_Int32 SvtModuleOptions::GetFactoryIcon( EFactory eFactory ) const
|
|
|
|
{
|
|
|
|
::osl::MutexGuard aGuard( impl_GetOwnStaticMutex() );
|
|
|
|
return m_pDataContainer->GetFactoryIcon( eFactory );
|
|
|
|
}
|
|
|
|
|
2000-10-24 10:56:40 +00:00
|
|
|
//*****************************************************************************************************************
|
2001-08-22 12:06:35 +00:00
|
|
|
sal_Bool SvtModuleOptions::ClassifyFactoryByName( const ::rtl::OUString& sName ,
|
|
|
|
EFactory& eFactory )
|
2000-10-24 10:56:40 +00:00
|
|
|
{
|
2001-08-22 12:06:35 +00:00
|
|
|
// We don't need any mutex here ... because we don't use any member here!
|
|
|
|
return SvtModuleOptions_Impl::ClassifyFactoryByName( sName, eFactory );
|
2000-10-24 10:56:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//*****************************************************************************************************************
|
2001-08-22 12:06:35 +00:00
|
|
|
void SvtModuleOptions::SetFactoryStandardTemplate( EFactory eFactory ,
|
|
|
|
const ::rtl::OUString& sTemplate )
|
|
|
|
{
|
|
|
|
::osl::MutexGuard aGuard( impl_GetOwnStaticMutex() );
|
|
|
|
m_pDataContainer->SetFactoryStandardTemplate( eFactory, sTemplate );
|
|
|
|
}
|
|
|
|
|
2000-10-24 10:56:40 +00:00
|
|
|
//*****************************************************************************************************************
|
2001-08-22 12:06:35 +00:00
|
|
|
void SvtModuleOptions::SetFactoryWindowAttributes( EFactory eFactory ,
|
|
|
|
const ::rtl::OUString& sAttributes)
|
2000-10-24 10:56:40 +00:00
|
|
|
{
|
2001-08-22 12:06:35 +00:00
|
|
|
::osl::MutexGuard aGuard( impl_GetOwnStaticMutex() );
|
|
|
|
m_pDataContainer->SetFactoryWindowAttributes( eFactory, sAttributes );
|
2000-10-24 10:56:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//*****************************************************************************************************************
|
2001-08-22 12:06:35 +00:00
|
|
|
sal_Bool SvtModuleOptions::IsMath( sal_Bool bClient ) const
|
|
|
|
{
|
|
|
|
OSL_ENSURE( !(bClient==sal_True), "SvtModuleOptions::IsMath()\nWho use special parameter [bClient=TRUE]? It's obsolete!" );
|
|
|
|
::osl::MutexGuard aGuard( impl_GetOwnStaticMutex() );
|
|
|
|
return m_pDataContainer->IsModuleInstalled( E_SMATH );
|
|
|
|
}
|
|
|
|
|
2000-10-24 10:56:40 +00:00
|
|
|
//*****************************************************************************************************************
|
2001-08-22 12:06:35 +00:00
|
|
|
sal_Bool SvtModuleOptions::IsChart( sal_Bool bClient ) const
|
2000-10-24 10:56:40 +00:00
|
|
|
{
|
2001-08-22 12:06:35 +00:00
|
|
|
OSL_ENSURE( !(bClient==sal_True), "SvtModuleOptions::IsChart()\nWho use special parameter [bClient=TRUE]? It's obsolete!" );
|
|
|
|
::osl::MutexGuard aGuard( impl_GetOwnStaticMutex() );
|
|
|
|
return m_pDataContainer->IsModuleInstalled( E_SCHART );
|
2000-10-24 10:56:40 +00:00
|
|
|
}
|
|
|
|
|
2000-11-03 08:45:51 +00:00
|
|
|
//*****************************************************************************************************************
|
2001-08-22 12:06:35 +00:00
|
|
|
sal_Bool SvtModuleOptions::IsCalc( sal_Bool bClient ) const
|
|
|
|
{
|
|
|
|
OSL_ENSURE( !(bClient==sal_True), "SvtModuleOptions::IsCalc()\nWho use special parameter [bClient=TRUE]? It's obsolete!" );
|
|
|
|
::osl::MutexGuard aGuard( impl_GetOwnStaticMutex() );
|
|
|
|
return m_pDataContainer->IsModuleInstalled( E_SCALC );
|
|
|
|
}
|
|
|
|
|
2000-11-03 08:45:51 +00:00
|
|
|
//*****************************************************************************************************************
|
2001-08-22 12:06:35 +00:00
|
|
|
sal_Bool SvtModuleOptions::IsDraw( sal_Bool bClient ) const
|
2000-11-03 08:45:51 +00:00
|
|
|
{
|
2001-08-22 12:06:35 +00:00
|
|
|
OSL_ENSURE( !(bClient==sal_True), "SvtModuleOptions::IsDraw()\nWho use special parameter [bClient=TRUE]? It's obsolete!" );
|
|
|
|
::osl::MutexGuard aGuard( impl_GetOwnStaticMutex() );
|
|
|
|
return m_pDataContainer->IsModuleInstalled( E_SDRAW );
|
2000-11-03 08:45:51 +00:00
|
|
|
}
|
|
|
|
|
2000-10-24 10:56:40 +00:00
|
|
|
//*****************************************************************************************************************
|
2001-08-22 12:06:35 +00:00
|
|
|
sal_Bool SvtModuleOptions::IsWriter( sal_Bool bClient ) const
|
|
|
|
{
|
|
|
|
OSL_ENSURE( !(bClient==sal_True), "SvtModuleOptions::IsWriter()\nWho use special parameter [bClient=TRUE]? It's obsolete!" );
|
|
|
|
::osl::MutexGuard aGuard( impl_GetOwnStaticMutex() );
|
|
|
|
return m_pDataContainer->IsModuleInstalled( E_SWRITER );
|
|
|
|
}
|
|
|
|
|
2000-10-24 10:56:40 +00:00
|
|
|
//*****************************************************************************************************************
|
2001-08-22 12:06:35 +00:00
|
|
|
sal_Bool SvtModuleOptions::IsImpress( sal_Bool bClient ) const
|
2000-10-24 10:56:40 +00:00
|
|
|
{
|
2001-08-22 12:06:35 +00:00
|
|
|
OSL_ENSURE( !(bClient==sal_True), "SvtModuleOptions::IsImpress()\nWho use special parameter [bClient=TRUE]? It's obsolete!" );
|
|
|
|
::osl::MutexGuard aGuard( impl_GetOwnStaticMutex() );
|
|
|
|
return m_pDataContainer->IsModuleInstalled( E_SIMPRESS );
|
2000-10-24 10:56:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//*****************************************************************************************************************
|
2001-08-22 12:06:35 +00:00
|
|
|
sal_Bool SvtModuleOptions::IsBasicIDE( sal_Bool bClient ) const
|
|
|
|
{
|
|
|
|
OSL_ENSURE( !(bClient==sal_True), "SvtModuleOptions::IsBasicIDE()\nWho use special parameter [bClient=TRUE]? It's obsolete!" );
|
|
|
|
return sal_True;
|
|
|
|
}
|
|
|
|
|
2000-10-24 10:56:40 +00:00
|
|
|
//*****************************************************************************************************************
|
2001-08-22 12:06:35 +00:00
|
|
|
sal_uInt32 SvtModuleOptions::GetFeatures( sal_Bool bClient ) const
|
|
|
|
{
|
|
|
|
OSL_ENSURE( !(bClient==sal_True), "SvtModuleOptions::GetFeatures()\nWho use special parameter [bClient=TRUE]? It's obsolete!" );
|
|
|
|
::osl::MutexGuard aGuard( impl_GetOwnStaticMutex() );
|
|
|
|
|
|
|
|
sal_uInt32 nFeature = 0;
|
|
|
|
|
|
|
|
if( m_pDataContainer->IsModuleInstalled( E_SWRITER ) == sal_True )
|
|
|
|
nFeature |= FEATUREFLAG_WRITER;
|
|
|
|
if( m_pDataContainer->IsModuleInstalled( E_SCALC ) == sal_True )
|
|
|
|
nFeature |= FEATUREFLAG_CALC;
|
|
|
|
if( m_pDataContainer->IsModuleInstalled( E_SDRAW ) == sal_True )
|
|
|
|
nFeature |= FEATUREFLAG_DRAW;
|
|
|
|
if( m_pDataContainer->IsModuleInstalled( E_SIMPRESS ) == sal_True )
|
|
|
|
nFeature |= FEATUREFLAG_IMPRESS;
|
|
|
|
if( m_pDataContainer->IsModuleInstalled( E_SCHART ) == sal_True )
|
|
|
|
nFeature |= FEATUREFLAG_CHART;
|
|
|
|
if( m_pDataContainer->IsModuleInstalled( E_SMATH ) == sal_True )
|
|
|
|
nFeature |= FEATUREFLAG_MATH;
|
|
|
|
if( m_pDataContainer->IsModuleInstalled( E_SBASIC ) == sal_True )
|
|
|
|
nFeature |= FEATUREFLAG_BASICIDE;
|
|
|
|
|
|
|
|
return nFeature;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*-****************************************************************************************************//**
|
|
|
|
@short return a reference to a static mutex
|
|
|
|
@descr These class is threadsafe.
|
|
|
|
We create a static mutex only for one time and use it to protect our refcount and container
|
|
|
|
member!
|
|
|
|
|
|
|
|
@seealso -
|
|
|
|
|
|
|
|
@param -
|
|
|
|
@return A reference to a static mutex member.
|
|
|
|
|
|
|
|
@onerror -
|
|
|
|
@threadsafe yes
|
|
|
|
*//*-*****************************************************************************************************/
|
|
|
|
::osl::Mutex& SvtModuleOptions::impl_GetOwnStaticMutex()
|
2000-10-24 10:56:40 +00:00
|
|
|
{
|
|
|
|
// Initialize static mutex only for one time!
|
2001-08-22 12:06:35 +00:00
|
|
|
static ::osl::Mutex* pMutex = NULL;
|
2000-10-24 10:56:40 +00:00
|
|
|
// If these method first called (Mutex not already exist!) ...
|
|
|
|
if( pMutex == NULL )
|
|
|
|
{
|
|
|
|
// ... we must create a new one. Protect follow code with the global mutex -
|
|
|
|
// It must be - we create a static variable!
|
2001-08-22 12:06:35 +00:00
|
|
|
::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
|
2000-10-24 10:56:40 +00:00
|
|
|
// We must check our pointer again - because it can be that another instance of ouer class will be fastr then these!
|
|
|
|
if( pMutex == NULL )
|
|
|
|
{
|
|
|
|
// Create the new mutex and set it for return on static variable.
|
2001-08-22 12:06:35 +00:00
|
|
|
static ::osl::Mutex aMutex;
|
2000-10-24 10:56:40 +00:00
|
|
|
pMutex = &aMutex;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// Return new created or already existing mutex object.
|
|
|
|
return *pMutex;
|
|
|
|
}
|