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 <config_folders.h>
21 :
22 : #include <vcl/canvastools.hxx>
23 : #include <vcl/status.hxx>
24 : #include <vcl/msgbox.hxx>
25 : #include <svl/whiter.hxx>
26 : #include <svl/stritem.hxx>
27 : #include <svl/intitem.hxx>
28 : #include <svl/eitem.hxx>
29 : #include <vcl/graphicfilter.hxx>
30 : #include <unotools/pathoptions.hxx>
31 : #include <com/sun/star/registry/InvalidRegistryException.hpp>
32 : #include <com/sun/star/rendering/XIntegerReadOnlyBitmap.hpp>
33 : #include <com/sun/star/beans/PropertyValue.hpp>
34 : #include <com/sun/star/frame/XFrame.hpp>
35 : #include <com/sun/star/graphic/Primitive2DTools.hpp>
36 : #include <com/sun/star/util/XURLTransformer.hpp>
37 : #include <com/sun/star/frame/XFramesSupplier.hpp>
38 : #include <com/sun/star/uno/Reference.h>
39 : #include <tools/rcid.h>
40 : #include <osl/mutex.hxx>
41 : #include <unotools/configmgr.hxx>
42 : #include <com/sun/star/frame/XDesktop.hpp>
43 : #include <unotools/ucbstreamhelper.hxx>
44 : #include <framework/menuconfiguration.hxx>
45 : #include <comphelper/processfactory.hxx>
46 : #include <unotools/localfilehelper.hxx>
47 : #include <unotools/bootstrap.hxx>
48 : #include <unotools/moduleoptions.hxx>
49 : #include <osl/file.hxx>
50 : #include <osl/process.h>
51 : #include <rtl/bootstrap.hxx>
52 :
53 : #include <sfx2/sfxresid.hxx>
54 : #include <sfx2/app.hxx>
55 : #include "appdata.hxx"
56 : #include "arrdecl.hxx"
57 : #include <sfx2/tbxctrl.hxx>
58 : #include <sfx2/stbitem.hxx>
59 : #include <sfx2/mnuitem.hxx>
60 : #include <sfx2/docfac.hxx>
61 : #include <sfx2/docfile.hxx>
62 : #include <sfx2/docfilt.hxx>
63 : #include <sfx2/request.hxx>
64 : #include <sfx2/bindings.hxx>
65 : #include <sfx2/dispatch.hxx>
66 : #include "workwin.hxx"
67 : #include <sfx2/fcontnr.hxx>
68 : #include "sfxlocal.hrc"
69 : #include <sfx2/sfx.hrc>
70 : #include "app.hrc"
71 : #include <sfx2/templdlg.hxx>
72 : #include <sfx2/module.hxx>
73 : #include <sfx2/msgpool.hxx>
74 : #include <sfx2/viewfrm.hxx>
75 : #include "openflag.hxx"
76 : #include <sfx2/viewsh.hxx>
77 : #include <sfx2/objface.hxx>
78 : #include "helper.hxx"
79 : #include <basegfx/matrix/b2dhommatrixtools.hxx>
80 : #include <drawinglayer/primitive2d/transformprimitive2d.hxx>
81 :
82 : using namespace ::com::sun::star;
83 : using namespace ::com::sun::star::uno;
84 : using namespace ::com::sun::star::util;
85 : using namespace ::com::sun::star::beans;
86 : using namespace ::com::sun::star::container;
87 :
88 :
89 :
90 : #define SfxApplication
91 : #include "sfxslots.hxx"
92 :
93 :
94 :
95 : #define SFX_ITEMTYPE_STATBAR 4
96 :
97 0 : SFX_IMPL_INTERFACE(SfxApplication,SfxShell,SfxResId(RID_DESKTOP))
98 : {
99 0 : SFX_STATUSBAR_REGISTRATION(SfxResId(SFX_ITEMTYPE_STATBAR));
100 0 : SFX_CHILDWINDOW_REGISTRATION(SID_DOCKWIN_0);
101 0 : SFX_CHILDWINDOW_REGISTRATION(SID_DOCKWIN_1);
102 0 : SFX_CHILDWINDOW_REGISTRATION(SID_DOCKWIN_2);
103 0 : SFX_CHILDWINDOW_REGISTRATION(SID_DOCKWIN_3);
104 0 : SFX_CHILDWINDOW_REGISTRATION(SID_DOCKWIN_4);
105 0 : SFX_CHILDWINDOW_REGISTRATION(SID_DOCKWIN_5);
106 0 : SFX_CHILDWINDOW_REGISTRATION(SID_DOCKWIN_6);
107 0 : SFX_CHILDWINDOW_REGISTRATION(SID_DOCKWIN_7);
108 0 : SFX_CHILDWINDOW_REGISTRATION(SID_DOCKWIN_8);
109 0 : SFX_CHILDWINDOW_REGISTRATION(SID_DOCKWIN_9);
110 0 : }
111 :
112 :
113 0 : SfxProgress* SfxApplication::GetProgress() const
114 :
115 : /* [Description]
116 :
117 : Returns the running SfxProgress for the entire application or 0 if
118 : none is running for the entire application.
119 :
120 : [Cross-reference]
121 :
122 : <SfxProgress::GetActiveProgress(SfxViewFrame*)>
123 : <SfxViewFrame::GetProgress()const>
124 : */
125 :
126 : {
127 0 : return pAppData_Impl->pProgress;
128 : }
129 :
130 0 : SfxModule* SfxApplication::GetModule_Impl()
131 : {
132 0 : SfxModule* pModule = SfxModule::GetActiveModule();
133 0 : if ( !pModule )
134 0 : pModule = SfxModule::GetActiveModule( SfxViewFrame::GetFirst( 0, false ) );
135 0 : if( pModule )
136 0 : return pModule;
137 : else
138 : {
139 : OSL_FAIL( "No module!" );
140 0 : return NULL;
141 : }
142 : }
143 :
144 0 : ISfxTemplateCommon* SfxApplication::GetCurrentTemplateCommon( SfxBindings& rBindings )
145 : {
146 0 : if( pAppData_Impl->pTemplateCommon )
147 0 : return pAppData_Impl->pTemplateCommon;
148 : SfxChildWindow *pChild = rBindings.GetWorkWindow_Impl()->GetChildWindow_Impl(
149 0 : SfxTemplateDialogWrapper::GetChildWindowId() );
150 0 : if ( pChild )
151 0 : return ((SfxTemplateDialog*) pChild->GetWindow())->GetISfxTemplateCommon();
152 0 : return 0;
153 : }
154 :
155 0 : bool SfxApplication::IsDowning() const { return pAppData_Impl->bDowning; }
156 0 : SfxDispatcher* SfxApplication::GetAppDispatcher_Impl() { return pAppData_Impl->pAppDispat; }
157 0 : SfxSlotPool& SfxApplication::GetAppSlotPool_Impl() const { return *pAppData_Impl->pSlotPool; }
158 :
159 0 : bool SfxApplication::loadBrandSvg(const char *pName, BitmapEx &rBitmap, int nWidth)
160 : {
161 : // Load from disk
162 :
163 0 : OUString aBaseName = OUString("/") + OUString::createFromAscii( pName );
164 :
165 0 : rtl_Locale *pLoc = NULL;
166 0 : osl_getProcessLocale (&pLoc);
167 0 : LanguageTag aLanguageTag( *pLoc);
168 :
169 0 : OUString uri = OUString( "$BRAND_BASE_DIR/" LIBO_ETC_FOLDER ) + aBaseName + ".svg";
170 0 : rtl::Bootstrap::expandMacros( uri );
171 0 : INetURLObject aObj( uri );
172 0 : SvgData aSvgData(aObj.PathToFileName());
173 :
174 : // transform into [0,0,width,width*aspect] std dimensions
175 :
176 0 : basegfx::B2DRange aRange(aSvgData.getRange());
177 0 : const double fAspectRatio(aRange.getWidth()/aRange.getHeight());
178 : basegfx::B2DHomMatrix aTransform(
179 : basegfx::tools::createTranslateB2DHomMatrix(
180 0 : -aRange.getMinX(),
181 0 : -aRange.getMinY()));
182 : aTransform.scale(
183 0 : nWidth / aRange.getWidth(),
184 0 : nWidth / fAspectRatio / aRange.getHeight());
185 : const drawinglayer::primitive2d::Primitive2DReference xTransformRef(
186 : new drawinglayer::primitive2d::TransformPrimitive2D(
187 : aTransform,
188 0 : aSvgData.getPrimitive2DSequence()));
189 :
190 : // UNO dance to render from drawinglayer
191 :
192 0 : uno::Reference< uno::XComponentContext > xContext(::comphelper::getProcessComponentContext());
193 :
194 : try
195 : {
196 : const uno::Reference< graphic::XPrimitive2DRenderer > xPrimitive2DRenderer =
197 0 : graphic::Primitive2DTools::create( xContext );
198 :
199 : // cancel out rasterize's mm2pixel conversion
200 : // see fFactor100th_mmToInch in
201 : // drawinglayer/source/drawinglayeruno/xprimitive2drenderer.cxx
202 0 : const double fFakeDPI=2.54 * 1000.0;
203 :
204 : geometry::RealRectangle2D aRealRect(
205 : 0, 0,
206 0 : nWidth, nWidth / fAspectRatio);
207 :
208 : const uno::Reference< rendering::XBitmap > xBitmap(
209 0 : xPrimitive2DRenderer->rasterize(
210 : drawinglayer::primitive2d::Primitive2DSequence(&xTransformRef, 1),
211 : uno::Sequence< beans::PropertyValue >(),
212 : fFakeDPI,
213 : fFakeDPI,
214 : aRealRect,
215 0 : 500000));
216 :
217 0 : if(xBitmap.is())
218 : {
219 0 : const uno::Reference< rendering::XIntegerReadOnlyBitmap> xIntBmp(xBitmap, uno::UNO_QUERY_THROW);
220 :
221 0 : if(xIntBmp.is())
222 : {
223 0 : rBitmap = vcl::unotools::bitmapExFromXBitmap(xIntBmp);
224 0 : return true;
225 0 : }
226 0 : }
227 : }
228 0 : catch(const uno::Exception&)
229 : {
230 : OSL_ENSURE(false, "Got no graphic::XPrimitive2DRenderer (!)" );
231 : }
232 0 : return false;
233 : }
234 :
235 : /** loads the application logo as used in the impress slideshow pause screen */
236 0 : BitmapEx SfxApplication::GetApplicationLogo(long nWidth)
237 : {
238 0 : BitmapEx aBitmap;
239 0 : SfxApplication::loadBrandSvg("flat_logo", aBitmap, nWidth);
240 0 : Application::LoadBrandBitmap ("about", aBitmap);
241 0 : return aBitmap;
242 : }
243 :
244 0 : SfxChildWinFactArr_Impl::~SfxChildWinFactArr_Impl()
245 : {
246 0 : for( const_iterator it = begin(); it != end(); ++it )
247 0 : delete *it;
248 0 : }
249 :
250 0 : SfxMenuCtrlFactArr_Impl::~SfxMenuCtrlFactArr_Impl()
251 : {
252 0 : for( const_iterator it = begin(); it != end(); ++it )
253 0 : delete *it;
254 0 : }
255 :
256 0 : SfxStbCtrlFactArr_Impl::~SfxStbCtrlFactArr_Impl()
257 : {
258 0 : for( const_iterator it = begin(); it != end(); ++it )
259 0 : delete *it;
260 0 : }
261 :
262 0 : SfxTbxCtrlFactArr_Impl::~SfxTbxCtrlFactArr_Impl()
263 : {
264 0 : for( const_iterator it = begin(); it != end(); ++it )
265 0 : delete *it;
266 0 : }
267 :
268 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|