Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #include "specialdispatchers.hxx"
30 : : #include <editeng/editeng.hxx>
31 : : #include <editeng/editview.hxx>
32 : : #include <svx/svxids.hrc>
33 : : #define ITEMID_SCRIPTSPACE SID_ATTR_PARA_SCRIPTSPACE
34 : : #include <editeng/scriptspaceitem.hxx>
35 : :
36 : : //........................................................................
37 : : namespace frm
38 : : {
39 : : //........................................................................
40 : :
41 : : using namespace ::com::sun::star::uno;
42 : : using namespace ::com::sun::star::lang;
43 : : using namespace ::com::sun::star::util;
44 : : using namespace ::com::sun::star::frame;
45 : : using namespace ::com::sun::star::beans;
46 : :
47 : : //====================================================================
48 : : //= OSelectAllDispatcher
49 : : //====================================================================
50 : : //--------------------------------------------------------------------
51 : 0 : OSelectAllDispatcher::OSelectAllDispatcher( EditView& _rView, const URL& _rURL )
52 : 0 : :ORichTextFeatureDispatcher( _rView, _rURL )
53 : : {
54 : 0 : }
55 : :
56 : : //--------------------------------------------------------------------
57 : 0 : OSelectAllDispatcher::~OSelectAllDispatcher( )
58 : : {
59 [ # # ]: 0 : if ( !isDisposed() )
60 : : {
61 : 0 : acquire();
62 [ # # ]: 0 : dispose();
63 : : }
64 [ # # ]: 0 : }
65 : :
66 : : //--------------------------------------------------------------------
67 : 0 : void SAL_CALL OSelectAllDispatcher::dispatch( const URL& _rURL, const Sequence< PropertyValue >& /*_rArguments*/ ) throw (RuntimeException)
68 : : {
69 [ # # ]: 0 : ::osl::MutexGuard aGuard( m_aMutex );
70 : : OSL_ENSURE( _rURL.Complete == getFeatureURL().Complete, "OSelectAllDispatcher::dispatch: invalid URL!" );
71 : : (void)_rURL;
72 : :
73 [ # # ]: 0 : checkDisposed();
74 : :
75 [ # # ][ # # ]: 0 : EditEngine* pEngine = getEditView() ? getEditView()->GetEditEngine() : NULL;
76 : : OSL_ENSURE( pEngine, "OSelectAllDispatcher::dispatch: no edit engine - but not yet disposed?" );
77 [ # # ]: 0 : if ( !pEngine )
78 : 0 : return;
79 : :
80 [ # # ]: 0 : sal_uInt16 nParagraphs = pEngine->GetParagraphCount();
81 [ # # ]: 0 : if ( nParagraphs )
82 : : {
83 : 0 : sal_uInt16 nLastParaNumber = nParagraphs - 1;
84 [ # # ]: 0 : xub_StrLen nParaLen = pEngine->GetTextLen( nLastParaNumber );
85 [ # # ]: 0 : getEditView()->SetSelection( ESelection( 0, 0, nLastParaNumber, nParaLen ) );
86 [ # # ][ # # ]: 0 : }
87 : : }
88 : :
89 : : //--------------------------------------------------------------------
90 : 0 : FeatureStateEvent OSelectAllDispatcher::buildStatusEvent() const
91 : : {
92 : 0 : FeatureStateEvent aEvent( ORichTextFeatureDispatcher::buildStatusEvent() );
93 : 0 : aEvent.IsEnabled = sal_True;
94 : 0 : return aEvent;
95 : : }
96 : :
97 : : //====================================================================
98 : : //= OParagraphDirectionDispatcher
99 : : //====================================================================
100 : : //--------------------------------------------------------------------
101 : 0 : OParagraphDirectionDispatcher::OParagraphDirectionDispatcher( EditView& _rView, AttributeId _nAttributeId, const URL& _rURL,
102 : : IMultiAttributeDispatcher* _pMasterDispatcher )
103 : 0 : :OAttributeDispatcher( _rView, _nAttributeId, _rURL, _pMasterDispatcher )
104 : : {
105 : 0 : }
106 : :
107 : : //--------------------------------------------------------------------
108 : 0 : FeatureStateEvent OParagraphDirectionDispatcher::buildStatusEvent() const
109 : : {
110 : 0 : FeatureStateEvent aEvent( OAttributeDispatcher::buildStatusEvent() );
111 : :
112 [ # # ][ # # ]: 0 : EditEngine* pEngine = getEditView() ? getEditView()->GetEditEngine() : NULL;
113 : : OSL_ENSURE( pEngine, "OParagraphDirectionDispatcher::dispatch: no edit engine - but not yet disposed?" );
114 [ # # ][ # # ]: 0 : if ( pEngine && pEngine->IsVertical() )
[ # # ][ # # ]
115 : 0 : aEvent.IsEnabled = sal_False;
116 : :
117 : 0 : return aEvent;
118 : : }
119 : :
120 : : //====================================================================
121 : : //= OTextDirectionDispatcher
122 : : //====================================================================
123 : : //--------------------------------------------------------------------
124 : 0 : OTextDirectionDispatcher::OTextDirectionDispatcher( EditView& _rView, const URL& _rURL )
125 : 0 : :ORichTextFeatureDispatcher( _rView, _rURL )
126 : : {
127 : 0 : }
128 : :
129 : : //--------------------------------------------------------------------
130 : 0 : void SAL_CALL OTextDirectionDispatcher::dispatch( const URL& _rURL, const Sequence< PropertyValue >& /*_rArguments*/ ) throw (RuntimeException)
131 : : {
132 [ # # ]: 0 : ::osl::MutexGuard aGuard( m_aMutex );
133 : : OSL_ENSURE( _rURL.Complete == getFeatureURL().Complete, "OTextDirectionDispatcher::dispatch: invalid URL!" );
134 : : (void)_rURL;
135 : :
136 [ # # ]: 0 : checkDisposed();
137 : :
138 [ # # ][ # # ]: 0 : EditEngine* pEngine = getEditView() ? getEditView()->GetEditEngine() : NULL;
139 : : OSL_ENSURE( pEngine, "OTextDirectionDispatcher::dispatch: no edit engine - but not yet disposed?" );
140 [ # # ]: 0 : if ( !pEngine )
141 : 0 : return;
142 : :
143 [ # # ][ # # ]: 0 : pEngine->SetVertical( !pEngine->IsVertical() );
[ # # ][ # # ]
144 : : }
145 : :
146 : : //--------------------------------------------------------------------
147 : 0 : FeatureStateEvent OTextDirectionDispatcher::buildStatusEvent() const
148 : : {
149 : 0 : FeatureStateEvent aEvent( ORichTextFeatureDispatcher::buildStatusEvent() );
150 : :
151 [ # # ][ # # ]: 0 : EditEngine* pEngine = getEditView() ? getEditView()->GetEditEngine() : NULL;
152 : : OSL_ENSURE( pEngine, "OTextDirectionDispatcher::dispatch: no edit engine - but not yet disposed?" );
153 : :
154 : 0 : aEvent.IsEnabled = sal_True;
155 [ # # ][ # # ]: 0 : aEvent.State <<= (sal_Bool)( pEngine && pEngine->IsVertical() );
[ # # ][ # # ]
156 : :
157 : 0 : return aEvent;
158 : : }
159 : :
160 : : //====================================================================
161 : : //= OAsianFontLayoutDispatcher
162 : : //====================================================================
163 : : //--------------------------------------------------------------------
164 : 0 : OAsianFontLayoutDispatcher::OAsianFontLayoutDispatcher( EditView& _rView, AttributeId _nAttributeId, const URL& _rURL, IMultiAttributeDispatcher* _pMasterDispatcher )
165 : 0 : :OParametrizedAttributeDispatcher( _rView, _nAttributeId, _rURL, _pMasterDispatcher )
166 : : {
167 : 0 : }
168 : :
169 : : //--------------------------------------------------------------------
170 : 0 : const SfxPoolItem* OAsianFontLayoutDispatcher::convertDispatchArgsToItem( const Sequence< PropertyValue >& _rArguments )
171 : : {
172 : : // look for the "Enable" parameter
173 : 0 : const PropertyValue* pLookup = _rArguments.getConstArray();
174 : 0 : const PropertyValue* pLookupEnd = _rArguments.getConstArray() + _rArguments.getLength();
175 [ # # ]: 0 : while ( pLookup != pLookupEnd )
176 : : {
177 [ # # ]: 0 : if ( pLookup->Name == "Enable" )
178 : 0 : break;
179 : 0 : ++pLookup;
180 : : }
181 [ # # ]: 0 : if ( pLookup != pLookupEnd )
182 : : {
183 : 0 : sal_Bool bEnable = sal_True;
184 : 0 : OSL_VERIFY( pLookup->Value >>= bEnable );
185 [ # # ]: 0 : if ( m_nAttributeId == SID_ATTR_PARA_SCRIPTSPACE )
186 [ # # ][ # # ]: 0 : return new SvxScriptSpaceItem( bEnable, (WhichId)m_nAttributeId );
187 [ # # ][ # # ]: 0 : return new SfxBoolItem( (WhichId)m_nAttributeId, bEnable );
188 : : }
189 : :
190 : : OSL_FAIL( "OAsianFontLayoutDispatcher::convertDispatchArgsToItem: did not find the one and only argument!" );
191 : 0 : return NULL;
192 : : }
193 : :
194 : : //........................................................................
195 : : } // namespace frm
196 : : //........................................................................
197 : :
198 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|