tdf#130857 qt weld: Implement QtInstanceWidget::get_text_height
[LibreOffice.git] / oox / source / drawingml / clrschemecontext.cxx
blob994a15b4840837bedca1e1492009ba8fd10a4d0d
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 <drawingml/clrschemecontext.hxx>
21 #include <oox/core/xmlfilterbase.hxx>
22 #include <oox/helper/attributelist.hxx>
23 #include <oox/token/namespaces.hxx>
24 #include <oox/token/tokens.hxx>
26 using namespace ::oox::core;
28 namespace oox::drawingml {
30 static void setClrMap( const ::oox::AttributeList& rAttributes,
31 ClrMap& rClrMap, sal_Int32 nToken )
33 if ( rAttributes.hasAttribute( nToken ) )
35 sal_Int32 nMappedToken = rAttributes.getToken( nToken, 0 );
36 rClrMap.setColorMap( nToken, nMappedToken );
40 clrMapContext::clrMapContext( ContextHandler2Helper const & rParent,
41 const ::oox::AttributeList& rAttributes, ClrMap& rClrMap )
42 : ContextHandler2( rParent )
44 setClrMap( rAttributes, rClrMap, XML_bg1 );
45 setClrMap( rAttributes, rClrMap, XML_tx1 );
46 setClrMap( rAttributes, rClrMap, XML_bg2 );
47 setClrMap( rAttributes, rClrMap, XML_tx2 );
48 setClrMap( rAttributes, rClrMap, XML_accent1 );
49 setClrMap( rAttributes, rClrMap, XML_accent2 );
50 setClrMap( rAttributes, rClrMap, XML_accent3 );
51 setClrMap( rAttributes, rClrMap, XML_accent4 );
52 setClrMap( rAttributes, rClrMap, XML_accent5 );
53 setClrMap( rAttributes, rClrMap, XML_accent6 );
54 setClrMap( rAttributes, rClrMap, XML_hlink );
55 setClrMap( rAttributes, rClrMap, XML_folHlink );
58 clrSchemeColorContext::clrSchemeColorContext(ContextHandler2Helper const & rParent, ClrScheme& rClrScheme, model::ColorSet& rColorSet, sal_Int32 nColorToken)
59 : ColorContext(rParent, *this, nullptr)
60 , mrClrScheme(rClrScheme)
61 , mrColorSet(rColorSet)
62 , mnColorToken(nColorToken)
66 clrSchemeColorContext::~clrSchemeColorContext()
68 ::Color aColor = getColor(getFilter().getGraphicHelper());
69 mrClrScheme.setColor(mnColorToken, aColor);
70 switch (mnColorToken)
72 case XML_tx1:
73 case XML_dk1: mrColorSet.add(model::ThemeColorType::Dark1, aColor); break;
74 case XML_bg1:
75 case XML_lt1: mrColorSet.add(model::ThemeColorType::Light1, aColor); break;
76 case XML_tx2:
77 case XML_dk2: mrColorSet.add(model::ThemeColorType::Dark2, aColor); break;
78 case XML_bg2:
79 case XML_lt2: mrColorSet.add(model::ThemeColorType::Light2, aColor); break;
80 case XML_accent1: mrColorSet.add(model::ThemeColorType::Accent1, aColor); break;
81 case XML_accent2: mrColorSet.add(model::ThemeColorType::Accent2, aColor); break;
82 case XML_accent3: mrColorSet.add(model::ThemeColorType::Accent3, aColor); break;
83 case XML_accent4: mrColorSet.add(model::ThemeColorType::Accent4, aColor); break;
84 case XML_accent5: mrColorSet.add(model::ThemeColorType::Accent5, aColor); break;
85 case XML_accent6: mrColorSet.add(model::ThemeColorType::Accent6, aColor); break;
86 case XML_hlink: mrColorSet.add(model::ThemeColorType::Hyperlink, aColor); break;
87 case XML_folHlink: mrColorSet.add(model::ThemeColorType::FollowedHyperlink, aColor); break;
88 default: break;
92 clrSchemeContext::clrSchemeContext(ContextHandler2Helper const & rParent, ClrScheme& rClrScheme, model::ColorSet& rColorSet)
93 : ContextHandler2(rParent)
94 , mrClrScheme(rClrScheme)
95 , mrColorSet(rColorSet)
99 ContextHandlerRef clrSchemeContext::onCreateContext(
100 sal_Int32 nElement, const AttributeList& )
102 switch( nElement )
104 case A_TOKEN( dk1 ):
105 case A_TOKEN( tx1 ):
106 case A_TOKEN( lt1 ):
107 case A_TOKEN( bg1 ):
108 case A_TOKEN( dk2 ):
109 case A_TOKEN( tx2 ):
110 case A_TOKEN( lt2 ):
111 case A_TOKEN( bg2 ):
112 case A_TOKEN( accent1 ):
113 case A_TOKEN( accent2 ):
114 case A_TOKEN( accent3 ):
115 case A_TOKEN( accent4 ):
116 case A_TOKEN( accent5 ):
117 case A_TOKEN( accent6 ):
118 case A_TOKEN( hlink ):
119 case A_TOKEN( folHlink ):
120 return new clrSchemeColorContext(*this, mrClrScheme, mrColorSet, getBaseToken(nElement));
122 return nullptr;
127 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */