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 "PageBackground.hxx"
21 #include <comphelper/lok.hxx>
22 #include <LinePropertiesHelper.hxx>
23 #include <FillProperties.hxx>
24 #include <UserDefinedProperties.hxx>
25 #include <PropertyHelper.hxx>
26 #include <ModifyListenerHelper.hxx>
27 #include <svtools/colorcfg.hxx>
28 #include <sfx2/viewsh.hxx>
30 #include <com/sun/star/drawing/LineStyle.hpp>
31 #include <cppuhelper/supportsservice.hxx>
36 namespace com::sun::star::uno
{ class XComponentContext
; }
38 using namespace ::com::sun::star
;
40 using ::com::sun::star::beans::Property
;
45 const ::chart::tPropertyValueMap
& StaticPageBackgroundDefaults()
47 static ::chart::tPropertyValueMap aStaticDefaults
= []()
49 ::chart::tPropertyValueMap aTmp
;
50 ::chart::LinePropertiesHelper::AddDefaultsToMap( aTmp
);
51 ::chart::FillProperties::AddDefaultsToMap( aTmp
);
53 // override other defaults
54 Color aDocColor
= COL_WHITE
;
55 if (comphelper::LibreOfficeKit::isActive()) {
58 if (SfxViewShell
* pCurrentSh
= SfxViewShell::Current()) {
59 aDocColor
= pCurrentSh
->GetColorConfigColor(svtools::DOCCOLOR
);
61 aDocColor
= svtools::ColorConfig().GetColorValue(svtools::DOCCOLOR
).nColor
;
64 ::chart::PropertyHelper::setPropertyValue( aTmp
, ::chart::FillProperties::PROP_FILL_COLOR
, aDocColor
);
65 ::chart::PropertyHelper::setPropertyValue( aTmp
, ::chart::LinePropertiesHelper::PROP_LINE_STYLE
, drawing::LineStyle_NONE
);
68 return aStaticDefaults
;
71 ::cppu::OPropertyArrayHelper
& StaticPageBackgroundInfoHelper()
73 static ::cppu::OPropertyArrayHelper aPropHelper
= []()
75 std::vector
< css::beans::Property
> aProperties
;
76 ::chart::LinePropertiesHelper::AddPropertiesToVector( aProperties
);
77 ::chart::FillProperties::AddPropertiesToVector( aProperties
);
78 ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties
);
80 std::sort( aProperties
.begin(), aProperties
.end(),
81 ::chart::PropertyNameLess() );
83 return comphelper::containerToSequence( aProperties
);
88 } // anonymous namespace
93 PageBackground::PageBackground() :
94 m_xModifyEventForwarder( new ModifyEventForwarder() )
97 PageBackground::PageBackground( const PageBackground
& rOther
) :
98 impl::PageBackground_Base(rOther
),
99 ::property::OPropertySet( rOther
),
100 m_xModifyEventForwarder( new ModifyEventForwarder() )
103 PageBackground::~PageBackground()
106 // ____ XTypeProvider ____
107 uno::Sequence
< css::uno::Type
> SAL_CALL
PageBackground::getTypes()
109 return ::comphelper::concatSequences(
110 impl::PageBackground_Base::getTypes(),
111 ::property::OPropertySet::getTypes());
114 // ____ XCloneable ____
115 uno::Reference
< util::XCloneable
> SAL_CALL
PageBackground::createClone()
117 return uno::Reference
< util::XCloneable
>( new PageBackground( *this ));
120 // ____ OPropertySet ____
121 void PageBackground::GetDefaultValue( sal_Int32 nHandle
, uno::Any
& rAny
) const
123 const tPropertyValueMap
& rStaticDefaults
= StaticPageBackgroundDefaults();
124 tPropertyValueMap::const_iterator
aFound( rStaticDefaults
.find( nHandle
) );
125 if( aFound
== rStaticDefaults
.end() )
128 rAny
= (*aFound
).second
;
131 ::cppu::IPropertyArrayHelper
& SAL_CALL
PageBackground::getInfoHelper()
133 return StaticPageBackgroundInfoHelper();
136 // ____ XPropertySet ____
137 uno::Reference
< beans::XPropertySetInfo
> SAL_CALL
PageBackground::getPropertySetInfo()
139 static uno::Reference
< beans::XPropertySetInfo
> xPropertySetInfo(
140 ::cppu::OPropertySetHelper::createPropertySetInfo(StaticPageBackgroundInfoHelper() ) );
141 return xPropertySetInfo
;
144 // ____ XModifyBroadcaster ____
145 void SAL_CALL
PageBackground::addModifyListener( const uno::Reference
< util::XModifyListener
>& aListener
)
147 m_xModifyEventForwarder
->addModifyListener( aListener
);
150 void SAL_CALL
PageBackground::removeModifyListener( const uno::Reference
< util::XModifyListener
>& aListener
)
152 m_xModifyEventForwarder
->removeModifyListener( aListener
);
155 // ____ XModifyListener ____
156 void SAL_CALL
PageBackground::modified( const lang::EventObject
& aEvent
)
158 m_xModifyEventForwarder
->modified( aEvent
);
161 // ____ XEventListener (base of XModifyListener) ____
162 void SAL_CALL
PageBackground::disposing( const lang::EventObject
& /* Source */ )
167 // ____ OPropertySet ____
168 void PageBackground::firePropertyChangeEvent()
170 m_xModifyEventForwarder
->modified( lang::EventObject( static_cast< uno::XWeak
* >( this )));
173 OUString SAL_CALL
PageBackground::getImplementationName()
175 return u
"com.sun.star.comp.chart2.PageBackground"_ustr
;
178 sal_Bool SAL_CALL
PageBackground::supportsService( const OUString
& rServiceName
)
180 return cppu::supportsService(this, rServiceName
);
183 css::uno::Sequence
< OUString
> SAL_CALL
PageBackground::getSupportedServiceNames()
186 u
"com.sun.star.chart2.PageBackground"_ustr
,
187 u
"com.sun.star.beans.PropertySet"_ustr
};
190 using impl::PageBackground_Base
;
192 IMPLEMENT_FORWARD_XINTERFACE2( PageBackground
, PageBackground_Base
, ::property::OPropertySet
)
196 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
*
197 com_sun_star_comp_chart2_PageBackground_get_implementation(css::uno::XComponentContext
*,
198 css::uno::Sequence
<css::uno::Any
> const &)
200 return cppu::acquire(new ::chart::PageBackground
);
203 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */