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 "specialdispatchers.hxx"
21 : #include <editeng/editeng.hxx>
22 : #include <editeng/editview.hxx>
23 : #include <svx/svxids.hrc>
24 : #include <editeng/scriptspaceitem.hxx>
25 :
26 :
27 : namespace frm
28 : {
29 :
30 :
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;
36 :
37 0 : OSelectAllDispatcher::OSelectAllDispatcher( EditView& _rView, const URL& _rURL )
38 0 : :ORichTextFeatureDispatcher( _rView, _rURL )
39 : {
40 0 : }
41 :
42 :
43 0 : OSelectAllDispatcher::~OSelectAllDispatcher( )
44 : {
45 0 : if ( !isDisposed() )
46 : {
47 0 : acquire();
48 0 : dispose();
49 : }
50 0 : }
51 :
52 :
53 0 : void SAL_CALL OSelectAllDispatcher::dispatch( const URL& _rURL, const Sequence< PropertyValue >& /*_rArguments*/ )
54 : throw (RuntimeException,
55 : std::exception)
56 : {
57 0 : ::osl::MutexGuard aGuard( m_aMutex );
58 : OSL_ENSURE( _rURL.Complete == getFeatureURL().Complete, "OSelectAllDispatcher::dispatch: invalid URL!" );
59 : (void)_rURL;
60 :
61 0 : checkDisposed();
62 :
63 0 : EditEngine* pEngine = getEditView() ? getEditView()->GetEditEngine() : NULL;
64 : OSL_ENSURE( pEngine, "OSelectAllDispatcher::dispatch: no edit engine - but not yet disposed?" );
65 0 : if ( !pEngine )
66 0 : return;
67 :
68 0 : sal_Int32 nParagraphs = pEngine->GetParagraphCount();
69 0 : if ( nParagraphs )
70 : {
71 0 : sal_Int32 nLastParaNumber = nParagraphs - 1;
72 0 : sal_Int32 nParaLen = pEngine->GetTextLen( nLastParaNumber );
73 0 : getEditView()->SetSelection( ESelection( 0, 0, nLastParaNumber, nParaLen ) );
74 0 : }
75 : }
76 :
77 :
78 0 : FeatureStateEvent OSelectAllDispatcher::buildStatusEvent() const
79 : {
80 0 : FeatureStateEvent aEvent( ORichTextFeatureDispatcher::buildStatusEvent() );
81 0 : aEvent.IsEnabled = sal_True;
82 0 : return aEvent;
83 : }
84 :
85 0 : OParagraphDirectionDispatcher::OParagraphDirectionDispatcher( EditView& _rView, AttributeId _nAttributeId, const URL& _rURL,
86 : IMultiAttributeDispatcher* _pMasterDispatcher )
87 0 : :OAttributeDispatcher( _rView, _nAttributeId, _rURL, _pMasterDispatcher )
88 : {
89 0 : }
90 :
91 :
92 0 : FeatureStateEvent OParagraphDirectionDispatcher::buildStatusEvent() const
93 : {
94 0 : FeatureStateEvent aEvent( OAttributeDispatcher::buildStatusEvent() );
95 :
96 0 : EditEngine* pEngine = getEditView() ? getEditView()->GetEditEngine() : NULL;
97 : OSL_ENSURE( pEngine, "OParagraphDirectionDispatcher::dispatch: no edit engine - but not yet disposed?" );
98 0 : if ( pEngine && pEngine->IsVertical() )
99 0 : aEvent.IsEnabled = sal_False;
100 :
101 0 : return aEvent;
102 : }
103 :
104 0 : OTextDirectionDispatcher::OTextDirectionDispatcher( EditView& _rView, const URL& _rURL )
105 0 : :ORichTextFeatureDispatcher( _rView, _rURL )
106 : {
107 0 : }
108 :
109 :
110 0 : void SAL_CALL OTextDirectionDispatcher::dispatch( const URL& _rURL, const Sequence< PropertyValue >& /*_rArguments*/ ) throw (RuntimeException, std::exception)
111 : {
112 0 : ::osl::MutexGuard aGuard( m_aMutex );
113 : OSL_ENSURE( _rURL.Complete == getFeatureURL().Complete, "OTextDirectionDispatcher::dispatch: invalid URL!" );
114 : (void)_rURL;
115 :
116 0 : checkDisposed();
117 :
118 0 : EditEngine* pEngine = getEditView() ? getEditView()->GetEditEngine() : NULL;
119 : OSL_ENSURE( pEngine, "OTextDirectionDispatcher::dispatch: no edit engine - but not yet disposed?" );
120 0 : if ( !pEngine )
121 0 : return;
122 :
123 0 : pEngine->SetVertical( !pEngine->IsVertical() );
124 : }
125 :
126 :
127 0 : FeatureStateEvent OTextDirectionDispatcher::buildStatusEvent() const
128 : {
129 0 : FeatureStateEvent aEvent( ORichTextFeatureDispatcher::buildStatusEvent() );
130 :
131 0 : EditEngine* pEngine = getEditView() ? getEditView()->GetEditEngine() : NULL;
132 : OSL_ENSURE( pEngine, "OTextDirectionDispatcher::dispatch: no edit engine - but not yet disposed?" );
133 :
134 0 : aEvent.IsEnabled = sal_True;
135 0 : aEvent.State <<= pEngine && pEngine->IsVertical();
136 :
137 0 : return aEvent;
138 : }
139 :
140 0 : OAsianFontLayoutDispatcher::OAsianFontLayoutDispatcher( EditView& _rView, AttributeId _nAttributeId, const URL& _rURL, IMultiAttributeDispatcher* _pMasterDispatcher )
141 0 : :OParametrizedAttributeDispatcher( _rView, _nAttributeId, _rURL, _pMasterDispatcher )
142 : {
143 0 : }
144 :
145 :
146 0 : const SfxPoolItem* OAsianFontLayoutDispatcher::convertDispatchArgsToItem( const Sequence< PropertyValue >& _rArguments )
147 : {
148 : // look for the "Enable" parameter
149 0 : const PropertyValue* pLookup = _rArguments.getConstArray();
150 0 : const PropertyValue* pLookupEnd = _rArguments.getConstArray() + _rArguments.getLength();
151 0 : while ( pLookup != pLookupEnd )
152 : {
153 0 : if ( pLookup->Name == "Enable" )
154 0 : break;
155 0 : ++pLookup;
156 : }
157 0 : if ( pLookup != pLookupEnd )
158 : {
159 0 : bool bEnable = true;
160 0 : OSL_VERIFY( pLookup->Value >>= bEnable );
161 0 : if ( m_nAttributeId == SID_ATTR_PARA_SCRIPTSPACE )
162 0 : return new SvxScriptSpaceItem( bEnable, (WhichId)m_nAttributeId );
163 0 : return new SfxBoolItem( (WhichId)m_nAttributeId, bEnable );
164 : }
165 :
166 : OSL_FAIL( "OAsianFontLayoutDispatcher::convertDispatchArgsToItem: did not find the one and only argument!" );
167 0 : return NULL;
168 : }
169 :
170 :
171 : } // namespace frm
172 :
173 :
174 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|