Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 : #include "richtextunowrapper.hxx"
21 :
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>
30 :
31 :
32 : namespace frm
33 : {
34 :
35 :
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;
40 :
41 :
42 : namespace
43 : {
44 0 : const SvxItemPropertySet* getTextEnginePropertySet()
45 : {
46 : // Propertymap fuer einen Outliner Text
47 : static const SfxItemPropertyMapEntry aTextEnginePropertyMap[] =
48 : {
49 0 : SVX_UNOEDIT_CHAR_PROPERTIES,
50 0 : SVX_UNOEDIT_FONT_PROPERTIES,
51 0 : SVX_UNOEDIT_PARA_PROPERTIES,
52 0 : { OUString("TextUserDefinedAttributes"), EE_CHAR_XMLATTRIBS, ::getCppuType( static_cast< const Reference< XNameContainer >* >( NULL ) ), 0, 0 },
53 0 : { OUString("ParaUserDefinedAttributes"), EE_PARA_XMLATTRIBS, ::getCppuType( static_cast< const Reference< XNameContainer >* >( NULL ) ), 0, 0 },
54 : { OUString(), 0, css::uno::Type(), 0, 0 }
55 0 : };
56 0 : static SvxItemPropertySet aTextEnginePropertySet( aTextEnginePropertyMap, SdrObject::GetGlobalDrawObjectItemPool() );
57 0 : return &aTextEnginePropertySet;
58 : }
59 : }
60 :
61 :
62 : //= ORichTextUnoWrapper
63 :
64 :
65 0 : ORichTextUnoWrapper::ORichTextUnoWrapper( EditEngine& _rEngine, IEngineTextChangeListener* _pTextChangeListener )
66 0 : :SvxUnoText( getTextEnginePropertySet() )
67 : {
68 0 : SetEditSource( new RichTextEditSource( _rEngine, _pTextChangeListener ) );
69 0 : }
70 :
71 :
72 0 : ORichTextUnoWrapper::~ORichTextUnoWrapper() throw()
73 : {
74 0 : }
75 :
76 :
77 : //= RichTextEditSource
78 :
79 :
80 0 : RichTextEditSource::RichTextEditSource( EditEngine& _rEngine, IEngineTextChangeListener* _pTextChangeListener )
81 : :m_rEngine ( _rEngine )
82 0 : ,m_pTextForwarder ( new SvxEditEngineForwarder( _rEngine ) )
83 0 : ,m_pTextChangeListener ( _pTextChangeListener )
84 : {
85 0 : }
86 :
87 :
88 0 : RichTextEditSource::~RichTextEditSource()
89 : {
90 0 : delete m_pTextForwarder;
91 0 : }
92 :
93 :
94 0 : SvxEditSource* RichTextEditSource::Clone() const
95 : {
96 0 : return new RichTextEditSource( m_rEngine, m_pTextChangeListener );
97 : }
98 :
99 :
100 0 : SvxTextForwarder* RichTextEditSource::GetTextForwarder()
101 : {
102 0 : return m_pTextForwarder;
103 : }
104 :
105 :
106 0 : void RichTextEditSource::UpdateData()
107 : {
108 : // this means that the content of the EditEngine changed via the UNO API
109 : // to reflect this in the views, we need to update them
110 0 : sal_uInt16 viewCount = m_rEngine.GetViewCount();
111 0 : for ( sal_uInt16 view = 0; view < viewCount; ++view )
112 : {
113 0 : EditView* pView = m_rEngine.GetView( view );
114 0 : if ( pView )
115 0 : pView->ForceUpdate();
116 : }
117 :
118 0 : if ( m_pTextChangeListener )
119 0 : m_pTextChangeListener->potentialTextChange();
120 0 : }
121 :
122 :
123 : } // namespace frm
124 :
125 :
126 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|