LanguageTool: don't crash if REST protocol isn't set
[LibreOffice.git] / forms / source / richtext / richtextunowrapper.cxx
blobd9c4269216ea8fc7885b0d723368474e377ca6c9
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 "richtextunowrapper.hxx"
22 #include <com/sun/star/lang/Locale.hpp>
23 #include <com/sun/star/container/XNameContainer.hpp>
24 #include <editeng/unofored.hxx>
25 #include <editeng/editview.hxx>
26 #include <editeng/unoipset.hxx>
27 #include <svx/svdpool.hxx>
28 #include <svx/svdobj.hxx>
29 #include <editeng/unoprnms.hxx>
32 namespace frm
36 using namespace ::com::sun::star::uno;
37 using namespace ::com::sun::star::lang;
38 using namespace ::com::sun::star::beans;
39 using namespace ::com::sun::star::container;
42 namespace
44 const SvxItemPropertySet* getTextEnginePropertySet()
46 // property map for an outliner text
47 static const SfxItemPropertyMapEntry aTextEnginePropertyMap[] =
49 SVX_UNOEDIT_CHAR_PROPERTIES,
50 SVX_UNOEDIT_FONT_PROPERTIES,
51 SVX_UNOEDIT_PARA_PROPERTIES,
52 { u"TextUserDefinedAttributes", EE_CHAR_XMLATTRIBS, cppu::UnoType<XNameContainer>::get(), 0, 0 },
53 { u"ParaUserDefinedAttributes", EE_PARA_XMLATTRIBS, cppu::UnoType<XNameContainer>::get(), 0, 0 },
54 { u"", 0, css::uno::Type(), 0, 0 }
56 static SvxItemPropertySet aTextEnginePropertySet( aTextEnginePropertyMap, SdrObject::GetGlobalDrawObjectItemPool() );
57 return &aTextEnginePropertySet;
61 ORichTextUnoWrapper::ORichTextUnoWrapper( EditEngine& _rEngine, IEngineTextChangeListener* _pTextChangeListener )
62 :SvxUnoText( getTextEnginePropertySet() )
64 SetEditSource( new RichTextEditSource( _rEngine, _pTextChangeListener ) );
68 ORichTextUnoWrapper::~ORichTextUnoWrapper() noexcept
72 RichTextEditSource::RichTextEditSource( EditEngine& _rEngine, IEngineTextChangeListener* _pTextChangeListener )
73 :m_rEngine ( _rEngine )
74 ,m_pTextForwarder ( new SvxEditEngineForwarder( _rEngine ) )
75 ,m_pTextChangeListener ( _pTextChangeListener )
80 RichTextEditSource::~RichTextEditSource()
85 std::unique_ptr<SvxEditSource> RichTextEditSource::Clone() const
87 return std::unique_ptr<SvxEditSource>(new RichTextEditSource( m_rEngine, m_pTextChangeListener ));
91 SvxTextForwarder* RichTextEditSource::GetTextForwarder()
93 return m_pTextForwarder.get();
97 void RichTextEditSource::UpdateData()
99 // this means that the content of the EditEngine changed via the UNO API
100 // to reflect this in the views, we need to update them
101 sal_uInt16 viewCount = m_rEngine.GetViewCount();
102 for ( sal_uInt16 view = 0; view < viewCount; ++view )
104 EditView* pView = m_rEngine.GetView( view );
105 if ( pView )
106 pView->ForceLayoutCalculation();
109 if ( m_pTextChangeListener )
110 m_pTextChangeListener->potentialTextChange();
114 } // namespace frm
117 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */