bump product version to 6.3.0.0.beta1
[LibreOffice.git] / oox / source / shape / ShapeFilterBase.cxx
blobbde8cdca19c38766e47bbf445527a79acab3f902
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 <oox/shape/ShapeFilterBase.hxx>
21 #include <oox/drawingml/chart/chartconverter.hxx>
22 #include <oox/drawingml/themefragmenthandler.hxx>
23 #include <oox/helper/graphichelper.hxx>
24 #include <oox/ole/vbaproject.hxx>
25 #include <oox/drawingml/theme.hxx>
27 #include <com/sun/star/beans/XPropertySet.hpp>
28 #include <com/sun/star/xml/sax/XFastSAXSerializable.hpp>
30 namespace oox {
31 namespace shape {
33 using namespace ::com::sun::star;
35 ShapeFilterBase::ShapeFilterBase( const uno::Reference< uno::XComponentContext >& rxContext ) :
36 XmlFilterBase( rxContext ),
37 mxChartConv( new ::oox::drawingml::chart::ChartConverter )
41 ShapeFilterBase::~ShapeFilterBase()
45 const ::oox::drawingml::Theme* ShapeFilterBase::getCurrentTheme() const
47 return mpTheme.get();
50 void ShapeFilterBase::setCurrentTheme(const ::oox::drawingml::ThemePtr& pTheme)
52 mpTheme = pTheme;
55 ::oox::vml::Drawing* ShapeFilterBase::getVmlDrawing()
57 return nullptr;
60 const ::oox::drawingml::table::TableStyleListPtr ShapeFilterBase::getTableStyles()
62 return ::oox::drawingml::table::TableStyleListPtr();
65 ::oox::drawingml::chart::ChartConverter* ShapeFilterBase::getChartConverter()
67 return mxChartConv.get();
70 ::oox::ole::VbaProject* ShapeFilterBase::implCreateVbaProject() const
72 return new ::oox::ole::VbaProject( getComponentContext(), getModel(), "Writer" );
75 OUString ShapeFilterBase::getImplementationName()
77 return OUString();
80 /// Graphic helper for shapes, that can manage color schemes.
81 class ShapeGraphicHelper : public GraphicHelper
83 public:
84 explicit ShapeGraphicHelper( const ShapeFilterBase& rFilter );
85 virtual ::Color getSchemeColor( sal_Int32 nToken ) const override;
86 private:
87 const ShapeFilterBase& mrFilter;
90 ShapeGraphicHelper::ShapeGraphicHelper( const ShapeFilterBase& rFilter ) :
91 GraphicHelper( rFilter.getComponentContext(), rFilter.getTargetFrame(), rFilter.getStorage() ),
92 mrFilter( rFilter )
96 ::Color ShapeGraphicHelper::getSchemeColor( sal_Int32 nToken ) const
98 return mrFilter.getSchemeColor( nToken );
101 GraphicHelper* ShapeFilterBase::implCreateGraphicHelper() const
103 return new ShapeGraphicHelper( *this );
106 ::Color ShapeFilterBase::getSchemeColor( sal_Int32 nToken ) const
108 ::Color nColor;
110 if (mpTheme.get())
111 mpTheme->getClrScheme().getColor( nToken, nColor );
113 return nColor;
116 void ShapeFilterBase::importTheme()
118 drawingml::ThemePtr pTheme(new drawingml::Theme);
119 uno::Reference<beans::XPropertySet> xPropSet(getModel(), uno::UNO_QUERY_THROW);
120 uno::Sequence<beans::PropertyValue> aGrabBag;
121 xPropSet->getPropertyValue("InteropGrabBag") >>= aGrabBag;
123 for (int i = 0; i < aGrabBag.getLength(); i++)
125 if (aGrabBag[i].Name == "OOXTheme")
127 uno::Reference<xml::sax::XFastSAXSerializable> xDoc;
128 if (aGrabBag[i].Value >>= xDoc)
130 rtl::Reference<core::FragmentHandler> xFragmentHandler(
131 new drawingml::ThemeFragmentHandler(*this, OUString(), *pTheme));
132 importFragment(xFragmentHandler, xDoc);
133 setCurrentTheme(pTheme);
142 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */