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/editids.hrc>
23 #include <editeng/editview.hxx>
24 #include <editeng/scriptspaceitem.hxx>
25 #include <osl/diagnose.h>
32 using namespace ::com::sun::star::uno
;
33 using namespace ::com::sun::star::lang
;
34 using namespace ::com::sun::star::util
;
35 using namespace ::com::sun::star::frame
;
36 using namespace ::com::sun::star::beans
;
38 OSelectAllDispatcher::OSelectAllDispatcher( EditView
& _rView
, const URL
& _rURL
)
39 :ORichTextFeatureDispatcher( _rView
, _rURL
)
44 OSelectAllDispatcher::~OSelectAllDispatcher( )
54 void SAL_CALL
OSelectAllDispatcher::dispatch( const URL
& _rURL
, const Sequence
< PropertyValue
>& /*_rArguments*/ )
56 ::osl::MutexGuard
aGuard( m_aMutex
);
57 OSL_ENSURE( _rURL
.Complete
== getFeatureURL().Complete
, "OSelectAllDispatcher::dispatch: invalid URL!" );
61 EditEngine
* pEngine
= getEditView() ? getEditView()->GetEditEngine() : nullptr;
62 OSL_ENSURE( pEngine
, "OSelectAllDispatcher::dispatch: no edit engine - but not yet disposed?" );
66 sal_Int32 nParagraphs
= pEngine
->GetParagraphCount();
69 sal_Int32 nLastParaNumber
= nParagraphs
- 1;
70 sal_Int32 nParaLen
= pEngine
->GetTextLen( nLastParaNumber
);
71 getEditView()->SetSelection( ESelection( 0, 0, nLastParaNumber
, nParaLen
) );
76 FeatureStateEvent
OSelectAllDispatcher::buildStatusEvent() const
78 FeatureStateEvent
aEvent( ORichTextFeatureDispatcher::buildStatusEvent() );
79 aEvent
.IsEnabled
= true;
83 OParagraphDirectionDispatcher::OParagraphDirectionDispatcher( EditView
& _rView
, AttributeId _nAttributeId
, const URL
& _rURL
,
84 IMultiAttributeDispatcher
* _pMasterDispatcher
)
85 :OAttributeDispatcher( _rView
, _nAttributeId
, _rURL
, _pMasterDispatcher
)
90 FeatureStateEvent
OParagraphDirectionDispatcher::buildStatusEvent() const
92 FeatureStateEvent
aEvent( OAttributeDispatcher::buildStatusEvent() );
94 EditEngine
* pEngine
= getEditView() ? getEditView()->GetEditEngine() : nullptr;
95 OSL_ENSURE( pEngine
, "OParagraphDirectionDispatcher::dispatch: no edit engine - but not yet disposed?" );
96 if ( pEngine
&& pEngine
->IsEffectivelyVertical() )
97 aEvent
.IsEnabled
= false;
102 OTextDirectionDispatcher::OTextDirectionDispatcher( EditView
& _rView
, const URL
& _rURL
)
103 :ORichTextFeatureDispatcher( _rView
, _rURL
)
108 void SAL_CALL
OTextDirectionDispatcher::dispatch( const URL
& _rURL
, const Sequence
< PropertyValue
>& /*_rArguments*/ )
110 ::osl::MutexGuard
aGuard( m_aMutex
);
111 OSL_ENSURE( _rURL
.Complete
== getFeatureURL().Complete
, "OTextDirectionDispatcher::dispatch: invalid URL!" );
115 EditEngine
* pEngine
= getEditView() ? getEditView()->GetEditEngine() : nullptr;
116 OSL_ENSURE( pEngine
, "OTextDirectionDispatcher::dispatch: no edit engine - but not yet disposed?" );
120 pEngine
->SetVertical( !pEngine
->IsEffectivelyVertical() );
124 FeatureStateEvent
OTextDirectionDispatcher::buildStatusEvent() const
126 FeatureStateEvent
aEvent( ORichTextFeatureDispatcher::buildStatusEvent() );
128 EditEngine
* pEngine
= getEditView() ? getEditView()->GetEditEngine() : nullptr;
129 OSL_ENSURE( pEngine
, "OTextDirectionDispatcher::dispatch: no edit engine - but not yet disposed?" );
131 aEvent
.IsEnabled
= true;
132 aEvent
.State
<<= pEngine
&& pEngine
->IsEffectivelyVertical();
137 OAsianFontLayoutDispatcher::OAsianFontLayoutDispatcher( EditView
& _rView
, AttributeId _nAttributeId
, const URL
& _rURL
, IMultiAttributeDispatcher
* _pMasterDispatcher
)
138 :OParametrizedAttributeDispatcher( _rView
, _nAttributeId
, _rURL
, _pMasterDispatcher
)
143 const SfxPoolItem
* OAsianFontLayoutDispatcher::convertDispatchArgsToItem( const Sequence
< PropertyValue
>& _rArguments
)
145 // look for the "Enable" parameter
146 const PropertyValue
* pLookup
= _rArguments
.getConstArray();
147 const PropertyValue
* pLookupEnd
= _rArguments
.getConstArray() + _rArguments
.getLength();
148 while ( pLookup
!= pLookupEnd
)
150 if ( pLookup
->Name
== "Enable" )
154 if ( pLookup
!= pLookupEnd
)
157 OSL_VERIFY( pLookup
->Value
>>= bEnable
);
158 if ( m_nAttributeId
== SID_ATTR_PARA_SCRIPTSPACE
)
159 return new SvxScriptSpaceItem( bEnable
, static_cast<WhichId
>(m_nAttributeId
) );
160 return new SfxBoolItem( static_cast<WhichId
>(m_nAttributeId
), bEnable
);
163 OSL_FAIL( "OAsianFontLayoutDispatcher::convertDispatchArgsToItem: did not find the one and only argument!" );
171 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */