1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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>
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 OSelectAllDispatcher::OSelectAllDispatcher( EditView
& _rView
, const URL
& _rURL
)
38 :ORichTextFeatureDispatcher( _rView
, _rURL
)
43 OSelectAllDispatcher::~OSelectAllDispatcher( )
53 void SAL_CALL
OSelectAllDispatcher::dispatch( const URL
& _rURL
, const Sequence
< PropertyValue
>& /*_rArguments*/ )
54 throw (RuntimeException
,
57 ::osl::MutexGuard
aGuard( m_aMutex
);
58 OSL_ENSURE( _rURL
.Complete
== getFeatureURL().Complete
, "OSelectAllDispatcher::dispatch: invalid URL!" );
63 EditEngine
* pEngine
= getEditView() ? getEditView()->GetEditEngine() : nullptr;
64 OSL_ENSURE( pEngine
, "OSelectAllDispatcher::dispatch: no edit engine - but not yet disposed?" );
68 sal_Int32 nParagraphs
= pEngine
->GetParagraphCount();
71 sal_Int32 nLastParaNumber
= nParagraphs
- 1;
72 sal_Int32 nParaLen
= pEngine
->GetTextLen( nLastParaNumber
);
73 getEditView()->SetSelection( ESelection( 0, 0, nLastParaNumber
, nParaLen
) );
78 FeatureStateEvent
OSelectAllDispatcher::buildStatusEvent() const
80 FeatureStateEvent
aEvent( ORichTextFeatureDispatcher::buildStatusEvent() );
81 aEvent
.IsEnabled
= true;
85 OParagraphDirectionDispatcher::OParagraphDirectionDispatcher( EditView
& _rView
, AttributeId _nAttributeId
, const URL
& _rURL
,
86 IMultiAttributeDispatcher
* _pMasterDispatcher
)
87 :OAttributeDispatcher( _rView
, _nAttributeId
, _rURL
, _pMasterDispatcher
)
92 FeatureStateEvent
OParagraphDirectionDispatcher::buildStatusEvent() const
94 FeatureStateEvent
aEvent( OAttributeDispatcher::buildStatusEvent() );
96 EditEngine
* pEngine
= getEditView() ? getEditView()->GetEditEngine() : nullptr;
97 OSL_ENSURE( pEngine
, "OParagraphDirectionDispatcher::dispatch: no edit engine - but not yet disposed?" );
98 if ( pEngine
&& pEngine
->IsVertical() )
99 aEvent
.IsEnabled
= false;
104 OTextDirectionDispatcher::OTextDirectionDispatcher( EditView
& _rView
, const URL
& _rURL
)
105 :ORichTextFeatureDispatcher( _rView
, _rURL
)
110 void SAL_CALL
OTextDirectionDispatcher::dispatch( const URL
& _rURL
, const Sequence
< PropertyValue
>& /*_rArguments*/ ) throw (RuntimeException
, std::exception
)
112 ::osl::MutexGuard
aGuard( m_aMutex
);
113 OSL_ENSURE( _rURL
.Complete
== getFeatureURL().Complete
, "OTextDirectionDispatcher::dispatch: invalid URL!" );
118 EditEngine
* pEngine
= getEditView() ? getEditView()->GetEditEngine() : nullptr;
119 OSL_ENSURE( pEngine
, "OTextDirectionDispatcher::dispatch: no edit engine - but not yet disposed?" );
123 pEngine
->SetVertical( !pEngine
->IsVertical() );
127 FeatureStateEvent
OTextDirectionDispatcher::buildStatusEvent() const
129 FeatureStateEvent
aEvent( ORichTextFeatureDispatcher::buildStatusEvent() );
131 EditEngine
* pEngine
= getEditView() ? getEditView()->GetEditEngine() : nullptr;
132 OSL_ENSURE( pEngine
, "OTextDirectionDispatcher::dispatch: no edit engine - but not yet disposed?" );
134 aEvent
.IsEnabled
= true;
135 aEvent
.State
<<= pEngine
&& pEngine
->IsVertical();
140 OAsianFontLayoutDispatcher::OAsianFontLayoutDispatcher( EditView
& _rView
, AttributeId _nAttributeId
, const URL
& _rURL
, IMultiAttributeDispatcher
* _pMasterDispatcher
)
141 :OParametrizedAttributeDispatcher( _rView
, _nAttributeId
, _rURL
, _pMasterDispatcher
)
146 const SfxPoolItem
* OAsianFontLayoutDispatcher::convertDispatchArgsToItem( const Sequence
< PropertyValue
>& _rArguments
)
148 // look for the "Enable" parameter
149 const PropertyValue
* pLookup
= _rArguments
.getConstArray();
150 const PropertyValue
* pLookupEnd
= _rArguments
.getConstArray() + _rArguments
.getLength();
151 while ( pLookup
!= pLookupEnd
)
153 if ( pLookup
->Name
== "Enable" )
157 if ( pLookup
!= pLookupEnd
)
160 OSL_VERIFY( pLookup
->Value
>>= bEnable
);
161 if ( m_nAttributeId
== SID_ATTR_PARA_SCRIPTSPACE
)
162 return new SvxScriptSpaceItem( bEnable
, (WhichId
)m_nAttributeId
);
163 return new SfxBoolItem( (WhichId
)m_nAttributeId
, bEnable
);
166 OSL_FAIL( "OAsianFontLayoutDispatcher::convertDispatchArgsToItem: did not find the one and only argument!" );
174 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */