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 "fielduno.hxx"
30 : : #include "textuno.hxx"
31 : : #include "miscuno.hxx"
32 : : #include "docsh.hxx"
33 : : #include "hints.hxx"
34 : : #include "editsrc.hxx"
35 : : #include "cellsuno.hxx"
36 : : #include "servuno.hxx" // fuer IDs
37 : : #include "unonames.hxx"
38 : : #include "editutil.hxx"
39 : :
40 : : #include <svl/smplhint.hxx>
41 : : #include <vcl/svapp.hxx>
42 : :
43 : :
44 : : #include <editeng/eeitem.hxx>
45 : :
46 : : #include <editeng/editeng.hxx>
47 : : #include <editeng/editobj.hxx>
48 : : #include <editeng/flditem.hxx>
49 : : #include <comphelper/servicehelper.hxx>
50 : :
51 : : #include <com/sun/star/beans/PropertyAttribute.hpp>
52 : : #include <com/sun/star/text/TextContentAnchorType.hpp>
53 : : #include <com/sun/star/text/WrapTextMode.hpp>
54 : : #include <com/sun/star/text/FilenameDisplayFormat.hpp>
55 : : #include <com/sun/star/text/textfield/Type.hpp>
56 : :
57 : : using namespace com::sun::star;
58 : :
59 : : namespace {
60 : :
61 : : // alles ohne Which-ID, Map nur fuer PropertySetInfo
62 : :
63 : 205 : const SfxItemPropertySet* getDateTimePropertySet()
64 : : {
65 : : static SfxItemPropertyMapEntry aMapContent[] =
66 : : {
67 [ + - ]: 33 : { MAP_CHAR_LEN(SC_UNONAME_DATETIME), 0, &getCppuType((const util::DateTime*)0), 0, 0 },
68 [ + - ]: 33 : { MAP_CHAR_LEN(SC_UNONAME_ISFIXED), 0, &getBooleanCppuType(), 0, 0 },
69 [ + - ]: 33 : { MAP_CHAR_LEN(SC_UNONAME_ISDATE), 0, &getBooleanCppuType(), 0, 0 },
70 [ + - ]: 33 : { MAP_CHAR_LEN(SC_UNONAME_NUMFMT), 0, &getCppuType((const sal_Int32*)0), 0, 0 },
71 : : {0,0,0,0,0,0}
72 [ + + ][ + - ]: 238 : };
[ # # ]
73 [ + + ][ + - ]: 205 : static SfxItemPropertySet aMap(aMapContent);
[ + - ][ # # ]
74 : 205 : return &aMap;
75 : : }
76 : :
77 : 97 : const SfxItemPropertySet* getEmptyPropertySet()
78 : : {
79 : : static SfxItemPropertyMapEntry aMapContent[] =
80 : : {
81 : : {0,0,0,0,0,0}
82 : : };
83 [ + + ][ + - ]: 97 : static SfxItemPropertySet aMap(aMapContent);
[ + - ][ # # ]
84 : 97 : return &aMap;
85 : : }
86 : :
87 : 18 : const SfxItemPropertySet* lcl_GetURLPropertySet()
88 : : {
89 : : static SfxItemPropertyMapEntry aURLPropertyMap_Impl[] =
90 : : {
91 [ + - ]: 3 : {MAP_CHAR_LEN(SC_UNONAME_ANCTYPE), 0, &getCppuType((text::TextContentAnchorType*)0), beans::PropertyAttribute::READONLY, 0 },
92 [ + - ]: 3 : {MAP_CHAR_LEN(SC_UNONAME_ANCTYPES), 0, &getCppuType((uno::Sequence<text::TextContentAnchorType>*)0), beans::PropertyAttribute::READONLY, 0 },
93 [ + - ]: 3 : {MAP_CHAR_LEN(SC_UNONAME_REPR), 0, &getCppuType((rtl::OUString*)0), 0, 0},
94 [ + - ]: 3 : {MAP_CHAR_LEN(SC_UNONAME_TARGET), 0, &getCppuType((rtl::OUString*)0), 0, 0},
95 [ + - ]: 3 : {MAP_CHAR_LEN(SC_UNONAME_TEXTWRAP), 0, &getCppuType((text::WrapTextMode*)0), beans::PropertyAttribute::READONLY, 0 },
96 [ + - ]: 3 : {MAP_CHAR_LEN(SC_UNONAME_URL), 0, &getCppuType((rtl::OUString*)0), 0, 0},
97 : : {0,0,0,0,0,0}
98 [ + + ][ + - ]: 21 : };
[ # # ]
99 [ + + ][ + - ]: 18 : static SfxItemPropertySet aURLPropertySet_Impl( aURLPropertyMap_Impl );
[ + - ][ # # ]
100 : 18 : return &aURLPropertySet_Impl;
101 : : }
102 : :
103 : 597 : const SfxItemPropertySet* lcl_GetHeaderFieldPropertySet()
104 : : {
105 : : static SfxItemPropertyMapEntry aHeaderFieldPropertyMap_Impl[] =
106 : : {
107 [ + - ]: 27 : {MAP_CHAR_LEN(SC_UNONAME_ANCTYPE), 0, &getCppuType((text::TextContentAnchorType*)0), beans::PropertyAttribute::READONLY, 0 },
108 [ + - ]: 27 : {MAP_CHAR_LEN(SC_UNONAME_ANCTYPES), 0, &getCppuType((uno::Sequence<text::TextContentAnchorType>*)0), beans::PropertyAttribute::READONLY, 0 },
109 [ + - ]: 27 : {MAP_CHAR_LEN(SC_UNONAME_TEXTWRAP), 0, &getCppuType((text::WrapTextMode*)0), beans::PropertyAttribute::READONLY, 0 },
110 : : {0,0,0,0,0,0}
111 [ + + ][ + - ]: 624 : };
[ # # ]
112 [ + + ][ + - ]: 597 : static SfxItemPropertySet aHeaderFieldPropertySet_Impl( aHeaderFieldPropertyMap_Impl );
[ + - ][ # # ]
113 : 597 : return &aHeaderFieldPropertySet_Impl;
114 : : }
115 : :
116 : 2 : const SfxItemPropertySet* lcl_GetFileFieldPropertySet()
117 : : {
118 : : static SfxItemPropertyMapEntry aFileFieldPropertyMap_Impl[] =
119 : : {
120 [ + - ]: 1 : {MAP_CHAR_LEN(SC_UNONAME_ANCTYPE), 0, &getCppuType((text::TextContentAnchorType*)0), beans::PropertyAttribute::READONLY, 0 },
121 [ + - ]: 1 : {MAP_CHAR_LEN(SC_UNONAME_ANCTYPES), 0, &getCppuType((uno::Sequence<text::TextContentAnchorType>*)0), beans::PropertyAttribute::READONLY, 0 },
122 [ + - ]: 1 : {MAP_CHAR_LEN(SC_UNONAME_FILEFORM), 0, &getCppuType((sal_Int16*)0), 0, 0 },
123 [ + - ]: 1 : {MAP_CHAR_LEN(SC_UNONAME_TEXTWRAP), 0, &getCppuType((text::WrapTextMode*)0), beans::PropertyAttribute::READONLY, 0 },
124 : : {0,0,0,0,0,0}
125 [ + + ][ + - ]: 3 : };
[ # # ]
126 [ + + ][ + - ]: 2 : static SfxItemPropertySet aFileFieldPropertySet_Impl( aFileFieldPropertyMap_Impl );
[ + - ][ # # ]
127 : 2 : return &aFileFieldPropertySet_Impl;
128 : : }
129 : :
130 : 0 : SvxFileFormat lcl_UnoToSvxFileFormat( sal_Int16 nUnoValue )
131 : : {
132 [ # # # # ]: 0 : switch( nUnoValue )
133 : : {
134 : 0 : case text::FilenameDisplayFormat::FULL: return SVXFILEFORMAT_FULLPATH;
135 : 0 : case text::FilenameDisplayFormat::PATH: return SVXFILEFORMAT_PATH;
136 : 0 : case text::FilenameDisplayFormat::NAME: return SVXFILEFORMAT_NAME;
137 : : default:
138 : 0 : return SVXFILEFORMAT_NAME_EXT;
139 : : }
140 : : }
141 : :
142 : 0 : sal_Int16 lcl_SvxToUnoFileFormat( SvxFileFormat nSvxValue )
143 : : {
144 [ # # # # ]: 0 : switch( nSvxValue )
145 : : {
146 : 0 : case SVXFILEFORMAT_NAME_EXT: return text::FilenameDisplayFormat::NAME_AND_EXT;
147 : 0 : case SVXFILEFORMAT_FULLPATH: return text::FilenameDisplayFormat::FULL;
148 : 0 : case SVXFILEFORMAT_PATH: return text::FilenameDisplayFormat::PATH;
149 : : default:
150 : 0 : return text::FilenameDisplayFormat::NAME;
151 : : }
152 : : }
153 : :
154 : : }
155 : :
156 : : #define SCTEXTFIELD_SERVICE "com.sun.star.text.TextField"
157 : : #define SCTEXTCONTENT_SERVICE "com.sun.star.text.TextContent"
158 : :
159 [ # # ]: 0 : SC_SIMPLE_SERVICE_INFO( ScCellFieldsObj, "ScCellFieldsObj", "com.sun.star.text.TextFields" )
160 [ # # ]: 0 : SC_SIMPLE_SERVICE_INFO( ScHeaderFieldsObj, "ScHeaderFieldsObj", "com.sun.star.text.TextFields" )
161 : :
162 : : //------------------------------------------------------------------------
163 : :
164 : : // ScUnoEditEngine nur um aus einer EditEngine die Felder herauszubekommen...
165 : :
166 : : enum ScUnoCollectMode
167 : : {
168 : : SC_UNO_COLLECT_NONE,
169 : : SC_UNO_COLLECT_COUNT,
170 : : SC_UNO_COLLECT_FINDINDEX,
171 : : SC_UNO_COLLECT_FINDPOS
172 : : };
173 : :
174 : : /**
175 : : * This class exists solely to allow searching through field items. TODO:
176 : : * Look into providing the same functionality directly in EditEngine, to
177 : : * avoid having this class altogether.
178 : : */
179 : : class ScUnoEditEngine : public ScEditEngineDefaulter
180 : : {
181 : : ScUnoCollectMode eMode;
182 : : sal_uInt16 nFieldCount;
183 : : sal_Int32 mnFieldType;
184 : : SvxFieldData* pFound; // lokale Kopie
185 : : sal_uInt16 nFieldPar;
186 : : xub_StrLen nFieldPos;
187 : : sal_uInt16 nFieldIndex;
188 : :
189 : : public:
190 : : ScUnoEditEngine(ScEditEngineDefaulter* pSource);
191 : : ~ScUnoEditEngine();
192 : :
193 : : //! nPos should be xub_StrLen
194 : : virtual String CalcFieldValue( const SvxFieldItem& rField, sal_uInt16 nPara, sal_uInt16 nPos,
195 : : Color*& rTxtColor, Color*& rFldColor );
196 : :
197 : : sal_uInt16 CountFields();
198 : : SvxFieldData* FindByIndex(sal_uInt16 nIndex);
199 : : SvxFieldData* FindByPos(sal_uInt16 nPar, xub_StrLen nPos, sal_Int32 nType);
200 : :
201 : 2 : sal_uInt16 GetFieldPar() const { return nFieldPar; }
202 : 2 : xub_StrLen GetFieldPos() const { return nFieldPos; }
203 : : };
204 : :
205 : 163 : ScUnoEditEngine::ScUnoEditEngine(ScEditEngineDefaulter* pSource) :
206 : : ScEditEngineDefaulter( *pSource ),
207 : : eMode( SC_UNO_COLLECT_NONE ),
208 : : nFieldCount( 0 ),
209 : : mnFieldType(text::textfield::Type::UNSPECIFIED),
210 : 163 : pFound( NULL )
211 : : {
212 [ + - ]: 163 : if (pSource)
213 : : {
214 [ + - ]: 163 : EditTextObject* pData = pSource->CreateTextObject();
215 [ + - ]: 163 : SetText( *pData );
216 [ + - ][ + - ]: 163 : delete pData;
217 : : }
218 : 163 : }
219 : :
220 : 163 : ScUnoEditEngine::~ScUnoEditEngine()
221 : : {
222 [ + + ][ + - ]: 163 : delete pFound;
223 [ - + ]: 163 : }
224 : :
225 : 326 : String ScUnoEditEngine::CalcFieldValue( const SvxFieldItem& rField,
226 : : sal_uInt16 nPara, sal_uInt16 nPos, Color*& rTxtColor, Color*& rFldColor )
227 : : {
228 : 326 : String aRet(EditEngine::CalcFieldValue( rField, nPara, nPos, rTxtColor, rFldColor ));
229 [ + + ]: 326 : if (eMode != SC_UNO_COLLECT_NONE)
230 : : {
231 : 163 : const SvxFieldData* pFieldData = rField.GetField();
232 [ + - ]: 163 : if ( pFieldData )
233 : : {
234 [ + + ][ + - ]: 163 : if (mnFieldType == text::textfield::Type::UNSPECIFIED || pFieldData->GetClassId() == mnFieldType)
[ + - ][ + - ]
235 : : {
236 [ + + ][ + - ]: 163 : if ( eMode == SC_UNO_COLLECT_FINDINDEX && !pFound && nFieldCount == nFieldIndex )
[ + + ]
237 : : {
238 [ + - ]: 2 : pFound = pFieldData->Clone();
239 : 2 : nFieldPar = nPara;
240 : 2 : nFieldPos = nPos;
241 : : }
242 [ + + ][ + - ]: 163 : if ( eMode == SC_UNO_COLLECT_FINDPOS && !pFound &&
[ + - ][ + - ]
243 : : nPara == nFieldPar && nPos == nFieldPos )
244 : : {
245 [ + - ]: 154 : pFound = pFieldData->Clone();
246 : 154 : nFieldIndex = nFieldCount;
247 : : }
248 : 163 : ++nFieldCount;
249 : : }
250 : : }
251 : : }
252 : 326 : return aRet;
253 : : }
254 : :
255 : 6 : sal_uInt16 ScUnoEditEngine::CountFields()
256 : : {
257 : 6 : eMode = SC_UNO_COLLECT_COUNT;
258 : 6 : mnFieldType = text::textfield::Type::UNSPECIFIED;
259 : 6 : nFieldCount = 0;
260 : 6 : UpdateFields();
261 : 6 : eMode = SC_UNO_COLLECT_NONE;
262 : :
263 : 6 : return nFieldCount;
264 : : }
265 : :
266 : 3 : SvxFieldData* ScUnoEditEngine::FindByIndex(sal_uInt16 nIndex)
267 : : {
268 : 3 : eMode = SC_UNO_COLLECT_FINDINDEX;
269 : 3 : nFieldIndex = nIndex;
270 : 3 : mnFieldType = text::textfield::Type::UNSPECIFIED;
271 : 3 : nFieldCount = 0;
272 : 3 : UpdateFields();
273 : 3 : eMode = SC_UNO_COLLECT_NONE;
274 : :
275 : 3 : return pFound;
276 : : }
277 : :
278 : 154 : SvxFieldData* ScUnoEditEngine::FindByPos(sal_uInt16 nPar, xub_StrLen nPos, sal_Int32 nType)
279 : : {
280 : 154 : eMode = SC_UNO_COLLECT_FINDPOS;
281 : 154 : nFieldPar = nPar;
282 : 154 : nFieldPos = nPos;
283 : 154 : mnFieldType = nType;
284 : 154 : nFieldCount = 0;
285 : 154 : UpdateFields();
286 : 154 : mnFieldType = text::textfield::Type::UNSPECIFIED;
287 : 154 : eMode = SC_UNO_COLLECT_NONE;
288 : :
289 : 154 : return pFound;
290 : : }
291 : :
292 : : //------------------------------------------------------------------------
293 : :
294 : 4 : ScCellFieldsObj::ScCellFieldsObj(
295 : : const uno::Reference<text::XTextRange>& xContent,
296 : : ScDocShell* pDocSh, const ScAddress& rPos) :
297 : : mxContent(xContent),
298 : : pDocShell( pDocSh ),
299 : : aCellPos( rPos ),
300 [ + - ][ + - ]: 4 : mpRefreshListeners( NULL )
301 : : {
302 [ + - ]: 4 : pDocShell->GetDocument()->AddUnoObject(*this);
303 : :
304 [ + - ][ + - ]: 4 : mpEditSource = new ScCellEditSource( pDocShell, aCellPos );
305 : 4 : }
306 : :
307 [ + - ][ + - ]: 4 : ScCellFieldsObj::~ScCellFieldsObj()
308 : : {
309 [ - + ]: 4 : if (pDocShell)
310 [ # # ]: 0 : pDocShell->GetDocument()->RemoveUnoObject(*this);
311 : :
312 [ + - ][ + - ]: 4 : delete mpEditSource;
313 : :
314 : : // increment refcount to prevent double call off dtor
315 [ + - ]: 4 : osl_incrementInterlockedCount( &m_refCount );
316 : :
317 [ + + ]: 4 : if (mpRefreshListeners)
318 : : {
319 [ + - ]: 1 : lang::EventObject aEvent;
320 [ + - ]: 1 : aEvent.Source.set(static_cast<cppu::OWeakObject*>(this));
321 [ + - ]: 1 : if (mpRefreshListeners)
322 : : {
323 [ + - ]: 1 : mpRefreshListeners->disposeAndClear(aEvent);
324 [ + - ][ + - ]: 1 : DELETEZ( mpRefreshListeners );
325 [ + - ]: 1 : }
326 : : }
327 [ - + ]: 8 : }
328 : :
329 : 4 : void ScCellFieldsObj::Notify( SfxBroadcaster&, const SfxHint& rHint )
330 : : {
331 [ + - ]: 4 : if ( rHint.ISA( ScUpdateRefHint ) )
332 : : {
333 : : //! Ref-Update
334 : : }
335 [ + - + - ]: 8 : else if ( rHint.ISA( SfxSimpleHint ) &&
[ + - ]
336 : 4 : ((const SfxSimpleHint&)rHint).GetId() == SFX_HINT_DYING )
337 : : {
338 : 4 : pDocShell = NULL; // ungueltig geworden
339 : : }
340 : :
341 : : // EditSource hat sich selber als Listener angemeldet
342 : 4 : }
343 : :
344 : : // XIndexAccess (via XTextFields)
345 : :
346 : 3 : uno::Reference<text::XTextField> ScCellFieldsObj::GetObjectByIndex_Impl(sal_Int32 Index) const
347 : : {
348 : : //! Feld-Funktionen muessen an den Forwarder !!!
349 [ + - ]: 3 : ScEditEngineDefaulter* pEditEngine = mpEditSource->GetEditEngine();
350 [ + - ]: 3 : ScUnoEditEngine aTempEngine(pEditEngine);
351 [ + - ]: 3 : SvxFieldData* pData = aTempEngine.FindByIndex(static_cast<sal_uInt16>(Index));
352 [ + + ]: 3 : if (!pData)
353 : 1 : return uno::Reference<text::XTextField>();
354 : :
355 : 2 : sal_uInt16 nPar = aTempEngine.GetFieldPar();
356 : 2 : xub_StrLen nPos = aTempEngine.GetFieldPos();
357 : 2 : ESelection aSelection( nPar, nPos, nPar, nPos+1 ); // Feld ist 1 Zeichen
358 : :
359 [ + - ]: 2 : sal_Int32 eType = pData->GetClassId();
360 : : uno::Reference<text::XTextField> xRet(
361 [ + - ][ + - ]: 2 : new ScEditFieldObj(mxContent, new ScCellEditSource(pDocShell, aCellPos), eType, aSelection));
[ + - ][ + - ]
[ + - ]
362 [ + - ]: 3 : return xRet;
363 : : }
364 : :
365 : 5 : sal_Int32 SAL_CALL ScCellFieldsObj::getCount() throw(uno::RuntimeException)
366 : : {
367 [ + - ]: 5 : SolarMutexGuard aGuard;
368 : :
369 : : //! Feld-Funktionen muessen an den Forwarder !!!
370 [ + - ]: 5 : ScEditEngineDefaulter* pEditEngine = mpEditSource->GetEditEngine();
371 [ + - ]: 5 : ScUnoEditEngine aTempEngine(pEditEngine);
372 : :
373 [ + - ][ + - ]: 5 : return aTempEngine.CountFields(); // Felder zaehlen, in Zelle ist der Typ egal
[ + - ]
374 : : }
375 : :
376 : 3 : uno::Any SAL_CALL ScCellFieldsObj::getByIndex( sal_Int32 nIndex )
377 : : throw(lang::IndexOutOfBoundsException,
378 : : lang::WrappedTargetException, uno::RuntimeException)
379 : : {
380 [ + - ]: 3 : SolarMutexGuard aGuard;
381 [ + - ]: 3 : uno::Reference<text::XTextField> xField(GetObjectByIndex_Impl(nIndex));
382 [ + + ]: 3 : if (xField.is())
383 [ + - ]: 4 : return uno::makeAny(xField);
384 : : else
385 [ + - ][ + - ]: 3 : throw lang::IndexOutOfBoundsException();
386 : : }
387 : :
388 : 1 : uno::Type SAL_CALL ScCellFieldsObj::getElementType() throw(uno::RuntimeException)
389 : : {
390 [ + - ]: 1 : SolarMutexGuard aGuard;
391 [ + - ][ + - ]: 1 : return getCppuType((uno::Reference<text::XTextField>*)0);
392 : : }
393 : :
394 : 1 : sal_Bool SAL_CALL ScCellFieldsObj::hasElements() throw(uno::RuntimeException)
395 : : {
396 [ + - ]: 1 : SolarMutexGuard aGuard;
397 [ + - ][ + - ]: 1 : return ( getCount() != 0 );
398 : : }
399 : :
400 : 3 : uno::Reference<container::XEnumeration> SAL_CALL ScCellFieldsObj::createEnumeration()
401 : : throw(uno::RuntimeException)
402 : : {
403 [ + - ]: 3 : SolarMutexGuard aGuard;
404 [ + - ][ + - ]: 3 : return new ScIndexEnumeration(this, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.TextFieldEnumeration")));
[ + - ][ + - ]
[ + - ][ + - ]
405 : : }
406 : :
407 : 0 : void SAL_CALL ScCellFieldsObj::addContainerListener(
408 : : const uno::Reference<container::XContainerListener>& /* xListener */ )
409 : : throw(uno::RuntimeException)
410 : : {
411 : : OSL_FAIL("not implemented");
412 : 0 : }
413 : :
414 : 0 : void SAL_CALL ScCellFieldsObj::removeContainerListener(
415 : : const uno::Reference<container::XContainerListener>& /* xListener */ )
416 : : throw(uno::RuntimeException)
417 : : {
418 : : OSL_FAIL("not implemented");
419 : 0 : }
420 : :
421 : : // XRefreshable
422 : 2 : void SAL_CALL ScCellFieldsObj::refresh( )
423 : : throw (uno::RuntimeException)
424 : : {
425 [ + - ]: 2 : if (mpRefreshListeners)
426 : : {
427 : : // Call all listeners.
428 [ + - ]: 2 : uno::Sequence< uno::Reference< uno::XInterface > > aListeners(mpRefreshListeners->getElements());
429 : 2 : sal_uInt32 nLength(aListeners.getLength());
430 [ + + ]: 2 : if (nLength)
431 : : {
432 : 1 : const uno::Reference< uno::XInterface >* pInterfaces = aListeners.getConstArray();
433 [ + - ]: 1 : if (pInterfaces)
434 : : {
435 [ + - ]: 1 : lang::EventObject aEvent;
436 [ + - ][ + - ]: 1 : aEvent.Source.set(uno::Reference< util::XRefreshable >(const_cast<ScCellFieldsObj*>(this)));
[ # # ]
437 : 1 : sal_uInt32 i(0);
438 [ + + ]: 2 : while (i < nLength)
439 : : {
440 : : try
441 : : {
442 [ + + ]: 2 : while(i < nLength)
443 : : {
444 [ + - ][ + - ]: 1 : static_cast< util::XRefreshListener* >(pInterfaces->get())->refreshed(aEvent);
445 : 1 : ++pInterfaces;
446 : 1 : ++i;
447 : : }
448 : : }
449 [ # # ]: 0 : catch(uno::RuntimeException&)
450 : : {
451 : 0 : ++pInterfaces;
452 : 0 : ++i;
453 : : }
454 [ + - ]: 1 : }
455 : : }
456 [ + - ]: 2 : }
457 : : }
458 : 2 : }
459 : :
460 : 1 : void SAL_CALL ScCellFieldsObj::addRefreshListener( const uno::Reference< util::XRefreshListener >& xListener )
461 : : throw (uno::RuntimeException)
462 : : {
463 [ + - ]: 1 : if (xListener.is())
464 : : {
465 [ + - ]: 1 : SolarMutexGuard aGuard;
466 [ + - ]: 1 : if (!mpRefreshListeners)
467 [ + - ]: 1 : mpRefreshListeners = new cppu::OInterfaceContainerHelper(aMutex);
468 [ + - ][ + - ]: 1 : mpRefreshListeners->addInterface(xListener);
469 : : }
470 : 1 : }
471 : :
472 : 1 : void SAL_CALL ScCellFieldsObj::removeRefreshListener( const uno::Reference<util::XRefreshListener >& xListener )
473 : : throw (uno::RuntimeException)
474 : : {
475 [ + - ]: 1 : if (xListener.is())
476 : : {
477 [ + - ]: 1 : SolarMutexGuard aGuard;
478 [ + - ]: 1 : if (mpRefreshListeners)
479 [ + - ][ + - ]: 1 : mpRefreshListeners->removeInterface(xListener);
480 : : }
481 : 1 : }
482 : :
483 : 1 : ScHeaderFieldsObj::ScHeaderFieldsObj(ScHeaderFooterTextData& rData) :
484 : : mrData(rData),
485 [ + - ]: 1 : mpRefreshListeners( NULL )
486 : : {
487 [ + - ][ + - ]: 1 : mpEditSource = new ScHeaderFooterEditSource(rData);
488 : 1 : }
489 : :
490 [ + - ]: 1 : ScHeaderFieldsObj::~ScHeaderFieldsObj()
491 : : {
492 [ + - ][ + - ]: 1 : delete mpEditSource;
493 : :
494 : : // increment refcount to prevent double call off dtor
495 [ + - ]: 1 : osl_incrementInterlockedCount( &m_refCount );
496 : :
497 [ + - ]: 1 : if (mpRefreshListeners)
498 : : {
499 [ + - ]: 1 : lang::EventObject aEvent;
500 [ + - ]: 1 : aEvent.Source = static_cast<cppu::OWeakObject*>(this);
501 [ + - ]: 1 : if (mpRefreshListeners)
502 : : {
503 [ + - ]: 1 : mpRefreshListeners->disposeAndClear(aEvent);
504 [ + - ][ + - ]: 1 : DELETEZ( mpRefreshListeners );
505 [ + - ]: 1 : }
506 : : }
507 [ - + ]: 2 : }
508 : :
509 : : // XIndexAccess (via XTextFields)
510 : :
511 : 0 : uno::Reference<text::XTextField> ScHeaderFieldsObj::GetObjectByIndex_Impl(sal_Int32 Index) const
512 : : {
513 : : //! Feld-Funktionen muessen an den Forwarder !!!
514 [ # # ]: 0 : ScEditEngineDefaulter* pEditEngine = mpEditSource->GetEditEngine();
515 [ # # ]: 0 : ScUnoEditEngine aTempEngine(pEditEngine);
516 : :
517 [ # # ]: 0 : SvxFieldData* pData = aTempEngine.FindByIndex(static_cast<sal_uInt16>(Index));
518 [ # # ]: 0 : if (!pData)
519 [ # # ]: 0 : return NULL;
520 : :
521 : : // Get the parent text range instance.
522 : 0 : uno::Reference<text::XTextRange> xTextRange;
523 : 0 : ScHeaderFooterContentObj& rContentObj = mrData.GetContentObj();
524 : 0 : uno::Reference<text::XText> xText;
525 : 0 : sal_uInt16 nPart = mrData.GetPart();
526 [ # # ]: 0 : if (nPart == SC_HDFT_LEFT)
527 [ # # ][ # # ]: 0 : xText = rContentObj.getLeftText();
528 [ # # ]: 0 : else if (nPart == SC_HDFT_CENTER)
529 [ # # ][ # # ]: 0 : xText = rContentObj.getCenterText();
530 : : else
531 [ # # ][ # # ]: 0 : xText = rContentObj.getRightText();
532 : :
533 [ # # ]: 0 : uno::Reference<text::XTextRange> xTemp(xText, uno::UNO_QUERY);
534 [ # # ]: 0 : xTextRange = xTemp;
535 : :
536 : 0 : sal_uInt16 nPar = aTempEngine.GetFieldPar();
537 : 0 : xub_StrLen nPos = aTempEngine.GetFieldPos();
538 : 0 : ESelection aSelection( nPar, nPos, nPar, nPos+1 ); // Field is 1 character
539 : :
540 [ # # ]: 0 : sal_Int32 eRealType = pData->GetClassId();
541 : : uno::Reference<text::XTextField> xRet(
542 [ # # ][ # # ]: 0 : new ScEditFieldObj(xTextRange, new ScHeaderFooterEditSource(mrData), eRealType, aSelection));
[ # # ][ # # ]
[ # # ]
543 [ # # ]: 0 : return xRet;
544 : : }
545 : :
546 : 1 : sal_Int32 SAL_CALL ScHeaderFieldsObj::getCount() throw(uno::RuntimeException)
547 : : {
548 [ + - ]: 1 : SolarMutexGuard aGuard;
549 : :
550 : : //! Feld-Funktionen muessen an den Forwarder !!!
551 [ + - ]: 1 : ScEditEngineDefaulter* pEditEngine = mpEditSource->GetEditEngine();
552 [ + - ]: 1 : ScUnoEditEngine aTempEngine(pEditEngine);
553 [ + - ][ + - ]: 1 : return aTempEngine.CountFields();
[ + - ]
554 : : }
555 : :
556 : 0 : uno::Any SAL_CALL ScHeaderFieldsObj::getByIndex( sal_Int32 nIndex )
557 : : throw(lang::IndexOutOfBoundsException,
558 : : lang::WrappedTargetException, uno::RuntimeException)
559 : : {
560 [ # # ]: 0 : SolarMutexGuard aGuard;
561 [ # # ]: 0 : uno::Reference<text::XTextField> xField(GetObjectByIndex_Impl(nIndex));
562 [ # # ]: 0 : if (xField.is())
563 [ # # ]: 0 : return uno::makeAny(xField);
564 : : else
565 [ # # ][ # # ]: 0 : throw lang::IndexOutOfBoundsException();
566 : : }
567 : :
568 : 1 : uno::Type SAL_CALL ScHeaderFieldsObj::getElementType() throw(uno::RuntimeException)
569 : : {
570 [ + - ]: 1 : SolarMutexGuard aGuard;
571 [ + - ][ + - ]: 1 : return getCppuType((uno::Reference<text::XTextField>*)0);
572 : : }
573 : :
574 : 1 : sal_Bool SAL_CALL ScHeaderFieldsObj::hasElements() throw(uno::RuntimeException)
575 : : {
576 [ + - ]: 1 : SolarMutexGuard aGuard;
577 [ + - ][ + - ]: 1 : return ( getCount() != 0 );
578 : : }
579 : :
580 : 1 : uno::Reference<container::XEnumeration> SAL_CALL ScHeaderFieldsObj::createEnumeration()
581 : : throw(uno::RuntimeException)
582 : : {
583 [ + - ]: 1 : SolarMutexGuard aGuard;
584 [ + - ][ + - ]: 1 : return new ScIndexEnumeration(this, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.TextFieldEnumeration")));
[ + - ][ + - ]
[ + - ][ + - ]
585 : : }
586 : :
587 : 0 : void SAL_CALL ScHeaderFieldsObj::addContainerListener(
588 : : const uno::Reference<container::XContainerListener>& /* xListener */ )
589 : : throw(uno::RuntimeException)
590 : : {
591 : : OSL_FAIL("not implemented");
592 : 0 : }
593 : :
594 : 0 : void SAL_CALL ScHeaderFieldsObj::removeContainerListener(
595 : : const uno::Reference<container::XContainerListener>& /* xListener */ )
596 : : throw(uno::RuntimeException)
597 : : {
598 : : OSL_FAIL("not implemented");
599 : 0 : }
600 : :
601 : : // XRefreshable
602 : 2 : void SAL_CALL ScHeaderFieldsObj::refresh( )
603 : : throw (uno::RuntimeException)
604 : : {
605 [ + - ]: 2 : if (mpRefreshListeners)
606 : : {
607 : : // Call all listeners.
608 [ + - ]: 2 : uno::Sequence< uno::Reference< uno::XInterface > > aListeners(mpRefreshListeners->getElements());
609 : 2 : sal_uInt32 nLength(aListeners.getLength());
610 [ + + ]: 2 : if (nLength)
611 : : {
612 : 1 : const uno::Reference< uno::XInterface >* pInterfaces = aListeners.getConstArray();
613 [ + - ]: 1 : if (pInterfaces)
614 : : {
615 [ + - ]: 1 : lang::EventObject aEvent;
616 [ + - ][ + - ]: 1 : aEvent.Source.set(uno::Reference< util::XRefreshable >(const_cast<ScHeaderFieldsObj*>(this)));
[ # # ]
617 : 1 : sal_uInt32 i(0);
618 [ + + ]: 2 : while (i < nLength)
619 : : {
620 : : try
621 : : {
622 [ + + ]: 2 : while(i < nLength)
623 : : {
624 [ + - ][ + - ]: 1 : static_cast< util::XRefreshListener* >(pInterfaces->get())->refreshed(aEvent);
625 : 1 : ++pInterfaces;
626 : 1 : ++i;
627 : : }
628 : : }
629 [ # # ]: 0 : catch(uno::RuntimeException&)
630 : : {
631 : 0 : ++pInterfaces;
632 : 0 : ++i;
633 : : }
634 [ + - ]: 1 : }
635 : : }
636 [ + - ]: 2 : }
637 : : }
638 : 2 : }
639 : :
640 : 1 : void SAL_CALL ScHeaderFieldsObj::addRefreshListener( const uno::Reference< util::XRefreshListener >& xListener )
641 : : throw (uno::RuntimeException)
642 : : {
643 [ + - ]: 1 : if (xListener.is())
644 : : {
645 [ + - ]: 1 : SolarMutexGuard aGuard;
646 [ + - ]: 1 : if (!mpRefreshListeners)
647 [ + - ]: 1 : mpRefreshListeners = new cppu::OInterfaceContainerHelper(aMutex);
648 [ + - ][ + - ]: 1 : mpRefreshListeners->addInterface(xListener);
649 : : }
650 : 1 : }
651 : :
652 : 1 : void SAL_CALL ScHeaderFieldsObj::removeRefreshListener( const uno::Reference<util::XRefreshListener >& xListener )
653 : : throw (uno::RuntimeException)
654 : : {
655 [ + - ]: 1 : if (xListener.is())
656 : : {
657 [ + - ]: 1 : SolarMutexGuard aGuard;
658 [ + - ]: 1 : if (mpRefreshListeners)
659 [ + - ][ + - ]: 1 : mpRefreshListeners->removeInterface(xListener);
660 : : }
661 : 1 : }
662 : :
663 : 890 : SvxFieldData* ScEditFieldObj::getData()
664 : : {
665 [ + + ]: 890 : if (!mpData)
666 : : {
667 [ - - + + : 882 : switch (meType)
+ + + + +
- ]
668 : : {
669 : : case text::textfield::Type::DATE:
670 [ # # ]: 0 : mpData.reset(new SvxDateField);
671 : 0 : break;
672 : : case text::textfield::Type::EXTENDED_FILE:
673 : : mpData.reset(
674 [ # # ][ # # ]: 0 : new SvxExtFileField(rtl::OUString(), SVXFILETYPE_VAR, SVXFILEFORMAT_NAME_EXT));
[ # # ]
675 : 0 : break;
676 : : case text::textfield::Type::PAGE:
677 [ + - ]: 249 : mpData.reset(new SvxPageField);
678 : 249 : break;
679 : : case text::textfield::Type::PAGES:
680 [ + - ]: 93 : mpData.reset(new SvxPagesField);
681 : 93 : break;
682 : : case text::textfield::Type::TABLE:
683 [ + - ]: 249 : mpData.reset(new SvxTableField);
684 : 249 : break;
685 : : case text::textfield::Type::TIME:
686 [ + - ]: 4 : mpData.reset(new SvxTimeField);
687 : 4 : break;
688 : : case text::textfield::Type::EXTENDED_TIME:
689 : : {
690 [ + + ]: 186 : if (mbIsDate)
691 [ + - ]: 93 : mpData.reset(new SvxDateField);
692 : : else
693 [ + - ]: 93 : mpData.reset(new SvxExtTimeField);
694 : : }
695 : 186 : break;
696 : : case text::textfield::Type::DOCINFO_TITLE:
697 [ + - ]: 93 : mpData.reset(new SvxFileField);
698 : 93 : break;
699 : : case text::textfield::Type::URL:
700 : : mpData.reset(
701 [ + - ][ + - ]: 8 : new SvxURLField(rtl::OUString(), rtl::OUString(), SVXURLFORMAT_APPDEFAULT));
[ + - ]
702 : 8 : break;
703 : : default:
704 [ # # ]: 882 : mpData.reset(new SvxFieldData);
705 : : }
706 : : }
707 : 890 : return mpData.get();
708 : : }
709 : :
710 : 32 : void ScEditFieldObj::setPropertyValueURL(const rtl::OUString& rName, const com::sun::star::uno::Any& rVal)
711 : : {
712 : 32 : rtl::OUString aStrVal;
713 [ + + ]: 32 : if (mpEditSource)
714 : : {
715 : : // Edit engine instance already exists for this field item. Use it.
716 [ + - ]: 24 : ScEditEngineDefaulter* pEditEngine = mpEditSource->GetEditEngine();
717 [ + - ]: 24 : ScUnoEditEngine aTempEngine(pEditEngine);
718 : :
719 : : // Typ egal (in Zellen gibts nur URLs)
720 : : SvxFieldData* pField = aTempEngine.FindByPos(
721 [ + - ]: 24 : aSelection.nStartPara, aSelection.nStartPos, text::textfield::Type::UNSPECIFIED);
722 : : OSL_ENSURE(pField,"setPropertyValue: Feld nicht gefunden");
723 [ + - ]: 24 : if (!pField)
724 : : return;
725 : :
726 [ + - ][ + - ]: 24 : if (pField->GetClassId() != text::textfield::Type::URL)
727 : : // Make sure this is indeed a URL field.
728 : : return;
729 : :
730 : 24 : SvxURLField* pURL = static_cast<SvxURLField*>(pField);
731 : :
732 [ + + ]: 24 : if (rName == SC_UNONAME_URL)
733 : : {
734 [ + - ]: 8 : if (rVal >>= aStrVal)
735 : 8 : pURL->SetURL(aStrVal);
736 : : }
737 [ + + ]: 16 : else if (rName == SC_UNONAME_REPR)
738 : : {
739 [ + - ]: 8 : if (rVal >>= aStrVal)
740 : 8 : pURL->SetRepresentation(aStrVal);
741 : : }
742 [ + - ]: 8 : else if (rName == SC_UNONAME_TARGET)
743 : : {
744 [ + - ]: 8 : if (rVal >>= aStrVal)
745 : 8 : pURL->SetTargetFrame(aStrVal);
746 : : }
747 : : else
748 [ # # ]: 0 : throw beans::UnknownPropertyException();
749 : :
750 [ + - ][ + - ]: 24 : pEditEngine->QuickInsertField( SvxFieldItem(*pField, EE_FEATURE_FIELD), aSelection );
[ + - ]
751 [ + - ]: 24 : mpEditSource->UpdateData();
752 [ + - ]: 24 : return;
753 : : }
754 : :
755 : : // Edit engine instance not yet present. Store the item data for later use.
756 [ + - ]: 8 : SvxFieldData* pData = getData();
757 [ - + ]: 8 : if (!pData)
758 [ # # ]: 0 : throw uno::RuntimeException();
759 : :
760 : 8 : SvxURLField* p = static_cast<SvxURLField*>(pData);
761 [ + + ]: 8 : if (rName == SC_UNONAME_URL)
762 : : {
763 [ + - ]: 4 : if (rVal >>= aStrVal)
764 : 4 : p->SetURL(aStrVal);
765 : : }
766 [ + - ]: 4 : else if (rName == SC_UNONAME_REPR)
767 : : {
768 [ + - ]: 4 : if (rVal >>= aStrVal)
769 : 4 : p->SetRepresentation(aStrVal);
770 : : }
771 [ # # ]: 0 : else if (rName == SC_UNONAME_TARGET)
772 : : {
773 [ # # ]: 0 : if (rVal >>= aStrVal)
774 : 0 : p->SetTargetFrame(aStrVal);
775 : : }
776 : : else
777 [ # # ][ + + ]: 32 : throw beans::UnknownPropertyException();
778 : : }
779 : :
780 : 54 : uno::Any ScEditFieldObj::getPropertyValueURL(const rtl::OUString& rName)
781 : : {
782 : 54 : uno::Any aRet;
783 : :
784 : : // anchor type is always "as character", text wrap always "none"
785 : :
786 [ + - ]: 54 : if (mpEditSource)
787 : : {
788 : : //! Feld-Funktionen muessen an den Forwarder !!!
789 [ + - ]: 54 : ScEditEngineDefaulter* pEditEngine = mpEditSource->GetEditEngine();
790 [ + - ]: 54 : ScUnoEditEngine aTempEngine(pEditEngine);
791 : :
792 : : // Typ egal (in Zellen gibts nur URLs)
793 : : const SvxFieldData* pField = aTempEngine.FindByPos(
794 [ + - ]: 54 : aSelection.nStartPara, aSelection.nStartPos, text::textfield::Type::UNSPECIFIED);
795 : : OSL_ENSURE(pField,"getPropertyValue: Feld nicht gefunden");
796 [ - + ]: 54 : if (!pField)
797 [ # # ]: 0 : throw uno::RuntimeException();
798 : :
799 [ + - ][ - + ]: 54 : if (pField->GetClassId() != text::textfield::Type::URL)
800 [ # # ]: 0 : throw uno::RuntimeException();
801 : :
802 : 54 : const SvxURLField* pURL = static_cast<const SvxURLField*>(pField);
803 : :
804 [ + + ]: 54 : if (rName == SC_UNONAME_URL)
805 [ + - ]: 18 : aRet <<= pURL->GetURL();
806 [ + + ]: 36 : else if (rName == SC_UNONAME_REPR)
807 [ + - ]: 18 : aRet <<= pURL->GetRepresentation();
808 [ + - ]: 18 : else if (rName == SC_UNONAME_TARGET)
809 [ + - ]: 18 : aRet <<= pURL->GetTargetFrame();
810 : : else
811 [ # # ][ + - ]: 54 : throw beans::UnknownPropertyException();
812 : : }
813 : : else // noch nicht eingefuegt
814 : : {
815 [ # # ]: 0 : const SvxFieldData* pField = getData();
816 [ # # ]: 0 : if (!pField)
817 : 0 : return aRet;
818 : :
819 : 0 : const SvxURLField* pURL = static_cast<const SvxURLField*>(pField);
820 [ # # ]: 0 : if (rName == SC_UNONAME_URL)
821 [ # # ]: 0 : aRet <<= pURL->GetURL();
822 [ # # ]: 0 : else if (rName == SC_UNONAME_REPR)
823 [ # # ]: 0 : aRet <<= pURL->GetRepresentation();
824 [ # # ]: 0 : else if (rName == SC_UNONAME_TARGET)
825 [ # # ]: 0 : aRet <<= pURL->GetTargetFrame();
826 : : else
827 [ # # ]: 0 : throw beans::UnknownPropertyException();
828 : : }
829 : 54 : return aRet;
830 : : }
831 : :
832 : 0 : void ScEditFieldObj::setPropertyValueFile(const rtl::OUString& rName, const uno::Any& rVal)
833 : : {
834 [ # # ]: 0 : if (rName == SC_UNONAME_FILEFORM)
835 : : {
836 : 0 : sal_Int16 nIntVal = 0;
837 [ # # ]: 0 : if (rVal >>= nIntVal)
838 : : {
839 : 0 : SvxFileFormat eFormat = lcl_UnoToSvxFileFormat(nIntVal);
840 [ # # ]: 0 : if (mpEditSource)
841 : : {
842 [ # # ]: 0 : ScEditEngineDefaulter* pEditEngine = mpEditSource->GetEditEngine();
843 [ # # ]: 0 : ScUnoEditEngine aTempEngine(pEditEngine);
844 : : SvxFieldData* pField = aTempEngine.FindByPos(
845 [ # # ]: 0 : aSelection.nStartPara, aSelection.nStartPos, text::textfield::Type::EXTENDED_FILE);
846 : : OSL_ENSURE(pField, "setPropertyValueFile: Field not found");
847 [ # # ]: 0 : if (pField)
848 : : {
849 : 0 : SvxExtFileField* pExtFile = static_cast<SvxExtFileField*>(pField); // local to the ScUnoEditEngine
850 : 0 : pExtFile->SetFormat(eFormat);
851 [ # # ][ # # ]: 0 : pEditEngine->QuickInsertField(SvxFieldItem(*pField, EE_FEATURE_FIELD), aSelection);
[ # # ]
852 [ # # ]: 0 : mpEditSource->UpdateData();
853 [ # # ]: 0 : }
854 : : }
855 : : else
856 : : {
857 [ # # ]: 0 : SvxFieldData* pField = getData();
858 : 0 : SvxExtFileField* pExtFile = static_cast<SvxExtFileField*>(pField);
859 : 0 : pExtFile->SetFormat(eFormat);
860 : : }
861 : : }
862 : : }
863 : : else
864 [ # # ]: 0 : throw beans::UnknownPropertyException();
865 : 0 : }
866 : :
867 : 0 : uno::Any ScEditFieldObj::getPropertyValueFile(const rtl::OUString& rName)
868 : : {
869 : 0 : uno::Any aRet;
870 [ # # ]: 0 : if (rName == SC_UNONAME_FILEFORM)
871 : : {
872 : 0 : SvxFileFormat eFormat = SVXFILEFORMAT_NAME_EXT;
873 : 0 : const SvxFieldData* pField = NULL;
874 [ # # ]: 0 : if (mpEditSource)
875 : : {
876 [ # # ]: 0 : ScEditEngineDefaulter* pEditEngine = mpEditSource->GetEditEngine();
877 [ # # ]: 0 : ScUnoEditEngine aTempEngine(pEditEngine);
878 : : pField = aTempEngine.FindByPos(
879 [ # # ][ # # ]: 0 : aSelection.nStartPara, aSelection.nStartPos, text::textfield::Type::EXTENDED_FILE);
880 : : }
881 : : else
882 [ # # ]: 0 : pField = getData();
883 : :
884 : : OSL_ENSURE(pField, "setPropertyValueFile: Field not found");
885 [ # # ]: 0 : if (!pField)
886 [ # # ]: 0 : throw uno::RuntimeException();
887 : :
888 : 0 : const SvxExtFileField* pExtFile = static_cast<const SvxExtFileField*>(pField);
889 : 0 : eFormat = pExtFile->GetFormat();
890 : 0 : sal_Int16 nIntVal = lcl_SvxToUnoFileFormat(eFormat);
891 [ # # ]: 0 : aRet <<= nIntVal;
892 : : }
893 : : else
894 [ # # ]: 0 : throw beans::UnknownPropertyException();
895 : :
896 : 0 : return aRet;
897 : : }
898 : :
899 : 396 : void ScEditFieldObj::setPropertyValueDateTime(const rtl::OUString& rName, const uno::Any& rVal)
900 : : {
901 [ + + ]: 396 : if (mpEditSource)
902 : : {
903 : : // Field already inserted.
904 [ + - ]: 24 : ScEditEngineDefaulter* pEditEngine = mpEditSource->GetEditEngine();
905 [ + - ]: 24 : ScUnoEditEngine aTempEngine(pEditEngine);
906 [ + - ]: 24 : SvxFieldData* pField = aTempEngine.FindByPos(aSelection.nStartPara, aSelection.nStartPos, meType);
907 [ - + ]: 24 : if (!pField)
908 : 396 : return;
909 : :
910 [ - + - - ]: 24 : switch (meType)
911 : : {
912 : : case text::textfield::Type::DATE:
913 : : {
914 : 0 : SvxDateField* p = static_cast<SvxDateField*>(pField);
915 [ # # ]: 0 : if (rName == SC_UNONAME_ISDATE)
916 : : {
917 : : // Do nothing for now.
918 : : }
919 [ # # ]: 0 : else if (rName == SC_UNONAME_ISFIXED)
920 : : {
921 [ # # ]: 0 : SvxDateType eType = rVal.get<sal_Bool>() ? SVXDATETYPE_FIX : SVXDATETYPE_VAR;
922 : 0 : p->SetType(eType);
923 : : }
924 [ # # ]: 0 : else if (rName == SC_UNONAME_DATETIME)
925 : : {
926 [ # # ]: 0 : maDateTime = rVal.get<util::DateTime>();
927 : 0 : Date aDate(maDateTime.Day, maDateTime.Month, maDateTime.Year);
928 : 0 : p->SetFixDate(aDate);
929 : : }
930 [ # # ]: 0 : else if (rName == SC_UNONAME_NUMFMT)
931 : : {
932 [ # # ]: 0 : mnNumFormat = rVal.get<sal_Int32>();
933 : 0 : p->SetFormat(static_cast<SvxDateFormat>(mnNumFormat));
934 : : }
935 : : else
936 [ # # ]: 0 : throw beans::UnknownPropertyException();
937 : : }
938 : 0 : break;
939 : : case text::textfield::Type::TIME:
940 : : {
941 : : // SvxTimeField doesn't have any attributes.
942 [ + + ][ + + : 42 : if (rName != SC_UNONAME_ISDATE && rName != SC_UNONAME_ISFIXED &&
+ + - + ]
[ - + ]
943 : 18 : rName != SC_UNONAME_DATETIME && rName != SC_UNONAME_NUMFMT)
944 [ # # ]: 0 : throw beans::UnknownPropertyException();
945 : : }
946 : 24 : break;
947 : : case text::textfield::Type::EXTENDED_TIME:
948 : : {
949 : 0 : SvxExtTimeField* p = static_cast<SvxExtTimeField*>(pField);
950 [ # # ]: 0 : if (rName == SC_UNONAME_ISDATE)
951 : : {
952 : : // Do nothing for now.
953 : : }
954 [ # # ]: 0 : else if (rName == SC_UNONAME_ISFIXED)
955 : : {
956 [ # # ]: 0 : SvxTimeType eType = rVal.get<sal_Bool>() ? SVXTIMETYPE_FIX : SVXTIMETYPE_VAR;
957 : 0 : p->SetType(eType);
958 : : }
959 [ # # ]: 0 : else if (rName == SC_UNONAME_DATETIME)
960 : : {
961 [ # # ]: 0 : maDateTime = rVal.get<util::DateTime>();
962 [ # # ]: 0 : Time aTime(maDateTime.Hours, maDateTime.Minutes, maDateTime.Seconds, maDateTime.HundredthSeconds);
963 : 0 : p->SetFixTime(aTime);
964 : : }
965 [ # # ]: 0 : else if (rName == SC_UNONAME_NUMFMT)
966 : : {
967 [ # # ]: 0 : mnNumFormat = rVal.get<sal_Int32>();
968 : 0 : p->SetFormat(static_cast<SvxTimeFormat>(mnNumFormat));
969 : : }
970 : : else
971 [ # # ]: 0 : throw beans::UnknownPropertyException();
972 : : }
973 : 0 : break;
974 : : default:
975 [ # # ]: 24 : throw beans::UnknownPropertyException();
976 [ + - ][ + - ]: 24 : }
977 : : }
978 : : else
979 : : {
980 [ + + ]: 372 : if (rName == SC_UNONAME_ISDATE)
981 : 186 : mbIsDate = rVal.get<sal_Bool>();
982 [ + - ]: 186 : else if (rName == SC_UNONAME_ISFIXED)
983 : 186 : mbIsFixed = rVal.get<sal_Bool>();
984 [ # # ]: 0 : else if (rName == SC_UNONAME_DATETIME)
985 : 0 : maDateTime = rVal.get<util::DateTime>();
986 [ # # ]: 0 : else if (rName == SC_UNONAME_NUMFMT)
987 : 0 : mnNumFormat = rVal.get<sal_Int32>();
988 : : else
989 [ # # ]: 0 : throw beans::UnknownPropertyException();
990 : : }
991 : : }
992 : :
993 : 60 : uno::Any ScEditFieldObj::getPropertyValueDateTime(const rtl::OUString& rName)
994 : : {
995 [ + + ]: 60 : if (mpEditSource)
996 : : {
997 : : // Field already inserted.
998 [ + - ]: 48 : ScEditEngineDefaulter* pEditEngine = mpEditSource->GetEditEngine();
999 [ + - ]: 48 : ScUnoEditEngine aTempEngine(pEditEngine);
1000 [ + - ]: 48 : SvxFieldData* pField = aTempEngine.FindByPos(aSelection.nStartPara, aSelection.nStartPos, meType);
1001 [ - + ]: 48 : if (!pField)
1002 [ # # ]: 0 : throw uno::RuntimeException();
1003 : :
1004 [ - + - - ]: 48 : switch (meType)
1005 : : {
1006 : : case text::textfield::Type::DATE:
1007 : : {
1008 : 0 : SvxDateField* p = static_cast<SvxDateField*>(pField);
1009 [ # # ]: 0 : if (rName == SC_UNONAME_ISDATE)
1010 [ # # ]: 0 : return uno::makeAny(sal_True);
1011 : :
1012 [ # # ]: 0 : if (rName == SC_UNONAME_ISFIXED)
1013 [ # # ]: 0 : return uno::makeAny<sal_Bool>(p->GetType() == SVXDATETYPE_FIX);
1014 : :
1015 [ # # ]: 0 : if (rName == SC_UNONAME_DATETIME)
1016 : : {
1017 : 0 : Date aD(p->GetFixDate());
1018 : 0 : maDateTime.Year = aD.GetYear();
1019 : 0 : maDateTime.Month = aD.GetMonth();
1020 : 0 : maDateTime.Day = aD.GetDay();
1021 : 0 : maDateTime.Hours = 0;
1022 : 0 : maDateTime.Minutes = 0;
1023 : 0 : maDateTime.Seconds = 0;
1024 : 0 : maDateTime.HundredthSeconds = 0;
1025 [ # # ]: 0 : return uno::makeAny(maDateTime);
1026 : : }
1027 : :
1028 [ # # ]: 0 : if (rName == SC_UNONAME_NUMFMT)
1029 [ # # ]: 0 : return uno::makeAny<sal_Int32>(p->GetFormat());
1030 : : }
1031 : 0 : break;
1032 : : case text::textfield::Type::TIME:
1033 : : {
1034 : : // SvxTimeField doesn't have any attributes.
1035 [ + + ]: 48 : if (rName == SC_UNONAME_ISDATE)
1036 [ + - ]: 12 : return uno::makeAny(sal_False);
1037 : :
1038 [ + + ]: 36 : if (rName == SC_UNONAME_ISFIXED)
1039 [ + - ]: 12 : return uno::makeAny(sal_False);
1040 : :
1041 [ + + ]: 24 : if (rName == SC_UNONAME_DATETIME)
1042 : : // This is the best we can do.
1043 [ + - ]: 12 : return uno::makeAny(maDateTime);
1044 : :
1045 [ + - ]: 12 : if (rName == SC_UNONAME_NUMFMT)
1046 : : // Same as above.
1047 [ + - ]: 12 : return uno::makeAny<sal_Int32>(0);
1048 : : }
1049 : 0 : break;
1050 : : case text::textfield::Type::EXTENDED_TIME:
1051 : : {
1052 : 0 : SvxExtTimeField* p = static_cast<SvxExtTimeField*>(pField);
1053 [ # # ]: 0 : if (rName == SC_UNONAME_ISDATE)
1054 [ # # ]: 0 : return uno::makeAny(sal_False);
1055 : :
1056 [ # # ]: 0 : if (rName == SC_UNONAME_ISFIXED)
1057 [ # # ]: 0 : return uno::makeAny<sal_Bool>(p->GetType() == SVXTIMETYPE_FIX);
1058 : :
1059 [ # # ]: 0 : if (rName == SC_UNONAME_DATETIME)
1060 : : {
1061 : 0 : Time aT(p->GetFixTime());
1062 : 0 : maDateTime.Year = 0;
1063 : 0 : maDateTime.Month = 0;
1064 : 0 : maDateTime.Day = 0;
1065 : 0 : maDateTime.Hours = aT.GetHour();
1066 : 0 : maDateTime.Minutes = aT.GetMin();
1067 : 0 : maDateTime.Seconds = aT.GetSec();
1068 : 0 : maDateTime.HundredthSeconds = aT.Get100Sec();
1069 [ # # ]: 0 : return uno::makeAny(maDateTime);
1070 : : }
1071 : :
1072 [ # # ]: 0 : if (rName == SC_UNONAME_NUMFMT)
1073 [ # # ]: 0 : return uno::makeAny<sal_Int32>(p->GetFormat());
1074 : : }
1075 : 0 : break;
1076 : : default:
1077 : : ;
1078 [ + - ][ - + ]: 48 : }
1079 : : }
1080 : : else
1081 : : {
1082 [ + + ]: 12 : if (rName == SC_UNONAME_ISDATE)
1083 [ + - ]: 3 : return uno::makeAny<sal_Bool>(mbIsDate);
1084 : :
1085 [ + + ]: 9 : if (rName == SC_UNONAME_ISFIXED)
1086 [ + - ]: 3 : return uno::makeAny<sal_Bool>(mbIsFixed);
1087 : :
1088 [ + + ]: 6 : if (rName == SC_UNONAME_DATETIME)
1089 : 3 : return uno::makeAny(maDateTime);
1090 : :
1091 [ + - ]: 3 : if (rName == SC_UNONAME_NUMFMT)
1092 : 3 : return uno::makeAny(mnNumFormat);
1093 : : }
1094 : :
1095 [ # # ]: 60 : throw beans::UnknownPropertyException();
1096 : : }
1097 : :
1098 : 0 : void ScEditFieldObj::setPropertyValueSheet(const rtl::OUString& rName, const uno::Any& rVal)
1099 : : {
1100 [ # # ]: 0 : if (mpEditSource)
1101 : : {
1102 : : // Edit engine instance already exists for this field item. Use it.
1103 [ # # ]: 0 : ScEditEngineDefaulter* pEditEngine = mpEditSource->GetEditEngine();
1104 [ # # ]: 0 : ScUnoEditEngine aTempEngine(pEditEngine);
1105 : :
1106 : : // Typ egal (in Zellen gibts nur URLs)
1107 : : SvxFieldData* pField = aTempEngine.FindByPos(
1108 [ # # ]: 0 : aSelection.nStartPara, aSelection.nStartPos, text::textfield::Type::UNSPECIFIED);
1109 : : OSL_ENSURE(pField,"setPropertyValue: Feld nicht gefunden");
1110 [ # # ]: 0 : if (!pField)
1111 : : return;
1112 : :
1113 [ # # ][ # # ]: 0 : if (pField->GetClassId() != text::textfield::Type::TABLE)
1114 : : // Make sure this is indeed a URL field.
1115 : : return;
1116 : :
1117 : 0 : SvxTableField* p = static_cast<SvxTableField*>(pField);
1118 : :
1119 [ # # ]: 0 : if (rName == SC_UNONAME_TABLEPOS)
1120 : : {
1121 [ # # ]: 0 : sal_Int32 nTab = rVal.get<sal_Int32>();
1122 [ # # ]: 0 : p->SetTab(nTab);
1123 : : }
1124 : : else
1125 [ # # ]: 0 : throw beans::UnknownPropertyException();
1126 : :
1127 [ # # ][ # # ]: 0 : pEditEngine->QuickInsertField(SvxFieldItem(*pField, EE_FEATURE_FIELD), aSelection);
[ # # ]
1128 [ # # ]: 0 : mpEditSource->UpdateData();
1129 [ # # ]: 0 : return;
1130 : : }
1131 : :
1132 : : // Edit engine instance not yet present. Store the item data for later use.
1133 : 0 : SvxFieldData* pData = getData();
1134 [ # # ]: 0 : if (!pData)
1135 [ # # ]: 0 : throw uno::RuntimeException();
1136 : :
1137 : 0 : SvxTableField* p = static_cast<SvxTableField*>(pData);
1138 [ # # ]: 0 : if (rName == SC_UNONAME_TABLEPOS)
1139 : : {
1140 : 0 : sal_Int32 nTab = rVal.get<sal_Int32>();
1141 : 0 : p->SetTab(nTab);
1142 : : }
1143 : : else
1144 [ # # ]: 0 : throw beans::UnknownPropertyException();
1145 : :
1146 : : }
1147 : :
1148 : 919 : ScEditFieldObj::ScEditFieldObj(
1149 : : const uno::Reference<text::XTextRange>& rContent,
1150 : : ScEditSource* pEditSrc, sal_Int32 eType, const ESelection& rSel) :
1151 : 919 : OComponentHelper(getMutex()),
1152 : : pPropSet(NULL),
1153 : : mpEditSource(pEditSrc),
1154 : : aSelection(rSel),
1155 [ + - + - ]: 1838 : meType(eType), mpData(NULL), mpContent(rContent), mnNumFormat(0), mbIsDate(false), mbIsFixed(false)
1156 : : {
1157 [ + + + + : 919 : switch (meType)
+ ]
1158 : : {
1159 : : case text::textfield::Type::DOCINFO_TITLE:
1160 [ + - ]: 97 : pPropSet = getEmptyPropertySet();
1161 : 97 : break;
1162 : : case text::textfield::Type::EXTENDED_FILE:
1163 [ + - ]: 2 : pPropSet = lcl_GetFileFieldPropertySet();
1164 : 2 : break;
1165 : : case text::textfield::Type::URL:
1166 [ + - ]: 18 : pPropSet = lcl_GetURLPropertySet();
1167 : 18 : break;
1168 : : case text::textfield::Type::DATE:
1169 : : case text::textfield::Type::TIME:
1170 : : case text::textfield::Type::EXTENDED_TIME:
1171 [ + - ]: 205 : pPropSet = getDateTimePropertySet();
1172 : 205 : break;
1173 : : default:
1174 [ + - ]: 597 : pPropSet = lcl_GetHeaderFieldPropertySet();
1175 : : }
1176 : :
1177 [ + + ]: 919 : if (meType == text::textfield::Type::DATE)
1178 : 4 : mbIsDate = true;
1179 : 919 : }
1180 : :
1181 : 882 : void ScEditFieldObj::InitDoc(
1182 : : const uno::Reference<text::XTextRange>& rContent, ScEditSource* pEditSrc, const ESelection& rSel)
1183 : : {
1184 [ + - ]: 882 : if (!mpEditSource)
1185 : : {
1186 : 882 : mpContent = rContent;
1187 : 882 : mpData.reset();
1188 : :
1189 : 882 : aSelection = rSel;
1190 : 882 : mpEditSource = pEditSrc;
1191 : : }
1192 : 882 : }
1193 : :
1194 [ + - ][ + - ]: 919 : ScEditFieldObj::~ScEditFieldObj()
[ + - ]
1195 : : {
1196 [ + + ][ + - ]: 919 : delete mpEditSource;
1197 [ - + ]: 1838 : }
1198 : :
1199 : 882 : SvxFieldItem ScEditFieldObj::CreateFieldItem()
1200 : : {
1201 : : OSL_ENSURE( !mpEditSource, "CreateFieldItem mit eingefuegtem Feld" );
1202 : 882 : return SvxFieldItem(*getData(), EE_FEATURE_FIELD);
1203 : : }
1204 : :
1205 : 8 : sal_Int32 ScEditFieldObj::GetFieldType() const
1206 : : {
1207 : 8 : return meType;
1208 : : }
1209 : :
1210 : 2 : void ScEditFieldObj::DeleteField()
1211 : : {
1212 [ + - ]: 2 : if (mpEditSource)
1213 : : {
1214 : 2 : SvxTextForwarder* pForwarder = mpEditSource->GetTextForwarder();
1215 [ + - ]: 2 : pForwarder->QuickInsertText( String(), aSelection );
1216 : 2 : mpEditSource->UpdateData();
1217 : :
1218 : 2 : aSelection.nEndPara = aSelection.nStartPara;
1219 : 2 : aSelection.nEndPos = aSelection.nStartPos;
1220 : :
1221 : : //! Broadcast, um Selektion in anderen Objekten anzupassen
1222 : : //! (auch bei anderen Aktionen)
1223 : : }
1224 : 2 : }
1225 : :
1226 : 884 : bool ScEditFieldObj::IsInserted() const
1227 : : {
1228 : 884 : return mpEditSource != NULL;
1229 : : }
1230 : :
1231 : : // XTextField
1232 : :
1233 : 4 : rtl::OUString SAL_CALL ScEditFieldObj::getPresentation( sal_Bool bShowCommand )
1234 : : throw(uno::RuntimeException)
1235 : : {
1236 [ + - ]: 4 : SolarMutexGuard aGuard;
1237 : :
1238 [ - + ]: 4 : if (!mpEditSource)
1239 : 0 : return rtl::OUString();
1240 : :
1241 : : //! Feld-Funktionen muessen an den Forwarder !!!
1242 [ + - ]: 4 : ScEditEngineDefaulter* pEditEngine = mpEditSource->GetEditEngine();
1243 [ + - ]: 4 : ScUnoEditEngine aTempEngine(pEditEngine);
1244 : :
1245 : : // Typ egal (in Zellen gibts nur URLs)
1246 : : const SvxFieldData* pField = aTempEngine.FindByPos(
1247 [ + - ]: 4 : aSelection.nStartPara, aSelection.nStartPos, text::textfield::Type::UNSPECIFIED);
1248 : : OSL_ENSURE(pField,"getPresentation: Feld nicht gefunden");
1249 [ - + ]: 4 : if (!pField)
1250 : 0 : return rtl::OUString();
1251 : :
1252 [ + - ]: 4 : switch (meType)
1253 : : {
1254 : : case text::textfield::Type::URL:
1255 : : {
1256 [ + - ][ - + ]: 4 : if (pField->GetClassId() != text::textfield::Type::URL)
1257 : : // Not an URL field, but URL is expected.
1258 [ # # ]: 0 : throw uno::RuntimeException();
1259 : :
1260 : 4 : const SvxURLField* pURL = static_cast<const SvxURLField*>(pField);
1261 [ + + ]: 4 : return bShowCommand ? pURL->GetURL() : pURL->GetRepresentation();
1262 : : }
1263 : : break;
1264 : : default:
1265 : : ;
1266 : : }
1267 [ + - ][ + - ]: 4 : return rtl::OUString();
1268 : : }
1269 : :
1270 : : // XTextContent
1271 : :
1272 : 4 : void SAL_CALL ScEditFieldObj::attach( const uno::Reference<text::XTextRange>& xTextRange )
1273 : : throw(lang::IllegalArgumentException, uno::RuntimeException)
1274 : : {
1275 [ + - ]: 4 : SolarMutexGuard aGuard;
1276 [ + - ]: 4 : if (xTextRange.is())
1277 : : {
1278 [ + - ][ + - ]: 4 : uno::Reference<text::XText> xText(xTextRange->getText());
1279 [ + - ]: 4 : if (xText.is())
1280 : : {
1281 [ + - ][ + - ]: 4 : xText->insertTextContent( xTextRange, this, sal_True );
[ + + ]
1282 : 4 : }
1283 [ + - ]: 4 : }
1284 : 2 : }
1285 : :
1286 : 8 : uno::Reference<text::XTextRange> SAL_CALL ScEditFieldObj::getAnchor() throw(uno::RuntimeException)
1287 : : {
1288 [ + - ]: 8 : SolarMutexGuard aGuard;
1289 [ + - ]: 8 : return mpContent;
1290 : : }
1291 : :
1292 : : // XComponent
1293 : :
1294 : 0 : void SAL_CALL ScEditFieldObj::dispose() throw(uno::RuntimeException)
1295 : : {
1296 : 0 : OComponentHelper::dispose();
1297 : 0 : }
1298 : :
1299 : 0 : void SAL_CALL ScEditFieldObj::addEventListener(
1300 : : const uno::Reference<lang::XEventListener>& xListener )
1301 : : throw(uno::RuntimeException)
1302 : : {
1303 : 0 : OComponentHelper::addEventListener( xListener );
1304 : 0 : }
1305 : :
1306 : 0 : void SAL_CALL ScEditFieldObj::removeEventListener(
1307 : : const uno::Reference<lang::XEventListener>& xListener )
1308 : : throw(uno::RuntimeException)
1309 : : {
1310 : 0 : OComponentHelper::removeEventListener( xListener );
1311 : 0 : }
1312 : :
1313 : : // XPropertySet
1314 : :
1315 : 586 : uno::Reference<beans::XPropertySetInfo> SAL_CALL ScEditFieldObj::getPropertySetInfo()
1316 : : throw(uno::RuntimeException)
1317 : : {
1318 [ + - ]: 586 : SolarMutexGuard aGuard;
1319 [ + - ]: 586 : uno::Reference<beans::XPropertySetInfo> aRef = pPropSet->getPropertySetInfo();
1320 [ + - ]: 586 : return aRef;
1321 : : }
1322 : :
1323 : 431 : void SAL_CALL ScEditFieldObj::setPropertyValue(
1324 : : const rtl::OUString& aPropertyName, const uno::Any& aValue )
1325 : : throw(beans::UnknownPropertyException, beans::PropertyVetoException,
1326 : : lang::IllegalArgumentException, lang::WrappedTargetException,
1327 : : uno::RuntimeException)
1328 : : {
1329 [ + - ]: 431 : SolarMutexGuard aGuard;
1330 [ + + ]: 431 : if (aPropertyName == SC_UNONAME_ANCHOR)
1331 : : {
1332 [ + - ]: 3 : aValue >>= mpContent;
1333 : 431 : return;
1334 : : }
1335 : :
1336 [ + - + - : 428 : switch (meType)
- ]
1337 : : {
1338 : : case text::textfield::Type::URL:
1339 [ + - ]: 32 : setPropertyValueURL(aPropertyName, aValue);
1340 : 32 : break;
1341 : : case text::textfield::Type::EXTENDED_FILE:
1342 [ # # ]: 0 : setPropertyValueFile(aPropertyName, aValue);
1343 : 0 : break;
1344 : : case text::textfield::Type::DATE:
1345 : : case text::textfield::Type::TIME:
1346 : : case text::textfield::Type::EXTENDED_TIME:
1347 [ + - ]: 396 : setPropertyValueDateTime(aPropertyName, aValue);
1348 : 396 : break;
1349 : : case text::textfield::Type::TABLE:
1350 [ # # ]: 0 : setPropertyValueSheet(aPropertyName, aValue);
1351 : 0 : break;
1352 : : case text::textfield::Type::DOCINFO_TITLE:
1353 : : default:
1354 [ # # ]: 428 : throw beans::UnknownPropertyException();
1355 [ + - ][ + + ]: 431 : }
1356 : : }
1357 : :
1358 : 123 : uno::Any SAL_CALL ScEditFieldObj::getPropertyValue( const rtl::OUString& aPropertyName )
1359 : : throw(beans::UnknownPropertyException, lang::WrappedTargetException,
1360 : : uno::RuntimeException)
1361 : : {
1362 [ + - ]: 123 : SolarMutexGuard aGuard;
1363 [ + + ]: 123 : if (aPropertyName.equals(SC_UNONAME_TEXTFIELD_TYPE))
1364 [ + - ]: 3 : return uno::makeAny(meType);
1365 : :
1366 [ - + ]: 120 : if (aPropertyName == SC_UNONAME_ANCHOR)
1367 [ # # ]: 0 : return uno::makeAny(mpContent);
1368 : :
1369 [ + + ]: 120 : if (aPropertyName == SC_UNONAME_ANCTYPE)
1370 : : {
1371 : 2 : uno::Any aRet;
1372 [ + - ]: 2 : aRet <<= text::TextContentAnchorType_AS_CHARACTER;
1373 : 2 : return aRet;
1374 : : }
1375 [ + + ]: 118 : if (aPropertyName == SC_UNONAME_ANCTYPES)
1376 : : {
1377 : 2 : uno::Any aRet;
1378 [ + - ]: 2 : uno::Sequence<text::TextContentAnchorType> aSeq(1);
1379 [ + - ]: 2 : aSeq[0] = text::TextContentAnchorType_AS_CHARACTER;
1380 [ + - ]: 2 : aRet <<= aSeq;
1381 [ + - ]: 2 : return aRet;
1382 : : }
1383 [ + + ]: 116 : if (aPropertyName == SC_UNONAME_TEXTWRAP)
1384 : : {
1385 : 2 : uno::Any aRet;
1386 [ + - ]: 2 : aRet <<= text::WrapTextMode_NONE;
1387 : 2 : return aRet;
1388 : : }
1389 : :
1390 [ + - + - ]: 114 : switch (meType)
1391 : : {
1392 : : case text::textfield::Type::URL:
1393 [ + - ]: 54 : return getPropertyValueURL(aPropertyName);
1394 : : case text::textfield::Type::EXTENDED_FILE:
1395 [ # # ]: 0 : return getPropertyValueFile(aPropertyName);
1396 : : case text::textfield::Type::DATE:
1397 : : case text::textfield::Type::TIME:
1398 : : case text::textfield::Type::EXTENDED_TIME:
1399 [ + - ]: 60 : return getPropertyValueDateTime(aPropertyName);
1400 : : case text::textfield::Type::DOCINFO_TITLE:
1401 : : default:
1402 [ # # ]: 0 : throw beans::UnknownPropertyException();
1403 [ + - ]: 123 : }
1404 : : }
1405 : :
1406 : 0 : SC_IMPL_DUMMY_PROPERTY_LISTENER( ScEditFieldObj )
1407 : :
1408 : : // XUnoTunnel
1409 : :
1410 : 884 : sal_Int64 SAL_CALL ScEditFieldObj::getSomething(
1411 : : const uno::Sequence<sal_Int8 >& rId ) throw(uno::RuntimeException)
1412 : : {
1413 [ + - + - ]: 1768 : if ( rId.getLength() == 16 &&
[ + - ]
1414 : 884 : 0 == memcmp( getUnoTunnelId().getConstArray(),
1415 : 884 : rId.getConstArray(), 16 ) )
1416 : : {
1417 : 884 : return sal::static_int_cast<sal_Int64>(reinterpret_cast<sal_IntPtr>(this));
1418 : : }
1419 : 884 : return 0;
1420 : : }
1421 : :
1422 : : namespace
1423 : : {
1424 : : class theScEditFieldObjUnoTunnelId : public rtl::Static< UnoTunnelIdInit, theScEditFieldObjUnoTunnelId> {};
1425 : : }
1426 : :
1427 : 1768 : const uno::Sequence<sal_Int8>& ScEditFieldObj::getUnoTunnelId()
1428 : : {
1429 : 1768 : return theScEditFieldObjUnoTunnelId::get().getSeq();
1430 : : }
1431 : :
1432 : 884 : ScEditFieldObj* ScEditFieldObj::getImplementation(const uno::Reference<text::XTextContent>& xObj)
1433 : : {
1434 : 884 : ScEditFieldObj* pRet = NULL;
1435 [ + - ]: 884 : uno::Reference<lang::XUnoTunnel> xUT( xObj, uno::UNO_QUERY );
1436 [ + - ]: 884 : if (xUT.is())
1437 [ + - ][ + - ]: 884 : pRet = reinterpret_cast<ScEditFieldObj*>(sal::static_int_cast<sal_IntPtr>(xUT->getSomething(getUnoTunnelId())));
[ + - ]
1438 : 884 : return pRet;
1439 : : }
1440 : :
1441 : : // XServiceInfo
1442 : :
1443 : 0 : rtl::OUString SAL_CALL ScEditFieldObj::getImplementationName() throw(uno::RuntimeException)
1444 : : {
1445 : 0 : return rtl::OUString("ScEditFieldObj");
1446 : : }
1447 : :
1448 : 0 : sal_Bool SAL_CALL ScEditFieldObj::supportsService( const rtl::OUString& rServiceName )
1449 : : throw(uno::RuntimeException)
1450 : : {
1451 [ # # ][ # # ]: 0 : return rServiceName == SCTEXTFIELD_SERVICE || rServiceName == SCTEXTCONTENT_SERVICE;
1452 : : }
1453 : :
1454 : 0 : uno::Sequence<rtl::OUString> SAL_CALL ScEditFieldObj::getSupportedServiceNames()
1455 : : throw(uno::RuntimeException)
1456 : : {
1457 : 0 : uno::Sequence<rtl::OUString> aRet(2);
1458 [ # # ]: 0 : rtl::OUString* pArray = aRet.getArray();
1459 : 0 : pArray[0] = SCTEXTFIELD_SERVICE;
1460 : 0 : pArray[1] = SCTEXTCONTENT_SERVICE;
1461 : 0 : return aRet;
1462 : : }
1463 : :
1464 : 0 : uno::Sequence<uno::Type> SAL_CALL ScEditFieldObj::getTypes() throw(uno::RuntimeException)
1465 : : {
1466 [ # # ][ # # ]: 0 : static uno::Sequence<uno::Type> aTypes;
[ # # ][ # # ]
1467 [ # # ]: 0 : if ( aTypes.getLength() == 0 )
1468 : : {
1469 [ # # ]: 0 : uno::Sequence<uno::Type> aParentTypes(OComponentHelper::getTypes());
1470 : 0 : long nParentLen = aParentTypes.getLength();
1471 : 0 : const uno::Type* pParentPtr = aParentTypes.getConstArray();
1472 : :
1473 [ # # ]: 0 : aTypes.realloc( nParentLen + 4 );
1474 [ # # ]: 0 : uno::Type* pPtr = aTypes.getArray();
1475 [ # # ]: 0 : pPtr[nParentLen + 0] = getCppuType((const uno::Reference<text::XTextField>*)0);
1476 [ # # ]: 0 : pPtr[nParentLen + 1] = getCppuType((const uno::Reference<beans::XPropertySet>*)0);
1477 [ # # ]: 0 : pPtr[nParentLen + 2] = getCppuType((const uno::Reference<lang::XUnoTunnel>*)0);
1478 [ # # ]: 0 : pPtr[nParentLen + 3] = getCppuType((const uno::Reference<lang::XServiceInfo>*)0);
1479 : :
1480 [ # # ]: 0 : for (long i=0; i<nParentLen; i++)
1481 [ # # ]: 0 : pPtr[i] = pParentPtr[i]; // parent types first
1482 : : }
1483 : 0 : return aTypes;
1484 : : }
1485 : :
1486 : : namespace
1487 : : {
1488 : : class theScEditFieldObjImplementationId : public rtl::Static<UnoTunnelIdInit, theScEditFieldObjImplementationId> {};
1489 : : }
1490 : :
1491 : 0 : uno::Sequence<sal_Int8> SAL_CALL ScEditFieldObj::getImplementationId()
1492 : : throw(uno::RuntimeException)
1493 : : {
1494 : 0 : return theScEditFieldObjImplementationId::get().getSeq();
1495 : : }
1496 : :
1497 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|