1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: kdecommonlayer.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_shell.hxx"
33 #include "kdecommonlayer.hxx"
34 #include <vcl/kde_headers.h>
35 #include <com/sun/star/configuration/backend/PropertyInfo.hpp>
36 #ifndef _COM_SUN_STAR_CONFIGURATION_BACKEND_XLAYERCONTENTDESCIBER_HPP_
37 #include <com/sun/star/configuration/backend/XLayerContentDescriber.hpp>
39 #include <com/sun/star/uno/Sequence.hxx>
43 //==============================================================================
45 KDECommonLayer::KDECommonLayer(const uno::Reference
<uno::XComponentContext
>& xContext
)
47 //Create instance of LayerContentDescriber Service
48 rtl::OUString
const k_sLayerDescriberService(RTL_CONSTASCII_USTRINGPARAM(
49 "com.sun.star.comp.configuration.backend.LayerDescriber"));
51 typedef uno::Reference
<backend::XLayerContentDescriber
> LayerDescriber
;
52 uno::Reference
< lang::XMultiComponentFactory
> xServiceManager
= xContext
->getServiceManager();
53 if( xServiceManager
.is() )
55 m_xLayerContentDescriber
= LayerDescriber::query(
56 xServiceManager
->createInstanceWithContext(k_sLayerDescriberService
, xContext
));
60 OSL_TRACE("Could not retrieve ServiceManager");
64 //------------------------------------------------------------------------------
66 void SAL_CALL
KDECommonLayer::readData( const uno::Reference
<backend::XLayerHandler
>& xHandler
)
67 throw ( backend::MalformedDataException
, lang::NullPointerException
,
68 lang::WrappedTargetException
, uno::RuntimeException
)
70 if( ! m_xLayerContentDescriber
.is() )
72 throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(
73 "Could not create com.sun.star.configuration.backend.LayerContentDescriber Service"
74 ) ), static_cast < backend::XLayer
* > (this) );
77 uno::Sequence
<backend::PropertyInfo
> aPropInfoList(3);
78 sal_Int32 nProperties
= 0;
80 // Email client settings
81 KEMailSettings aEmailSettings
;
82 QString aClientProgram
;
83 ::rtl::OUString sClientProgram
;
85 aClientProgram
= aEmailSettings
.getSetting( KEMailSettings::ClientProgram
);
86 if ( aClientProgram
.isEmpty() )
87 aClientProgram
= "kmail";
89 aClientProgram
= aClientProgram
.section(SPACE
, 0, 0);
90 sClientProgram
= (const sal_Unicode
*) aClientProgram
.ucs2();
92 aPropInfoList
[nProperties
].Name
= rtl::OUString(
93 RTL_CONSTASCII_USTRINGPARAM( "org.openoffice.Office.Common/ExternalMailer/Program") );
94 aPropInfoList
[nProperties
].Type
= rtl::OUString(
95 RTL_CONSTASCII_USTRINGPARAM( "string" ) );
96 aPropInfoList
[nProperties
].Protected
= sal_False
;
97 aPropInfoList
[nProperties
++].Value
= uno::makeAny( sClientProgram
);
99 // Source code font settings
102 :: rtl::OUString sFontName
;
105 aFixedFont
= KGlobalSettings::fixedFont();
106 aFontName
= aFixedFont
.family();
107 sFontName
= (const sal_Unicode
*) aFontName
.ucs2();
108 nFontHeight
= aFixedFont
.pointSize();
110 aPropInfoList
[nProperties
].Name
= rtl::OUString(
111 RTL_CONSTASCII_USTRINGPARAM( "org.openoffice.Office.Common/Font/SourceViewFont/FontName") );
112 aPropInfoList
[nProperties
].Type
= rtl::OUString(
113 RTL_CONSTASCII_USTRINGPARAM( "string" ) );
114 aPropInfoList
[nProperties
].Protected
= sal_False
;
115 aPropInfoList
[nProperties
++].Value
= uno::makeAny( sFontName
);
117 aPropInfoList
[nProperties
].Name
= rtl::OUString(
118 RTL_CONSTASCII_USTRINGPARAM( "org.openoffice.Office.Common/Font/SourceViewFont/FontHeight") );
119 aPropInfoList
[nProperties
].Type
= rtl::OUString(
120 RTL_CONSTASCII_USTRINGPARAM( "short" ) );
121 aPropInfoList
[nProperties
].Protected
= sal_False
;
122 aPropInfoList
[nProperties
++].Value
= uno::makeAny( nFontHeight
);
124 if( nProperties
> 0 )
126 aPropInfoList
.realloc(nProperties
);
127 m_xLayerContentDescriber
->describeLayer(xHandler
, aPropInfoList
);
131 //------------------------------------------------------------------------------
133 rtl::OUString SAL_CALL
KDECommonLayer::getTimestamp(void)
134 throw (uno::RuntimeException
)
136 // Return the value as timestamp to avoid regenerating the binary cache
137 // on each office launch.
139 KEMailSettings aEmailSettings
;
140 QString aClientProgram
= aEmailSettings
.getSetting( KEMailSettings::ClientProgram
);
141 aClientProgram
= aClientProgram
.section(SPACE
, 0, 0);
143 QString aFixedFont
= KGlobalSettings::fixedFont().toString();
145 ::rtl::OUString sTimeStamp
,
146 sep( RTL_CONSTASCII_USTRINGPARAM( "$" ) );
148 sTimeStamp
= (const sal_Unicode
*) aClientProgram
.ucs2();
150 sTimeStamp
+= (const sal_Unicode
*) aFixedFont
.ucs2();