1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <config_folders.h>
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>
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>
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>
79 #include <basegfx/matrix/b2dhommatrixtools.hxx>
80 #include <drawinglayer/primitive2d/transformprimitive2d.hxx>
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
;
88 //===================================================================
90 #define SfxApplication
91 #include "sfxslots.hxx"
93 //====================================================================
95 #define SFX_ITEMTYPE_STATBAR 4
97 SFX_IMPL_INTERFACE(SfxApplication
,SfxShell
,SfxResId(RID_DESKTOP
))
99 SFX_STATUSBAR_REGISTRATION(SfxResId(SFX_ITEMTYPE_STATBAR
));
100 SFX_CHILDWINDOW_REGISTRATION(SID_DOCKWIN_0
);
101 SFX_CHILDWINDOW_REGISTRATION(SID_DOCKWIN_1
);
102 SFX_CHILDWINDOW_REGISTRATION(SID_DOCKWIN_2
);
103 SFX_CHILDWINDOW_REGISTRATION(SID_DOCKWIN_3
);
104 SFX_CHILDWINDOW_REGISTRATION(SID_DOCKWIN_4
);
105 SFX_CHILDWINDOW_REGISTRATION(SID_DOCKWIN_5
);
106 SFX_CHILDWINDOW_REGISTRATION(SID_DOCKWIN_6
);
107 SFX_CHILDWINDOW_REGISTRATION(SID_DOCKWIN_7
);
108 SFX_CHILDWINDOW_REGISTRATION(SID_DOCKWIN_8
);
109 SFX_CHILDWINDOW_REGISTRATION(SID_DOCKWIN_9
);
112 //--------------------------------------------------------------------
113 SfxProgress
* SfxApplication::GetProgress() const
117 Returns the running SfxProgress for the entire application or 0 if
118 none is running for the entire application.
122 <SfxProgress::GetActiveProgress(SfxViewFrame*)>
123 <SfxViewFrame::GetProgress()const>
127 return pAppData_Impl
->pProgress
;
130 SfxModule
* SfxApplication::GetModule_Impl()
132 SfxModule
* pModule
= SfxModule::GetActiveModule();
134 pModule
= SfxModule::GetActiveModule( SfxViewFrame::GetFirst( 0, sal_False
) );
139 OSL_FAIL( "No module!" );
144 ISfxTemplateCommon
* SfxApplication::GetCurrentTemplateCommon( SfxBindings
& rBindings
)
146 if( pAppData_Impl
->pTemplateCommon
)
147 return pAppData_Impl
->pTemplateCommon
;
148 SfxChildWindow
*pChild
= rBindings
.GetWorkWindow_Impl()->GetChildWindow_Impl(
149 SfxTemplateDialogWrapper::GetChildWindowId() );
151 return ((SfxTemplateDialog
*) pChild
->GetWindow())->GetISfxTemplateCommon();
155 sal_Bool
SfxApplication::IsDowning() const { return pAppData_Impl
->bDowning
; }
156 SfxDispatcher
* SfxApplication::GetAppDispatcher_Impl() { return pAppData_Impl
->pAppDispat
; }
157 SfxSlotPool
& SfxApplication::GetAppSlotPool_Impl() const { return *pAppData_Impl
->pSlotPool
; }
159 bool SfxApplication::loadBrandSvg(const char *pName
, BitmapEx
&rBitmap
, int nWidth
)
162 // ---------------------------------------------------------------------
163 OUString aBaseName
= ( OUString("/") +
164 OUString::createFromAscii( pName
) );
165 OUString
aSvg( ".svg" );
167 rtl_Locale
*pLoc
= NULL
;
168 osl_getProcessLocale (&pLoc
);
169 LanguageTag
aLanguageTag( *pLoc
);
171 OUString uri
= OUString::createFromAscii( "$BRAND_BASE_DIR/" LIBO_ETC_FOLDER
) + aBaseName
+aSvg
;
172 rtl::Bootstrap::expandMacros( uri
);
173 INetURLObject
aObj( uri
);
174 SvgData
aSvgData(aObj
.PathToFileName());
176 // transform into [0,0,width,width*aspect] std dimensions
177 // ---------------------------------------------------------------------
178 basegfx::B2DRange
aRange(aSvgData
.getRange());
179 const double fAspectRatio(aRange
.getWidth()/aRange
.getHeight());
180 basegfx::B2DHomMatrix
aTransform(
181 basegfx::tools::createTranslateB2DHomMatrix(
185 nWidth
/ aRange
.getWidth(),
186 nWidth
/ fAspectRatio
/ aRange
.getHeight());
187 const drawinglayer::primitive2d::Primitive2DReference
xTransformRef(
188 new drawinglayer::primitive2d::TransformPrimitive2D(
190 aSvgData
.getPrimitive2DSequence()));
192 // UNO dance to render from drawinglayer
193 // ---------------------------------------------------------------------
194 uno::Reference
< uno::XComponentContext
> xContext(::comphelper::getProcessComponentContext());
198 const uno::Reference
< graphic::XPrimitive2DRenderer
> xPrimitive2DRenderer
=
199 graphic::Primitive2DTools::create( xContext
);
201 // cancel out rasterize's mm2pixel conversion
202 // see fFactor100th_mmToInch in
203 // drawinglayer/source/drawinglayeruno/xprimitive2drenderer.cxx
204 const double fFakeDPI
=2.54 * 1000.0;
206 geometry::RealRectangle2D
aRealRect(
208 nWidth
, nWidth
/ fAspectRatio
);
210 const uno::Reference
< rendering::XBitmap
> xBitmap(
211 xPrimitive2DRenderer
->rasterize(
212 drawinglayer::primitive2d::Primitive2DSequence(&xTransformRef
, 1),
213 uno::Sequence
< beans::PropertyValue
>(),
221 const uno::Reference
< rendering::XIntegerReadOnlyBitmap
> xIntBmp(xBitmap
, uno::UNO_QUERY_THROW
);
225 rBitmap
= vcl::unotools::bitmapExFromXBitmap(xIntBmp
);
230 catch(const uno::Exception
&)
232 OSL_ENSURE(sal_False
, "Got no graphic::XPrimitive2DRenderer (!)" );
237 /** loads the application logo as used in the impress slideshow pause screen */
238 BitmapEx
SfxApplication::GetApplicationLogo(long nWidth
)
241 SfxApplication::loadBrandSvg("flat_logo", aBitmap
, nWidth
);
242 Application::LoadBrandBitmap ("about", aBitmap
);
246 SfxChildWinFactArr_Impl::~SfxChildWinFactArr_Impl()
248 for( const_iterator it
= begin(); it
!= end(); ++it
)
252 SfxMenuCtrlFactArr_Impl::~SfxMenuCtrlFactArr_Impl()
254 for( const_iterator it
= begin(); it
!= end(); ++it
)
258 SfxStbCtrlFactArr_Impl::~SfxStbCtrlFactArr_Impl()
260 for( const_iterator it
= begin(); it
!= end(); ++it
)
264 SfxTbxCtrlFactArr_Impl::~SfxTbxCtrlFactArr_Impl()
266 for( const_iterator it
= begin(); it
!= end(); ++it
)
270 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */