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/.
10 #include <DrawViewShell.hxx>
11 #include <ViewShellBase.hxx>
14 #include <com/sun/star/presentation/SlideShow.hpp>
16 #include <comphelper/lok.hxx>
17 #include <comphelper/diagnose_ex.hxx>
18 #include <comphelper/processfactory.hxx>
19 #include <comphelper/servicehelper.hxx>
20 #include <sfx2/lokhelper.hxx>
21 #include <LibreOfficeKit/LibreOfficeKitEnums.h>
22 #include <unomodel.hxx>
28 void DrawViewShell::ConfigurationChanged( utl::ConfigurationBroadcaster
* pCb
, ConfigurationHints
)
30 svtools::ColorConfig
*pColorConfig
= dynamic_cast<svtools::ColorConfig
*>(pCb
);
31 ConfigureAppBackgroundColor(pColorConfig
);
32 if (!comphelper::LibreOfficeKit::isActive())
34 SdViewOptions aViewOptions
= GetViewOptions();
35 aViewOptions
.mnDocBackgroundColor
= pColorConfig
->GetColorValue(svtools::DOCCOLOR
).nColor
;
36 SetViewOptions(aViewOptions
);
40 SfxViewShell
* pCurrentShell
= SfxViewShell::Current();
41 ViewShellBase
* pShellBase
= dynamic_cast<ViewShellBase
*>(pCurrentShell
);
44 SdViewOptions aViewOptions
= pShellBase
->GetViewOptions();
45 aViewOptions
.mnDocBackgroundColor
= pColorConfig
->GetColorValue(svtools::DOCCOLOR
).nColor
;
46 aViewOptions
.msColorSchemeName
= svtools::ColorConfig::GetCurrentSchemeName();
47 pShellBase
->SetViewOptions(aViewOptions
);
48 SdXImpressDocument
* pDoc
= comphelper::getFromUnoTunnel
<SdXImpressDocument
>(pCurrentShell
->GetCurrentDocument());
49 SfxLokHelper::notifyViewRenderState(pCurrentShell
, pDoc
);
50 Color
aFillColor(pColorConfig
->GetColorValue(svtools::APPBACKGROUND
).nColor
);
51 pCurrentShell
->libreOfficeKitViewCallback(LOK_CALLBACK_APPLICATION_BACKGROUND_COLOR
,
52 aFillColor
.AsRGBHexString().toUtf8());
56 void DrawViewShell::ConfigureAppBackgroundColor( svtools::ColorConfig
*pColorConfig
)
59 pColorConfig
= &SdModule::get()->GetColorConfig();
60 Color
aFillColor( pColorConfig
->GetColorValue( svtools::APPBACKGROUND
).nColor
);
61 if (comphelper::LibreOfficeKit::isActive())
62 aFillColor
= COL_TRANSPARENT
;
63 // tdf#87905 Use darker background color for master view
64 if (meEditMode
== EditMode::MasterPage
)
65 aFillColor
.DecreaseLuminance( 64 );
66 SdViewOptions aViewOptions
= GetViewOptions();
67 aViewOptions
.mnAppBackgroundColor
= aFillColor
;
68 SetViewOptions(aViewOptions
);
71 void DrawViewShell::destroyXSlideShowInstance()
73 if (!mxSlideShow
.is())
78 uno::Reference
<lang::XComponent
> xComponent(mxSlideShow
, uno::UNO_QUERY
);
80 xComponent
->dispose();
82 catch (uno::Exception
&)
84 TOOLS_WARN_EXCEPTION( "sd", "DrawViewShell::destroyXSlideShowInstance dispose");
90 const uno::Reference
<presentation::XSlideShow
> & DrawViewShell::getXSlideShowInstance()
92 if (!mxSlideShow
.is())
96 const auto& xContext
= ::comphelper::getProcessComponentContext();
97 mxSlideShow
.set(presentation::SlideShow::create(xContext
), uno::UNO_SET_THROW
);
99 catch (uno::Exception
&)
101 TOOLS_WARN_EXCEPTION("sd", "DrawViewShell::createXSlideShowInstance()");
109 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */