update credits
[LibreOffice.git] / forms / source / richtext / specialdispatchers.cxx
blob15c2c4242138975c948cb259c3eb8c91a7d58c2f
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 "specialdispatchers.hxx"
21 #include <editeng/editeng.hxx>
22 #include <editeng/editview.hxx>
23 #include <svx/svxids.hrc>
24 #include <editeng/scriptspaceitem.hxx>
26 //........................................................................
27 namespace frm
29 //........................................................................
31 using namespace ::com::sun::star::uno;
32 using namespace ::com::sun::star::lang;
33 using namespace ::com::sun::star::util;
34 using namespace ::com::sun::star::frame;
35 using namespace ::com::sun::star::beans;
37 //====================================================================
38 //= OSelectAllDispatcher
39 //====================================================================
40 //--------------------------------------------------------------------
41 OSelectAllDispatcher::OSelectAllDispatcher( EditView& _rView, const URL& _rURL )
42 :ORichTextFeatureDispatcher( _rView, _rURL )
46 //--------------------------------------------------------------------
47 OSelectAllDispatcher::~OSelectAllDispatcher( )
49 if ( !isDisposed() )
51 acquire();
52 dispose();
56 //--------------------------------------------------------------------
57 void SAL_CALL OSelectAllDispatcher::dispatch( const URL& _rURL, const Sequence< PropertyValue >& /*_rArguments*/ ) throw (RuntimeException)
59 ::osl::MutexGuard aGuard( m_aMutex );
60 OSL_ENSURE( _rURL.Complete == getFeatureURL().Complete, "OSelectAllDispatcher::dispatch: invalid URL!" );
61 (void)_rURL;
63 checkDisposed();
65 EditEngine* pEngine = getEditView() ? getEditView()->GetEditEngine() : NULL;
66 OSL_ENSURE( pEngine, "OSelectAllDispatcher::dispatch: no edit engine - but not yet disposed?" );
67 if ( !pEngine )
68 return;
70 sal_Int32 nParagraphs = pEngine->GetParagraphCount();
71 if ( nParagraphs )
73 sal_Int32 nLastParaNumber = nParagraphs - 1;
74 xub_StrLen nParaLen = pEngine->GetTextLen( nLastParaNumber );
75 getEditView()->SetSelection( ESelection( 0, 0, nLastParaNumber, nParaLen ) );
79 //--------------------------------------------------------------------
80 FeatureStateEvent OSelectAllDispatcher::buildStatusEvent() const
82 FeatureStateEvent aEvent( ORichTextFeatureDispatcher::buildStatusEvent() );
83 aEvent.IsEnabled = sal_True;
84 return aEvent;
87 //====================================================================
88 //= OParagraphDirectionDispatcher
89 //====================================================================
90 //--------------------------------------------------------------------
91 OParagraphDirectionDispatcher::OParagraphDirectionDispatcher( EditView& _rView, AttributeId _nAttributeId, const URL& _rURL,
92 IMultiAttributeDispatcher* _pMasterDispatcher )
93 :OAttributeDispatcher( _rView, _nAttributeId, _rURL, _pMasterDispatcher )
97 //--------------------------------------------------------------------
98 FeatureStateEvent OParagraphDirectionDispatcher::buildStatusEvent() const
100 FeatureStateEvent aEvent( OAttributeDispatcher::buildStatusEvent() );
102 EditEngine* pEngine = getEditView() ? getEditView()->GetEditEngine() : NULL;
103 OSL_ENSURE( pEngine, "OParagraphDirectionDispatcher::dispatch: no edit engine - but not yet disposed?" );
104 if ( pEngine && pEngine->IsVertical() )
105 aEvent.IsEnabled = sal_False;
107 return aEvent;
110 //====================================================================
111 //= OTextDirectionDispatcher
112 //====================================================================
113 //--------------------------------------------------------------------
114 OTextDirectionDispatcher::OTextDirectionDispatcher( EditView& _rView, const URL& _rURL )
115 :ORichTextFeatureDispatcher( _rView, _rURL )
119 //--------------------------------------------------------------------
120 void SAL_CALL OTextDirectionDispatcher::dispatch( const URL& _rURL, const Sequence< PropertyValue >& /*_rArguments*/ ) throw (RuntimeException)
122 ::osl::MutexGuard aGuard( m_aMutex );
123 OSL_ENSURE( _rURL.Complete == getFeatureURL().Complete, "OTextDirectionDispatcher::dispatch: invalid URL!" );
124 (void)_rURL;
126 checkDisposed();
128 EditEngine* pEngine = getEditView() ? getEditView()->GetEditEngine() : NULL;
129 OSL_ENSURE( pEngine, "OTextDirectionDispatcher::dispatch: no edit engine - but not yet disposed?" );
130 if ( !pEngine )
131 return;
133 pEngine->SetVertical( !pEngine->IsVertical() );
136 //--------------------------------------------------------------------
137 FeatureStateEvent OTextDirectionDispatcher::buildStatusEvent() const
139 FeatureStateEvent aEvent( ORichTextFeatureDispatcher::buildStatusEvent() );
141 EditEngine* pEngine = getEditView() ? getEditView()->GetEditEngine() : NULL;
142 OSL_ENSURE( pEngine, "OTextDirectionDispatcher::dispatch: no edit engine - but not yet disposed?" );
144 aEvent.IsEnabled = sal_True;
145 aEvent.State <<= (sal_Bool)( pEngine && pEngine->IsVertical() );
147 return aEvent;
150 //====================================================================
151 //= OAsianFontLayoutDispatcher
152 //====================================================================
153 //--------------------------------------------------------------------
154 OAsianFontLayoutDispatcher::OAsianFontLayoutDispatcher( EditView& _rView, AttributeId _nAttributeId, const URL& _rURL, IMultiAttributeDispatcher* _pMasterDispatcher )
155 :OParametrizedAttributeDispatcher( _rView, _nAttributeId, _rURL, _pMasterDispatcher )
159 //--------------------------------------------------------------------
160 const SfxPoolItem* OAsianFontLayoutDispatcher::convertDispatchArgsToItem( const Sequence< PropertyValue >& _rArguments )
162 // look for the "Enable" parameter
163 const PropertyValue* pLookup = _rArguments.getConstArray();
164 const PropertyValue* pLookupEnd = _rArguments.getConstArray() + _rArguments.getLength();
165 while ( pLookup != pLookupEnd )
167 if ( pLookup->Name == "Enable" )
168 break;
169 ++pLookup;
171 if ( pLookup != pLookupEnd )
173 sal_Bool bEnable = sal_True;
174 OSL_VERIFY( pLookup->Value >>= bEnable );
175 if ( m_nAttributeId == SID_ATTR_PARA_SCRIPTSPACE )
176 return new SvxScriptSpaceItem( bEnable, (WhichId)m_nAttributeId );
177 return new SfxBoolItem( (WhichId)m_nAttributeId, bEnable );
180 OSL_FAIL( "OAsianFontLayoutDispatcher::convertDispatchArgsToItem: did not find the one and only argument!" );
181 return NULL;
184 //........................................................................
185 } // namespace frm
186 //........................................................................
188 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */