merge the formfield patch from ooo-build
[ooovba.git] / shell / source / backends / kde4be / kde4commonlayer.cxx
blob6e718cbddb552915d78d914f02a8465bac8591fc
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: kde4commonlayer.cxx,v $
10 * $Revision: 1.7 $
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"
34 #include "kde4commonlayer.hxx"
36 #include <kemailsettings.h>
37 #include <kglobalsettings.h>
39 #include <QFont>
41 #include <com/sun/star/configuration/backend/PropertyInfo.hpp>
42 #include <com/sun/star/configuration/backend/XLayerContentDescriber.hpp>
43 #include <com/sun/star/uno/Sequence.hxx>
45 #define SPACE ' '
47 //==============================================================================
49 KDECommonLayer::KDECommonLayer(const uno::Reference<uno::XComponentContext>& xContext)
51 //Create instance of LayerContentDescriber Service
52 rtl::OUString const k_sLayerDescriberService(RTL_CONSTASCII_USTRINGPARAM(
53 "com.sun.star.comp.configuration.backend.LayerDescriber"));
55 typedef uno::Reference<backend::XLayerContentDescriber> LayerDescriber;
56 uno::Reference< lang::XMultiComponentFactory > xServiceManager = xContext->getServiceManager();
57 if( xServiceManager.is() )
59 m_xLayerContentDescriber = LayerDescriber::query(
60 xServiceManager->createInstanceWithContext(k_sLayerDescriberService, xContext));
62 else
64 OSL_TRACE("Could not retrieve ServiceManager");
68 //------------------------------------------------------------------------------
70 void SAL_CALL KDECommonLayer::readData( const uno::Reference<backend::XLayerHandler>& xHandler)
71 throw ( backend::MalformedDataException, lang::NullPointerException,
72 lang::WrappedTargetException, uno::RuntimeException)
74 if( ! m_xLayerContentDescriber.is() )
76 throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(
77 "Could not create com.sun.star.configuration.backend.LayerContentDescriber Service"
78 ) ), static_cast < backend::XLayer * > (this) );
81 uno::Sequence<backend::PropertyInfo> aPropInfoList(3);
82 sal_Int32 nProperties = 0;
84 // Email client settings
85 KEMailSettings aEmailSettings;
86 QString aClientProgram;
87 ::rtl::OUString sClientProgram;
89 aClientProgram = aEmailSettings.getSetting( KEMailSettings::ClientProgram );
90 if ( aClientProgram.isEmpty() )
91 aClientProgram = "kmail";
92 else
93 aClientProgram = aClientProgram.section(SPACE, 0, 0);
94 sClientProgram = (const sal_Unicode *) aClientProgram.utf16();
96 aPropInfoList[nProperties].Name = rtl::OUString(
97 RTL_CONSTASCII_USTRINGPARAM( "org.openoffice.Office.Common/ExternalMailer/Program") );
98 aPropInfoList[nProperties].Type = rtl::OUString(
99 RTL_CONSTASCII_USTRINGPARAM( "string" ) );
100 aPropInfoList[nProperties].Protected = sal_False;
101 aPropInfoList[nProperties++].Value = uno::makeAny( sClientProgram );
103 // Source code font settings
104 QFont aFixedFont;
105 QString aFontName;
106 :: rtl::OUString sFontName;
107 short nFontHeight;
109 aFixedFont = KGlobalSettings::fixedFont();
110 aFontName = aFixedFont.family();
111 sFontName = (const sal_Unicode *) aFontName.utf16();
112 nFontHeight = aFixedFont.pointSize();
114 aPropInfoList[nProperties].Name = rtl::OUString(
115 RTL_CONSTASCII_USTRINGPARAM( "org.openoffice.Office.Common/Font/SourceViewFont/FontName") );
116 aPropInfoList[nProperties].Type = rtl::OUString(
117 RTL_CONSTASCII_USTRINGPARAM( "string" ) );
118 aPropInfoList[nProperties].Protected = sal_False;
119 aPropInfoList[nProperties++].Value = uno::makeAny( sFontName );
121 aPropInfoList[nProperties].Name = rtl::OUString(
122 RTL_CONSTASCII_USTRINGPARAM( "org.openoffice.Office.Common/Font/SourceViewFont/FontHeight") );
123 aPropInfoList[nProperties].Type = rtl::OUString(
124 RTL_CONSTASCII_USTRINGPARAM( "short" ) );
125 aPropInfoList[nProperties].Protected = sal_False;
126 aPropInfoList[nProperties++].Value = uno::makeAny( nFontHeight );
128 if( nProperties > 0 )
130 aPropInfoList.realloc(nProperties);
131 m_xLayerContentDescriber->describeLayer(xHandler, aPropInfoList);
135 //------------------------------------------------------------------------------
137 rtl::OUString SAL_CALL KDECommonLayer::getTimestamp(void)
138 throw (uno::RuntimeException)
140 // Return the value as timestamp to avoid regenerating the binary cache
141 // on each office launch.
143 KEMailSettings aEmailSettings;
144 QString aClientProgram = aEmailSettings.getSetting( KEMailSettings::ClientProgram );
145 aClientProgram = aClientProgram.section(SPACE, 0, 0);
147 QString aFixedFont = KGlobalSettings::fixedFont().toString();
149 ::rtl::OUString sTimeStamp,
150 sep( RTL_CONSTASCII_USTRINGPARAM( "$" ) );
152 sTimeStamp = (const sal_Unicode *) aClientProgram.utf16();
153 sTimeStamp += sep;
154 sTimeStamp += (const sal_Unicode *) aFixedFont.utf16();
156 return sTimeStamp;