Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : :
30 : : #include <generic/gensys.h>
31 : :
32 : : #include <vcl/msgbox.hxx>
33 : : #include <vcl/button.hxx>
34 : :
35 : : #include <svdata.hxx>
36 : :
37 : : #include <rtl/ustrbuf.hxx>
38 : : #include <rtl/strbuf.hxx>
39 : : #include <rtl/bootstrap.hxx>
40 : : #include <osl/process.h>
41 : : #include <osl/thread.h>
42 : :
43 : : #include "vcl/unohelp.hxx"
44 : : #include <com/sun/star/beans/PropertyValue.hpp>
45 : : #include <com/sun/star/container/XNameAccess.hpp>
46 : : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
47 : :
48 : : using namespace com::sun::star;
49 : :
50 : 106 : SalGenericSystem::SalGenericSystem()
51 : : {
52 : 106 : }
53 : :
54 : 58 : SalGenericSystem::~SalGenericSystem()
55 : : {
56 [ - + ]: 58 : }
57 : :
58 : 0 : int SalGenericSystem::ShowNativeMessageBox( const rtl::OUString& rTitle, const rtl::OUString& rMessage,
59 : : int nButtonCombination, int nDefaultButton )
60 : : {
61 : 0 : int nDefButton = 0;
62 [ # # ]: 0 : std::list< rtl::OUString > aButtons;
63 : 0 : int nButtonIds[5], nBut = 0;
64 : :
65 [ # # ]: 0 : ImplHideSplash();
66 : :
67 [ # # ][ # # ]: 0 : if( nButtonCombination == SALSYSTEM_SHOWNATIVEMSGBOX_BTNCOMBI_OK ||
68 : : nButtonCombination == SALSYSTEM_SHOWNATIVEMSGBOX_BTNCOMBI_OK_CANCEL )
69 : : {
70 [ # # ][ # # ]: 0 : aButtons.push_back( Button::GetStandardText( BUTTON_OK ) );
[ # # ][ # # ]
71 : 0 : nButtonIds[nBut++] = SALSYSTEM_SHOWNATIVEMSGBOX_BTN_OK;
72 : : }
73 [ # # ][ # # ]: 0 : if( nButtonCombination == SALSYSTEM_SHOWNATIVEMSGBOX_BTNCOMBI_YES_NO_CANCEL ||
74 : : nButtonCombination == SALSYSTEM_SHOWNATIVEMSGBOX_BTNCOMBI_YES_NO )
75 : : {
76 [ # # ][ # # ]: 0 : aButtons.push_back( Button::GetStandardText( BUTTON_YES ) );
[ # # ][ # # ]
77 : 0 : nButtonIds[nBut++] = SALSYSTEM_SHOWNATIVEMSGBOX_BTN_YES;
78 [ # # ][ # # ]: 0 : aButtons.push_back( Button::GetStandardText( BUTTON_NO ) );
[ # # ][ # # ]
79 : 0 : nButtonIds[nBut++] = SALSYSTEM_SHOWNATIVEMSGBOX_BTN_NO;
80 [ # # ]: 0 : if( nDefaultButton == SALSYSTEM_SHOWNATIVEMSGBOX_BTN_NO )
81 : 0 : nDefButton = 1;
82 : : }
83 [ # # ][ # # ]: 0 : if( nButtonCombination == SALSYSTEM_SHOWNATIVEMSGBOX_BTNCOMBI_OK_CANCEL ||
[ # # ]
84 : : nButtonCombination == SALSYSTEM_SHOWNATIVEMSGBOX_BTNCOMBI_YES_NO_CANCEL ||
85 : : nButtonCombination == SALSYSTEM_SHOWNATIVEMSGBOX_BTNCOMBI_RETRY_CANCEL )
86 : : {
87 [ # # ]: 0 : if( nButtonCombination == SALSYSTEM_SHOWNATIVEMSGBOX_BTNCOMBI_RETRY_CANCEL )
88 : : {
89 [ # # ][ # # ]: 0 : aButtons.push_back( Button::GetStandardText( BUTTON_RETRY ) );
[ # # ][ # # ]
90 : 0 : nButtonIds[nBut++] = SALSYSTEM_SHOWNATIVEMSGBOX_BTN_RETRY;
91 : : }
92 [ # # ][ # # ]: 0 : aButtons.push_back( Button::GetStandardText( BUTTON_CANCEL ) );
[ # # ][ # # ]
93 : 0 : nButtonIds[nBut++] = SALSYSTEM_SHOWNATIVEMSGBOX_BTN_CANCEL;
94 [ # # ]: 0 : if( nDefaultButton == SALSYSTEM_SHOWNATIVEMSGBOX_BTN_CANCEL )
95 : 0 : nDefButton = aButtons.size()-1;
96 : : }
97 [ # # ]: 0 : if( nButtonCombination == SALSYSTEM_SHOWNATIVEMSGBOX_BTNCOMBI_ABORT_RETRY_IGNORE )
98 : : {
99 [ # # ][ # # ]: 0 : aButtons.push_back( Button::GetStandardText( BUTTON_ABORT ) );
[ # # ][ # # ]
100 : 0 : nButtonIds[nBut++] = SALSYSTEM_SHOWNATIVEMSGBOX_BTN_ABORT;
101 [ # # ][ # # ]: 0 : aButtons.push_back( Button::GetStandardText( BUTTON_RETRY ) );
[ # # ][ # # ]
102 : 0 : nButtonIds[nBut++] = SALSYSTEM_SHOWNATIVEMSGBOX_BTN_RETRY;
103 [ # # ][ # # ]: 0 : aButtons.push_back( Button::GetStandardText( BUTTON_IGNORE ) );
[ # # ][ # # ]
104 : 0 : nButtonIds[nBut++] = SALSYSTEM_SHOWNATIVEMSGBOX_BTN_IGNORE;
105 [ # # # ]: 0 : switch( nDefaultButton )
106 : : {
107 : 0 : case SALSYSTEM_SHOWNATIVEMSGBOX_BTN_RETRY: nDefButton = 1;break;
108 : 0 : case SALSYSTEM_SHOWNATIVEMSGBOX_BTN_IGNORE: nDefButton = 2;break;
109 : : }
110 : : }
111 : :
112 [ # # ]: 0 : int nResult = ShowNativeDialog( rTitle, rMessage, aButtons, nDefButton );
113 : :
114 [ # # ]: 0 : return nResult != -1 ? nButtonIds[ nResult ] : 0;
115 : : }
116 : :
117 : : // ------------------------------------------------------------------------
118 : : // Helpers primarily for X Windowing derivatives
119 : : // ------------------------------------------------------------------------
120 : :
121 : 0 : const char* SalGenericSystem::getFrameResName()
122 : : {
123 : : /* according to ICCCM:
124 : : * first search command line for -name parameter
125 : : * then try RESOURCE_NAME environment variable
126 : : * then use argv[0] stripped by directories
127 : : */
128 [ # # ][ # # ]: 0 : static rtl::OStringBuffer aResName;
129 [ # # ]: 0 : if( !aResName.getLength() )
130 : : {
131 : 0 : int nArgs = osl_getCommandArgCount();
132 [ # # ]: 0 : for( int n = 0; n < nArgs-1; n++ )
133 : : {
134 : 0 : rtl::OUString aArg;
135 [ # # # # ]: 0 : if( ! osl_getCommandArg( n, &aArg.pData ) &&
[ # # ][ # # ]
[ # # ]
136 : 0 : aArg.equalsIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM("-name")) &&
137 [ # # ]: 0 : ! osl_getCommandArg( n+1, &aArg.pData ) )
138 : : {
139 [ # # ][ # # ]: 0 : aResName.append( rtl::OUStringToOString( aArg, osl_getThreadTextEncoding() ) );
[ # # ]
140 : : break;
141 : : }
142 [ # # ]: 0 : }
143 [ # # ]: 0 : if( !aResName.getLength() )
144 : : {
145 : 0 : const char* pEnv = getenv( "RESOURCE_NAME" );
146 [ # # ][ # # ]: 0 : if( pEnv && *pEnv )
147 [ # # ]: 0 : aResName.append( pEnv );
148 : : }
149 [ # # ]: 0 : if( !aResName.getLength() )
150 : 0 : aResName.append( "VCLSalFrame" );
151 : : }
152 : 0 : return aResName.getStr();
153 : : }
154 : :
155 : 0 : const char* SalGenericSystem::getFrameClassName()
156 : : {
157 [ # # ][ # # ]: 0 : static rtl::OStringBuffer aClassName;
158 [ # # ]: 0 : if( !aClassName.getLength() )
159 : : {
160 : 0 : rtl::OUString aIni, aProduct;
161 [ # # ]: 0 : rtl::Bootstrap::get( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "BRAND_BASE_DIR" ) ), aIni );
162 [ # # ]: 0 : aIni += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "/program/" SAL_CONFIGFILE( "bootstrap" ) ) );
163 : 0 : rtl::Bootstrap aBootstrap( aIni );
164 [ # # ]: 0 : aBootstrap.getFrom( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ProductKey" ) ), aProduct );
165 : :
166 [ # # ]: 0 : if( !aProduct.isEmpty() )
167 [ # # ][ # # ]: 0 : aClassName.append( rtl::OUStringToOString( aProduct, osl_getThreadTextEncoding() ) );
[ # # ]
168 : : else
169 [ # # ]: 0 : aClassName.append( "VCLSalFrame" );
170 : : }
171 : 0 : return aClassName.getStr();
172 : : }
173 : :
174 : 0 : rtl::OString SalGenericSystem::getFrameResName( SalExtStyle nStyle )
175 : : {
176 : 0 : rtl::OStringBuffer aBuf( 64 );
177 [ # # ][ # # ]: 0 : aBuf.append( getFrameResName() );
178 [ # # ]: 0 : if( (nStyle & SAL_FRAME_EXT_STYLE_DOCUMENT) )
179 [ # # ]: 0 : aBuf.append( ".DocumentWindow" );
180 : :
181 : 0 : return aBuf.makeStringAndClear();
182 : : }
183 : :
184 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|