Branch data 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 <DomainMapper_Impl.hxx>
21 : : #include <ConversionHelper.hxx>
22 : : #include <DomainMapperTableHandler.hxx>
23 : : #include <com/sun/star/uno/XComponentContext.hpp>
24 : : #include <com/sun/star/graphic/XGraphic.hpp>
25 : : #include <com/sun/star/beans/XPropertySet.hpp>
26 : : #include <com/sun/star/beans/XPropertyState.hpp>
27 : : #include <com/sun/star/container/XIndexReplace.hpp>
28 : : #include <com/sun/star/container/XNamed.hpp>
29 : : #include <com/sun/star/drawing/XDrawPageSupplier.hpp>
30 : : #include <com/sun/star/drawing/XShapes.hpp>
31 : : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
32 : : #include <com/sun/star/lang/XServiceInfo.hpp>
33 : : #include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
34 : : #include <com/sun/star/style/LineNumberPosition.hpp>
35 : : #include <com/sun/star/style/LineSpacing.hpp>
36 : : #include <com/sun/star/style/LineSpacingMode.hpp>
37 : : #include <com/sun/star/style/NumberingType.hpp>
38 : : #include <com/sun/star/drawing/XShape.hpp>
39 : : #include <com/sun/star/table/BorderLine2.hpp>
40 : : #include <com/sun/star/text/ChapterFormat.hpp>
41 : : #include <com/sun/star/text/FilenameDisplayFormat.hpp>
42 : : #include <com/sun/star/text/UserDataPart.hpp>
43 : : #include <com/sun/star/text/SetVariableType.hpp>
44 : : #include <com/sun/star/text/XFootnote.hpp>
45 : : #include <com/sun/star/text/XLineNumberingProperties.hpp>
46 : : #include <com/sun/star/text/PageNumberType.hpp>
47 : : #include <com/sun/star/text/RelOrientation.hpp>
48 : : #include <com/sun/star/text/HoriOrientation.hpp>
49 : : #include <com/sun/star/text/VertOrientation.hpp>
50 : : #include <com/sun/star/text/ReferenceFieldPart.hpp>
51 : : #include <com/sun/star/text/ReferenceFieldSource.hpp>
52 : : #include <com/sun/star/text/SizeType.hpp>
53 : : #include <com/sun/star/text/TextContentAnchorType.hpp>
54 : : #include <com/sun/star/text/WrapTextMode.hpp>
55 : : #include <com/sun/star/text/XDependentTextField.hpp>
56 : : #include <com/sun/star/text/XParagraphCursor.hpp>
57 : : #include <com/sun/star/text/XRedline.hpp>
58 : : #include <com/sun/star/text/XTextAppendAndConvert.hpp>
59 : : #include <com/sun/star/text/XTextCopy.hpp>
60 : : #include <com/sun/star/text/XTextField.hpp>
61 : : #include <com/sun/star/text/XTextFieldsSupplier.hpp>
62 : : #include <com/sun/star/text/XFormField.hpp>
63 : : #include <com/sun/star/style/DropCapFormat.hpp>
64 : : #include <com/sun/star/util/DateTime.hpp>
65 : : #include <com/sun/star/util/XNumberFormatsSupplier.hpp>
66 : : #include <com/sun/star/util/XNumberFormats.hpp>
67 : : #include <com/sun/star/embed/XEmbeddedObject.hpp>
68 : : #include <com/sun/star/document/XViewDataSupplier.hpp>
69 : : #include <com/sun/star/container/XIndexContainer.hpp>
70 : : #include <rtl/ustrbuf.hxx>
71 : : #include <rtl/string.h>
72 : : #include <rtl/oustringostreaminserter.hxx>
73 : : #include "FieldTypes.hxx"
74 : : #include <oox/mathml/import.hxx>
75 : :
76 : : #include <tools/string.hxx>
77 : : #ifdef DEBUG_DOMAINMAPPER
78 : : #include <resourcemodel/QNameToString.hxx>
79 : : #include <resourcemodel/util.hxx>
80 : : #include <dmapperLoggers.hxx>
81 : : #endif
82 : : #include <ooxml/OOXMLFastTokens.hxx>
83 : :
84 : : #if DEBUG
85 : : #include <stdio.h>
86 : : #include <com/sun/star/style/TabStop.hpp>
87 : : #endif
88 : :
89 : : #include <map>
90 : :
91 : : #include <comphelper/configurationhelper.hxx>
92 : : #include <comphelper/stlunosequence.hxx>
93 : :
94 : : using namespace ::com::sun::star;
95 : : using namespace ::rtl;
96 : : namespace writerfilter {
97 : : namespace dmapper{
98 : :
99 : 506 : sal_Bool lcl_IsUsingEnhancedFields( const uno::Reference< lang::XMultiServiceFactory >& rFac )
100 : : {
101 : 506 : bool bResult(sal_False);
102 : : try
103 : : {
104 : 506 : OUString writerConfig = "org.openoffice.Office.Common";
105 : :
106 [ + - ]: 506 : uno::Reference< uno::XInterface > xCfgAccess = ::comphelper::ConfigurationHelper::openConfig( rFac, writerConfig, ::comphelper::ConfigurationHelper::E_READONLY );
107 [ # # ][ + - ]: 506 : ::comphelper::ConfigurationHelper::readRelativeKey( xCfgAccess, OUString( "Filter/Microsoft/Import" ), OUString( "ImportWWFieldsAsEnhancedFields" ) ) >>= bResult;
108 : :
109 : : }
110 [ # # ]: 0 : catch( const uno::Exception& )
111 : : {
112 : : }
113 : 506 : return bResult;
114 : : }
115 : :
116 : : // Populate Dropdown Field properties from FFData structure
117 : 0 : void lcl_handleDropdownField( const uno::Reference< beans::XPropertySet >& rxFieldProps, FFDataHandler::Pointer_t pFFDataHandler )
118 : : {
119 [ # # ]: 0 : if ( rxFieldProps.is() )
120 : : {
121 [ # # ][ # # ]: 0 : if ( !pFFDataHandler->getName().isEmpty() )
122 [ # # ][ # # ]: 0 : rxFieldProps->setPropertyValue( "Name", uno::makeAny( pFFDataHandler->getName() ) );
[ # # ][ # # ]
123 : :
124 [ # # ]: 0 : const FFDataHandler::DropDownEntries_t& rEntries = pFFDataHandler->getDropDownEntries();
125 [ # # ]: 0 : uno::Sequence< OUString > sItems( rEntries.size() );
126 [ # # ][ # # ]: 0 : ::std::copy( rEntries.begin(), rEntries.end(), ::comphelper::stl_begin(sItems));
127 [ # # ]: 0 : if ( sItems.getLength() )
128 [ # # ][ # # ]: 0 : rxFieldProps->setPropertyValue( "Items", uno::makeAny( sItems ) );
[ # # ]
129 : :
130 [ # # ]: 0 : sal_Int32 nResult = pFFDataHandler->getDropDownResult().toInt32();
131 [ # # ]: 0 : if ( nResult )
132 [ # # ][ # # ]: 0 : rxFieldProps->setPropertyValue( "SelectedItem", uno::makeAny( sItems[ nResult ] ) );
[ # # ][ # # ]
133 [ # # ][ # # ]: 0 : if ( !pFFDataHandler->getHelpText().isEmpty() )
134 [ # # ][ # # ]: 0 : rxFieldProps->setPropertyValue( "Help", uno::makeAny( pFFDataHandler->getHelpText() ) );
[ # # ][ # # ]
[ # # ]
135 : : }
136 : 0 : }
137 : :
138 : 0 : void lcl_handleTextField( const uno::Reference< beans::XPropertySet >& rxFieldProps, FFDataHandler::Pointer_t pFFDataHandler, PropertyNameSupplier& rPropNameSupplier )
139 : : {
140 [ # # ][ # # ]: 0 : if ( rxFieldProps.is() && pFFDataHandler )
[ # # ]
141 : : {
142 : 0 : rxFieldProps->setPropertyValue
143 [ # # ]: 0 : (rPropNameSupplier.GetName(PROP_HINT),
144 [ # # ]: 0 : uno::makeAny(pFFDataHandler->getStatusText()));
145 : 0 : rxFieldProps->setPropertyValue
146 [ # # ]: 0 : (rPropNameSupplier.GetName(PROP_HELP),
147 [ # # ]: 0 : uno::makeAny(pFFDataHandler->getHelpText()));
148 : 0 : rxFieldProps->setPropertyValue
149 [ # # ]: 0 : (rPropNameSupplier.GetName(PROP_CONTENT),
150 [ # # ]: 0 : uno::makeAny(pFFDataHandler->getTextDefault()));
151 : : }
152 : 0 : }
153 : :
154 : 5997 : struct FieldConversion
155 : : {
156 : : OUString sWordCommand;
157 : : const sal_Char* cFieldServiceName;
158 : : const sal_Char* cFieldMasterServiceName;
159 : : FieldId eFieldId;
160 : : };
161 : :
162 : : typedef ::std::map< OUString, FieldConversion>
163 : : FieldConversionMap_t;
164 : :
165 : :
166 : 0 : void FIB::SetData( Id nName, sal_Int32 nValue )
167 : : {
168 : : OSL_ENSURE( nName >= NS_rtf::LN_WIDENT && nName <= NS_rtf::LN_LCBSTTBFUSSR, "invalid index in FIB");
169 [ # # ][ # # ]: 0 : if( nName >= NS_rtf::LN_WIDENT && nName <= NS_rtf::LN_LCBSTTBFUSSR)
170 : 0 : aFIBData[nName - NS_rtf::LN_WIDENT] = nValue;
171 : 0 : }
172 : :
173 : :
174 : 506 : DomainMapper_Impl::DomainMapper_Impl(
175 : : DomainMapper& rDMapper,
176 : : uno::Reference < uno::XComponentContext > xContext,
177 : : uno::Reference< lang::XComponent > xModel,
178 : : SourceDocumentType eDocumentType) :
179 : : m_eDocumentType( eDocumentType ),
180 : : m_rDMapper( rDMapper ),
181 : : m_xTextDocument( xModel, uno::UNO_QUERY ),
182 : : m_xTextFactory( xModel, uno::UNO_QUERY ),
183 : : m_xComponentContext( xContext ),
184 : : m_bFieldMode( false ),
185 : : m_bSetUserFieldContent( false ),
186 : : m_bIsFirstSection( true ),
187 : : m_bIsColumnBreakDeferred( false ),
188 : : m_bIsPageBreakDeferred( false ),
189 : : m_pLastSectionContext( ),
190 : : m_pLastCharacterContext(),
191 : : m_nCurrentTabStopIndex( 0 ),
192 : : m_sCurrentParaStyleId(),
193 : : m_bInStyleSheetImport( false ),
194 : : m_bInAnyTableImport( false ),
195 : : m_bInHeaderFooterImport( false ),
196 : : m_bLineNumberingSet( false ),
197 : : m_bIsInFootnoteProperties( true ),
198 : : m_bIsCustomFtnMark( false ),
199 : : m_bIsParaChange( false ),
200 : : m_bParaChanged( false ),
201 : : m_bIsFirstParaInSection( true ),
202 : : m_bIsLastParaInSection( false ),
203 : : m_bParaSectpr( false ),
204 [ + - ][ + - ]: 3036 : m_bUsingEnhancedFields( false )
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + + ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ # # # # ]
205 : : {
206 [ + - ]: 506 : appendTableManager( );
207 [ + - ]: 506 : GetBodyText();
208 [ + - ]: 506 : uno::Reference< text::XTextAppend > xBodyTextAppend = uno::Reference< text::XTextAppend >( m_xBodyText, uno::UNO_QUERY );
209 [ + - ][ + - ]: 506 : m_aTextAppendStack.push(xBodyTextAppend);
[ + - ]
210 : :
211 : : //todo: does it make sense to set the body text as static text interface?
212 [ + - ]: 506 : uno::Reference< text::XTextAppendAndConvert > xBodyTextAppendAndConvert( m_xBodyText, uno::UNO_QUERY );
213 : : m_pTableHandler.reset
214 [ + - ][ + - ]: 506 : (new DomainMapperTableHandler(xBodyTextAppendAndConvert, *this));
[ + - ]
215 [ + - ][ + - ]: 506 : getTableManager( ).setHandler(m_pTableHandler);
[ + - ][ + - ]
216 : :
217 [ + - ][ + - ]: 506 : getTableManager( ).startLevel();
218 [ + - ][ + - ]: 506 : m_bUsingEnhancedFields = lcl_IsUsingEnhancedFields( uno::Reference< lang::XMultiServiceFactory >( m_xComponentContext->getServiceManager(), uno::UNO_QUERY ) );
[ + - ][ + - ]
219 : :
220 [ # # # # ]: 506 : }
221 : :
222 : :
223 [ + - ][ + - ]: 3542 : DomainMapper_Impl::~DomainMapper_Impl()
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
224 : : {
225 [ + - ]: 506 : RemoveLastParagraph( );
226 [ + - ][ + - ]: 506 : getTableManager( ).endLevel();
227 [ + - ]: 506 : popTableManager( );
228 [ + - ]: 4048 : }
[ + + - + ]
[ # # # # ]
229 : :
230 : :
231 : 1162 : uno::Reference< container::XNameContainer > DomainMapper_Impl::GetPageStyles()
232 : : {
233 [ + + ]: 1162 : if(!m_xPageStyles.is())
234 : : {
235 [ + - ]: 512 : uno::Reference< style::XStyleFamiliesSupplier > xSupplier( m_xTextDocument, uno::UNO_QUERY );
236 [ + + ]: 512 : if (xSupplier.is())
237 [ + - ][ + - ]: 512 : xSupplier->getStyleFamilies()->getByName("PageStyles") >>= m_xPageStyles;
[ + - ][ + - ]
[ + - ]
238 : : }
239 : 1162 : return m_xPageStyles;
240 : : }
241 : :
242 : :
243 : 997 : uno::Reference< text::XText > DomainMapper_Impl::GetBodyText()
244 : : {
245 [ + + ][ + + ]: 997 : if(!m_xBodyText.is() && m_xTextDocument.is())
[ + + ]
246 : : {
247 [ + - ]: 473 : m_xBodyText = m_xTextDocument->getText();
248 : : }
249 : 997 : return m_xBodyText;
250 : : }
251 : :
252 : :
253 : 1012 : uno::Reference< beans::XPropertySet > DomainMapper_Impl::GetDocumentSettings()
254 : : {
255 [ + + ][ + + ]: 1012 : if( !m_xDocumentSettings.is() && m_xTextFactory.is())
[ + + ]
256 : : {
257 : : m_xDocumentSettings = uno::Reference< beans::XPropertySet >(
258 [ + - ][ + - ]: 473 : m_xTextFactory->createInstance("com.sun.star.document.Settings"), uno::UNO_QUERY );
[ + - ]
259 : : }
260 : 1012 : return m_xDocumentSettings;
261 : : }
262 : :
263 : :
264 : 1012 : void DomainMapper_Impl::SetDocumentSettingsProperty( const OUString& rPropName, const uno::Any& rValue )
265 : : {
266 [ + - ]: 1012 : uno::Reference< beans::XPropertySet > xSettings = GetDocumentSettings();
267 [ + + ]: 1012 : if( xSettings.is() )
268 : : {
269 : : try
270 : : {
271 [ + - ][ + - ]: 946 : xSettings->setPropertyValue( rPropName, rValue );
272 : : }
273 [ # # ]: 0 : catch( const uno::Exception& )
274 : : {
275 : : }
276 : 1012 : }
277 [ # # ]: 1012 : }
278 : :
279 : 644 : void DomainMapper_Impl::RemoveLastParagraph( )
280 : : {
281 [ + - ]: 644 : if (m_aTextAppendStack.empty())
282 : : return;
283 [ + - ]: 644 : uno::Reference< text::XTextAppend > xTextAppend = m_aTextAppendStack.top().xTextAppend;
284 [ + + ]: 644 : if (!xTextAppend.is())
285 : : return;
286 : : try
287 : : {
288 [ + - ][ + - ]: 611 : uno::Reference< text::XTextCursor > xCursor = xTextAppend->createTextCursor();
289 [ + - ][ + - ]: 611 : xCursor->gotoEnd(false);
290 [ + - ][ + - ]: 611 : xCursor->goLeft( 1, true );
291 [ + - ][ + - ]: 611 : xCursor->setString(OUString());
[ # # ]
292 : : }
293 [ # # ]: 0 : catch( const uno::Exception& )
294 : : {
295 [ + + ]: 644 : }
296 : : }
297 : :
298 : 209 : void DomainMapper_Impl::SetIsLastParagraphInSection( bool bIsLast )
299 : : {
300 : 209 : m_bIsLastParaInSection = bIsLast;
301 : 209 : }
302 : :
303 : 218 : bool DomainMapper_Impl::GetIsLastParagraphInSection()
304 : : {
305 : 218 : return m_bIsLastParaInSection;
306 : : }
307 : :
308 : 524 : void DomainMapper_Impl::SetIsFirstParagraphInSection( bool bIsFirst )
309 : : {
310 : 524 : m_bIsFirstParaInSection = bIsFirst;
311 : 524 : }
312 : :
313 : 785 : bool DomainMapper_Impl::GetIsFirstParagraphInSection()
314 : : {
315 : 785 : return m_bIsFirstParaInSection;
316 : : }
317 : :
318 : 1136 : void DomainMapper_Impl::SetParaSectpr(bool bParaSectpr)
319 : : {
320 : 1136 : m_bParaSectpr = bParaSectpr;
321 : 1136 : }
322 : :
323 : 530 : bool DomainMapper_Impl::GetParaSectpr()
324 : : {
325 : 530 : return m_bParaSectpr;
326 : : }
327 : :
328 : 785 : bool DomainMapper_Impl::GetParaChanged()
329 : : {
330 : 785 : return m_bParaChanged;
331 : : }
332 : :
333 : 17632 : void DomainMapper_Impl::PushProperties(ContextType eId)
334 : : {
335 : : PropertyMapPtr pInsert(eId == CONTEXT_SECTION ?
336 [ + - ]: 530 : (new SectionPropertyMap( m_bIsFirstSection )) :
337 [ + + ][ + - ]: 18162 : eId == CONTEXT_PARAGRAPH ? new ParagraphPropertyMap : new PropertyMap);
[ + + ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
338 [ + + ]: 17632 : if(eId == CONTEXT_SECTION)
339 : : {
340 [ + + ]: 530 : if( m_bIsFirstSection )
341 : 497 : m_bIsFirstSection = false;
342 : : // beginning with the second section group a section has to be inserted
343 : : // into the document
344 [ - + ]: 530 : SectionPropertyMap* pSectionContext_ = dynamic_cast< SectionPropertyMap* >( pInsert.get() );
345 [ + - ]: 530 : if (!m_aTextAppendStack.empty())
346 : : {
347 [ + - ]: 530 : uno::Reference< text::XTextAppend > xTextAppend = m_aTextAppendStack.top().xTextAppend;
348 [ + + ]: 530 : if (xTextAppend.is())
349 [ + - ][ + - ]: 530 : pSectionContext_->SetStart( xTextAppend->getEnd() );
[ + - ]
350 : : }
351 : : }
352 [ + - ]: 17632 : m_aPropertyStacks[eId].push( pInsert );
353 [ + - ]: 17632 : m_aContextStack.push(eId);
354 : :
355 [ + - ][ + - ]: 17632 : m_pTopContext = m_aPropertyStacks[eId].top();
[ + - ]
356 : 17632 : }
357 : :
358 : :
359 : 7056 : void DomainMapper_Impl::PushStyleProperties( PropertyMapPtr pStyleProperties )
360 : : {
361 : 7056 : m_aPropertyStacks[CONTEXT_STYLESHEET].push( pStyleProperties );
362 [ + - ]: 7056 : m_aContextStack.push(CONTEXT_STYLESHEET);
363 : :
364 : 7056 : m_pTopContext = m_aPropertyStacks[CONTEXT_STYLESHEET].top();
365 : 7056 : }
366 : :
367 : :
368 : 315 : void DomainMapper_Impl::PushListProperties(PropertyMapPtr pListProperties)
369 : : {
370 : 315 : m_aPropertyStacks[CONTEXT_LIST].push( pListProperties );
371 [ + - ]: 315 : m_aContextStack.push(CONTEXT_LIST);
372 : 315 : m_pTopContext = m_aPropertyStacks[CONTEXT_LIST].top();
373 : 315 : }
374 : :
375 : :
376 : 24928 : void DomainMapper_Impl::PopProperties(ContextType eId)
377 : : {
378 : : OSL_ENSURE(!m_aPropertyStacks[eId].empty(), "section stack already empty");
379 [ - + ]: 24928 : if ( m_aPropertyStacks[eId].empty() )
380 : 24928 : return;
381 : :
382 [ + + ]: 24928 : if ( eId == CONTEXT_SECTION )
383 : : {
384 : 524 : m_pLastSectionContext = m_aPropertyStacks[eId].top( );
385 : : }
386 [ + + ]: 24404 : else if (eId == CONTEXT_CHARACTER)
387 : : {
388 : 14478 : m_pLastCharacterContext = m_aPropertyStacks[eId].top();
389 : : // Sadly an assert about deferredCharacterProperties being empty is not possible
390 : : // here, becase appendTextPortion() may not be called for every character section.
391 : 14478 : deferredCharacterProperties.clear();
392 : : }
393 : :
394 : 24928 : m_aPropertyStacks[eId].pop();
395 : 24928 : m_aContextStack.pop();
396 [ + - ][ + + ]: 24928 : if(!m_aContextStack.empty() && !m_aPropertyStacks[m_aContextStack.top()].empty())
[ + + ]
397 : :
398 : 21986 : m_pTopContext = m_aPropertyStacks[m_aContextStack.top()].top();
399 : : else
400 : : {
401 : : // OSL_ENSURE(eId == CONTEXT_SECTION, "this should happen at a section context end");
402 : 2942 : m_pTopContext.reset();
403 : : }
404 : : }
405 : :
406 : :
407 : 59018 : PropertyMapPtr DomainMapper_Impl::GetTopContextOfType(ContextType eId)
408 : : {
409 : 59018 : PropertyMapPtr pRet;
410 : : SAL_WARN_IF( m_aPropertyStacks[eId].empty(), "writerfilter",
411 : : "no context of type " << static_cast<int>(eId) << " available");
412 [ + + ]: 59018 : if(!m_aPropertyStacks[eId].empty())
413 [ + - ][ + - ]: 58892 : pRet = m_aPropertyStacks[eId].top();
414 : 59018 : return pRet;
415 : : }
416 : :
417 : :
418 : :
419 : 18 : uno::Reference< text::XTextAppend > DomainMapper_Impl::GetTopTextAppend()
420 : : {
421 : : OSL_ENSURE(!m_aTextAppendStack.empty(), "text append stack is empty" );
422 : 18 : return m_aTextAppendStack.top().xTextAppend;
423 : : }
424 : :
425 : :
426 : :
427 : 0 : void DomainMapper_Impl::InitTabStopFromStyle( const uno::Sequence< style::TabStop >& rInitTabStops )
428 : : {
429 : : OSL_ENSURE(!m_aCurrentTabStops.size(), "tab stops already initialized");
430 [ # # ]: 0 : for( sal_Int32 nTab = 0; nTab < rInitTabStops.getLength(); ++nTab)
431 : : {
432 [ # # ]: 0 : m_aCurrentTabStops.push_back( DeletableTabStop(rInitTabStops[nTab]) );
433 : : }
434 : 0 : }
435 : :
436 : :
437 : :
438 : 0 : void DomainMapper_Impl::ModifyCurrentTabStop( Id nId, sal_Int32 nValue)
439 : : {
440 : : OSL_ENSURE(nId == NS_rtf::LN_dxaAdd || m_nCurrentTabStopIndex < m_aCurrentTabStops.size(),
441 : : "tab stop creation error");
442 : :
443 [ # # ][ # # ]: 0 : if( nId != NS_rtf::LN_dxaAdd && m_nCurrentTabStopIndex >= m_aCurrentTabStops.size())
[ # # ]
444 : 0 : return;
445 : : static const style::TabAlign aTabAlignFromWord[] =
446 : : {
447 : : style::TabAlign_LEFT,
448 : : style::TabAlign_CENTER,
449 : : style::TabAlign_RIGHT,
450 : : style::TabAlign_DECIMAL,
451 : : style::TabAlign_LEFT
452 : : };
453 : : static const sal_Unicode aTabFillCharWord[] =
454 : : {
455 : : ' ',
456 : : '.',
457 : : '-',
458 : : '_',
459 : : '_',
460 : : 0xb7
461 : : };
462 : :
463 [ # # # # : 0 : switch(nId)
# ]
464 : : {
465 : : case NS_rtf::LN_dxaAdd: //set tab
466 : : m_aCurrentTabStops.push_back(
467 [ # # ][ # # ]: 0 : DeletableTabStop(style::TabStop(ConversionHelper::convertTwipToMM100(nValue), style::TabAlign_LEFT, ' ', ' ')));
468 : 0 : break;
469 : : case NS_rtf::LN_dxaDel: //deleted tab
470 : : {
471 : : //mark the tab stop at the given position as deleted
472 : 0 : ::std::vector<DeletableTabStop>::iterator aIt = m_aCurrentTabStops.begin();
473 : 0 : ::std::vector<DeletableTabStop>::iterator aEndIt = m_aCurrentTabStops.end();
474 [ # # ]: 0 : sal_Int32 nConverted = ConversionHelper::convertTwipToMM100(nValue);
475 [ # # ][ # # ]: 0 : for( ; aIt != aEndIt; ++aIt)
476 : : {
477 [ # # ]: 0 : if( aIt->Position == nConverted )
478 : : {
479 : 0 : aIt->bDeleted = true;
480 : 0 : break;
481 : : }
482 : : }
483 : : }
484 : 0 : break;
485 : : case NS_rtf::LN_TLC: //tab leading characters - for decimal tabs
486 : : // 0 - no leader, 1- dotted, 2 - hyphenated, 3 - single line, 4 - heavy line, 5 - middle dot
487 [ # # ][ # # ]: 0 : if( nValue >= 0 && nValue < sal::static_int_cast<sal_Int32>(sizeof(aTabFillCharWord) / sizeof (sal_Unicode)))
[ # # ]
488 : 0 : m_aCurrentTabStops[m_nCurrentTabStopIndex].FillChar = aTabFillCharWord[nValue];
489 : 0 : break;
490 : : case NS_rtf::LN_JC: //tab justification
491 : : //0 - left, 1 - centered, 2 - right, 3 - decimal 4 - bar
492 [ # # ][ # # ]: 0 : if( nValue >= 0 && nValue < sal::static_int_cast<sal_Int32>(sizeof(aTabAlignFromWord) / sizeof (style::TabAlign)))
[ # # ]
493 : 0 : m_aCurrentTabStops[m_nCurrentTabStopIndex].Alignment = aTabAlignFromWord[nValue];
494 : 0 : break;
495 : : }
496 : : }
497 : :
498 : 381 : void DomainMapper_Impl::IncorporateTabStop( const DeletableTabStop & rTabStop )
499 : : {
500 : 381 : ::std::vector<DeletableTabStop>::iterator aIt = m_aCurrentTabStops.begin();
501 : 381 : ::std::vector<DeletableTabStop>::iterator aEndIt = m_aCurrentTabStops.end();
502 : 381 : sal_Int32 nConverted = rTabStop.Position;
503 : 381 : bool bFound = false;
504 [ + - ][ + + ]: 2712 : for( ; aIt != aEndIt; ++aIt)
505 : : {
506 [ - + ]: 2331 : if( aIt->Position == nConverted )
507 : : {
508 : 0 : bFound = true;
509 [ # # ]: 0 : if( rTabStop.bDeleted )
510 [ # # ]: 0 : m_aCurrentTabStops.erase( aIt );
511 : : else
512 : 0 : *aIt = rTabStop;
513 : 0 : break;
514 : : }
515 : : }
516 [ + - ]: 381 : if( !bFound )
517 [ + - ]: 381 : m_aCurrentTabStops.push_back( rTabStop );
518 : 381 : }
519 : :
520 : :
521 : 210 : uno::Sequence< style::TabStop > DomainMapper_Impl::GetCurrentTabStopAndClear()
522 : : {
523 [ + - ]: 210 : uno::Sequence< style::TabStop > aRet( sal_Int32( m_aCurrentTabStops.size() ) );
524 [ + - ]: 210 : style::TabStop* pArray = aRet.getArray();
525 [ + - ]: 210 : ::std::vector<DeletableTabStop>::const_iterator aIt = m_aCurrentTabStops.begin();
526 [ + - ]: 210 : ::std::vector<DeletableTabStop>::const_iterator aEndIt = m_aCurrentTabStops.end();
527 : 210 : sal_Int32 nDeleted = 0;
528 [ + - ][ + + ]: 591 : for(sal_Int32 nIndex = 0; aIt != aEndIt; ++aIt)
529 : : {
530 [ + - ]: 381 : if(!aIt->bDeleted)
531 : 381 : pArray[nIndex++] = *aIt;
532 : : else
533 : 0 : ++nDeleted;
534 : : }
535 : 210 : m_aCurrentTabStops.clear();
536 : 210 : m_nCurrentTabStopIndex = 0;
537 [ - + ]: 210 : if(nDeleted)
538 : : {
539 [ # # ]: 210 : aRet.realloc( aRet.getLength() - nDeleted);
540 : : }
541 : 210 : return aRet;
542 : : }
543 : :
544 : : /*-------------------------------------------------------------------------
545 : : returns a the value from the current paragraph style - if available
546 : : TODO: What about parent styles?
547 : : -----------------------------------------------------------------------*/
548 : 60 : uno::Any DomainMapper_Impl::GetPropertyFromStyleSheet(PropertyIds eId)
549 : : {
550 [ + - ]: 60 : StyleSheetEntryPtr pEntry;
551 [ - + ]: 60 : if( m_bInStyleSheetImport )
552 [ # # ][ # # ]: 0 : pEntry = GetStyleSheetTable()->FindParentStyleSheet(OUString());
[ # # ][ # # ]
[ # # ]
553 : : else
554 : : pEntry =
555 [ + - ][ + - ]: 60 : GetStyleSheetTable()->FindStyleSheetByISTD(GetCurrentParaStyleId());
[ + - ][ + - ]
[ + - ]
556 [ + + ]: 75 : while(pEntry.get( ) )
557 : : {
558 : : //is there a tab stop set?
559 [ + - ]: 18 : if(pEntry->pProperties)
560 : : {
561 : : PropertyMap::const_iterator aPropertyIter =
562 [ + - ]: 18 : pEntry->pProperties->find(PropertyDefinition(eId, false ));
563 [ + + ]: 18 : if( aPropertyIter != pEntry->pProperties->end())
564 : : {
565 : 18 : return aPropertyIter->second;
566 : : }
567 : : }
568 : : //search until the property is set or no parent is available
569 [ + - ][ + - ]: 15 : StyleSheetEntryPtr pNewEntry = GetStyleSheetTable()->FindParentStyleSheet(pEntry->sBaseStyleIdentifier);
[ + - ]
570 : :
571 : : SAL_WARN_IF( pEntry == pNewEntry, "writerfilter", "circular loop in style hierarchy?");
572 : :
573 [ - + ]: 15 : if (pEntry == pNewEntry) //fdo#49587
574 : : break;
575 : :
576 [ + - ][ + - ]: 30 : pEntry = pNewEntry;
577 [ + - ]: 15 : }
578 [ + - ]: 60 : return uno::Any();
579 : : }
580 : :
581 : :
582 : 198 : ListsManager::Pointer DomainMapper_Impl::GetListTable()
583 : : {
584 [ + + ]: 198 : if(!m_pListTable)
585 : : m_pListTable.reset(
586 [ + - ][ + - ]: 33 : new ListsManager( m_rDMapper, m_xTextFactory ));
[ + - ]
587 : 198 : return m_pListTable;
588 : : }
589 : :
590 : :
591 : 156 : void DomainMapper_Impl::deferBreak( BreakType deferredBreakType)
592 : : {
593 [ - + - ]: 156 : switch (deferredBreakType)
594 : : {
595 : : case COLUMN_BREAK:
596 : 0 : m_bIsColumnBreakDeferred = true;
597 : 0 : break;
598 : : case PAGE_BREAK:
599 : 156 : m_bIsPageBreakDeferred = true;
600 : 156 : break;
601 : : default:
602 : 156 : return;
603 : : }
604 : : }
605 : :
606 : 30756 : bool DomainMapper_Impl::isBreakDeferred( BreakType deferredBreakType )
607 : : {
608 [ + + - ]: 30756 : switch (deferredBreakType)
609 : : {
610 : : case COLUMN_BREAK:
611 : 15300 : return m_bIsColumnBreakDeferred;
612 : : case PAGE_BREAK:
613 : 15456 : return m_bIsPageBreakDeferred;
614 : : default:
615 : 30756 : return false;
616 : : }
617 : : }
618 : :
619 : 15456 : void DomainMapper_Impl::clearDeferredBreaks()
620 : : {
621 : 15456 : m_bIsColumnBreakDeferred = false;
622 : 15456 : m_bIsPageBreakDeferred = false;
623 : 15456 : }
624 : :
625 : :
626 : 15 : void lcl_MoveBorderPropertiesToFrame(uno::Sequence<beans::PropertyValue>& rFrameProperties,
627 : : uno::Reference<text::XTextRange> xStartTextRange,
628 : : uno::Reference<text::XTextRange> xEndTextRange )
629 : : {
630 : : try
631 : : {
632 [ + - ][ + - ]: 15 : uno::Reference<text::XTextCursor> xRangeCursor = xStartTextRange->getText()->createTextCursorByRange( xStartTextRange );
[ + - ][ + - ]
633 [ + - ][ + - ]: 15 : xRangeCursor->gotoRange( xEndTextRange, true );
634 : :
635 [ + - ]: 15 : uno::Reference<beans::XPropertySet> xTextRangeProperties(xRangeCursor, uno::UNO_QUERY);
636 [ - + ]: 15 : if(!xTextRangeProperties.is())
637 : 15 : return ;
638 : :
639 : : PropertyIds aBorderProperties[] =
640 : : {
641 : : PROP_LEFT_BORDER,
642 : : PROP_RIGHT_BORDER,
643 : : PROP_TOP_BORDER,
644 : : PROP_BOTTOM_BORDER,
645 : : PROP_LEFT_BORDER_DISTANCE,
646 : : PROP_RIGHT_BORDER_DISTANCE,
647 : : PROP_TOP_BORDER_DISTANCE,
648 : : PROP_BOTTOM_BORDER_DISTANCE
649 : 15 : };
650 : :
651 : 15 : sal_uInt32 nStart = rFrameProperties.getLength();
652 : 15 : sal_uInt32 nBorderPropertyCount = sizeof( aBorderProperties ) / sizeof(PropertyIds);
653 [ + - ]: 15 : rFrameProperties.realloc(nStart + nBorderPropertyCount);
654 : :
655 [ + - ]: 15 : beans::PropertyValue* pFrameProperties = rFrameProperties.getArray();
656 [ + - ]: 15 : PropertyNameSupplier& rPropNameSupplier = PropertyNameSupplier::GetPropertyNameSupplier();
657 [ + + ]: 135 : for( sal_uInt32 nProperty = 0; nProperty < nBorderPropertyCount; ++nProperty)
658 : : {
659 [ + - ]: 120 : OUString sPropertyName = rPropNameSupplier.GetName(aBorderProperties[nProperty]);
660 : 120 : pFrameProperties[nStart].Name = sPropertyName;
661 [ + - ][ + - ]: 120 : pFrameProperties[nStart].Value = xTextRangeProperties->getPropertyValue(sPropertyName);
662 [ + + ]: 120 : if( nProperty < 4 )
663 [ + - ][ + - ]: 60 : xTextRangeProperties->setPropertyValue( sPropertyName, uno::makeAny(table::BorderLine2()));
[ + - ]
664 : 120 : ++nStart;
665 : 120 : }
666 [ + - ][ - + ]: 15 : rFrameProperties.realloc(nStart);
[ + - ][ # # ]
667 : : }
668 : 0 : catch( const uno::Exception& )
669 : : {
670 : : }
671 : : }
672 : :
673 : :
674 : 15 : void lcl_AddRangeAndStyle(
675 : : ParagraphPropertiesPtr& pToBeSavedProperties,
676 : : uno::Reference< text::XTextAppend > xTextAppend,
677 : : PropertyMapPtr pPropertyMap)
678 : : {
679 : : uno::Reference<text::XParagraphCursor> xParaCursor(
680 [ + - ][ + - ]: 15 : xTextAppend->createTextCursorByRange( xTextAppend->getEnd()), uno::UNO_QUERY_THROW );
[ + - ][ + - ]
[ + - ]
681 [ + - ][ + - ]: 15 : pToBeSavedProperties->SetEndingRange(xParaCursor->getStart());
[ + - ]
682 [ + - ][ + - ]: 15 : xParaCursor->gotoStartOfParagraph( false );
683 : :
684 [ + - ][ + - ]: 15 : pToBeSavedProperties->SetStartingRange(xParaCursor->getStart());
[ + - ]
685 [ + - ]: 15 : if(pPropertyMap)
686 : : {
687 [ + - ]: 15 : PropertyMap::iterator aParaStyleIter = pPropertyMap->find(PropertyDefinition( PROP_PARA_STYLE_NAME, false ) );
688 [ + - ]: 15 : if( aParaStyleIter != pPropertyMap->end())
689 : : {
690 : 15 : OUString sName;
691 : 15 : aParaStyleIter->second >>= sName;
692 : 15 : pToBeSavedProperties->SetParaStyleName(sName);
693 : : }
694 : 15 : }
695 : 15 : }
696 : :
697 : :
698 : : //define some default frame width - 0cm ATM: this allow the frame to be wrapped around the text
699 : : #define DEFAULT_FRAME_MIN_WIDTH 0
700 : :
701 : 533 : void DomainMapper_Impl::CheckUnregisteredFrameConversion( )
702 : : {
703 : 533 : PropertyNameSupplier& rPropNameSupplier = PropertyNameSupplier::GetPropertyNameSupplier();
704 : 533 : TextAppendContext& rAppendContext = m_aTextAppendStack.top();
705 [ + - ][ + + ]: 533 : if( rAppendContext.pLastParagraphProperties.get() && rAppendContext.pLastParagraphProperties->IsFrameMode() )
[ + + ]
706 : : {
707 : : try
708 : : {
709 : : StyleSheetEntryPtr pParaStyle =
710 [ + - ][ + - ]: 15 : GetStyleSheetTable()->FindStyleSheetByConvertedStyleName(rAppendContext.pLastParagraphProperties->GetParaStyleName());
[ + - ]
711 : :
712 [ - + ][ + - ]: 15 : uno::Sequence< beans::PropertyValue > aFrameProperties(pParaStyle ? 16: 9);
713 : :
714 [ - + ]: 15 : if ( pParaStyle.get( ) )
715 : : {
716 [ # # ]: 0 : beans::PropertyValue* pFrameProperties = aFrameProperties.getArray();
717 [ # # ]: 0 : pFrameProperties[0].Name = rPropNameSupplier.GetName(PROP_WIDTH);
718 [ # # ]: 0 : pFrameProperties[1].Name = rPropNameSupplier.GetName(PROP_HEIGHT);
719 [ # # ]: 0 : pFrameProperties[2].Name = rPropNameSupplier.GetName(PROP_SIZE_TYPE);
720 [ # # ]: 0 : pFrameProperties[3].Name = rPropNameSupplier.GetName(PROP_WIDTH_TYPE);
721 [ # # ]: 0 : pFrameProperties[4].Name = rPropNameSupplier.GetName(PROP_HORI_ORIENT);
722 [ # # ]: 0 : pFrameProperties[5].Name = rPropNameSupplier.GetName(PROP_HORI_ORIENT_POSITION);
723 [ # # ]: 0 : pFrameProperties[6].Name = rPropNameSupplier.GetName(PROP_HORI_ORIENT_RELATION);
724 [ # # ]: 0 : pFrameProperties[7].Name = rPropNameSupplier.GetName(PROP_VERT_ORIENT);
725 [ # # ]: 0 : pFrameProperties[8].Name = rPropNameSupplier.GetName(PROP_VERT_ORIENT_POSITION);
726 [ # # ]: 0 : pFrameProperties[9].Name = rPropNameSupplier.GetName(PROP_VERT_ORIENT_RELATION);
727 [ # # ]: 0 : pFrameProperties[10].Name = rPropNameSupplier.GetName(PROP_SURROUND);
728 [ # # ]: 0 : pFrameProperties[11].Name = rPropNameSupplier.GetName(PROP_LEFT_MARGIN);
729 [ # # ]: 0 : pFrameProperties[12].Name = rPropNameSupplier.GetName(PROP_RIGHT_MARGIN);
730 [ # # ]: 0 : pFrameProperties[13].Name = rPropNameSupplier.GetName(PROP_TOP_MARGIN);
731 [ # # ]: 0 : pFrameProperties[14].Name = rPropNameSupplier.GetName(PROP_BOTTOM_MARGIN);
732 [ # # ]: 0 : pFrameProperties[15].Name = rPropNameSupplier.GetName(PROP_BACK_COLOR_TRANSPARENCY);
733 : :
734 [ # # ]: 0 : const ParagraphProperties* pStyleProperties = dynamic_cast<const ParagraphProperties*>( pParaStyle->pProperties.get() );
735 : : sal_Int32 nWidth =
736 : 0 : rAppendContext.pLastParagraphProperties->Getw() > 0 ?
737 : 0 : rAppendContext.pLastParagraphProperties->Getw() :
738 [ # # ]: 0 : pStyleProperties->Getw();
739 : 0 : bool bAutoWidth = nWidth < 1;
740 [ # # ]: 0 : if( bAutoWidth )
741 : 0 : nWidth = DEFAULT_FRAME_MIN_WIDTH;
742 [ # # ]: 0 : pFrameProperties[0].Value <<= nWidth;
743 : :
744 : 0 : pFrameProperties[1].Value <<=
745 : 0 : rAppendContext.pLastParagraphProperties->Geth() > 0 ?
746 : 0 : rAppendContext.pLastParagraphProperties->Geth() :
747 [ # # ][ # # ]: 0 : pStyleProperties->Geth();
748 : :
749 : 0 : pFrameProperties[2].Value <<= sal_Int16(
750 : 0 : rAppendContext.pLastParagraphProperties->GethRule() >= 0 ?
751 : 0 : rAppendContext.pLastParagraphProperties->GethRule() :
752 [ # # ][ # # ]: 0 : pStyleProperties->GethRule() >=0 ? pStyleProperties->GethRule() : text::SizeType::VARIABLE);
[ # # ]
753 : :
754 [ # # ][ # # ]: 0 : pFrameProperties[3].Value <<= bAutoWidth ? text::SizeType::MIN : text::SizeType::FIX;
755 : :
756 : : sal_Int16 nHoriOrient = sal_Int16(
757 : 0 : rAppendContext.pLastParagraphProperties->GetxAlign() >= 0 ?
758 : 0 : rAppendContext.pLastParagraphProperties->GetxAlign() :
759 [ # # ][ # # ]: 0 : pStyleProperties->GetxAlign() >= 0 ? pStyleProperties->GetxAlign() : text::HoriOrientation::NONE );
760 [ # # ]: 0 : pFrameProperties[4].Value <<= nHoriOrient;
761 : :
762 : 0 : pFrameProperties[5].Value <<=
763 : 0 : rAppendContext.pLastParagraphProperties->IsxValid() ?
764 [ # # ][ # # ]: 0 : rAppendContext.pLastParagraphProperties->Getx() : pStyleProperties->Getx();
765 : 0 : pFrameProperties[6].Value <<= sal_Int16(
766 : 0 : rAppendContext.pLastParagraphProperties->GethAnchor() >= 0 ?
767 : 0 : rAppendContext.pLastParagraphProperties->GethAnchor() :
768 [ # # ][ # # ]: 0 : pStyleProperties->GethAnchor() );
769 : :
770 : : sal_Int16 nVertOrient = sal_Int16(
771 : 0 : rAppendContext.pLastParagraphProperties->GetyAlign() >= 0 ?
772 : 0 : rAppendContext.pLastParagraphProperties->GetyAlign() :
773 [ # # ][ # # ]: 0 : pStyleProperties->GetyAlign() >= 0 ? pStyleProperties->GetyAlign() : text::VertOrientation::NONE );
774 [ # # ]: 0 : pFrameProperties[7].Value <<= nVertOrient;
775 : :
776 : 0 : pFrameProperties[8].Value <<=
777 : 0 : rAppendContext.pLastParagraphProperties->IsyValid() ?
778 [ # # ][ # # ]: 0 : rAppendContext.pLastParagraphProperties->Gety() : pStyleProperties->Gety();
779 : 0 : pFrameProperties[9].Value <<= sal_Int16(
780 : 0 : rAppendContext.pLastParagraphProperties->GetvAnchor() >= 0 ?
781 : 0 : rAppendContext.pLastParagraphProperties->GetvAnchor() :
782 [ # # ][ # # ]: 0 : pStyleProperties->GetvAnchor() );
783 : :
784 : 0 : pFrameProperties[10].Value <<= text::WrapTextMode(
785 : 0 : rAppendContext.pLastParagraphProperties->GetWrap() >= 0 ?
786 : 0 : rAppendContext.pLastParagraphProperties->GetWrap() :
787 [ # # ][ # # ]: 0 : pStyleProperties->GetWrap());
788 : :
789 : : sal_Int32 nBottomDist;
790 : : sal_Int32 nTopDist = nBottomDist =
791 : 0 : rAppendContext.pLastParagraphProperties->GethSpace() >= 0 ?
792 : 0 : rAppendContext.pLastParagraphProperties->GethSpace() :
793 [ # # ]: 0 : pStyleProperties->GethSpace();
794 : :
795 [ # # ][ # # ]: 0 : pFrameProperties[11].Value <<= nVertOrient == text::VertOrientation::TOP ? 0 : nTopDist;
796 [ # # ][ # # ]: 0 : pFrameProperties[12].Value <<= nVertOrient == text::VertOrientation::BOTTOM ? 0 : nBottomDist;
797 : :
798 : : sal_Int32 nRightDist;
799 : : sal_Int32 nLeftDist = nRightDist =
800 : 0 : rAppendContext.pLastParagraphProperties->GetvSpace() >= 0 ?
801 : 0 : rAppendContext.pLastParagraphProperties->GetvSpace() :
802 [ # # ][ # # ]: 0 : pStyleProperties->GetvSpace() >= 0 ? pStyleProperties->GetvSpace() : 0;
803 [ # # ][ # # ]: 0 : pFrameProperties[13].Value <<= nHoriOrient == text::HoriOrientation::LEFT ? 0 : nLeftDist;
804 [ # # ][ # # ]: 0 : pFrameProperties[14].Value <<= nHoriOrient == text::HoriOrientation::RIGHT ? 0 : nRightDist;
805 : : // If there is no fill, the Word default is 100% transparency.
806 : : // Otherwise CellColorHandler has priority, and this setting
807 : : // will be ignored.
808 [ # # ]: 0 : pFrameProperties[15].Value <<= sal_Int32(100);
809 : :
810 : : lcl_MoveBorderPropertiesToFrame(aFrameProperties,
811 : : rAppendContext.pLastParagraphProperties->GetStartingRange(),
812 [ # # ][ # # ]: 0 : rAppendContext.pLastParagraphProperties->GetEndingRange());
[ # # ]
813 : : }
814 : : else
815 : : {
816 [ + - ]: 15 : beans::PropertyValue* pFrameProperties = aFrameProperties.getArray();
817 [ + - ]: 15 : pFrameProperties[0].Name = rPropNameSupplier.GetName(PROP_WIDTH);
818 [ + - ]: 15 : pFrameProperties[1].Name = rPropNameSupplier.GetName(PROP_SIZE_TYPE);
819 [ + - ]: 15 : pFrameProperties[2].Name = rPropNameSupplier.GetName(PROP_WIDTH_TYPE);
820 [ + - ]: 15 : pFrameProperties[3].Name = rPropNameSupplier.GetName(PROP_HORI_ORIENT);
821 [ + - ]: 15 : pFrameProperties[4].Name = rPropNameSupplier.GetName(PROP_VERT_ORIENT);
822 [ + - ]: 15 : pFrameProperties[5].Name = rPropNameSupplier.GetName(PROP_LEFT_MARGIN);
823 [ + - ]: 15 : pFrameProperties[6].Name = rPropNameSupplier.GetName(PROP_RIGHT_MARGIN);
824 [ + - ]: 15 : pFrameProperties[7].Name = rPropNameSupplier.GetName(PROP_TOP_MARGIN);
825 [ + - ]: 15 : pFrameProperties[8].Name = rPropNameSupplier.GetName(PROP_BOTTOM_MARGIN);
826 : :
827 : 15 : sal_Int32 nWidth = rAppendContext.pLastParagraphProperties->Getw();
828 : 15 : bool bAutoWidth = nWidth < 1;
829 [ - + ]: 15 : if( bAutoWidth )
830 : 0 : nWidth = DEFAULT_FRAME_MIN_WIDTH;
831 [ + - ]: 15 : pFrameProperties[0].Value <<= nWidth;
832 : :
833 : 15 : pFrameProperties[1].Value <<= sal_Int16(
834 : 15 : rAppendContext.pLastParagraphProperties->GethRule() >= 0 ?
835 : 15 : rAppendContext.pLastParagraphProperties->GethRule() :
836 [ + - ][ + - ]: 30 : text::SizeType::VARIABLE);
837 : :
838 [ - + ][ + - ]: 15 : pFrameProperties[2].Value <<= bAutoWidth ? text::SizeType::MIN : text::SizeType::FIX;
839 : :
840 : : sal_Int16 nHoriOrient = sal_Int16(
841 : 15 : rAppendContext.pLastParagraphProperties->GetxAlign() >= 0 ?
842 : 15 : rAppendContext.pLastParagraphProperties->GetxAlign() :
843 [ + - ]: 30 : text::HoriOrientation::NONE );
844 [ + - ]: 15 : pFrameProperties[3].Value <<= nHoriOrient;
845 : :
846 : : sal_Int16 nVertOrient = sal_Int16(
847 : 15 : rAppendContext.pLastParagraphProperties->GetyAlign() >= 0 ?
848 : 15 : rAppendContext.pLastParagraphProperties->GetyAlign() :
849 [ + - ]: 30 : text::VertOrientation::NONE );
850 [ + - ]: 15 : pFrameProperties[4].Value <<= nVertOrient;
851 : :
852 : 15 : sal_Int32 nVertDist = rAppendContext.pLastParagraphProperties->GethSpace();
853 [ + - ]: 15 : if( nVertDist < 0 )
854 : 15 : nVertDist = 0;
855 [ + - ][ + - ]: 15 : pFrameProperties[5].Value <<= nVertOrient == text::VertOrientation::TOP ? 0 : nVertDist;
856 [ + - ][ + - ]: 15 : pFrameProperties[6].Value <<= nVertOrient == text::VertOrientation::BOTTOM ? 0 : nVertDist;
857 : :
858 : 15 : sal_Int32 nHoriDist = rAppendContext.pLastParagraphProperties->GetvSpace();
859 [ + - ]: 15 : if( nHoriDist < 0 )
860 : 15 : nHoriDist = 0;
861 [ + - ][ + - ]: 15 : pFrameProperties[7].Value <<= nHoriOrient == text::HoriOrientation::LEFT ? 0 : nHoriDist;
862 [ + - ][ + - ]: 15 : pFrameProperties[8].Value <<= nHoriOrient == text::HoriOrientation::RIGHT ? 0 : nHoriDist;
863 : :
864 [ + - ]: 15 : if( rAppendContext.pLastParagraphProperties->Geth() > 0 )
865 : : {
866 : 15 : sal_Int32 nOldSize = aFrameProperties.getLength();
867 [ + - ]: 15 : aFrameProperties.realloc( nOldSize + 1 );
868 [ + - ]: 15 : pFrameProperties = aFrameProperties.getArray();
869 [ + - ]: 15 : pFrameProperties[nOldSize].Name = rPropNameSupplier.GetName(PROP_HEIGHT);
870 [ + - ]: 15 : pFrameProperties[nOldSize].Value <<= rAppendContext.pLastParagraphProperties->Geth();
871 : : }
872 : :
873 [ + - ]: 15 : if( rAppendContext.pLastParagraphProperties->IsxValid() )
874 : : {
875 : 15 : sal_Int32 nOldSize = aFrameProperties.getLength();
876 [ + - ]: 15 : aFrameProperties.realloc( nOldSize + 1 );
877 [ + - ]: 15 : pFrameProperties = aFrameProperties.getArray();
878 [ + - ]: 15 : pFrameProperties[nOldSize].Name = rPropNameSupplier.GetName(PROP_HORI_ORIENT_POSITION);
879 [ + - ]: 15 : pFrameProperties[nOldSize].Value <<= rAppendContext.pLastParagraphProperties->Getx();
880 : : }
881 : :
882 [ + + ]: 15 : if( rAppendContext.pLastParagraphProperties->GethAnchor() >= 0 )
883 : : {
884 : 9 : sal_Int32 nOldSize = aFrameProperties.getLength();
885 [ + - ]: 9 : aFrameProperties.realloc( nOldSize + 1 );
886 [ + - ]: 9 : pFrameProperties = aFrameProperties.getArray();
887 [ + - ]: 9 : pFrameProperties[nOldSize].Name = rPropNameSupplier.GetName(PROP_HORI_ORIENT_RELATION);
888 : 9 : pFrameProperties[nOldSize].Value <<= sal_Int16(
889 [ + - ]: 9 : rAppendContext.pLastParagraphProperties->GethAnchor() );
890 : : }
891 : :
892 [ + - ]: 15 : if( rAppendContext.pLastParagraphProperties->IsyValid() )
893 : : {
894 : 15 : sal_Int32 nOldSize = aFrameProperties.getLength();
895 [ + - ]: 15 : aFrameProperties.realloc( nOldSize + 1 );
896 [ + - ]: 15 : pFrameProperties = aFrameProperties.getArray();
897 [ + - ]: 15 : pFrameProperties[nOldSize].Name = rPropNameSupplier.GetName(PROP_VERT_ORIENT_POSITION);
898 [ + - ]: 15 : pFrameProperties[nOldSize].Value <<= rAppendContext.pLastParagraphProperties->Gety();
899 : : }
900 : :
901 [ + - ]: 15 : if( rAppendContext.pLastParagraphProperties->GetvAnchor() >= 0 )
902 : : {
903 : 15 : sal_Int32 nOldSize = aFrameProperties.getLength();
904 [ + - ]: 15 : aFrameProperties.realloc( nOldSize + 1 );
905 [ + - ]: 15 : pFrameProperties = aFrameProperties.getArray();
906 [ + - ]: 15 : pFrameProperties[nOldSize].Name = rPropNameSupplier.GetName(PROP_VERT_ORIENT_RELATION);
907 : 15 : pFrameProperties[nOldSize].Value <<= sal_Int16(
908 [ + - ]: 15 : rAppendContext.pLastParagraphProperties->GetvAnchor() );
909 : : }
910 : :
911 [ - + ]: 15 : if( rAppendContext.pLastParagraphProperties->GetWrap() >= 0 )
912 : : {
913 : 0 : sal_Int32 nOldSize = aFrameProperties.getLength();
914 [ # # ]: 0 : aFrameProperties.realloc( nOldSize + 1 );
915 [ # # ]: 0 : pFrameProperties = aFrameProperties.getArray();
916 [ # # ]: 0 : pFrameProperties[nOldSize].Name = rPropNameSupplier.GetName(PROP_SURROUND);
917 : 0 : pFrameProperties[nOldSize].Value <<= text::WrapTextMode(
918 [ # # ]: 0 : rAppendContext.pLastParagraphProperties->GetWrap() );
919 : : }
920 : :
921 : : lcl_MoveBorderPropertiesToFrame(aFrameProperties,
922 : : rAppendContext.pLastParagraphProperties->GetStartingRange(),
923 [ + - ][ + - ]: 15 : rAppendContext.pLastParagraphProperties->GetEndingRange());
[ + - ]
924 : : }
925 : :
926 : : //frame conversion has to be executed after table conversion
927 : : RegisterFrameConversion(
928 : : rAppendContext.pLastParagraphProperties->GetStartingRange(),
929 : : rAppendContext.pLastParagraphProperties->GetEndingRange(),
930 [ + - ][ + - ]: 15 : aFrameProperties );
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ # # ]
931 : : }
932 : 0 : catch( const uno::Exception& )
933 : : {
934 : : }
935 : : }
936 : 533 : }
937 : :
938 : 2123 : void DomainMapper_Impl::finishParagraph( PropertyMapPtr pPropertyMap )
939 : : {
940 : : #ifdef DEBUG_DOMAINMAPPER
941 : : dmapper_logger->startElement("finishParagraph");
942 : : #endif
943 : :
944 [ - + ]: 2123 : ParagraphPropertyMap* pParaContext = dynamic_cast< ParagraphPropertyMap* >( pPropertyMap.get() );
945 [ + - ]: 2123 : TextAppendContext& rAppendContext = m_aTextAppendStack.top();
946 : 2123 : uno::Reference< text::XTextAppend > xTextAppend;
947 [ + - ]: 2123 : if (!m_aTextAppendStack.empty())
948 [ + - ]: 2123 : xTextAppend = rAppendContext.xTextAppend;
949 [ + - ]: 2123 : PropertyNameSupplier& rPropNameSupplier = PropertyNameSupplier::GetPropertyNameSupplier();
950 : :
951 : : #ifdef DEBUG_DOMAINMAPPER
952 : : dmapper_logger->attribute("isTextAppend", xTextAppend.is());
953 : : #endif
954 : :
955 [ + + ][ + - ]: 2123 : if(xTextAppend.is() && ! getTableManager( ).isIgnore() && pParaContext != NULL)
[ + - ][ + + ]
[ + - ][ + + ]
956 : : {
957 : : try
958 : : {
959 : : /*the following combinations of previous and current frame settings can occur:
960 : : (1) - no old frame and no current frame -> no special action
961 : : (2) - no old frame and current DropCap -> save DropCap for later use, don't call finishParagraph
962 : : remove character properties of the DropCap?
963 : : (3) - no old frame and current Frame -> save Frame for later use
964 : : (4) - old DropCap and no current frame -> add DropCap to the properties of the finished paragraph, delete previous setting
965 : : (5) - old DropCap and current frame -> add DropCap to the properties of the finished paragraph, save current frame settings
966 : : (6) - old Frame and new DropCap -> add old Frame, save DropCap for later use
967 : : (7) - old Frame and new same Frame -> continue
968 : : (8) - old Frame and new different Frame -> add old Frame, save new Frame for later use
969 : : (9) - old Frame and no current frame -> add old Frame, delete previous settings
970 : :
971 : : old _and_ new DropCap must not occur
972 : : */
973 : :
974 : : bool bIsDropCap =
975 : 1486 : pParaContext->IsFrameMode() &&
976 [ - + ][ + + ]: 1486 : sal::static_int_cast<Id>(pParaContext->GetDropCap()) != NS_ooxml::LN_Value_wordprocessingml_ST_DropCap_none;
977 : :
978 : 1486 : style::DropCapFormat aDrop;
979 [ + - ]: 1486 : ParagraphPropertiesPtr pToBeSavedProperties;
980 : 1486 : bool bKeepLastParagraphProperties = false;
981 [ - + ]: 1486 : if( bIsDropCap )
982 : : {
983 : : uno::Reference<text::XParagraphCursor> xParaCursor(
984 [ # # ][ # # ]: 0 : xTextAppend->createTextCursorByRange(xTextAppend->getEnd()), uno::UNO_QUERY_THROW);
[ # # ][ # # ]
[ # # ]
985 : : //select paragraph
986 [ # # ][ # # ]: 0 : xParaCursor->gotoStartOfParagraph( true );
987 [ # # ]: 0 : uno::Reference< beans::XPropertyState > xParaProperties( xParaCursor, uno::UNO_QUERY_THROW );
988 [ # # ][ # # ]: 0 : xParaProperties->setPropertyToDefault(rPropNameSupplier.GetName(PROP_CHAR_ESCAPEMENT));
[ # # ]
989 [ # # ][ # # ]: 0 : xParaProperties->setPropertyToDefault(rPropNameSupplier.GetName(PROP_CHAR_HEIGHT));
[ # # ]
990 : : //handles (2) and part of (6)
991 [ # # ][ # # ]: 0 : pToBeSavedProperties.reset( new ParagraphProperties(*pParaContext) );
[ # # ]
992 [ # # ][ # # ]: 0 : sal_Int32 nCount = xParaCursor->getString().getLength();
993 [ # # ][ # # ]: 0 : pToBeSavedProperties->SetDropCapLength(nCount > 0 && nCount < 255 ? (sal_Int8)nCount : 1);
994 : : }
995 [ + + ]: 1486 : if( rAppendContext.pLastParagraphProperties.get() )
996 : : {
997 [ - + ]: 18 : if( sal::static_int_cast<Id>(rAppendContext.pLastParagraphProperties->GetDropCap()) != NS_ooxml::LN_Value_wordprocessingml_ST_DropCap_none)
998 : : {
999 : : //handles (4) and part of (5)
1000 : : //create a DropCap property, add it to the property sequence of finishParagraph
1001 : 0 : sal_Int32 nLines = rAppendContext.pLastParagraphProperties->GetLines();
1002 [ # # ][ # # ]: 0 : aDrop.Lines = nLines > 0 && nLines < 254 ? (sal_Int8)++nLines : 2;
1003 : 0 : aDrop.Count = rAppendContext.pLastParagraphProperties->GetDropCapLength();
1004 : 0 : aDrop.Distance = 0; //TODO: find distance value
1005 : : //completes (5)
1006 [ # # ]: 0 : if( pParaContext->IsFrameMode() )
1007 [ # # ][ # # ]: 0 : pToBeSavedProperties.reset( new ParagraphProperties(*pParaContext) );
[ # # ]
1008 : : }
1009 [ + - ][ + + ]: 18 : else if(*rAppendContext.pLastParagraphProperties == *pParaContext )
1010 : : {
1011 : : //handles (7)
1012 [ + - ][ + - ]: 9 : rAppendContext.pLastParagraphProperties->SetEndingRange(xTextAppend->getEnd());
[ + - ]
1013 : 9 : bKeepLastParagraphProperties = true;
1014 : : }
1015 : : else
1016 : : {
1017 : : //handles (8)(9) and completes (6)
1018 [ + - ]: 9 : CheckUnregisteredFrameConversion( );
1019 : :
1020 : : // If different frame properties are set on this paragraph, keep them.
1021 [ + - ][ + + ]: 9 : if ( !bIsDropCap && pParaContext->IsFrameMode() )
[ + + ]
1022 : : {
1023 [ + - ][ + - ]: 6 : pToBeSavedProperties.reset( new ParagraphProperties(*pParaContext) );
[ + - ]
1024 [ + - ][ + - ]: 6 : lcl_AddRangeAndStyle(pToBeSavedProperties, xTextAppend, pPropertyMap);
[ + - ]
1025 : : }
1026 : : }
1027 : :
1028 : : }
1029 : : else //
1030 : : {
1031 : : // (1) doesn't need handling
1032 : : //
1033 [ + - ][ + + ]: 1468 : if( !bIsDropCap && pParaContext->IsFrameMode() )
[ + + ]
1034 : : {
1035 [ + - ][ + - ]: 9 : pToBeSavedProperties.reset( new ParagraphProperties(*pParaContext) );
[ + - ]
1036 [ + - ][ + - ]: 9 : lcl_AddRangeAndStyle(pToBeSavedProperties, xTextAppend, pPropertyMap);
[ + - ]
1037 : : }
1038 : : }
1039 [ + - ]: 1486 : uno::Sequence< beans::PropertyValue > aProperties;
1040 [ + - ]: 1486 : if( pPropertyMap.get() )
1041 : : {
1042 [ + - ][ + - ]: 1486 : aProperties = pPropertyMap->GetPropertyValues();
[ + - ]
1043 : : }
1044 [ + - ]: 1486 : if( !bIsDropCap )
1045 : : {
1046 [ - + ]: 1486 : if( aDrop.Lines > 1 )
1047 : : {
1048 : 0 : sal_uInt32 nLength = aProperties.getLength();
1049 [ # # ]: 0 : aProperties.realloc( nLength + 1 );
1050 [ # # ][ # # ]: 0 : aProperties[nLength].Value <<= aDrop;
1051 [ # # ][ # # ]: 0 : aProperties[nLength].Name = rPropNameSupplier.GetName(PROP_DROP_CAP_FORMAT);
1052 : : }
1053 : : uno::Reference< text::XTextRange > xTextRange =
1054 [ + - ][ + + ]: 1486 : xTextAppend->finishParagraph( aProperties );
1055 [ + - ][ + - ]: 1474 : getTableManager( ).handle(xTextRange);
1056 : :
1057 : : // Get the end of paragraph character inserted
1058 [ + - ][ + - ]: 1474 : uno::Reference< text::XTextCursor > xCur = xTextRange->getText( )->createTextCursor( );
[ + - ][ + - ]
1059 [ + - ][ + - ]: 1474 : xCur->gotoEnd( false );
1060 [ + - ][ + - ]: 1474 : xCur->goLeft( 1 , true );
1061 [ + - ]: 1474 : uno::Reference< text::XTextRange > xParaEnd( xCur, uno::UNO_QUERY );
1062 [ + - ]: 1474 : CheckParaRedline( xParaEnd );
1063 : :
1064 : 1474 : m_bIsFirstParaInSection = false;
1065 : 1474 : m_bIsLastParaInSection = false;
1066 : 1474 : m_bParaChanged = false;
1067 : :
1068 : : // Reset the frame properties for the next paragraph
1069 [ + - ]: 1486 : pParaContext->ResetFrameProperties();
1070 : : }
1071 [ + + ]: 1474 : if( !bKeepLastParagraphProperties )
1072 [ + - ][ + - ]: 1486 : rAppendContext.pLastParagraphProperties = pToBeSavedProperties;
[ + - ]
[ - - + ]
1073 : : }
1074 [ # # ]: 0 : catch(const lang::IllegalArgumentException&)
1075 : : {
1076 : : OSL_FAIL( "IllegalArgumentException in DomainMapper_Impl::finishParagraph" );
1077 : : }
1078 [ + - ]: 12 : catch(const uno::Exception&)
1079 : : {
1080 : : }
1081 : 2123 : }
1082 : :
1083 : : #ifdef DEBUG_DOMAINMAPPER
1084 : : dmapper_logger->endElement();
1085 : : #endif
1086 : 2123 : }
1087 : :
1088 : :
1089 : 12 : util::DateTime lcl_DateStringToDateTime( const OUString& rDateTime )
1090 : : {
1091 : 12 : util::DateTime aDateTime;
1092 : : //xsd::DateTime in the format [-]CCYY-MM-DDThh:mm:ss[Z|(+|-)hh:mm] example: 2008-01-21T10:42:00Z
1093 : : //OUString getToken( sal_Int32 token, sal_Unicode cTok, sal_Int32& index ) const SAL_THROW(())
1094 : 12 : sal_Int32 nIndex = 0;
1095 : 12 : OUString sDate = rDateTime.getToken( 0, 'T', nIndex );
1096 : : // HACK: this is broken according to the spec, but MSOffice always treats the time as local,
1097 : : // and writes it as Z (=UTC+0)
1098 : 12 : OUString sTime = rDateTime.getToken( 0, 'Z', nIndex );
1099 : 12 : nIndex = 0;
1100 : 12 : aDateTime.Year = sal_uInt16( sDate.getToken( 0, '-', nIndex ).toInt32() );
1101 : 12 : aDateTime.Month = sal_uInt16( sDate.getToken( 0, '-', nIndex ).toInt32() );
1102 : 12 : aDateTime.Day = sal_uInt16( sDate.copy( nIndex ).toInt32() );
1103 : :
1104 : 12 : nIndex = 0;
1105 : 12 : aDateTime.Hours = sal_uInt16( sTime.getToken( 0, ':', nIndex ).toInt32() );
1106 : 12 : aDateTime.Minutes = sal_uInt16( sTime.getToken( 0, ':', nIndex ).toInt32() );
1107 : 12 : aDateTime.Seconds = sal_uInt16( sTime.copy( nIndex ).toInt32() );
1108 : :
1109 : 12 : return aDateTime;
1110 : : }
1111 : 12766 : void DomainMapper_Impl::appendTextPortion( const OUString& rString, PropertyMapPtr pPropertyMap )
1112 : : {
1113 [ + - ]: 12766 : if (m_aTextAppendStack.empty())
1114 : 12766 : return;
1115 [ + - ][ + + ]: 12766 : if( pPropertyMap == m_pTopContext && !deferredCharacterProperties.empty())
[ + + ]
1116 [ + - ]: 12033 : processDeferredCharacterProperties();
1117 [ + - ]: 12766 : uno::Reference< text::XTextAppend > xTextAppend = m_aTextAppendStack.top().xTextAppend;
1118 [ + - ][ + - ]: 12766 : if(xTextAppend.is() && ! getTableManager( ).isIgnore())
[ + - ][ + + ]
[ + + ]
1119 : : {
1120 : : try
1121 : : {
1122 : : uno::Reference< text::XTextRange > xTextRange =
1123 [ + - ]: 1390 : xTextAppend->appendTextPortion
1124 [ + - ][ + - ]: 1390 : (rString, pPropertyMap->GetPropertyValues());
[ + - ]
1125 [ + - ]: 1390 : CheckRedline( xTextRange );
1126 [ # # # ]: 1390 : m_bParaChanged = true;
1127 : :
1128 : : //getTableManager( ).handle(xTextRange);
1129 : : }
1130 [ # # ]: 0 : catch(const lang::IllegalArgumentException&)
1131 : : {
1132 : : OSL_FAIL( "IllegalArgumentException in DomainMapper_Impl::appendTextPortion" );
1133 : : }
1134 [ # # ]: 0 : catch(const uno::Exception&)
1135 : : {
1136 : : OSL_FAIL( "Exception in DomainMapper_Impl::appendTextPortion" );
1137 : : }
1138 : 12766 : }
1139 : : }
1140 : :
1141 : :
1142 : 528 : void DomainMapper_Impl::appendTextContent(
1143 : : const uno::Reference< text::XTextContent > xContent,
1144 : : const uno::Sequence< beans::PropertyValue > xPropertyValues
1145 : : )
1146 : : {
1147 [ + - ][ + - ]: 528 : uno::Reference< text::XTextAppendAndConvert > xTextAppendAndConvert( m_aTextAppendStack.top().xTextAppend, uno::UNO_QUERY );
1148 : : OSL_ENSURE( xTextAppendAndConvert.is(), "trying to append a text content without XTextAppendAndConvert" );
1149 [ + - ][ + - ]: 528 : if(xTextAppendAndConvert.is() && ! getTableManager( ).isIgnore())
[ + - ][ + - ]
[ + - ]
1150 : : {
1151 : : try
1152 : : {
1153 [ + - ][ + + ]: 528 : xTextAppendAndConvert->appendTextContent( xContent, xPropertyValues );
1154 : : }
1155 [ # # ]: 0 : catch(const lang::IllegalArgumentException&)
1156 : : {
1157 : : }
1158 [ + - ]: 60 : catch(const uno::Exception&)
1159 : : {
1160 : : }
1161 : 528 : }
1162 [ - - + ]: 588 : }
1163 : :
1164 : :
1165 : :
1166 : 0 : void DomainMapper_Impl::appendOLE( const OUString& rStreamName, OLEHandlerPtr pOLEHandler )
1167 : : {
1168 [ # # ][ # # ]: 0 : static const OUString sEmbeddedService("com.sun.star.text.TextEmbeddedObject");
1169 : : try
1170 : : {
1171 [ # # ][ # # ]: 0 : uno::Reference< text::XTextContent > xOLE( m_xTextFactory->createInstance(sEmbeddedService), uno::UNO_QUERY_THROW );
[ # # ]
1172 [ # # ]: 0 : uno::Reference< beans::XPropertySet > xOLEProperties(xOLE, uno::UNO_QUERY_THROW);
1173 : :
1174 [ # # ][ # # ]: 0 : xOLEProperties->setPropertyValue(PropertyNameSupplier::GetPropertyNameSupplier().GetName( PROP_STREAM_NAME ),
[ # # ]
1175 [ # # ][ # # ]: 0 : uno::makeAny( rStreamName ));
1176 : 0 : awt::Size aSize = pOLEHandler->getSize();
1177 [ # # ]: 0 : if( !aSize.Width )
1178 : 0 : aSize.Width = 1000;
1179 [ # # ]: 0 : if( !aSize.Height )
1180 : 0 : aSize.Height = 1000;
1181 [ # # ][ # # ]: 0 : xOLEProperties->setPropertyValue(PropertyNameSupplier::GetPropertyNameSupplier().GetName( PROP_WIDTH ),
[ # # ]
1182 [ # # ][ # # ]: 0 : uno::makeAny(aSize.Width));
1183 [ # # ][ # # ]: 0 : xOLEProperties->setPropertyValue(PropertyNameSupplier::GetPropertyNameSupplier().GetName( PROP_HEIGHT ),
[ # # ]
1184 [ # # ][ # # ]: 0 : uno::makeAny(aSize.Height));
1185 : :
1186 [ # # ]: 0 : uno::Reference< graphic::XGraphic > xGraphic = pOLEHandler->getReplacement();
1187 [ # # ][ # # ]: 0 : xOLEProperties->setPropertyValue(PropertyNameSupplier::GetPropertyNameSupplier().GetName( PROP_GRAPHIC ),
[ # # ]
1188 [ # # ][ # # ]: 0 : uno::makeAny(xGraphic));
1189 : : // mimic the treatment of graphics here.. it seems anchoring as character
1190 : : // gives a better ( visually ) result
1191 [ # # ][ # # ]: 0 : xOLEProperties->setPropertyValue(PropertyNameSupplier::GetPropertyNameSupplier().GetName( PROP_ANCHOR_TYPE ), uno::makeAny( text::TextContentAnchorType_AS_CHARACTER ) );
[ # # ][ # # ]
[ # # ]
1192 : : // remove ( if valid ) associated shape ( used for graphic replacement )
1193 [ # # ]: 0 : m_aAnchoredStack.top( ).bToRemove = true;
1194 [ # # ]: 0 : RemoveLastParagraph();
1195 [ # # ]: 0 : m_aTextAppendStack.pop();
1196 : :
1197 : : //
1198 [ # # ][ # # ]: 0 : appendTextContent( xOLE, uno::Sequence< beans::PropertyValue >() );
[ # # ][ # # ]
1199 : :
1200 : : }
1201 : 0 : catch( const uno::Exception& )
1202 : : {
1203 : : OSL_FAIL( "Exception in creation of OLE object" );
1204 : : }
1205 : :
1206 : 0 : }
1207 : :
1208 : 426 : void DomainMapper_Impl::appendStarMath( const Value& val )
1209 : : {
1210 : 426 : uno::Reference< embed::XEmbeddedObject > formula;
1211 [ + - ][ + - ]: 426 : val.getAny() >>= formula;
1212 [ + - ]: 426 : if( formula.is() )
1213 : : {
1214 [ + + ][ + - ]: 426 : static const OUString sEmbeddedService("com.sun.star.text.TextEmbeddedObject");
1215 : : try
1216 : : {
1217 [ + - ][ + - ]: 426 : uno::Reference< text::XTextContent > xStarMath( m_xTextFactory->createInstance(sEmbeddedService), uno::UNO_QUERY_THROW );
[ + - ]
1218 [ + - ]: 426 : uno::Reference< beans::XPropertySet > xStarMathProperties(xStarMath, uno::UNO_QUERY_THROW);
1219 : :
1220 [ + - ][ + - ]: 852 : xStarMathProperties->setPropertyValue(PropertyNameSupplier::GetPropertyNameSupplier().GetName( PROP_EMBEDDED_OBJECT ),
[ + - ]
1221 [ + - ][ + - ]: 852 : val.getAny());
1222 : :
1223 [ + - ][ + - ]: 426 : uno::Reference< uno::XInterface > xInterface( formula->getComponent(), uno::UNO_QUERY );
[ + - ]
1224 : 426 : Size size( 1000, 1000 );
1225 [ - + ][ + - ]: 426 : if( oox::FormulaImportBase* formulaimport = dynamic_cast< oox::FormulaImportBase* >( xInterface.get()))
[ + - ]
1226 [ + - ]: 426 : size = formulaimport->getFormulaSize();
1227 [ + - ][ + - ]: 852 : xStarMathProperties->setPropertyValue(PropertyNameSupplier::GetPropertyNameSupplier().GetName( PROP_WIDTH ),
[ + - ]
1228 [ + - ][ + - ]: 852 : uno::makeAny( sal_Int32(size.Width())));
1229 [ + - ][ + - ]: 852 : xStarMathProperties->setPropertyValue(PropertyNameSupplier::GetPropertyNameSupplier().GetName( PROP_HEIGHT ),
[ + - ]
1230 [ + - ][ + - ]: 852 : uno::makeAny( sal_Int32(size.Height())));
1231 : : // mimic the treatment of graphics here.. it seems anchoring as character
1232 : : // gives a better ( visually ) result
1233 [ + - ][ + - ]: 852 : xStarMathProperties->setPropertyValue(PropertyNameSupplier::GetPropertyNameSupplier().GetName( PROP_ANCHOR_TYPE ),
[ + - ]
1234 [ + - ][ + - ]: 852 : uno::makeAny( text::TextContentAnchorType_AS_CHARACTER ) );
1235 [ + - ][ + - ]: 426 : appendTextContent( xStarMath, uno::Sequence< beans::PropertyValue >() );
[ # # ][ + - ]
1236 : : }
1237 [ # # ]: 0 : catch( const uno::Exception& )
1238 : : {
1239 : : OSL_FAIL( "Exception in creation of StarMath object" );
1240 : : }
1241 : 426 : }
1242 : 426 : }
1243 : :
1244 : 3 : uno::Reference< beans::XPropertySet > DomainMapper_Impl::appendTextSectionAfter(
1245 : : uno::Reference< text::XTextRange >& xBefore )
1246 : : {
1247 : 3 : uno::Reference< beans::XPropertySet > xRet;
1248 [ + - ]: 3 : if (m_aTextAppendStack.empty())
1249 : : return xRet;
1250 [ + - ]: 3 : uno::Reference< text::XTextAppend > xTextAppend = m_aTextAppendStack.top().xTextAppend;
1251 [ + - ]: 3 : if(xTextAppend.is())
1252 : : {
1253 : : try
1254 : : {
1255 : : uno::Reference< text::XParagraphCursor > xCursor(
1256 [ + - ][ + - ]: 3 : xTextAppend->createTextCursorByRange( xBefore ), uno::UNO_QUERY_THROW);
[ + - ]
1257 : : //the cursor has been moved to the end of the paragraph because of the appendTextPortion() calls
1258 [ + - ][ + - ]: 3 : xCursor->gotoStartOfParagraph( false );
1259 [ + - ][ + - ]: 3 : xCursor->gotoEnd( true );
1260 : : //the paragraph after this new section is already inserted
1261 [ + - ][ + - ]: 3 : xCursor->goLeft(1, true);
1262 [ + - ][ + - ]: 3 : static const OUString sSectionService("com.sun.star.text.TextSection");
1263 [ + - ][ + - ]: 3 : uno::Reference< text::XTextContent > xSection( m_xTextFactory->createInstance(sSectionService), uno::UNO_QUERY_THROW );
[ + - ]
1264 [ + - ][ + - ]: 3 : xSection->attach( uno::Reference< text::XTextRange >( xCursor, uno::UNO_QUERY_THROW) );
[ + - ]
1265 [ + - ][ # # ]: 3 : xRet = uno::Reference< beans::XPropertySet > (xSection, uno::UNO_QUERY );
[ + - ]
1266 : : }
1267 [ # # ]: 0 : catch(const uno::Exception&)
1268 : : {
1269 : : }
1270 : :
1271 : : }
1272 : :
1273 : 3 : return xRet;
1274 : : }
1275 : :
1276 : :
1277 : 33 : void DomainMapper_Impl::PushPageHeader(SectionPropertyMap::PageType eType)
1278 : : {
1279 : 33 : m_bInHeaderFooterImport = true;
1280 : :
1281 : : //get the section context
1282 [ + - ]: 33 : PropertyMapPtr pContext = DomainMapper_Impl::GetTopContextOfType(CONTEXT_SECTION);
1283 : : //ask for the header name of the given type
1284 [ - + ]: 33 : SectionPropertyMap* pSectionContext = dynamic_cast< SectionPropertyMap* >( pContext.get() );
1285 [ + - ]: 33 : if(pSectionContext)
1286 : : {
1287 : : uno::Reference< beans::XPropertySet > xPageStyle =
1288 : : pSectionContext->GetPageStyle(
1289 : : GetPageStyles(),
1290 : : m_xTextFactory,
1291 [ + - ][ + - ]: 33 : eType == SectionPropertyMap::PAGE_FIRST );
1292 [ - + ]: 33 : if (!xPageStyle.is())
1293 : 33 : return;
1294 : : try
1295 : : {
1296 [ + - ]: 33 : PropertyNameSupplier& rPropNameSupplier = PropertyNameSupplier::GetPropertyNameSupplier();
1297 : : //switch on header use
1298 [ + - ]: 33 : xPageStyle->setPropertyValue(
1299 [ + - ]: 33 : rPropNameSupplier.GetName(PROP_HEADER_IS_ON),
1300 [ + - ][ + - ]: 66 : uno::makeAny(sal_True) );
1301 : : // if a left header is available then header are not shared
1302 : 33 : bool bLeft = eType == SectionPropertyMap::PAGE_LEFT;
1303 [ + - ][ - + ]: 33 : if( bLeft && m_pSettingsTable->GetEvenAndOddHeaders())
[ - + ][ + + ]
1304 [ # # ][ # # ]: 0 : xPageStyle->setPropertyValue(rPropNameSupplier.GetName(PROP_HEADER_IS_SHARED), uno::makeAny( false ));
[ # # ][ # # ]
1305 : :
1306 : : //set the interface
1307 : 33 : uno::Reference< text::XText > xHeaderText;
1308 [ + + ][ + - ]: 33 : xPageStyle->getPropertyValue(rPropNameSupplier.GetName( bLeft ? PROP_HEADER_TEXT_LEFT : PROP_HEADER_TEXT) ) >>= xHeaderText;
[ + - ][ + - ]
[ + - ]
1309 [ + - ][ + - ]: 33 : m_aTextAppendStack.push( uno::Reference< text::XTextAppend >( xHeaderText, uno::UNO_QUERY_THROW));
[ + - ][ # # ]
[ + - ]
1310 : : }
1311 [ # # ]: 0 : catch( const uno::Exception& )
1312 : : {
1313 [ + - ]: 33 : }
1314 [ + - ][ + - ]: 33 : }
1315 : : }
1316 : :
1317 : :
1318 : 9 : void DomainMapper_Impl::PushPageFooter(SectionPropertyMap::PageType eType)
1319 : : {
1320 : 9 : m_bInHeaderFooterImport = true;
1321 : :
1322 : : //get the section context
1323 [ + - ]: 9 : PropertyMapPtr pContext = DomainMapper_Impl::GetTopContextOfType(CONTEXT_SECTION);
1324 : : //ask for the footer name of the given type
1325 [ - + ]: 9 : SectionPropertyMap* pSectionContext = dynamic_cast< SectionPropertyMap* >( pContext.get() );
1326 [ + - ]: 9 : if(pSectionContext)
1327 : : {
1328 : : uno::Reference< beans::XPropertySet > xPageStyle =
1329 : : pSectionContext->GetPageStyle(
1330 : : GetPageStyles(),
1331 : : m_xTextFactory,
1332 [ + - ][ + - ]: 9 : eType == SectionPropertyMap::PAGE_FIRST );
1333 [ - + ]: 9 : if (!xPageStyle.is())
1334 : 9 : return;
1335 : : try
1336 : : {
1337 [ + - ]: 9 : PropertyNameSupplier& rPropNameSupplier = PropertyNameSupplier::GetPropertyNameSupplier();
1338 : : //switch on footer use
1339 [ + - ]: 9 : xPageStyle->setPropertyValue(
1340 [ + - ]: 9 : rPropNameSupplier.GetName(PROP_FOOTER_IS_ON),
1341 [ + - ][ + - ]: 18 : uno::makeAny(sal_True) );
1342 : : // if a left header is available then footer is not shared
1343 : 9 : bool bLeft = eType == SectionPropertyMap::PAGE_LEFT;
1344 [ + - ][ - + ]: 9 : if( bLeft && m_pSettingsTable->GetEvenAndOddHeaders())
[ - + ][ + + ]
1345 [ # # ][ # # ]: 0 : xPageStyle->setPropertyValue(rPropNameSupplier.GetName(PROP_FOOTER_IS_SHARED), uno::makeAny( false ));
[ # # ][ # # ]
1346 : : //set the interface
1347 : 9 : uno::Reference< text::XText > xFooterText;
1348 [ + + ][ + - ]: 9 : xPageStyle->getPropertyValue(rPropNameSupplier.GetName( bLeft ? PROP_FOOTER_TEXT_LEFT : PROP_FOOTER_TEXT) ) >>= xFooterText;
[ + - ][ + - ]
[ + - ]
1349 [ + - ][ + - ]: 9 : m_aTextAppendStack.push(uno::Reference< text::XTextAppend >( xFooterText, uno::UNO_QUERY_THROW ));
[ + - ][ # # ]
[ + - ]
1350 : : }
1351 [ # # ]: 0 : catch( const uno::Exception& )
1352 : : {
1353 [ + - ]: 9 : }
1354 [ + - ][ + - ]: 9 : }
1355 : : }
1356 : :
1357 : :
1358 : 42 : void DomainMapper_Impl::PopPageHeaderFooter()
1359 : : {
1360 : : //header and footer always have an empty paragraph at the end
1361 : : //this has to be removed
1362 : 42 : RemoveLastParagraph( );
1363 [ + - ]: 42 : if (!m_aTextAppendStack.empty())
1364 : 42 : m_aTextAppendStack.pop();
1365 : 42 : m_bInHeaderFooterImport = false;
1366 : 42 : }
1367 : :
1368 : :
1369 : 3 : void DomainMapper_Impl::PushFootOrEndnote( bool bIsFootnote )
1370 : : {
1371 : : try
1372 : : {
1373 [ + - ]: 3 : PropertyMapPtr pTopContext = GetTopContext();
1374 : 3 : uno::Reference< text::XText > xFootnoteText;
1375 [ + - ][ + - ]: 3 : if (GetTextFactory().is())
1376 [ + - ][ + - ]: 6 : xFootnoteText.set( GetTextFactory()->createInstance(
1377 : : bIsFootnote ?
1378 : 3 : OUString( "com.sun.star.text.Footnote" ) : OUString( "com.sun.star.text.Endnote" )),
1379 [ + - ][ + - ]: 3 : uno::UNO_QUERY_THROW );
[ + - ][ - + ]
[ + - ]
[ # # # # ]
1380 [ + - ]: 3 : uno::Reference< text::XFootnote > xFootnote( xFootnoteText, uno::UNO_QUERY_THROW );
1381 [ + - ]: 3 : pTopContext->SetFootnote( xFootnote );
1382 [ - + ]: 3 : if( pTopContext->GetFootnoteSymbol() != 0)
1383 : : {
1384 [ # # ][ # # ]: 0 : xFootnote->setLabel( OUString( pTopContext->GetFootnoteSymbol() ) );
1385 : : }
1386 [ + - ]: 3 : FontTablePtr pFontTable = GetFontTable();
1387 [ + - ]: 3 : uno::Sequence< beans::PropertyValue > aFontProperties;
1388 [ + - ][ - + ]: 3 : if( pFontTable && pTopContext->GetFootnoteFontId() >= 0 && pFontTable->size() > (size_t)pTopContext->GetFootnoteFontId() )
[ # # ][ # # ]
[ - + ]
1389 : : {
1390 [ # # ]: 0 : const FontEntry::Pointer_t pFontEntry(pFontTable->getFontEntry(sal_uInt32(pTopContext->GetFootnoteFontId())));
1391 [ # # ][ # # ]: 0 : PropertyMapPtr aFontProps( new PropertyMap );
[ # # ]
1392 [ # # ][ # # ]: 0 : aFontProps->Insert(PROP_CHAR_FONT_NAME, true, uno::makeAny( pFontEntry->sFontName ));
1393 [ # # ][ # # ]: 0 : aFontProps->Insert(PROP_CHAR_FONT_CHAR_SET, true, uno::makeAny( (sal_Int16)pFontEntry->nTextEncoding ));
1394 [ # # ][ # # ]: 0 : aFontProps->Insert(PROP_CHAR_FONT_PITCH, true, uno::makeAny( pFontEntry->nPitchRequest ));
1395 [ # # ][ # # ]: 0 : aFontProperties = aFontProps->GetPropertyValues();
[ # # ][ # # ]
[ # # ]
1396 : : }
1397 [ - + ]: 3 : else if(!pTopContext->GetFootnoteFontName().isEmpty())
1398 : : {
1399 [ # # ][ # # ]: 0 : PropertyMapPtr aFontProps( new PropertyMap );
[ # # ]
1400 [ # # ][ # # ]: 0 : aFontProps->Insert(PROP_CHAR_FONT_NAME, true, uno::makeAny( pTopContext->GetFootnoteFontName() ));
1401 [ # # ][ # # ]: 0 : aFontProperties = aFontProps->GetPropertyValues();
[ # # ][ # # ]
1402 : : }
1403 [ + - ][ + - ]: 3 : appendTextContent( uno::Reference< text::XTextContent >( xFootnoteText, uno::UNO_QUERY_THROW ), aFontProperties );
[ + - ][ + - ]
1404 [ + - ][ + - ]: 3 : m_aTextAppendStack.push(uno::Reference< text::XTextAppend >( xFootnoteText, uno::UNO_QUERY_THROW ));
[ + - ][ + - ]
1405 : :
1406 : : // Redlines for the footnote anchor
1407 [ + - ][ + - ]: 3 : CheckRedline( xFootnote->getAnchor( ) );
[ + - ][ + - ]
[ + - ][ # # ]
[ + - ]
1408 : : }
1409 : 0 : catch( const uno::Exception& )
1410 : : {
1411 : : OSL_FAIL( "exception in PushFootOrEndnote" );
1412 : : }
1413 : 3 : }
1414 : :
1415 : 0 : void DomainMapper_Impl::CreateRedline( uno::Reference< text::XTextRange > xRange, RedlineParamsPtr& pRedline )
1416 : : {
1417 [ # # ]: 0 : if ( pRedline.get( ) )
1418 : : {
1419 : : try
1420 : : {
1421 : 0 : OUString sType;
1422 [ # # ]: 0 : PropertyNameSupplier & rPropNameSupplier = PropertyNameSupplier::GetPropertyNameSupplier( );
1423 [ # # # # ]: 0 : switch ( pRedline->m_nToken & 0xffff )
1424 : : {
1425 : : case ooxml::OOXML_mod:
1426 [ # # ]: 0 : sType = rPropNameSupplier.GetName( PROP_FORMAT );
1427 : 0 : break;
1428 : : case ooxml::OOXML_ins:
1429 [ # # ]: 0 : sType = rPropNameSupplier.GetName( PROP_INSERT );
1430 : 0 : break;
1431 : : case ooxml::OOXML_del:
1432 [ # # ]: 0 : sType = rPropNameSupplier.GetName( PROP_DELETE );
1433 : 0 : break;
1434 : : }
1435 [ # # ]: 0 : uno::Reference < text::XRedline > xRedline( xRange, uno::UNO_QUERY_THROW );
1436 [ # # ]: 0 : beans::PropertyValues aRedlineProperties( 2 );
1437 [ # # ]: 0 : beans::PropertyValue * pRedlineProperties = aRedlineProperties.getArray( );
1438 [ # # ]: 0 : pRedlineProperties[0].Name = rPropNameSupplier.GetName( PROP_REDLINE_AUTHOR );
1439 [ # # ]: 0 : pRedlineProperties[0].Value <<= pRedline->m_sAuthor;
1440 [ # # ]: 0 : pRedlineProperties[1].Name = rPropNameSupplier.GetName( PROP_REDLINE_DATE_TIME );
1441 [ # # ]: 0 : pRedlineProperties[1].Value <<= lcl_DateStringToDateTime( pRedline->m_sDate );
1442 : :
1443 [ # # ][ # # ]: 0 : xRedline->makeRedline( sType, aRedlineProperties );
[ # # ][ # # ]
1444 : : }
1445 : 0 : catch( const uno::Exception & )
1446 : : {
1447 : : OSL_FAIL( "Exception in makeRedline" );
1448 : : }
1449 : : }
1450 : 0 : }
1451 : :
1452 : 1474 : void DomainMapper_Impl::CheckParaRedline( uno::Reference< text::XTextRange > xRange )
1453 : : {
1454 [ - + ]: 1474 : if ( m_pParaRedline.get( ) )
1455 : : {
1456 [ # # ]: 0 : CreateRedline( xRange, m_pParaRedline );
1457 : 0 : ResetParaRedline( );
1458 : : }
1459 : 1474 : }
1460 : :
1461 : 1393 : void DomainMapper_Impl::CheckRedline( uno::Reference< text::XTextRange > xRange )
1462 : : {
1463 : 1393 : vector<RedlineParamsPtr>::iterator pIt = m_aRedlines.begin( );
1464 [ + - ]: 1393 : vector< RedlineParamsPtr > aCleaned;
1465 [ + - ][ - + ]: 1393 : for (; pIt != m_aRedlines.end( ); ++pIt )
1466 : : {
1467 [ # # ]: 0 : CreateRedline( xRange, *pIt );
1468 : :
1469 : : // Adding the non-mod redlines to the temporary vector
1470 [ # # ][ # # ]: 0 : if ( pIt->get( ) && ( ( *pIt )->m_nToken & 0xffff ) != ooxml::OOXML_mod )
[ # # ]
1471 : : {
1472 [ # # ]: 0 : aCleaned.push_back( *pIt );
1473 : : }
1474 : : }
1475 : :
1476 : 1393 : m_aRedlines.swap( aCleaned );
1477 : 1393 : }
1478 : :
1479 : 0 : void DomainMapper_Impl::StartParaChange( )
1480 : : {
1481 : 0 : m_bIsParaChange = true;
1482 : 0 : }
1483 : :
1484 : 0 : void DomainMapper_Impl::EndParaChange( )
1485 : : {
1486 : 0 : m_bIsParaChange = false;
1487 : 0 : }
1488 : :
1489 : :
1490 : :
1491 : 12 : void DomainMapper_Impl::PushAnnotation()
1492 : : {
1493 : : try
1494 : : {
1495 [ + - ]: 12 : PropertyMapPtr pTopContext = GetTopContext();
1496 [ + - ][ - + ]: 12 : if (!GetTextFactory().is())
1497 : 12 : return;
1498 [ + - ][ + - ]: 24 : m_xAnnotationField = uno::Reference< beans::XPropertySet >( GetTextFactory()->createInstance(
1499 : 12 : "com.sun.star.text.TextField.Annotation" ),
1500 [ + - ][ + - ]: 12 : uno::UNO_QUERY_THROW );
[ + - ]
1501 : 12 : uno::Reference< text::XText > xAnnotationText;
1502 [ + - ][ + - ]: 12 : m_xAnnotationField->getPropertyValue("TextRange") >>= xAnnotationText;
[ + - ]
1503 [ + - ][ + - ]: 12 : m_aTextAppendStack.push(uno::Reference< text::XTextAppend >( xAnnotationText, uno::UNO_QUERY_THROW ));
[ + - ][ + - ]
[ + - ][ # # ]
[ + - ]
1504 : : }
1505 : 0 : catch( const uno::Exception& )
1506 : : {
1507 : : OSL_FAIL( "exception in PushAnnotation" );
1508 : : }
1509 : : }
1510 : :
1511 : :
1512 : 3 : void DomainMapper_Impl::PopFootOrEndnote()
1513 : : {
1514 : 3 : RemoveLastParagraph();
1515 [ + - ]: 3 : if (!m_aTextAppendStack.empty())
1516 : 3 : m_aTextAppendStack.pop();
1517 : 3 : }
1518 : :
1519 : :
1520 : 12 : void DomainMapper_Impl::PopAnnotation()
1521 : : {
1522 : 12 : RemoveLastParagraph();
1523 : :
1524 : 12 : m_aTextAppendStack.pop();
1525 : :
1526 : : // See if the annotation will be a single position or a range.
1527 [ - + ][ - + ]: 12 : if (!m_aAnnotationPosition.m_xStart.is() || !m_aAnnotationPosition.m_xEnd.is())
[ + - ]
1528 : : {
1529 [ # # ]: 0 : uno::Sequence< beans::PropertyValue > aEmptyProperties;
1530 [ # # ][ # # ]: 0 : appendTextContent( uno::Reference< text::XTextContent >( m_xAnnotationField, uno::UNO_QUERY_THROW ), aEmptyProperties );
[ # # ][ # # ]
[ # # ]
1531 : : }
1532 : : else
1533 : : {
1534 : : // Create a range that points to the annotation start/end.
1535 [ + - ][ + - ]: 12 : uno::Reference<text::XText> xText = m_aAnnotationPosition.m_xStart->getText();
1536 [ + - ][ + - ]: 12 : uno::Reference<text::XTextCursor> xCursor = xText->createTextCursorByRange(m_aAnnotationPosition.m_xStart);
1537 [ + - ][ + - ]: 12 : xCursor->gotoRange(m_aAnnotationPosition.m_xEnd, true);
1538 [ + - ]: 12 : uno::Reference<text::XTextRange> xTextRange(xCursor, uno::UNO_QUERY_THROW);
1539 : :
1540 : : // Attach the annotation to the range.
1541 [ + - ]: 12 : uno::Reference<text::XTextAppend> xTextAppend = m_aTextAppendStack.top().xTextAppend;
1542 [ + - ][ + - ]: 12 : xTextAppend->insertTextContent(xTextRange, uno::Reference<text::XTextContent>(m_xAnnotationField, uno::UNO_QUERY_THROW), !xCursor->isCollapsed());
[ + - ][ + - ]
[ + - ]
1543 : : }
1544 : :
1545 : 12 : m_aAnnotationPosition.m_xStart.clear();
1546 : 12 : m_aAnnotationPosition.m_xEnd.clear();
1547 : 12 : m_xAnnotationField.clear();
1548 : :
1549 : 12 : }
1550 : :
1551 : 75 : void DomainMapper_Impl::PushShapeContext( const uno::Reference< drawing::XShape > xShape )
1552 : : {
1553 [ + - ]: 75 : if (m_aTextAppendStack.empty())
1554 : 75 : return;
1555 [ + - ]: 75 : uno::Reference<text::XTextAppend> xTextAppend = m_aTextAppendStack.top().xTextAppend;
1556 : : try
1557 : : {
1558 : : // Add the shape to the text append stack
1559 [ + - ][ + - ]: 75 : m_aTextAppendStack.push( uno::Reference< text::XTextAppend >( xShape, uno::UNO_QUERY_THROW ) );
[ + - ][ + + ]
1560 : :
1561 : : // Add the shape to the anchored objects stack
1562 [ + - ]: 69 : uno::Reference< text::XTextContent > xTxtContent( xShape, uno::UNO_QUERY_THROW );
1563 [ + - ][ + - ]: 69 : m_aAnchoredStack.push( xTxtContent );
[ + - ]
1564 : :
1565 [ + - ]: 69 : PropertyNameSupplier& rPropNameSupplier = PropertyNameSupplier::GetPropertyNameSupplier();
1566 : :
1567 [ + - ]: 69 : uno::Reference< beans::XPropertySet > xProps( xShape, uno::UNO_QUERY_THROW );
1568 : : #ifdef DEBUG_DOMAINMAPPER
1569 : : dmapper_logger->unoPropertySet(xProps);
1570 : : #endif
1571 [ + - ]: 69 : uno::Reference< lang::XServiceInfo > xSInfo( xShape, uno::UNO_QUERY_THROW );
1572 [ + - ][ + - ]: 69 : bool bIsGraphic = xSInfo->supportsService( "com.sun.star.drawing.GraphicObjectShape" );
1573 : :
1574 : : // If there are position properties, the shape should not be inserted "as character".
1575 : 69 : sal_Int32 nHoriPosition = 0, nVertPosition = 0;
1576 [ + - ][ + - ]: 69 : xProps->getPropertyValue(rPropNameSupplier.GetName(PROP_HORI_ORIENT_POSITION)) >>= nHoriPosition;
[ + - ]
1577 [ + - ][ + - ]: 69 : xProps->getPropertyValue(rPropNameSupplier.GetName(PROP_VERT_ORIENT_POSITION)) >>= nVertPosition;
[ + - ]
1578 [ - + ][ + + ]: 69 : if (nHoriPosition != 0 || nVertPosition != 0)
1579 : 15 : bIsGraphic = false;
1580 : 69 : text::TextContentAnchorType nAnchorType(text::TextContentAnchorType_AT_PARAGRAPH);
1581 [ + - ][ + - ]: 69 : xProps->getPropertyValue(rPropNameSupplier.GetName( PROP_ANCHOR_TYPE )) >>= nAnchorType;
[ + - ][ + - ]
1582 [ + + ]: 69 : if (nAnchorType == text::TextContentAnchorType_AT_PAGE)
1583 : 39 : bIsGraphic = false;
1584 : :
1585 [ + + ]: 69 : if (nAnchorType != text::TextContentAnchorType_AT_PAGE)
1586 [ + - ]: 30 : xProps->setPropertyValue(
1587 [ + - ]: 30 : rPropNameSupplier.GetName( PROP_OPAQUE ),
1588 [ + - ][ + - ]: 60 : uno::makeAny( true ) );
1589 [ + - ][ + - ]: 69 : if (xSInfo->supportsService("com.sun.star.text.TextFrame"))
[ + + ]
1590 : : {
1591 [ + - ]: 12 : uno::Reference<text::XTextContent> xTextContent(xShape, uno::UNO_QUERY_THROW);
1592 [ + - ][ + - ]: 12 : uno::Reference<text::XTextRange> xTextRange(xTextAppend->createTextCursorByRange(xTextAppend->getEnd()), uno::UNO_QUERY_THROW);
[ + - ][ + - ]
[ + - ]
1593 [ + - ][ + - ]: 12 : xTextAppend->insertTextContent(xTextRange, xTextContent, sal_False);
1594 : : }
1595 [ + + ]: 57 : else if (nAnchorType != text::TextContentAnchorType_AS_CHARACTER)
1596 : : {
1597 [ + - ][ - + ]: 51 : xProps->setPropertyValue( rPropNameSupplier.GetName( PROP_ANCHOR_TYPE ), bIsGraphic ? uno::makeAny( text::TextContentAnchorType_AS_CHARACTER ) : uno::makeAny( text::TextContentAnchorType_AT_PARAGRAPH ) );
[ # # ][ + - ]
[ + - ][ + - ]
[ + - ][ - + ]
[ # # # # ]
1598 : : }
1599 : :
1600 [ + - ]: 69 : appendTableManager( );
1601 [ + - ][ + - ]: 75 : getTableManager().startLevel();
[ - + ]
1602 : : }
1603 [ + - ]: 6 : catch ( const uno::Exception& e )
1604 : : {
1605 : : SAL_WARN("writerfilter", "Exception when adding shape: " << e.Message);
1606 : 75 : }
1607 : : }
1608 : :
1609 : :
1610 : :
1611 : 75 : void DomainMapper_Impl::PopShapeContext()
1612 : : {
1613 [ + + ]: 75 : if ( m_aAnchoredStack.size() > 0 )
1614 : : {
1615 [ + - ][ + - ]: 69 : getTableManager().endLevel();
1616 [ + - ]: 69 : popTableManager();
1617 : :
1618 : : // For OLE object replacement shape, the text append context was already removed
1619 : : // or the OLE object couldn't be inserted.
1620 [ + - ][ + - ]: 69 : if ( !m_aAnchoredStack.top().bToRemove )
1621 : : {
1622 [ + - ]: 69 : RemoveLastParagraph();
1623 [ + - ]: 69 : m_aTextAppendStack.pop();
1624 : : }
1625 : :
1626 [ + - ]: 69 : uno::Reference< text::XTextContent > xObj = m_aAnchoredStack.top( ).xTextContent;
1627 : : try
1628 : : {
1629 [ + - ][ + - ]: 69 : appendTextContent( xObj, uno::Sequence< beans::PropertyValue >() );
[ # # ][ + - ]
1630 : : }
1631 [ # # ]: 0 : catch ( const uno::RuntimeException& )
1632 : : {
1633 : : // this is normal: the shape is already attached
1634 : : }
1635 : :
1636 : : // Remove the shape if required (most likely replacement shape for OLE object)
1637 [ + - ][ - + ]: 69 : if ( m_aAnchoredStack.top().bToRemove )
1638 : : {
1639 : : try
1640 : : {
1641 [ # # ]: 0 : uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(m_xTextDocument, uno::UNO_QUERY_THROW);
1642 [ # # ][ # # ]: 0 : uno::Reference<drawing::XDrawPage> xDrawPage = xDrawPageSupplier->getDrawPage();
1643 [ # # ]: 0 : if ( xDrawPage.is() )
1644 : : {
1645 [ # # ]: 0 : uno::Reference<drawing::XShape> xShape( xObj, uno::UNO_QUERY_THROW );
1646 [ # # ][ # # ]: 0 : xDrawPage->remove( xShape );
1647 [ # # ]: 0 : }
1648 : : }
1649 [ # # ]: 0 : catch( const uno::Exception& )
1650 : : {
1651 : : }
1652 : : }
1653 [ + - ]: 69 : m_aAnchoredStack.pop();
1654 : : }
1655 : 75 : }
1656 : :
1657 : :
1658 : 15 : OUString lcl_FindQuotedText( const OUString& rCommand,
1659 : : const sal_Char* cStartQuote, const sal_Unicode uEndQuote )
1660 : : {
1661 : 15 : OUString sRet;
1662 : 15 : OUString sStartQuote( OUString::createFromAscii(cStartQuote) );
1663 : 15 : sal_Int32 nStartIndex = rCommand.indexOf( sStartQuote );
1664 [ + + ]: 15 : if( nStartIndex >= 0 )
1665 : : {
1666 : 3 : sal_Int32 nStartLength = sStartQuote.getLength();
1667 : 3 : sal_Int32 nEndIndex = rCommand.indexOf( uEndQuote, nStartIndex + nStartLength);
1668 [ + - ]: 3 : if( nEndIndex > nStartIndex )
1669 : : {
1670 : 3 : sRet = rCommand.copy( nStartIndex + nStartLength, nEndIndex - nStartIndex - nStartLength);
1671 : : }
1672 : : }
1673 : 15 : return sRet;
1674 : :
1675 : : }
1676 : :
1677 : :
1678 : 12 : sal_Int16 lcl_ParseNumberingType( const OUString& rCommand )
1679 : : {
1680 : 12 : sal_Int16 nRet = style::NumberingType::PAGE_DESCRIPTOR;
1681 : :
1682 : : // The command looks like: " PAGE \* Arabic "
1683 : 12 : OUString sNumber = lcl_FindQuotedText(rCommand, "\\* ", ' ');
1684 : :
1685 [ - + ]: 12 : if( !sNumber.isEmpty() )
1686 : : {
1687 : : //todo: might make sense to hash this list, too
1688 : : struct NumberingPairs
1689 : : {
1690 : : const sal_Char* cWordName;
1691 : : sal_Int16 nType;
1692 : : };
1693 : : static const NumberingPairs aNumberingPairs[] =
1694 : : {
1695 : : {"Arabic", style::NumberingType::ARABIC}
1696 : : ,{"ROMAN", style::NumberingType::ROMAN_UPPER}
1697 : : ,{"roman", style::NumberingType::ROMAN_LOWER}
1698 : : ,{"ALPHABETIC", style::NumberingType::CHARS_UPPER_LETTER}
1699 : : ,{"alphabetic", style::NumberingType::CHARS_LOWER_LETTER}
1700 : : ,{"CircleNum", style::NumberingType::CIRCLE_NUMBER}
1701 : : ,{"ThaiArabic", style::NumberingType::CHARS_THAI}
1702 : : ,{"ThaiCardText", style::NumberingType::CHARS_THAI}
1703 : : ,{"ThaiLetter", style::NumberingType::CHARS_THAI}
1704 : : // ,{"SBCHAR", style::NumberingType::}
1705 : : // ,{"DBCHAR", style::NumberingType::}
1706 : : // ,{"DBNUM1", style::NumberingType::}
1707 : : // ,{"DBNUM2", style::NumberingType::}
1708 : : // ,{"DBNUM3", style::NumberingType::}
1709 : : // ,{"DBNUM4", style::NumberingType::}
1710 : : ,{"Aiueo", style::NumberingType::AIU_FULLWIDTH_JA}
1711 : : ,{"Iroha", style::NumberingType::IROHA_FULLWIDTH_JA}
1712 : : // ,{"ZODIAC1", style::NumberingType::}
1713 : : // ,{"ZODIAC2", style::NumberingType::}
1714 : : // ,{"ZODIAC3", style::NumberingType::}
1715 : : // ,{"CHINESENUM1", style::NumberingType::}
1716 : : // ,{"CHINESENUM2", style::NumberingType::}
1717 : : // ,{"CHINESENUM3", style::NumberingType::}
1718 : : ,{"ArabicAlpha", style::NumberingType::CHARS_ARABIC}
1719 : : ,{"ArabicAbjad", style::NumberingType::FULLWIDTH_ARABIC}
1720 : : /* possible values:
1721 : : style::NumberingType::
1722 : :
1723 : : CHARS_UPPER_LETTER_N
1724 : : CHARS_LOWER_LETTER_N
1725 : : TRANSLITERATION
1726 : : NATIVE_NUMBERING
1727 : : CIRCLE_NUMBER
1728 : : NUMBER_LOWER_ZH
1729 : : NUMBER_UPPER_ZH
1730 : : NUMBER_UPPER_ZH_TW
1731 : : TIAN_GAN_ZH
1732 : : DI_ZI_ZH
1733 : : NUMBER_TRADITIONAL_JA
1734 : : AIU_HALFWIDTH_JA
1735 : : IROHA_HALFWIDTH_JA
1736 : : NUMBER_UPPER_KO
1737 : : NUMBER_HANGUL_KO
1738 : : HANGUL_JAMO_KO
1739 : : HANGUL_SYLLABLE_KO
1740 : : HANGUL_CIRCLED_JAMO_KO
1741 : : HANGUL_CIRCLED_SYLLABLE_KO
1742 : : CHARS_HEBREW
1743 : : CHARS_NEPALI
1744 : : CHARS_KHMER
1745 : : CHARS_LAO
1746 : : CHARS_TIBETAN
1747 : : CHARS_CYRILLIC_UPPER_LETTER_BG
1748 : : CHARS_CYRILLIC_LOWER_LETTER_BG
1749 : : CHARS_CYRILLIC_UPPER_LETTER_N_BG
1750 : : CHARS_CYRILLIC_LOWER_LETTER_N_BG
1751 : : CHARS_CYRILLIC_UPPER_LETTER_RU
1752 : : CHARS_CYRILLIC_LOWER_LETTER_RU
1753 : : CHARS_CYRILLIC_UPPER_LETTER_N_RU
1754 : : CHARS_CYRILLIC_LOWER_LETTER_N_RU
1755 : : CHARS_CYRILLIC_UPPER_LETTER_SR
1756 : : CHARS_CYRILLIC_LOWER_LETTER_SR
1757 : : CHARS_CYRILLIC_UPPER_LETTER_N_SR
1758 : : CHARS_CYRILLIC_LOWER_LETTER_N_SR*/
1759 : :
1760 : : };
1761 [ # # ]: 0 : for( sal_uInt32 nNum = 0; nNum < sizeof(aNumberingPairs)/sizeof( NumberingPairs ); ++nNum)
1762 : : {
1763 [ # # ]: 0 : if( /*sCommand*/sNumber.equalsAscii(aNumberingPairs[nNum].cWordName ))
1764 : : {
1765 : 0 : nRet = aNumberingPairs[nNum].nType;
1766 : 0 : break;
1767 : : }
1768 : : }
1769 : :
1770 : : }
1771 : 12 : return nRet;
1772 : : }
1773 : :
1774 : :
1775 : 3 : OUString lcl_ParseFormat( const OUString& rCommand )
1776 : : {
1777 : : // The command looks like: " DATE \@ "dd MMMM yyyy"
1778 : 3 : return lcl_FindQuotedText(rCommand, "\\@ \"", '\"');
1779 : : }
1780 : : /*-------------------------------------------------------------------------
1781 : : extract a parameter (with or without quotes) between the command and the following backslash
1782 : : -----------------------------------------------------------------------*/
1783 : 3 : OUString lcl_ExtractParameter(const OUString& rCommand, sal_Int32 nCommandLength )
1784 : : {
1785 : 3 : sal_Int32 nStartIndex = nCommandLength;
1786 : 3 : sal_Int32 nEndIndex = 0;
1787 : 3 : sal_Int32 nQuoteIndex = rCommand.indexOf( '\"', nStartIndex);
1788 [ - + ]: 3 : if( nQuoteIndex >= 0)
1789 : : {
1790 : 0 : nStartIndex = nQuoteIndex + 1;
1791 : 0 : nEndIndex = rCommand.indexOf( '\"', nStartIndex + 1) - 1;
1792 : : }
1793 : : else
1794 : : {
1795 : 3 : nEndIndex = rCommand.indexOf(" \\", nStartIndex);
1796 : : }
1797 : 3 : OUString sRet;
1798 [ + - ]: 3 : if( nEndIndex > nStartIndex + 1 )
1799 : : {
1800 : : //remove spaces at start and end of the result
1801 [ + - ]: 3 : if(nQuoteIndex <= 0)
1802 : : {
1803 : 3 : const sal_Unicode* pCommandStr = rCommand.getStr();
1804 [ + - ][ - + ]: 3 : while( nStartIndex < nEndIndex && pCommandStr[nStartIndex] == ' ')
[ - + ]
1805 : 0 : ++nStartIndex;
1806 [ + - ][ + + ]: 9 : while( nEndIndex > nStartIndex && pCommandStr[nEndIndex] == ' ')
[ + + ]
1807 : 6 : --nEndIndex;
1808 : : }
1809 : 3 : sRet = rCommand.copy( nStartIndex, nEndIndex - nStartIndex + 1);
1810 : : }
1811 : 3 : return sRet;
1812 : : }
1813 : :
1814 : :
1815 : :
1816 : 3 : OUString lcl_ExctractAskVariableAndHint( const OUString& rCommand, OUString& rHint )
1817 : : {
1818 : : // the first word after "ASK " is the variable
1819 : : // the text after the variable and before a '\' is the hint
1820 : : // if no hint is set the variable is used as hint
1821 : : // the quotes of the hint have to be removed
1822 : 3 : sal_Int32 nIndex = rCommand.indexOf( ' ', 2);//find last space after 'ASK'
1823 [ + + ]: 6 : while(rCommand.getStr()[nIndex] == ' ')
1824 : 3 : ++nIndex;
1825 : 3 : OUString sShortCommand( rCommand.copy( nIndex ) ); //cut off the " ASK "
1826 : :
1827 : 3 : nIndex = 0;
1828 : 3 : sShortCommand = sShortCommand.getToken( 0, '\\', nIndex);
1829 : 3 : nIndex = 0;
1830 : 3 : OUString sRet = sShortCommand.getToken( 0, ' ', nIndex);
1831 [ + - ]: 3 : if( nIndex > 0)
1832 : 3 : rHint = sShortCommand.copy( nIndex );
1833 [ - + ]: 3 : if( rHint.isEmpty() )
1834 : 0 : rHint = sRet;
1835 : 3 : return sRet;
1836 : : }
1837 : :
1838 : :
1839 : 0 : bool lcl_FindInCommand(
1840 : : const OUString& rCommand,
1841 : : sal_Unicode cSwitch,
1842 : : OUString& rValue )
1843 : : {
1844 : 0 : bool bRet = false;
1845 : 0 : OUString sSearch('\\');
1846 : 0 : sSearch += OUString( cSwitch );
1847 : 0 : sal_Int32 nIndex = rCommand.indexOf( sSearch );
1848 [ # # ]: 0 : if( nIndex >= 0 )
1849 : : {
1850 : 0 : bRet = true;
1851 : : //find next '\' or end of string
1852 : 0 : sal_Int32 nEndIndex = rCommand.indexOf( '\\', nIndex + 1);
1853 [ # # ]: 0 : if( nEndIndex < 0 )
1854 : 0 : nEndIndex = rCommand.getLength() - 1;
1855 [ # # ]: 0 : if( nEndIndex - nIndex > 3 )
1856 : 0 : rValue = rCommand.copy( nIndex + 3, nEndIndex - nIndex - 3);
1857 : : }
1858 : 0 : return bRet;
1859 : : }
1860 : :
1861 : :
1862 : :
1863 : 3 : void DomainMapper_Impl::GetCurrentLocale(lang::Locale& rLocale)
1864 : : {
1865 [ + - ]: 3 : PropertyMapPtr pTopContext = GetTopContext();
1866 : 3 : PropertyDefinition aCharLocale( PROP_CHAR_LOCALE, true );
1867 [ + - ]: 3 : PropertyMap::iterator aLocaleIter = pTopContext->find( aCharLocale );
1868 [ - + ]: 3 : if( aLocaleIter != pTopContext->end())
1869 [ # # ]: 0 : aLocaleIter->second >>= rLocale;
1870 : : else
1871 : : {
1872 [ + - ]: 3 : PropertyMapPtr pParaContext = GetTopContextOfType(CONTEXT_PARAGRAPH);
1873 [ + - ]: 3 : aLocaleIter = pParaContext->find(aCharLocale);
1874 [ + - ]: 3 : if( aLocaleIter != pParaContext->end())
1875 : : {
1876 [ + - ]: 3 : aLocaleIter->second >>= rLocale;
1877 [ + - ]: 3 : }
1878 [ + - ]: 3 : }
1879 : 3 : }
1880 : :
1881 : : /*-------------------------------------------------------------------------
1882 : : extract the number format from the command and apply the resulting number
1883 : : format to the XPropertySet
1884 : : -----------------------------------------------------------------------*/
1885 : 3 : void DomainMapper_Impl::SetNumberFormat( const OUString& rCommand,
1886 : : uno::Reference< beans::XPropertySet >& xPropertySet )
1887 : : {
1888 : 3 : OUString sFormatString = lcl_ParseFormat( rCommand );
1889 : : // find \h - hijri/luna calendar todo: what about saka/era calendar?
1890 : 3 : bool bHijri = 0 < rCommand.indexOf("\\h ");
1891 : 3 : lang::Locale aUSLocale;
1892 : 3 : aUSLocale.Language = "en";
1893 : 3 : aUSLocale.Country = "US";
1894 : :
1895 : : //determine current locale - todo: is it necessary to initialize this locale?
1896 : 3 : lang::Locale aCurrentLocale = aUSLocale;
1897 [ + - ]: 3 : GetCurrentLocale( aCurrentLocale );
1898 [ + - ]: 3 : OUString sFormat = ConversionHelper::ConvertMSFormatStringToSO( sFormatString, aCurrentLocale, bHijri);
1899 : : //get the number formatter and convert the string to a format value
1900 : : try
1901 : : {
1902 [ + - ]: 3 : uno::Reference< util::XNumberFormatsSupplier > xNumberSupplier( m_xTextDocument, uno::UNO_QUERY_THROW );
1903 [ + - ][ + - ]: 3 : sal_Int32 nKey = xNumberSupplier->getNumberFormats()->addNewConverted( sFormat, aUSLocale, aCurrentLocale );
[ + - ][ + - ]
1904 [ + - ]: 3 : xPropertySet->setPropertyValue(
1905 [ + - ][ + - ]: 3 : PropertyNameSupplier::GetPropertyNameSupplier().GetName(PROP_NUMBER_FORMAT),
1906 [ + - ][ + - ]: 6 : uno::makeAny( nKey ));
1907 [ + - ]: 3 : xPropertySet->getPropertyValue(
1908 [ + - ][ + - ]: 3 : PropertyNameSupplier::GetPropertyNameSupplier().GetName(PROP_NUMBER_FORMAT ) ) >>= nKey;
[ + - ][ # # ]
1909 : : }
1910 [ # # ]: 0 : catch(const uno::Exception&)
1911 : : {
1912 : 3 : }
1913 : 3 : }
1914 : :
1915 : :
1916 : :
1917 : 3 : uno::Reference< beans::XPropertySet > DomainMapper_Impl::FindOrCreateFieldMaster(
1918 : : const sal_Char* pFieldMasterService, const OUString& rFieldMasterName )
1919 : : throw(::com::sun::star::uno::Exception)
1920 : : {
1921 : : // query master, create if not available
1922 [ + - ][ + - ]: 3 : uno::Reference< text::XTextFieldsSupplier > xFieldsSupplier( GetTextDocument(), uno::UNO_QUERY_THROW );
1923 [ + - ][ + - ]: 3 : uno::Reference< container::XNameAccess > xFieldMasterAccess = xFieldsSupplier->getTextFieldMasters();
1924 : 3 : uno::Reference< beans::XPropertySet > xMaster;
1925 : 3 : OUString sFieldMasterService( OUString::createFromAscii(pFieldMasterService) );
1926 : 3 : OUStringBuffer aFieldMasterName;
1927 [ + - ]: 3 : aFieldMasterName.appendAscii( pFieldMasterService );
1928 [ + - ]: 3 : aFieldMasterName.append(sal_Unicode('.'));
1929 [ + - ]: 3 : aFieldMasterName.append(rFieldMasterName);
1930 [ + - ]: 3 : OUString sFieldMasterName = aFieldMasterName.makeStringAndClear();
1931 [ + - ][ + - ]: 3 : if(xFieldMasterAccess->hasByName(sFieldMasterName))
[ - + ]
1932 : : {
1933 : : //get the master
1934 [ # # ]: 0 : xMaster = uno::Reference< beans::XPropertySet >(xFieldMasterAccess->getByName(sFieldMasterName),
1935 [ # # ][ # # ]: 0 : uno::UNO_QUERY_THROW);
[ # # ]
1936 : : }
1937 : : else
1938 : : {
1939 : : //create the master
1940 : : xMaster = uno::Reference< beans::XPropertySet >(
1941 [ + - ][ + - ]: 3 : m_xTextFactory->createInstance(sFieldMasterService), uno::UNO_QUERY_THROW);
[ + - ][ + - ]
1942 : : //set the master's name
1943 [ + - ]: 3 : xMaster->setPropertyValue(
1944 [ + - ][ + - ]: 3 : PropertyNameSupplier::GetPropertyNameSupplier().GetName(PROP_NAME),
1945 [ + - ][ + - ]: 6 : uno::makeAny(rFieldMasterName));
1946 : : }
1947 : 3 : return xMaster;
1948 : : }
1949 : :
1950 : : /*-------------------------------------------------------------------------
1951 : : //field context starts with a 0x13
1952 : : -----------------------------------------------------------------------*/
1953 : 39 : void DomainMapper_Impl::PushFieldContext()
1954 : : {
1955 : : #ifdef DEBUG_DOMAINMAPPER
1956 : : dmapper_logger->element("pushFieldContext");
1957 : : #endif
1958 : :
1959 : 39 : uno::Reference< text::XTextAppend > xTextAppend;
1960 [ + - ]: 39 : if (!m_aTextAppendStack.empty())
1961 [ + - ][ + - ]: 39 : xTextAppend = m_aTextAppendStack.top().xTextAppend;
1962 : 39 : uno::Reference< text::XTextRange > xStart;
1963 [ + - ]: 39 : if (xTextAppend.is())
1964 : : {
1965 : : //insert a dummy char to make sure the start range doesn't move together with the to-be-appended text
1966 [ + - ][ + - ]: 39 : xTextAppend->appendTextPortion(OUString( '-' ), uno::Sequence< beans::PropertyValue >() );
[ + - ][ + - ]
1967 [ + - ][ + - ]: 39 : uno::Reference< text::XTextCursor > xCrsr = xTextAppend->createTextCursorByRange( xTextAppend->getEnd() );
[ + - ][ + - ]
1968 [ + - ][ + - ]: 39 : xCrsr->goLeft( 1, false );
1969 [ + - ][ + - ]: 39 : xStart = xCrsr->getStart();
[ + - ]
1970 : : }
1971 [ + - ][ + - ]: 39 : m_aFieldStack.push( FieldContextPtr( new FieldContext( xStart ) ) );
[ + - ][ + - ]
[ + - ]
1972 : 39 : }
1973 : : /*-------------------------------------------------------------------------
1974 : : //the current field context waits for the completion of the command
1975 : : -----------------------------------------------------------------------*/
1976 : 12865 : bool DomainMapper_Impl::IsOpenFieldCommand() const
1977 : : {
1978 [ + + ][ + + ]: 12865 : return !m_aFieldStack.empty() && !m_aFieldStack.top()->IsCommandCompleted();
1979 : : }
1980 : : /*-------------------------------------------------------------------------
1981 : : //the current field context waits for the completion of the command
1982 : : -----------------------------------------------------------------------*/
1983 : 12775 : bool DomainMapper_Impl::IsOpenField() const
1984 : : {
1985 : 12775 : return !m_aFieldStack.empty();
1986 : : }
1987 : :
1988 : :
1989 : 39 : FieldContext::FieldContext(uno::Reference< text::XTextRange > xStart) :
1990 : : m_bFieldCommandCompleted( false )
1991 [ + - ][ + - ]: 39 : ,m_xStartRange( xStart )
1992 : : {
1993 : 39 : }
1994 : :
1995 : :
1996 [ + - ][ + - ]: 39 : FieldContext::~FieldContext()
1997 : : {
1998 : 39 : }
1999 : :
2000 : :
2001 : 90 : void FieldContext::AppendCommand(const OUString& rPart)
2002 : : {
2003 : 90 : m_sCommand += rPart;
2004 : 90 : }
2005 : :
2006 : 3 : ::std::vector<OUString> FieldContext::GetCommandParts() const
2007 : : {
2008 [ + - ]: 3 : ::std::vector<OUString> aResult;
2009 : 3 : sal_Int32 nIndex = 0;
2010 : 3 : bool bInString = false;
2011 : 3 : OUString sPart;
2012 [ + + ]: 18 : while (nIndex != -1)
2013 : : {
2014 : 15 : OUString sToken = GetCommand().getToken(0, ' ', nIndex);
2015 : 15 : bool bInStringNext = bInString;
2016 : :
2017 [ + + ]: 15 : if (sToken.isEmpty())
2018 : 3 : continue;
2019 : :
2020 [ + + ]: 12 : if (sToken.getStr()[0] == '"')
2021 : : {
2022 : 6 : bInStringNext = true;
2023 : 6 : sToken = sToken.copy(1);
2024 : : }
2025 [ + + ]: 12 : if (sToken.getStr()[sToken.getLength() - 1] == '"')
2026 : : {
2027 : 6 : bInStringNext = false;
2028 : 6 : sToken = sToken.copy(0, sToken.getLength() - 1);
2029 : : }
2030 : :
2031 [ - + ]: 12 : if (bInString)
2032 : : {
2033 [ # # ]: 0 : if (bInStringNext)
2034 : : {
2035 : 0 : sPart += OUString(' ');
2036 : 0 : sPart += sToken;
2037 : : }
2038 : : else
2039 : : {
2040 : 0 : sPart += sToken;
2041 [ # # ]: 0 : aResult.push_back(sPart);
2042 : : }
2043 : : }
2044 : : else
2045 : : {
2046 [ - + ]: 12 : if (bInStringNext)
2047 : : {
2048 : 0 : sPart = sToken;
2049 : : }
2050 : : else
2051 : : {
2052 [ + - ]: 12 : aResult.push_back(sToken);
2053 : : }
2054 : : }
2055 : :
2056 [ + + ]: 27 : bInString = bInStringNext;
2057 : 15 : }
2058 : :
2059 : 3 : return aResult;
2060 : : }
2061 : :
2062 : : /*-------------------------------------------------------------------------
2063 : : //collect the pieces of the command
2064 : : -----------------------------------------------------------------------*/
2065 : 90 : void DomainMapper_Impl::AppendFieldCommand(OUString& rPartOfCommand)
2066 : : {
2067 : : #ifdef DEBUG_DOMAINMAPPER
2068 : : dmapper_logger->startElement("appendFieldCommand");
2069 : : dmapper_logger->chars(rPartOfCommand);
2070 : : dmapper_logger->endElement();
2071 : : #endif
2072 : :
2073 [ + - ][ + - ]: 90 : FieldContextPtr pContext = m_aFieldStack.top();
2074 : : OSL_ENSURE( pContext.get(), "no field context available");
2075 [ + - ]: 90 : if( pContext.get() )
2076 : : {
2077 : 90 : pContext->AppendCommand( rPartOfCommand );
2078 [ + - ]: 90 : }
2079 : 90 : }
2080 : :
2081 : :
2082 : : typedef std::multimap < sal_Int32, OUString > TOCStyleMap;
2083 : :
2084 : 39 : const FieldConversionMap_t & lcl_GetFieldConversion()
2085 : : {
2086 [ + + ][ + - ]: 39 : static FieldConversionMap_t aFieldConversionMap;
[ + - ][ # # ]
2087 [ + + ][ + - ]: 39 : static FieldConversionMap_t aEnhancedFieldConversionMap;
[ + - ][ # # ]
2088 : :
2089 : : static bool bFilled = false;
2090 : :
2091 [ + + ]: 39 : if(!bFilled)
2092 : : {
2093 : : static const FieldConversion aFields[] =
2094 : : {
2095 : : // {OUString("ADDRESSBLOCK"), "", "", FIELD_ADDRESSBLOCK },
2096 : : // {OUString("ADVANCE"), "", "", FIELD_ADVANCE },
2097 : : {OUString("ASK"), "SetExpression", "SetExpression", FIELD_ASK },
2098 : : {OUString("AUTONUM"), "SetExpression", "SetExpression", FIELD_AUTONUM },
2099 : : {OUString("AUTONUMLGL"), "SetExpression", "SetExpression", FIELD_AUTONUMLGL },
2100 : : {OUString("AUTONUMOUT"), "SetExpression", "SetExpression", FIELD_AUTONUMOUT },
2101 : : {OUString("AUTHOR"), "DocInfo.CreateAuthor", "", FIELD_AUTHOR },
2102 : : {OUString("DATE"), "DateTime", "", FIELD_DATE },
2103 : : {OUString("COMMENTS"), "DocInfo.Description", "", FIELD_COMMENTS },
2104 : : {OUString("CREATEDATE"), "DocInfo.CreateDateTime", "", FIELD_CREATEDATE },
2105 : : {OUString("DOCPROPERTY"), "", "", FIELD_DOCPROPERTY },
2106 : : {OUString("DOCVARIABLE"), "User", "", FIELD_DOCVARIABLE },
2107 : : {OUString("EDITTIME"), "DocInfo.EditTime", "", FIELD_EDITTIME },
2108 : : {OUString("EQ"), "", "", FIELD_EQ },
2109 : : {OUString("FILLIN"), "Input", "", FIELD_FILLIN },
2110 : : {OUString("FILENAME"), "FileName", "", FIELD_FILENAME },
2111 : : // {OUString("FILESIZE"), "", "", FIELD_FILESIZE },
2112 : : // {OUString("FORMULA"), "", "", FIELD_FORMULA },
2113 : : {OUString("FORMCHECKBOX"), "", "", FIELD_FORMCHECKBOX},
2114 : : {OUString("FORMDROPDOWN"), "DropDown", "", FIELD_FORMDROPDOWN},
2115 : : {OUString("FORMTEXT"), "Input", "", FIELD_FORMTEXT},
2116 : : // {OUString("GOTOBUTTON"), "", "", FIELD_GOTOBUTTON },
2117 : : {OUString("HYPERLINK"), "", "", FIELD_HYPERLINK },
2118 : : {OUString("IF"), "ConditionalText", "", FIELD_IF },
2119 : : // {OUString("INFO"), "","", FIELD_INFO },
2120 : : // {OUString("INCLUDEPICTURE"), "", "", FIELD_INCLUDEPICTURE},
2121 : : {OUString("KEYWORDS"), "DocInfo.KeyWords", "", FIELD_KEYWORDS },
2122 : : {OUString("LASTSAVEDBY"), "DocInfo.ChangeAuthor", "", FIELD_LASTSAVEDBY },
2123 : : {OUString("MACROBUTTON"), "Macro", "", FIELD_MACROBUTTON },
2124 : : {OUString("MERGEFIELD"), "Database", "Database", FIELD_MERGEFIELD},
2125 : : {OUString("MERGEREC"), "DatabaseNumberOfSet", "", FIELD_MERGEREC },
2126 : : // {OUString("MERGESEQ"), "", "", FIELD_MERGESEQ },
2127 : : {OUString("NEXT"), "DatabaseNextSet", "", FIELD_NEXT },
2128 : : {OUString("NEXTIF"), "DatabaseNextSet", "", FIELD_NEXTIF },
2129 : : {OUString("PAGE"), "PageNumber", "", FIELD_PAGE },
2130 : : {OUString("PAGEREF"), "GetReference", "", FIELD_PAGEREF },
2131 : : {OUString("REF"), "GetReference", "", FIELD_REF },
2132 : : {OUString("REVNUM"), "DocInfo.Revision", "", FIELD_REVNUM },
2133 : : {OUString("SAVEDATE"), "DocInfo.Change", "", FIELD_SAVEDATE },
2134 : : // {OUString("SECTION"), "", "", FIELD_SECTION },
2135 : : // {OUString("SECTIONPAGES"), "", "", FIELD_SECTIONPAGES },
2136 : : {OUString("SEQ"), "SetExpression", "SetExpression", FIELD_SEQ },
2137 : : // {OUString("SET"), "","", FIELD_SET },
2138 : : // {OUString("SKIPIF"),"", "", FIELD_SKIPIF },
2139 : : // {OUString("STYLEREF"),"", "", FIELD_STYLEREF },
2140 : : {OUString("SUBJECT"), "DocInfo.Subject", "", FIELD_SUBJECT },
2141 : : // {OUString("SYMBOL"),"", "", FIELD_SYMBOL },
2142 : : {OUString("TEMPLATE"), "TemplateName", "", FIELD_TEMPLATE},
2143 : : {OUString("TIME"), "DateTime", "", FIELD_TIME },
2144 : : {OUString("TITLE"), "DocInfo.Title", "", FIELD_TITLE },
2145 : : {OUString("USERINITIALS"), "Author", "", FIELD_USERINITIALS },
2146 : : // {OUString("USERADDRESS"), "", "", FIELD_USERADDRESS },
2147 : : {OUString("USERNAME"), "Author", "", FIELD_USERNAME },
2148 : :
2149 : :
2150 : : {OUString("TOC"), "com.sun.star.text.ContentIndex", "", FIELD_TOC},
2151 : : {OUString("TC"), "com.sun.star.text.ContentIndexMark", "", FIELD_TC},
2152 : : {OUString("NUMCHARS"), "CharacterCount", "", FIELD_NUMCHARS},
2153 : : {OUString("NUMWORDS"), "WordCount", "", FIELD_NUMWORDS},
2154 : : {OUString("NUMPAGES"), "PageCount", "", FIELD_NUMPAGES},
2155 : :
2156 : : // {OUString(""), "", "", FIELD_},
2157 : :
2158 [ + - ][ + - ]: 540 : };
[ + + ]
2159 : 12 : size_t nConversions = SAL_N_ELEMENTS(aFields);
2160 [ + + ]: 528 : for( size_t nConversion = 0; nConversion < nConversions; ++nConversion)
2161 : : {
2162 : : aFieldConversionMap.insert( FieldConversionMap_t::value_type(
2163 : : aFields[nConversion].sWordCommand,
2164 [ + - ]: 516 : aFields[nConversion] ));
2165 : : }
2166 : :
2167 : 12 : bFilled = true;
2168 : : }
2169 : :
2170 : 39 : return aFieldConversionMap;
2171 : : }
2172 : :
2173 : 3 : const FieldConversionMap_t & lcl_GetEnhancedFieldConversion()
2174 : : {
2175 [ + - ][ + - ]: 3 : static FieldConversionMap_t aEnhancedFieldConversionMap;
[ + - ][ # # ]
2176 : :
2177 : : static bool bFilled = false;
2178 : :
2179 [ + - ]: 3 : if(!bFilled)
2180 : : {
2181 : : static const FieldConversion aEnhancedFields[] =
2182 : : {
2183 : : {OUString("FORMCHECKBOX"), "FormFieldmark", "", FIELD_FORMCHECKBOX},
2184 : : {OUString("FORMDROPDOWN"), "FormFieldmark", "", FIELD_FORMDROPDOWN},
2185 : : {OUString("FORMTEXT"), "Fieldmark", "", FIELD_FORMTEXT},
2186 [ + - ][ + - ]: 15 : };
[ + + ]
2187 : :
2188 : 3 : size_t nConversions = SAL_N_ELEMENTS(aEnhancedFields);
2189 [ + + ]: 12 : for( size_t nConversion = 0; nConversion < nConversions; ++nConversion)
2190 : : {
2191 : : aEnhancedFieldConversionMap.insert( FieldConversionMap_t::value_type(
2192 : : aEnhancedFields[nConversion].sWordCommand,
2193 [ + - ]: 9 : aEnhancedFields[nConversion] ));
2194 : : }
2195 : : }
2196 : 3 : return aEnhancedFieldConversionMap;
2197 : : }
2198 : :
2199 : 3 : void DomainMapper_Impl::handleFieldAsk
2200 : : (FieldContextPtr pContext,
2201 : : PropertyNameSupplier& rPropNameSupplier,
2202 : : uno::Reference< uno::XInterface > & xFieldInterface,
2203 : : uno::Reference< beans::XPropertySet > xFieldProperties)
2204 : : {
2205 : : //doesn the command contain a variable name?
2206 : 3 : OUString sVariable, sHint;
2207 : :
2208 : 3 : sVariable = lcl_ExctractAskVariableAndHint( pContext->GetCommand(),
2209 : 3 : sHint );
2210 [ + - ]: 3 : if(!sVariable.isEmpty())
2211 : : {
2212 : : // determine field master name
2213 : : uno::Reference< beans::XPropertySet > xMaster =
2214 : : FindOrCreateFieldMaster
2215 [ + - ]: 3 : ("com.sun.star.text.FieldMaster.SetExpression", sVariable );
2216 : : // An ASK field is always a string of characters
2217 [ + - ][ + - ]: 3 : xMaster->setPropertyValue(rPropNameSupplier.GetName(PROP_SUB_TYPE), uno::makeAny(text::SetVariableType::STRING));
[ + - ][ + - ]
2218 : :
2219 : : // attach the master to the field
2220 : : uno::Reference< text::XDependentTextField > xDependentField
2221 [ + - ]: 3 : ( xFieldInterface, uno::UNO_QUERY_THROW );
2222 [ + - ][ + - ]: 3 : xDependentField->attachTextFieldMaster( xMaster );
2223 : :
2224 : : // set input flag at the field
2225 [ + - ]: 3 : xFieldProperties->setPropertyValue(
2226 [ + - ][ + - ]: 3 : rPropNameSupplier.GetName(PROP_IS_INPUT), uno::makeAny( true ));
[ + - ]
2227 : : // set the prompt
2228 [ + - ]: 3 : xFieldProperties->setPropertyValue(
2229 [ + - ]: 3 : rPropNameSupplier.GetName(PROP_HINT),
2230 [ + - ][ + - ]: 6 : uno::makeAny( sHint ));
2231 [ + - ][ + - ]: 3 : xFieldProperties->setPropertyValue(rPropNameSupplier.GetName(PROP_SUB_TYPE), uno::makeAny(text::SetVariableType::STRING));
[ + - ][ + - ]
2232 : : // The ASK has no field value to display
2233 [ + - ][ + - ]: 3 : xFieldProperties->setPropertyValue(rPropNameSupplier.GetName(PROP_IS_VISIBLE), uno::makeAny(sal_False));
[ + - ][ + - ]
2234 : : }
2235 : : else
2236 : : {
2237 : : //don't insert the field
2238 : : //todo: maybe import a 'normal' input field here?
2239 [ # # ]: 0 : xFieldInterface = 0;
2240 : 3 : }
2241 : 3 : }
2242 : :
2243 : 0 : void DomainMapper_Impl::handleAutoNum
2244 : : (FieldContextPtr pContext,
2245 : : PropertyNameSupplier& rPropNameSupplier,
2246 : : uno::Reference< uno::XInterface > & xFieldInterface,
2247 : : uno::Reference< beans::XPropertySet > xFieldProperties)
2248 : : {
2249 : : //create a sequence field master "AutoNr"
2250 : : uno::Reference< beans::XPropertySet > xMaster =
2251 : : FindOrCreateFieldMaster
2252 : : ("com.sun.star.text.FieldMaster.SetExpression",
2253 [ # # ]: 0 : "AutoNr");
2254 : :
2255 [ # # ][ # # ]: 0 : xMaster->setPropertyValue( rPropNameSupplier.GetName(PROP_SUB_TYPE),
2256 [ # # ][ # # ]: 0 : uno::makeAny(text::SetVariableType::SEQUENCE));
2257 : :
2258 : : //apply the numbering type
2259 [ # # ]: 0 : xFieldProperties->setPropertyValue(
2260 [ # # ]: 0 : rPropNameSupplier.GetName(PROP_NUMBERING_TYPE),
2261 [ # # ][ # # ]: 0 : uno::makeAny( lcl_ParseNumberingType(pContext->GetCommand()) ));
2262 : : // attach the master to the field
2263 : : uno::Reference< text::XDependentTextField > xDependentField
2264 [ # # ]: 0 : ( xFieldInterface, uno::UNO_QUERY_THROW );
2265 [ # # ][ # # ]: 0 : xDependentField->attachTextFieldMaster( xMaster );
2266 : 0 : }
2267 : :
2268 : 0 : void DomainMapper_Impl::handleAuthor
2269 : : (FieldContextPtr pContext,
2270 : : PropertyNameSupplier& rPropNameSupplier,
2271 : : uno::Reference< uno::XInterface > & /*xFieldInterface*/,
2272 : : uno::Reference< beans::XPropertySet > xFieldProperties,
2273 : : FieldId eFieldId )
2274 : : {
2275 [ # # ]: 0 : if ( eFieldId != FIELD_USERINITIALS )
2276 [ # # ]: 0 : xFieldProperties->setPropertyValue
2277 [ # # ][ # # ]: 0 : ( rPropNameSupplier.GetName(PROP_FULL_NAME), uno::makeAny( true ));
[ # # ]
2278 : :
2279 : 0 : sal_Int32 nLen = sizeof( " AUTHOR" );
2280 [ # # ]: 0 : if ( eFieldId != FIELD_AUTHOR )
2281 : : {
2282 [ # # ]: 0 : if ( eFieldId == FIELD_USERINITIALS )
2283 : 0 : nLen = sizeof( " USERINITIALS" );
2284 [ # # ]: 0 : else if ( eFieldId == FIELD_USERNAME )
2285 : 0 : nLen = sizeof( " USERNAME" );
2286 : : }
2287 : :
2288 : : OUString sParam =
2289 [ # # ]: 0 : lcl_ExtractParameter(pContext->GetCommand(), nLen );
2290 : :
2291 [ # # ]: 0 : if(!sParam.isEmpty())
2292 : : {
2293 [ # # ]: 0 : xFieldProperties->setPropertyValue(
2294 [ # # ]: 0 : rPropNameSupplier.GetName( PROP_IS_FIXED ),
2295 [ # # ][ # # ]: 0 : uno::makeAny( true ));
2296 : : //PROP_CURRENT_PRESENTATION is set later anyway
2297 : 0 : }
2298 : 0 : }
2299 : :
2300 : 0 : void DomainMapper_Impl::handleDocProperty
2301 : : (FieldContextPtr pContext,
2302 : : PropertyNameSupplier& rPropNameSupplier,
2303 : : uno::Reference< uno::XInterface > & xFieldInterface,
2304 : : uno::Reference< beans::XPropertySet > xFieldProperties)
2305 : : {
2306 : : //some docproperties should be imported as document statistic fields, some as DocInfo fields
2307 : : //others should be user fields
2308 : : OUString sParam =
2309 [ # # ]: 0 : lcl_ExtractParameter(pContext->GetCommand(), sizeof(" DOCPROPERTY") );
2310 : :
2311 [ # # ]: 0 : if(!sParam.isEmpty())
2312 : : {
2313 : : #define SET_ARABIC 0x01
2314 : : #define SET_FULL_NAME 0x02
2315 : : #define SET_DATE 0x04
2316 : : struct DocPropertyMap
2317 : : {
2318 : : const sal_Char* pDocPropertyName;
2319 : : const sal_Char* pServiceName;
2320 : : sal_uInt8 nFlags;
2321 : : };
2322 : : static const DocPropertyMap aDocProperties[] =
2323 : : {
2324 : : {"CreateTime", "DocInfo.CreateDateTime", SET_DATE},
2325 : : {"Characters", "CharacterCount", SET_ARABIC},
2326 : : {"Comments", "DocInfo.Description", 0},
2327 : : {"Keywords", "DocInfo.KeyWords", 0},
2328 : : {"LastPrinted", "DocInfo.PrintDateTime", 0},
2329 : : {"LastSavedBy", "DocInfo.ChangeAuthor", 0},
2330 : : {"LastSavedTime", "DocInfo.ChangeDateTime", SET_DATE},
2331 : : {"Paragraphs", "ParagraphCount", SET_ARABIC},
2332 : : {"RevisionNumber", "DocInfo.Revision", 0},
2333 : : {"Subject", "DocInfo.Subject", 0},
2334 : : {"Template", "TemplateName", 0},
2335 : : {"Title", "DocInfo.Title", 0},
2336 : : {"TotalEditingTime", "DocInfo.EditTime", 0},
2337 : : {"Words", "WordCount", SET_ARABIC}
2338 : :
2339 : : //other available DocProperties:
2340 : : //Bytes, Category, CharactersWithSpaces, Company
2341 : : //HyperlinkBase,
2342 : : //Lines, Manager, NameofApplication, ODMADocId, Pages,
2343 : : //Security,
2344 : : };
2345 : : //search for a field mapping
2346 : 0 : OUString sFieldServiceName;
2347 : 0 : sal_uInt16 nMap = 0;
2348 [ # # ]: 0 : for( ; nMap < sizeof(aDocProperties) / sizeof(DocPropertyMap);
2349 : : ++nMap )
2350 : : {
2351 [ # # ]: 0 : if(sParam.equalsAscii(aDocProperties[nMap].pDocPropertyName))
2352 : : {
2353 : : sFieldServiceName =
2354 : : OUString::createFromAscii
2355 : 0 : (aDocProperties[nMap].pServiceName);
2356 : 0 : break;
2357 : : }
2358 : : }
2359 : 0 : OUString sServiceName("com.sun.star.text.TextField.");
2360 : 0 : bool bIsCustomField = false;
2361 [ # # ]: 0 : if(sFieldServiceName.isEmpty())
2362 : : {
2363 : : //create a custom property field
2364 : 0 : sServiceName += "DocInfo.Custom";
2365 : 0 : bIsCustomField = true;
2366 : : }
2367 : : else
2368 : : {
2369 : 0 : sServiceName += sFieldServiceName;
2370 : : }
2371 [ # # ]: 0 : if (m_xTextFactory.is())
2372 [ # # ][ # # ]: 0 : xFieldInterface = m_xTextFactory->createInstance(sServiceName);
[ # # ]
2373 : : xFieldProperties =
2374 : : uno::Reference< beans::XPropertySet >( xFieldInterface,
2375 [ # # ][ # # ]: 0 : uno::UNO_QUERY_THROW);
2376 [ # # ]: 0 : if( bIsCustomField )
2377 [ # # ]: 0 : xFieldProperties->setPropertyValue(
2378 [ # # ][ # # ]: 0 : rPropNameSupplier.GetName(PROP_NAME), uno::makeAny( sParam ));
[ # # ]
2379 : : else
2380 : : {
2381 [ # # ]: 0 : if(0 != (aDocProperties[nMap].nFlags & SET_ARABIC))
2382 [ # # ]: 0 : xFieldProperties->setPropertyValue(
2383 [ # # ]: 0 : rPropNameSupplier.GetName(PROP_NUMBERING_TYPE),
2384 [ # # ][ # # ]: 0 : uno::makeAny( style::NumberingType::ARABIC ));
2385 [ # # ]: 0 : else if(0 != (aDocProperties[nMap].nFlags & SET_FULL_NAME))
2386 [ # # ]: 0 : xFieldProperties->setPropertyValue(
2387 [ # # ]: 0 : rPropNameSupplier.GetName(PROP_FULL_NAME),
2388 [ # # ][ # # ]: 0 : uno::makeAny( true ));
2389 [ # # ]: 0 : else if(0 != (aDocProperties[nMap].nFlags & SET_DATE))
2390 : : {
2391 [ # # ]: 0 : xFieldProperties->setPropertyValue(
2392 [ # # ]: 0 : rPropNameSupplier.GetName(PROP_IS_DATE),
2393 [ # # ][ # # ]: 0 : uno::makeAny( true ));
2394 [ # # ]: 0 : SetNumberFormat( pContext->GetCommand(), xFieldProperties );
2395 : : }
2396 : 0 : }
2397 : 0 : }
2398 : :
2399 : : #undef SET_ARABIC
2400 : : #undef SET_FULL_NAME
2401 : : #undef SET_DATE
2402 : 0 : }
2403 : :
2404 : 0 : void DomainMapper_Impl::handleToc
2405 : : (FieldContextPtr pContext,
2406 : : PropertyNameSupplier& rPropNameSupplier,
2407 : : uno::Reference< uno::XInterface > & /*xFieldInterface*/,
2408 : : uno::Reference< beans::XPropertySet > /*xFieldProperties*/,
2409 : : const OUString & sTOCServiceName)
2410 : : {
2411 : 0 : OUString sValue;
2412 : 0 : bool bTableOfFigures = false;
2413 : 0 : bool bHyperlinks = false;
2414 : 0 : bool bFromOutline = false;
2415 : 0 : bool bFromEntries = false;
2416 : 0 : sal_Int16 nMaxLevel = 10;
2417 : 0 : OUString sTemplate;
2418 : 0 : OUString sChapterNoSeparator;
2419 : : // \a Builds a table of figures but does not include the captions's label and number
2420 [ # # ]: 0 : if( lcl_FindInCommand( pContext->GetCommand(), 'a', sValue ))
2421 : : { //make it a table of figures
2422 : 0 : bTableOfFigures = true;
2423 : : }
2424 : : // \b Uses a bookmark to specify area of document from which to build table of contents
2425 : : // if( lcl_FindInCommand( pContext->GetCommand(), 'b', sValue ))
2426 : : // { //todo: sValue contains the bookmark name - unsupported feature
2427 : : // }
2428 [ # # ]: 0 : if( lcl_FindInCommand( pContext->GetCommand(), 'c', sValue ))
2429 : : // \c Builds a table of figures of the given label
2430 : : {
2431 : : //todo: sValue contains the label's name
2432 : 0 : bTableOfFigures = true;
2433 : : }
2434 : : // \d Defines the separator between sequence and page numbers
2435 [ # # ]: 0 : if( lcl_FindInCommand( pContext->GetCommand(), 'd', sValue ))
2436 : : {
2437 : : //todo: insert the chapter number into each level and insert the separator additionally
2438 : 0 : sChapterNoSeparator = sValue;
2439 : : }
2440 : : // \f Builds a table of contents using TC entries instead of outline levels
2441 [ # # ]: 0 : if( lcl_FindInCommand( pContext->GetCommand(), 'f', sValue ))
2442 : : {
2443 : : //todo: sValue can contain a TOC entry identifier - use unclear
2444 : 0 : bFromEntries = true;
2445 : : }
2446 : : // \h Hyperlinks the entries and page numbers within the table of contents
2447 [ # # ]: 0 : if( lcl_FindInCommand( pContext->GetCommand(), 'h', sValue ))
2448 : : {
2449 : : //todo: make all entries to hyperlinks
2450 : 0 : bHyperlinks = true;
2451 : : }
2452 : : // \l Defines the TC entries field level used to build a table of contents
2453 : : // if( lcl_FindInCommand( pContext->GetCommand(), 'l', sValue ))
2454 : : // {
2455 : : //todo: entries can only be included completely
2456 : : // }
2457 : : // \n Builds a table of contents or a range of entries, sucah as �1-9�, in a table of contents without page numbers
2458 : : // if( lcl_FindInCommand( pContext->GetCommand(), 'n', sValue ))
2459 : : // {
2460 : : //todo: what does the description mean?
2461 : : // }
2462 : : // \o Builds a table of contents by using outline levels instead of TC entries
2463 [ # # ]: 0 : if( lcl_FindInCommand( pContext->GetCommand(), 'o', sValue ))
2464 : : {
2465 : 0 : bFromOutline = true;
2466 : 0 : sal_Int32 nIndex = 0;
2467 : 0 : sValue.getToken( 0, '-', nIndex );
2468 [ # # ][ # # ]: 0 : nMaxLevel = static_cast<sal_Int16>(nIndex != -1 ? sValue.copy(nIndex).toInt32() : 0);
2469 : : }
2470 : : // \p Defines the separator between the table entry and its page number
2471 : 0 : if( lcl_FindInCommand( pContext->GetCommand(), 'p', sValue ))
2472 : : { }
2473 : : // \s Builds a table of contents by using a sequence type
2474 : 0 : if( lcl_FindInCommand( pContext->GetCommand(), 's', sValue ))
2475 : : { }
2476 : : // \t Builds a table of contents by using style names other than the standard outline styles
2477 [ # # ]: 0 : if( lcl_FindInCommand( pContext->GetCommand(), 't', sValue ))
2478 : : {
2479 : 0 : sal_Int32 nPos = 0;
2480 : 0 : OUString sToken = sValue.getToken( 1, '"', nPos);
2481 [ # # ]: 0 : sTemplate = sToken.isEmpty() ? sValue : sToken;
2482 : : }
2483 : : // \u Builds a table of contents by using the applied paragraph outline level
2484 [ # # ]: 0 : if( lcl_FindInCommand( pContext->GetCommand(), 'u', sValue ))
2485 : : {
2486 : 0 : bFromOutline = true;
2487 : : //todo: what doesn 'the applied paragraph outline level' refer to?
2488 : : }
2489 : : // \w Preserve tab characters within table entries
2490 : : // if( lcl_FindInCommand( pContext->GetCommand(), 'w', sValue ))
2491 : : // {
2492 : : //todo: not supported
2493 : : // }
2494 : : // \x Preserve newline characters within table entries
2495 : : // if( lcl_FindInCommand( pContext->GetCommand(), 'x', sValue ))
2496 : : // {
2497 : : //todo: unsupported
2498 : : // }
2499 : : // \z Hides page numbers within the table of contens when shown in Web Layout View
2500 : : // if( lcl_FindInCommand( pContext->GetCommand(), 'z', sValue ))
2501 : : // { //todo: unsupported feature }
2502 : :
2503 : : //if there's no option then it should be created from outline
2504 [ # # ][ # # ]: 0 : if( !bFromOutline && !bFromEntries && sTemplate.isEmpty() )
[ # # ][ # # ]
2505 : 0 : bFromOutline = true;
2506 : :
2507 : 0 : uno::Reference< beans::XPropertySet > xTOC;
2508 [ # # ]: 0 : if (m_xTextFactory.is())
2509 : : xTOC.set(
2510 [ # # ]: 0 : m_xTextFactory->createInstance
2511 : : ( bTableOfFigures ?
2512 : : "com.sun.star.text.IllustrationsIndex"
2513 : 0 : : sTOCServiceName),
2514 [ # # ][ # # ]: 0 : uno::UNO_QUERY_THROW);
[ # # ][ # # ]
[ # # ]
2515 [ # # ]: 0 : if (xTOC.is())
2516 [ # # ][ # # ]: 0 : xTOC->setPropertyValue(rPropNameSupplier.GetName( PROP_TITLE ), uno::makeAny(OUString()));
[ # # ][ # # ]
2517 [ # # ][ # # ]: 0 : if( !bTableOfFigures && xTOC.is() )
[ # # ]
2518 : : {
2519 [ # # ][ # # ]: 0 : xTOC->setPropertyValue( rPropNameSupplier.GetName( PROP_LEVEL ), uno::makeAny( nMaxLevel ) );
[ # # ][ # # ]
2520 [ # # ][ # # ]: 0 : xTOC->setPropertyValue( rPropNameSupplier.GetName( PROP_CREATE_FROM_OUTLINE ), uno::makeAny( bFromOutline ));
[ # # ][ # # ]
2521 [ # # ][ # # ]: 0 : xTOC->setPropertyValue( rPropNameSupplier.GetName( PROP_CREATE_FROM_MARKS ), uno::makeAny( bFromEntries ));
[ # # ][ # # ]
2522 [ # # ]: 0 : if( !sTemplate.isEmpty() )
2523 : : {
2524 : : //the string contains comma separated the names and related levels
2525 : : //like: "Heading 1,1,Heading 2,2"
2526 [ # # ]: 0 : TOCStyleMap aMap;
2527 : : sal_Int32 nLevel;
2528 : 0 : sal_Int32 nPosition = 0;
2529 [ # # ]: 0 : while( nPosition >= 0)
2530 : : {
2531 : 0 : OUString sStyleName = sTemplate.getToken( 0, ',', nPosition );
2532 : : //empty tokens should be skipped
2533 [ # # ][ # # ]: 0 : while( sStyleName.isEmpty() && nPosition > 0 )
[ # # ]
2534 : 0 : sStyleName = sTemplate.getToken( 0, ',', nPosition );
2535 : 0 : nLevel = sTemplate.getToken( 0, ',', nPosition ).toInt32();
2536 [ # # ]: 0 : if( !nLevel )
2537 : 0 : nLevel = 1;
2538 [ # # ]: 0 : if( !sStyleName.isEmpty() )
2539 [ # # ]: 0 : aMap.insert( TOCStyleMap::value_type(nLevel, sStyleName) );
2540 : 0 : }
2541 : 0 : uno::Reference< container::XIndexReplace> xParaStyles;
2542 [ # # ][ # # ]: 0 : xTOC->getPropertyValue(rPropNameSupplier.GetName(PROP_LEVEL_PARAGRAPH_STYLES)) >>= xParaStyles;
[ # # ][ # # ]
2543 [ # # ]: 0 : for( nLevel = 1; nLevel < 10; ++nLevel)
2544 : : {
2545 [ # # ]: 0 : sal_Int32 nLevelCount = aMap.count( nLevel );
2546 [ # # ]: 0 : if( nLevelCount )
2547 : : {
2548 [ # # ]: 0 : TOCStyleMap::iterator aTOCStyleIter = aMap.find( nLevel );
2549 : :
2550 [ # # ]: 0 : uno::Sequence< OUString> aStyles( nLevelCount );
2551 [ # # ]: 0 : for ( sal_Int32 nStyle = 0; nStyle < nLevelCount; ++nStyle, ++aTOCStyleIter )
2552 : : {
2553 [ # # ]: 0 : aStyles[nStyle] = aTOCStyleIter->second;
2554 : : }
2555 [ # # ][ # # ]: 0 : xParaStyles->replaceByIndex(nLevel - 1, uno::makeAny(aStyles));
[ # # ][ # # ]
2556 : : }
2557 : : }
2558 [ # # ][ # # ]: 0 : xTOC->setPropertyValue(rPropNameSupplier.GetName(PROP_CREATE_FROM_LEVEL_PARAGRAPH_STYLES), uno::makeAny( true ));
[ # # ][ # # ]
2559 : :
2560 : : }
2561 [ # # ][ # # ]: 0 : if(bHyperlinks || !sChapterNoSeparator.isEmpty())
[ # # ]
2562 : : {
2563 : 0 : uno::Reference< container::XIndexReplace> xLevelFormats;
2564 [ # # ][ # # ]: 0 : xTOC->getPropertyValue(rPropNameSupplier.GetName(PROP_LEVEL_FORMAT)) >>= xLevelFormats;
[ # # ][ # # ]
2565 [ # # ][ # # ]: 0 : sal_Int32 nLevelCount = xLevelFormats->getCount();
2566 : : //start with level 1, 0 is the header level
2567 [ # # ]: 0 : for( sal_Int32 nLevel = 1; nLevel < nLevelCount; ++nLevel)
2568 : : {
2569 [ # # ]: 0 : uno::Sequence< beans::PropertyValues > aLevel;
2570 [ # # ][ # # ]: 0 : xLevelFormats->getByIndex( nLevel ) >>= aLevel;
[ # # ]
2571 : : //create a copy of the level and add two new entries - hyperlink start and end
2572 : 0 : bool bChapterNoSeparator = !sChapterNoSeparator.isEmpty();
2573 [ # # ][ # # ]: 0 : sal_Int32 nAdd = (bHyperlinks && bChapterNoSeparator) ? 4 : 2;
2574 [ # # ]: 0 : uno::Sequence< beans::PropertyValues > aNewLevel( aLevel.getLength() + nAdd);
2575 [ # # ]: 0 : beans::PropertyValues* pNewLevel = aNewLevel.getArray();
2576 [ # # ]: 0 : if( bHyperlinks )
2577 : : {
2578 [ # # ]: 0 : beans::PropertyValues aHyperlink(1);
2579 [ # # ][ # # ]: 0 : aHyperlink[0].Name = rPropNameSupplier.GetName( PROP_TOKEN_TYPE );
2580 [ # # ][ # # ]: 0 : aHyperlink[0].Value <<= rPropNameSupplier.GetName( PROP_TOKEN_HYPERLINK_START );
[ # # ]
2581 [ # # ]: 0 : pNewLevel[0] = aHyperlink;
2582 [ # # ][ # # ]: 0 : aHyperlink[0].Value <<= rPropNameSupplier.GetName( PROP_TOKEN_HYPERLINK_END );
[ # # ]
2583 [ # # ][ # # ]: 0 : pNewLevel[aNewLevel.getLength() -1] = aHyperlink;
2584 : : }
2585 [ # # ]: 0 : if( bChapterNoSeparator )
2586 : : {
2587 [ # # ]: 0 : beans::PropertyValues aChapterNo(2);
2588 [ # # ][ # # ]: 0 : aChapterNo[0].Name = rPropNameSupplier.GetName( PROP_TOKEN_TYPE );
2589 [ # # ][ # # ]: 0 : aChapterNo[0].Value <<= rPropNameSupplier.GetName( PROP_TOKEN_CHAPTER_INFO );
[ # # ]
2590 [ # # ][ # # ]: 0 : aChapterNo[1].Name = rPropNameSupplier.GetName( PROP_CHAPTER_FORMAT );
2591 : : //todo: is ChapterFormat::Number correct?
2592 [ # # ][ # # ]: 0 : aChapterNo[1].Value <<= (sal_Int16)text::ChapterFormat::NUMBER;
2593 [ # # ][ # # ]: 0 : pNewLevel[aNewLevel.getLength() - (bHyperlinks ? 4 : 2) ] = aChapterNo;
2594 : :
2595 [ # # ]: 0 : beans::PropertyValues aChapterSeparator(2);
2596 [ # # ][ # # ]: 0 : aChapterSeparator[0].Name = rPropNameSupplier.GetName( PROP_TOKEN_TYPE );
2597 [ # # ][ # # ]: 0 : aChapterSeparator[0].Value <<= rPropNameSupplier.GetName( PROP_TOKEN_TEXT );
[ # # ]
2598 [ # # ][ # # ]: 0 : aChapterSeparator[1].Name = rPropNameSupplier.GetName( PROP_TEXT );
2599 [ # # ][ # # ]: 0 : aChapterSeparator[1].Value <<= sChapterNoSeparator;
2600 [ # # ][ # # ]: 0 : pNewLevel[aNewLevel.getLength() - (bHyperlinks ? 3 : 1)] = aChapterSeparator;
[ # # ][ # # ]
2601 : : }
2602 : : //copy the 'old' entries except the last (page no)
2603 [ # # ]: 0 : for( sal_Int32 nToken = 0; nToken < aLevel.getLength() - 1; ++nToken)
2604 : : {
2605 [ # # ][ # # ]: 0 : pNewLevel[nToken + 1] = aLevel[nToken];
2606 : : }
2607 : : //copy page no entry (last or last but one depending on bHyperlinks
2608 [ # # ]: 0 : sal_Int32 nPageNo = aNewLevel.getLength() - (bHyperlinks ? 2 : 3);
2609 [ # # ][ # # ]: 0 : pNewLevel[nPageNo] = aLevel[aLevel.getLength() - 1];
2610 : :
2611 [ # # ][ # # ]: 0 : xLevelFormats->replaceByIndex( nLevel, uno::makeAny( aNewLevel ) );
[ # # ]
2612 [ # # ][ # # ]: 0 : }
2613 : : }
2614 : : }
2615 [ # # ]: 0 : pContext->SetTOC( xTOC );
2616 : 0 : }
2617 : :
2618 : :
2619 : : /*-------------------------------------------------------------------------
2620 : : //the field command has to be closed (0x14 appeared)
2621 : : -----------------------------------------------------------------------*/
2622 : 39 : void DomainMapper_Impl::CloseFieldCommand()
2623 : : {
2624 : : #ifdef DEBUG_DOMAINMAPPER
2625 : : dmapper_logger->element("closeFieldCommand");
2626 : : #endif
2627 : :
2628 [ + - ][ + - ]: 39 : FieldContextPtr pContext = m_aFieldStack.top();
2629 : : OSL_ENSURE( pContext.get(), "no field context available");
2630 [ + - ]: 39 : if( pContext.get() )
2631 : : {
2632 : 39 : m_bSetUserFieldContent = false;
2633 [ + - ][ + - ]: 39 : FieldConversionMap_t aFieldConversionMap = lcl_GetFieldConversion();
2634 : 39 : bool bCreateEnhancedField = false;
2635 : :
2636 : : try
2637 : : {
2638 : 39 : uno::Reference< uno::XInterface > xFieldInterface;
2639 : : //at first determine the field type - erase leading and trailing whitespaces
2640 : 39 : OUString sCommand( pContext->GetCommand().trim() );
2641 : 39 : sal_Int32 nSpaceIndex = sCommand.indexOf( ' ' );
2642 [ + + ]: 39 : if( 0 <= nSpaceIndex )
2643 : 15 : sCommand = sCommand.copy( 0, nSpaceIndex );
2644 : :
2645 [ + - ]: 39 : FieldConversionMap_t::iterator aIt = aFieldConversionMap.find(sCommand);
2646 [ + + ]: 39 : if(aIt != aFieldConversionMap.end())
2647 : : {
2648 : 30 : uno::Reference< beans::XPropertySet > xFieldProperties;
2649 : 30 : bool bCreateField = true;
2650 [ + + + ]: 30 : switch (aIt->second.eFieldId)
2651 : : {
2652 : : case FIELD_HYPERLINK:
2653 : : case FIELD_DOCPROPERTY:
2654 : : case FIELD_TOC:
2655 : : case FIELD_TC:
2656 : : case FIELD_EQ:
2657 : 6 : bCreateField = false;
2658 : 6 : break;
2659 : : case FIELD_FORMCHECKBOX :
2660 : : case FIELD_FORMTEXT :
2661 : : case FIELD_FORMDROPDOWN :
2662 : : {
2663 : : // If we use 'enhanced' fields then FIELD_FORMCHECKBOX,
2664 : : // FIELD_FORMTEXT & FIELD_FORMDROPDOWN are treated specially
2665 [ + - ]: 3 : if ( m_bUsingEnhancedFields )
2666 : : {
2667 : 3 : bCreateField = false;
2668 : 3 : bCreateEnhancedField = true;
2669 : : }
2670 : : // for non enhanced fields checkboxes are displayed
2671 : : // as an awt control not a field
2672 [ # # ]: 0 : else if ( aIt->second.eFieldId == FIELD_FORMCHECKBOX )
2673 : 0 : bCreateField = false;
2674 : 3 : break;
2675 : : }
2676 : : default:
2677 : 21 : break;
2678 : : }
2679 : :
2680 [ + + ][ + + ]: 30 : if( bCreateField || bCreateEnhancedField )
2681 : : {
2682 : : //add the service prefix
2683 : 24 : OUString sServiceName("com.sun.star.text.");
2684 [ + + ]: 24 : if ( bCreateEnhancedField )
2685 : : {
2686 [ + - ][ + - ]: 3 : FieldConversionMap_t aEnhancedFieldConversionMap = lcl_GetEnhancedFieldConversion();
2687 [ + - ]: 3 : FieldConversionMap_t::iterator aEnhancedIt = aEnhancedFieldConversionMap.find(sCommand);
2688 [ + - ]: 3 : if ( aEnhancedIt != aEnhancedFieldConversionMap.end())
2689 : 3 : sServiceName += OUString::createFromAscii(aEnhancedIt->second.cFieldServiceName );
2690 : : }
2691 : : else
2692 : : {
2693 : 21 : sServiceName += OUString( "TextField.");
2694 : 21 : sServiceName += OUString::createFromAscii(aIt->second.cFieldServiceName );
2695 : : }
2696 : :
2697 : : #ifdef DEBUG_DOMAINMAPPER
2698 : : dmapper_logger->startElement("fieldService");
2699 : : dmapper_logger->chars(sServiceName);
2700 : : dmapper_logger->endElement();
2701 : : #endif
2702 : :
2703 [ + - ]: 24 : if (m_xTextFactory.is())
2704 : : {
2705 [ + - ][ + - ]: 24 : xFieldInterface = m_xTextFactory->createInstance(sServiceName);
[ + - ]
2706 [ + - ][ + - ]: 24 : xFieldProperties = uno::Reference< beans::XPropertySet >( xFieldInterface, uno::UNO_QUERY_THROW);
2707 : 24 : }
2708 : : }
2709 [ + - ]: 30 : PropertyNameSupplier& rPropNameSupplier = PropertyNameSupplier::GetPropertyNameSupplier();
2710 [ - - + - : 30 : switch( aIt->second.eFieldId )
- + - - -
- - + - -
- - + - +
- - - - -
- - - - -
- + + - -
- - - - -
- - - - -
- - - - -
- ]
2711 : : {
2712 : 0 : case FIELD_ADDRESSBLOCK: break;
2713 : 0 : case FIELD_ADVANCE : break;
2714 : : case FIELD_ASK :
2715 [ + - ][ + - ]: 3 : handleFieldAsk(pContext, rPropNameSupplier, xFieldInterface, xFieldProperties);
[ + - ]
2716 : 3 : break;
2717 : : case FIELD_AUTONUM :
2718 : : case FIELD_AUTONUMLGL :
2719 : : case FIELD_AUTONUMOUT :
2720 [ # # ][ # # ]: 0 : handleAutoNum(pContext, rPropNameSupplier, xFieldInterface, xFieldProperties);
[ # # ]
2721 : 0 : break;
2722 : : case FIELD_AUTHOR :
2723 : : case FIELD_USERNAME :
2724 : : case FIELD_USERINITIALS :
2725 [ # # ][ # # ]: 0 : handleAuthor(pContext, rPropNameSupplier, xFieldInterface, xFieldProperties, aIt->second.eFieldId );
[ # # ]
2726 : 0 : break;
2727 : : case FIELD_DATE:
2728 [ + - ]: 3 : if (xFieldProperties.is())
2729 : : {
2730 : : //not fixed,
2731 [ + - ]: 3 : xFieldProperties->setPropertyValue(
2732 [ + - ]: 3 : rPropNameSupplier.GetName(PROP_IS_FIXED),
2733 [ + - ][ + - ]: 6 : uno::makeAny( false ));
2734 [ + - ]: 3 : xFieldProperties->setPropertyValue(
2735 [ + - ]: 3 : rPropNameSupplier.GetName(PROP_IS_DATE),
2736 [ + - ][ + - ]: 6 : uno::makeAny( true ));
2737 [ + - ]: 3 : SetNumberFormat( pContext->GetCommand(), xFieldProperties );
2738 : : }
2739 : 3 : break;
2740 : : case FIELD_COMMENTS :
2741 : : {
2742 [ # # ]: 0 : OUString sParam = lcl_ExtractParameter(pContext->GetCommand(), sizeof(" COMMENTS") );
2743 : : // A parameter with COMMENTS shouldn't set fixed
2744 : : // ( or at least the binary filter doesn't )
2745 : : // If we set fixed then we wont export a field cmd.
2746 : : // Additionally the para in COMMENTS is more like an
2747 : : // instruction to set the document property comments
2748 : : // with the param ( e.g. each COMMENT with a param will
2749 : : // overwrite the Comments document property
2750 : : // #TODO implement the above too
2751 [ # # ]: 0 : xFieldProperties->setPropertyValue(
2752 [ # # ][ # # ]: 0 : rPropNameSupplier.GetName( PROP_IS_FIXED ), uno::makeAny( false ));
[ # # ]
2753 : : //PROP_CURRENT_PRESENTATION is set later anyway
2754 : : }
2755 : 0 : break;
2756 : : case FIELD_CREATEDATE :
2757 : : {
2758 [ # # ]: 0 : xFieldProperties->setPropertyValue(
2759 [ # # ][ # # ]: 0 : rPropNameSupplier.GetName( PROP_IS_DATE ), uno::makeAny( true ));
[ # # ]
2760 [ # # ]: 0 : SetNumberFormat( pContext->GetCommand(), xFieldProperties );
2761 : : }
2762 : 0 : break;
2763 : : case FIELD_DOCPROPERTY :
2764 [ # # ][ # # ]: 0 : handleDocProperty(pContext, rPropNameSupplier, xFieldInterface, xFieldProperties);
[ # # ]
2765 : 0 : break;
2766 : : case FIELD_DOCVARIABLE :
2767 : : {
2768 [ # # ]: 0 : OUString sParam = lcl_ExtractParameter(pContext->GetCommand(), sizeof(" DOCVARIABLE") );
2769 : : //create a user field and type
2770 : : uno::Reference< beans::XPropertySet > xMaster =
2771 [ # # ]: 0 : FindOrCreateFieldMaster( "com.sun.star.text.FieldMaster.User", sParam );
2772 [ # # ]: 0 : uno::Reference< text::XDependentTextField > xDependentField( xFieldInterface, uno::UNO_QUERY_THROW );
2773 [ # # ][ # # ]: 0 : xDependentField->attachTextFieldMaster( xMaster );
2774 : 0 : m_bSetUserFieldContent = true;
2775 : : }
2776 : 0 : break;
2777 : : case FIELD_EDITTIME :
2778 : : //it's a numbering type, no number format! SetNumberFormat( pContext->GetCommand(), xFieldProperties );
2779 : 0 : break;
2780 : : case FIELD_EQ:
2781 : : {
2782 : 3 : OUString aCommand = pContext->GetCommand().trim();
2783 : 3 : nSpaceIndex = aCommand.indexOf(' ');
2784 [ + - ]: 3 : if(nSpaceIndex > 0)
2785 : 3 : aCommand = aCommand.copy(nSpaceIndex).trim();
2786 [ + - ]: 3 : if (aCommand.compareTo("\\s", 2) == 0)
2787 : : {
2788 : 3 : aCommand = aCommand.copy(2);
2789 [ + - ]: 3 : if (aCommand.compareTo("\\do", 3) == 0)
2790 : : {
2791 : 3 : aCommand = aCommand.copy(3);
2792 : 3 : sal_Int32 nStartIndex = aCommand.indexOf('(');
2793 : 3 : sal_Int32 nEndIndex = aCommand.indexOf(')');
2794 [ + - ][ + - ]: 3 : if (nStartIndex > 0 && nEndIndex > 0)
2795 : : {
2796 : : // nDown is the requested "lower by" value in points.
2797 : 3 : sal_Int32 nDown = aCommand.copy(0, nStartIndex).toInt32();
2798 : 3 : OUString aContent = aCommand.copy(nStartIndex + 1, nEndIndex - nStartIndex - 1);
2799 [ + - ]: 3 : PropertyMapPtr pCharContext = GetTopContext();
2800 : : // dHeight is the font size of the current style.
2801 : 3 : double dHeight = 0;
2802 [ + - ][ + - ]: 3 : if (GetPropertyFromStyleSheet(PROP_CHAR_HEIGHT) >>= dHeight)
2803 : : // Character escapement should be given in negative percents for subscripts.
2804 [ + - ][ + - ]: 3 : pCharContext->Insert(PROP_CHAR_ESCAPEMENT, true, uno::makeAny( sal_Int16(- 100 * nDown / dHeight) ) );
2805 [ + - ][ + - ]: 3 : appendTextPortion(aContent, pCharContext);
[ + - ][ + - ]
2806 : : }
2807 : : }
2808 : 3 : }
2809 : : }
2810 : 3 : break;
2811 : : case FIELD_FILLIN :
2812 : : {
2813 : 0 : sal_Int32 nIndex = 0;
2814 [ # # ]: 0 : if (xFieldProperties.is())
2815 [ # # ]: 0 : xFieldProperties->setPropertyValue(
2816 [ # # ][ # # ]: 0 : rPropNameSupplier.GetName(PROP_HINT), uno::makeAny( pContext->GetCommand().getToken( 1, '\"', nIndex)));
[ # # ]
2817 : : }
2818 : 0 : break;
2819 : : case FIELD_FILENAME:
2820 : : {
2821 : 0 : sal_Int32 nNumberingTypeIndex = pContext->GetCommand().indexOf("\\p");
2822 [ # # ]: 0 : if (xFieldProperties.is())
2823 [ # # ]: 0 : xFieldProperties->setPropertyValue(
2824 [ # # ]: 0 : rPropNameSupplier.GetName(PROP_FILE_FORMAT),
2825 [ # # ][ # # ]: 0 : uno::makeAny( nNumberingTypeIndex > 0 ? text::FilenameDisplayFormat::FULL : text::FilenameDisplayFormat::NAME ));
[ # # ]
2826 : : }
2827 : 0 : break;
2828 : 0 : case FIELD_FILESIZE : break;
2829 : 0 : case FIELD_FORMULA : break;
2830 : : case FIELD_FORMCHECKBOX :
2831 : : case FIELD_FORMDROPDOWN :
2832 : : case FIELD_FORMTEXT :
2833 : : {
2834 [ + - ]: 3 : uno::Reference< text::XTextField > xTextField( xFieldInterface, uno::UNO_QUERY );
2835 [ + - ]: 3 : if ( !xTextField.is() )
2836 : : {
2837 : : FFDataHandler::Pointer_t
2838 [ + - ]: 3 : pFFDataHandler(pContext->getFFDataHandler());
2839 : : FormControlHelper::Pointer_t
2840 : : pFormControlHelper(new FormControlHelper
2841 : 3 : (m_bUsingEnhancedFields ? aIt->second.eFieldId : FIELD_FORMCHECKBOX,
2842 : :
2843 [ + - ][ + - ]: 6 : m_xTextDocument, pFFDataHandler));
[ + - ][ + - ]
[ + - ][ + - ]
2844 [ + - ][ + - ]: 3 : pContext->setFormControlHelper(pFormControlHelper);
[ + - ]
2845 [ + - ]: 3 : uno::Reference< text::XFormField > xFormField( xFieldInterface, uno::UNO_QUERY );
2846 [ + - ]: 3 : uno::Reference< container::XNamed > xNamed( xFormField, uno::UNO_QUERY );
2847 [ + - ]: 3 : if ( xNamed.is() )
2848 : : {
2849 [ + - ][ + - ]: 3 : if ( pFFDataHandler && !pFFDataHandler->getName().isEmpty() )
[ - + ][ - + ]
2850 [ # # ][ # # ]: 0 : xNamed->setName( pFFDataHandler->getName() );
[ # # ]
2851 [ + - ]: 3 : pContext->SetFormField( xFormField );
2852 [ + - ][ + - ]: 3 : }
2853 : : }
2854 : : else
2855 : : {
2856 [ # # ]: 0 : if ( aIt->second.eFieldId == FIELD_FORMDROPDOWN )
2857 [ # # ][ # # ]: 0 : lcl_handleDropdownField( xFieldProperties, pContext->getFFDataHandler() );
[ # # ]
2858 : : else
2859 [ # # ][ # # ]: 0 : lcl_handleTextField( xFieldProperties, pContext->getFFDataHandler(), rPropNameSupplier );
[ # # ]
2860 : 3 : }
2861 : : }
2862 : 3 : break;
2863 : 0 : case FIELD_GOTOBUTTON : break;
2864 : : case FIELD_HYPERLINK:
2865 : : {
2866 [ + - ]: 3 : ::std::vector<OUString> aParts = pContext->GetCommandParts();
2867 [ + - ]: 3 : ::std::vector<OUString>::const_iterator aItEnd = aParts.end();
2868 [ + - ]: 3 : ::std::vector<OUString>::const_iterator aPartIt = aParts.begin();
2869 : :
2870 : 3 : OUString sURL;
2871 : :
2872 [ + - ][ + + ]: 12 : while (aPartIt != aItEnd)
2873 : : {
2874 [ + + ]: 9 : if ( *aPartIt == "\\l" )
2875 : : {
2876 : 3 : ++aPartIt;
2877 : :
2878 [ - + ][ + - ]: 3 : if (aPartIt == aItEnd)
2879 : 0 : break;
2880 : :
2881 : 3 : sURL += OUString('#');
2882 : 3 : sURL += *aPartIt;
2883 : : }
2884 [ + - ][ - + ]: 6 : else if ( *aPartIt == "\\m" || *aPartIt == "\\n" )
[ + - ]
2885 : : {
2886 : : }
2887 [ + - ][ - + ]: 6 : else if ( *aPartIt == "\\o" || *aPartIt == "\\t" )
[ - + ]
2888 : : {
2889 : 0 : ++aPartIt;
2890 : :
2891 [ # # ][ # # ]: 0 : if (aPartIt == aItEnd)
2892 : 0 : break;
2893 : : }
2894 : : else
2895 : : {
2896 : 6 : sURL = *aPartIt;
2897 : : }
2898 : :
2899 : 9 : ++aPartIt;
2900 : : }
2901 : :
2902 [ + - ]: 3 : if (!sURL.isEmpty())
2903 : : {
2904 : 3 : pContext->SetHyperlinkURL(sURL);
2905 : 3 : }
2906 : : }
2907 : 3 : break;
2908 : 0 : case FIELD_IF : break;
2909 : 0 : case FIELD_INFO : break;
2910 : 0 : case FIELD_INCLUDEPICTURE: break;
2911 : : case FIELD_KEYWORDS :
2912 : : {
2913 [ # # ]: 0 : OUString sParam = lcl_ExtractParameter(pContext->GetCommand(), sizeof(" KEYWORDS") );
2914 [ # # ]: 0 : if(!sParam.isEmpty())
2915 : : {
2916 [ # # ]: 0 : xFieldProperties->setPropertyValue(
2917 [ # # ][ # # ]: 0 : rPropNameSupplier.GetName( PROP_IS_FIXED ), uno::makeAny( true ));
[ # # ]
2918 : : //PROP_CURRENT_PRESENTATION is set later anyway
2919 : 0 : }
2920 : : }
2921 : 0 : break;
2922 : 0 : case FIELD_LASTSAVEDBY : break;
2923 : : case FIELD_MACROBUTTON:
2924 : : {
2925 : : //extract macro name
2926 : 0 : sal_Int32 nIndex = sizeof(" MACROBUTTON ");
2927 : 0 : OUString sMacro = pContext->GetCommand().getToken( 0, ' ', nIndex);
2928 [ # # ]: 0 : if (xFieldProperties.is())
2929 [ # # ]: 0 : xFieldProperties->setPropertyValue(
2930 [ # # ][ # # ]: 0 : rPropNameSupplier.GetName(PROP_MACRO_NAME), uno::makeAny( sMacro ));
[ # # ]
2931 : :
2932 : : //extract quick help text
2933 [ # # ][ # # ]: 0 : if(xFieldProperties.is() && pContext->GetCommand().getLength() > nIndex + 1)
[ # # ]
2934 : : {
2935 [ # # ]: 0 : xFieldProperties->setPropertyValue(
2936 [ # # ]: 0 : rPropNameSupplier.GetName(PROP_HINT),
2937 [ # # ][ # # ]: 0 : uno::makeAny( pContext->GetCommand().copy( nIndex )));
2938 : 0 : }
2939 : : }
2940 : 0 : break;
2941 : : case FIELD_MERGEFIELD :
2942 : : {
2943 : : //todo: create a database field and fieldmaster pointing to a column, only
2944 [ # # ]: 0 : OUString sParam = lcl_ExtractParameter(pContext->GetCommand(), sizeof(" MERGEFIELD") );
2945 : : //create a user field and type
2946 : : uno::Reference< beans::XPropertySet > xMaster =
2947 [ # # ]: 0 : FindOrCreateFieldMaster( "com.sun.star.text.FieldMaster.Database", sParam );
2948 : :
2949 : : // xFieldProperties->setPropertyValue(
2950 : : // "FieldCode",
2951 : : // uno::makeAny( pContext->GetCommand().copy( nIndex + 1 )));
2952 [ # # ]: 0 : uno::Reference< text::XDependentTextField > xDependentField( xFieldInterface, uno::UNO_QUERY_THROW );
2953 [ # # ][ # # ]: 0 : xDependentField->attachTextFieldMaster( xMaster );
2954 : 0 : m_bSetUserFieldContent = true;
2955 : : }
2956 : 0 : break;
2957 : 0 : case FIELD_MERGEREC : break;
2958 : 0 : case FIELD_MERGESEQ : break;
2959 : 0 : case FIELD_NEXT : break;
2960 : 0 : case FIELD_NEXTIF : break;
2961 : : case FIELD_PAGE :
2962 [ + - ]: 12 : if (xFieldProperties.is())
2963 : : {
2964 [ + - ]: 12 : xFieldProperties->setPropertyValue(
2965 [ + - ]: 12 : rPropNameSupplier.GetName(PROP_NUMBERING_TYPE),
2966 [ + - ][ + - ]: 24 : uno::makeAny( lcl_ParseNumberingType(pContext->GetCommand()) ));
2967 [ + - ]: 12 : xFieldProperties->setPropertyValue(
2968 [ + - ]: 12 : rPropNameSupplier.GetName(PROP_SUB_TYPE),
2969 [ + - ][ + - ]: 24 : uno::makeAny( text::PageNumberType_CURRENT ));
2970 : : }
2971 : :
2972 : 12 : break;
2973 : : case FIELD_PAGEREF:
2974 : : case FIELD_REF:
2975 [ + - ]: 3 : if (xFieldProperties.is())
2976 : : {
2977 : 3 : bool bPageRef = aIt->second.eFieldId == FIELD_PAGEREF;
2978 : 3 : OUString sBookmark = lcl_ExtractParameter(pContext->GetCommand(),
2979 [ + - ][ - + ]: 6 : (bPageRef ? sizeof(" PAGEREF") : sizeof(" REF")));
2980 : :
2981 : : // Do we need a GetReference (default) or a GetExpression field?
2982 [ + - ][ + - ]: 3 : uno::Reference< text::XTextFieldsSupplier > xFieldsSupplier( GetTextDocument(), uno::UNO_QUERY );
2983 [ + - ][ + - ]: 3 : uno::Reference< container::XNameAccess > xFieldMasterAccess = xFieldsSupplier->getTextFieldMasters();
2984 : :
2985 [ + - ][ + - ]: 3 : if (!xFieldMasterAccess->hasByName("com.sun.star.text.FieldMaster.SetExpression." + sBookmark))
[ - + ]
2986 : : {
2987 [ # # ]: 0 : xFieldProperties->setPropertyValue(
2988 [ # # ]: 0 : rPropNameSupplier.GetName(PROP_REFERENCE_FIELD_SOURCE),
2989 [ # # ][ # # ]: 0 : uno::makeAny( sal_Int16(text::ReferenceFieldSource::BOOKMARK)) );
2990 [ # # ]: 0 : xFieldProperties->setPropertyValue(
2991 [ # # ]: 0 : rPropNameSupplier.GetName(PROP_SOURCE_NAME),
2992 [ # # ][ # # ]: 0 : uno::makeAny( sBookmark) );
2993 [ # # ]: 0 : sal_Int16 nFieldPart = (bPageRef ? text::ReferenceFieldPart::PAGE : text::ReferenceFieldPart::TEXT);
2994 : 0 : OUString sValue;
2995 [ # # ]: 0 : if( lcl_FindInCommand( pContext->GetCommand(), 'p', sValue ))
2996 : : {
2997 : : //above-below
2998 : 0 : nFieldPart = text::ReferenceFieldPart::UP_DOWN;
2999 : : }
3000 [ # # ]: 0 : else if( lcl_FindInCommand( pContext->GetCommand(), 'r', sValue ))
3001 : : {
3002 : : //number
3003 : 0 : nFieldPart = text::ReferenceFieldPart::NUMBER;
3004 : : }
3005 [ # # ]: 0 : else if( lcl_FindInCommand( pContext->GetCommand(), 'n', sValue ))
3006 : : {
3007 : : //number-no-context
3008 : 0 : nFieldPart = text::ReferenceFieldPart::NUMBER_NO_CONTEXT;
3009 : : }
3010 [ # # ]: 0 : else if( lcl_FindInCommand( pContext->GetCommand(), 'w', sValue ))
3011 : : {
3012 : : //number-full-context
3013 : 0 : nFieldPart = text::ReferenceFieldPart::NUMBER_FULL_CONTEXT;
3014 : : }
3015 [ # # ]: 0 : xFieldProperties->setPropertyValue(
3016 [ # # ][ # # ]: 0 : rPropNameSupplier.GetName( PROP_REFERENCE_FIELD_PART ), uno::makeAny( nFieldPart ));
[ # # ]
3017 : : }
3018 : : else
3019 : : {
3020 [ + - ][ + - ]: 3 : xFieldInterface = m_xTextFactory->createInstance("com.sun.star.text.TextField.GetExpression");
[ + - ]
3021 [ + - ]: 3 : xFieldProperties.set(xFieldInterface, uno::UNO_QUERY);
3022 [ + - ][ + - ]: 3 : xFieldProperties->setPropertyValue(rPropNameSupplier.GetName(PROP_CONTENT), uno::makeAny(sBookmark));
[ + - ][ + - ]
3023 [ + - ][ + - ]: 3 : xFieldProperties->setPropertyValue(rPropNameSupplier.GetName(PROP_SUB_TYPE), uno::makeAny(text::SetVariableType::STRING));
[ + - ][ + - ]
3024 : 3 : }
3025 : : }
3026 : 3 : break;
3027 : 0 : case FIELD_REVNUM : break;
3028 : : case FIELD_SAVEDATE :
3029 [ # # ]: 0 : SetNumberFormat( pContext->GetCommand(), xFieldProperties );
3030 : 0 : break;
3031 : 0 : case FIELD_SECTION : break;
3032 : 0 : case FIELD_SECTIONPAGES : break;
3033 : 0 : case FIELD_SEQ : break;
3034 : 0 : case FIELD_SET : break;
3035 : 0 : case FIELD_SKIPIF : break;
3036 : 0 : case FIELD_STYLEREF : break;
3037 : : case FIELD_SUBJECT :
3038 : : {
3039 [ # # ]: 0 : OUString sParam = lcl_ExtractParameter(pContext->GetCommand(), sizeof(" SUBJECT") );
3040 [ # # ]: 0 : if(!sParam.isEmpty())
3041 : : {
3042 [ # # ]: 0 : xFieldProperties->setPropertyValue(
3043 [ # # ][ # # ]: 0 : rPropNameSupplier.GetName( PROP_IS_FIXED ), uno::makeAny( true ));
[ # # ]
3044 : : //PROP_CURRENT_PRESENTATION is set later anyway
3045 : 0 : }
3046 : : }
3047 : 0 : break;
3048 : 0 : case FIELD_SYMBOL : break;
3049 : 0 : case FIELD_TEMPLATE: break;
3050 : : case FIELD_TIME :
3051 [ # # ]: 0 : SetNumberFormat( pContext->GetCommand(), xFieldProperties );
3052 : 0 : break;
3053 : : case FIELD_TITLE :
3054 : : {
3055 [ # # ]: 0 : OUString sParam = lcl_ExtractParameter(pContext->GetCommand(), sizeof(" TITLE") );
3056 [ # # ]: 0 : if(!sParam.isEmpty())
3057 : : {
3058 [ # # ]: 0 : xFieldProperties->setPropertyValue(
3059 [ # # ][ # # ]: 0 : rPropNameSupplier.GetName( PROP_IS_FIXED ), uno::makeAny( true ));
[ # # ]
3060 : : //PROP_CURRENT_PRESENTATION is set later anyway
3061 : 0 : }
3062 : : }
3063 : 0 : break;
3064 : : case FIELD_USERADDRESS : //todo: user address collects street, city ...
3065 : 0 : break;
3066 : : case FIELD_TOC:
3067 : : handleToc(pContext, rPropNameSupplier, xFieldInterface, xFieldProperties,
3068 [ # # ][ # # ]: 0 : OUString::createFromAscii(aIt->second.cFieldServiceName));
[ # # ]
3069 : 0 : break;
3070 : : case FIELD_TC :
3071 : : {
3072 : : uno::Reference< beans::XPropertySet > xTC(
3073 [ # # ]: 0 : m_xTextFactory->createInstance(
3074 : 0 : OUString::createFromAscii(aIt->second.cFieldServiceName)),
3075 [ # # ][ # # ]: 0 : uno::UNO_QUERY_THROW);
3076 [ # # ]: 0 : OUString sTCText = lcl_ExtractParameter(pContext->GetCommand(), sizeof(" TC") );
3077 [ # # ]: 0 : if( !sTCText.isEmpty())
3078 [ # # ][ # # ]: 0 : xTC->setPropertyValue(rPropNameSupplier.GetName(PROP_ALTERNATIVE_TEXT),
3079 [ # # ][ # # ]: 0 : uno::makeAny(sTCText));
3080 : 0 : OUString sValue;
3081 : : // \f TC entry in doc with multiple tables
3082 : : // if( lcl_FindInCommand( pContext->GetCommand(), 'f', sValue ))
3083 : : // {
3084 : : // todo: unsupported
3085 : : // }
3086 [ # # ]: 0 : if( lcl_FindInCommand( pContext->GetCommand(), 'l', sValue ))
3087 : : // \l Outline Level
3088 : : {
3089 : 0 : sal_Int32 nLevel = sValue.toInt32();
3090 [ # # ][ # # ]: 0 : if( !sValue.isEmpty() && nLevel >= 0 && nLevel <= 10 )
[ # # ][ # # ]
3091 [ # # ][ # # ]: 0 : xTC->setPropertyValue(rPropNameSupplier.GetName(PROP_LEVEL), uno::makeAny( (sal_Int16)nLevel ));
[ # # ][ # # ]
3092 : : }
3093 : : // if( lcl_FindInCommand( pContext->GetCommand(), 'n', sValue ))
3094 : : // \n Suppress page numbers
3095 : : // {
3096 : : //todo: unsupported feature
3097 : : // }
3098 [ # # ]: 0 : pContext->SetTC( xTC );
3099 : : }
3100 : 0 : break;
3101 : : case FIELD_NUMCHARS:
3102 : : case FIELD_NUMWORDS:
3103 : : case FIELD_NUMPAGES:
3104 [ # # ]: 0 : if (xFieldProperties.is())
3105 [ # # ]: 0 : xFieldProperties->setPropertyValue(
3106 [ # # ]: 0 : rPropNameSupplier.GetName(PROP_NUMBERING_TYPE),
3107 [ # # ][ # # ]: 0 : uno::makeAny( lcl_ParseNumberingType(pContext->GetCommand()) ));
3108 : 0 : break;
3109 : :
3110 : 30 : }
3111 : : }
3112 : : //set the text field if there is any
3113 [ + - ][ + - ]: 39 : pContext->SetTextField( uno::Reference< text::XTextField >( xFieldInterface, uno::UNO_QUERY ) );
[ # # ]
3114 : : }
3115 [ # # ]: 0 : catch( const uno::Exception& )
3116 : : {
3117 : : OSL_FAIL( "Exception in CloseFieldCommand()" );
3118 : : }
3119 : 39 : pContext->SetCommandCompleted();
3120 [ + - ]: 39 : }
3121 : 39 : }
3122 : : /*-------------------------------------------------------------------------
3123 : : //the _current_ fields require a string type result while TOCs accept richt results
3124 : : -----------------------------------------------------------------------*/
3125 : 15 : bool DomainMapper_Impl::IsFieldResultAsString()
3126 : : {
3127 : 15 : bool bRet = false;
3128 : : OSL_ENSURE( !m_aFieldStack.empty(), "field stack empty?");
3129 [ + - ][ + - ]: 15 : FieldContextPtr pContext = m_aFieldStack.top();
3130 : : OSL_ENSURE( pContext.get(), "no field context available");
3131 [ + - ]: 15 : if( pContext.get() )
3132 : : {
3133 [ + - ]: 15 : bRet = pContext->GetTextField().is();
3134 : : }
3135 [ + - ]: 15 : return bRet;
3136 : : }
3137 : :
3138 : :
3139 : 12 : void DomainMapper_Impl::SetFieldResult( OUString& rResult )
3140 : : {
3141 : : #ifdef DEBUG_DOMAINMAPPER
3142 : : dmapper_logger->startElement("setFieldResult");
3143 : : dmapper_logger->chars(rResult);
3144 : : #endif
3145 : :
3146 [ + - ][ + - ]: 12 : FieldContextPtr pContext = m_aFieldStack.top();
3147 : : OSL_ENSURE( pContext.get(), "no field context available");
3148 [ + - ]: 12 : if( pContext.get() )
3149 : : {
3150 [ + - ]: 12 : uno::Reference<text::XTextField> xTextField = pContext->GetTextField();
3151 : : try
3152 : : {
3153 [ + - ]: 12 : PropertyNameSupplier& rPropNameSupplier = PropertyNameSupplier::GetPropertyNameSupplier();
3154 : : OSL_ENSURE( xTextField.is()
3155 : : //||m_xTOC.is() ||m_xTC.is()
3156 : : //||m_sHyperlinkURL.getLength()
3157 : : , "DomainMapper_Impl::SetFieldResult: field not created" );
3158 [ + - ]: 12 : if(xTextField.is())
3159 : : {
3160 : : try
3161 : : {
3162 [ - + ]: 12 : if( m_bSetUserFieldContent )
3163 : : {
3164 : : // user field content has to be set at the field master
3165 [ # # ]: 0 : uno::Reference< text::XDependentTextField > xDependentField( xTextField, uno::UNO_QUERY_THROW );
3166 [ # # ][ # # ]: 0 : xDependentField->getTextFieldMaster()->setPropertyValue(
[ # # ]
3167 [ # # ]: 0 : rPropNameSupplier.GetName(PROP_CONTENT),
3168 [ # # ][ # # ]: 0 : uno::makeAny( rResult ));
3169 : : }
3170 : : else
3171 : : {
3172 [ + - ]: 12 : uno::Reference< beans::XPropertySet > xFieldProperties( xTextField, uno::UNO_QUERY_THROW);
3173 : : // In case of SetExpression, the field result contains the content of the variable.
3174 [ + - ]: 12 : uno::Reference<lang::XServiceInfo> xServiceInfo(xTextField, uno::UNO_QUERY);
3175 [ + - ][ + - ]: 12 : bool bIsSetExpression = xServiceInfo->supportsService("com.sun.star.text.TextField.SetExpression");
3176 [ + - ]: 12 : xFieldProperties->setPropertyValue(
3177 [ + + ][ + - ]: 12 : rPropNameSupplier.GetName(bIsSetExpression ? PROP_CONTENT : PROP_CURRENT_PRESENTATION),
3178 [ + - ][ + + ]: 24 : uno::makeAny( rResult ));
[ - + ]
3179 : : }
3180 : : }
3181 [ + - # # ]: 6 : catch( const beans::UnknownPropertyException& )
3182 : : {
3183 : : //some fields don't have a CurrentPresentation (DateTime)
3184 : : }
3185 : : }
3186 : : }
3187 [ # # ]: 0 : catch( const uno::Exception& )
3188 : : {
3189 : :
3190 : 12 : }
3191 [ + - ]: 12 : }
3192 : 12 : }
3193 : :
3194 : 21 : void DomainMapper_Impl::SetFieldFFData(FFDataHandler::Pointer_t pFFDataHandler)
3195 : : {
3196 : : #ifdef DEBUG_DOMAINMAPPER
3197 : : dmapper_logger->startElement("setFieldFFData");
3198 : : #endif
3199 : :
3200 [ + - ]: 21 : if (m_aFieldStack.size())
3201 : : {
3202 [ + - ][ + - ]: 21 : FieldContextPtr pContext = m_aFieldStack.top();
3203 [ + - ]: 21 : if (pContext.get())
3204 : : {
3205 [ + - ][ + - ]: 21 : pContext->setFFDataHandler(pFFDataHandler);
[ + - ]
3206 [ + - ]: 21 : }
3207 : : }
3208 : :
3209 : : #ifdef DEBUG_DOMAINMAPPER
3210 : : dmapper_logger->endElement();
3211 : : #endif
3212 : 21 : }
3213 : :
3214 : : /*-------------------------------------------------------------------------
3215 : : //the end of field is reached (0x15 appeared) - the command might still be open
3216 : : -----------------------------------------------------------------------*/
3217 : 39 : void DomainMapper_Impl::PopFieldContext()
3218 : : {
3219 : : #ifdef DEBUG_DOMAINMAPPER
3220 : : dmapper_logger->element("popFieldContext");
3221 : : #endif
3222 : :
3223 [ + - ]: 39 : if (m_aFieldStack.empty())
3224 : 39 : return;
3225 : :
3226 [ + - ][ + - ]: 39 : FieldContextPtr pContext = m_aFieldStack.top();
3227 : : OSL_ENSURE( pContext.get(), "no field context available");
3228 [ + - ]: 39 : if( pContext.get() )
3229 : : {
3230 [ + + ]: 39 : if( !pContext->IsCommandCompleted() )
3231 [ + - ]: 3 : CloseFieldCommand();
3232 : :
3233 : : //insert the field, TC or TOC
3234 : 39 : uno::Reference< text::XTextAppend > xTextAppend;
3235 [ + - ]: 39 : if (!m_aTextAppendStack.empty())
3236 [ + - ][ + - ]: 39 : xTextAppend = m_aTextAppendStack.top().xTextAppend;
3237 [ + - ]: 39 : if(xTextAppend.is())
3238 : : {
3239 : : try
3240 : : {
3241 [ + - ][ + - ]: 39 : uno::Reference< text::XTextCursor > xCrsr = xTextAppend->createTextCursorByRange(pContext->GetStartRange());
[ + - ]
3242 : : //remove the dummy character
3243 [ + - ][ + - ]: 39 : xCrsr->goRight( 1, true );
3244 [ + - ][ + - ]: 39 : xCrsr->setString( OUString() );
3245 [ + - ][ + - ]: 39 : uno::Reference< text::XTextContent > xToInsert( pContext->GetTOC(), uno::UNO_QUERY );
3246 [ - + ]: 39 : if( xToInsert.is() )
3247 : : {
3248 [ # # ][ # # ]: 0 : xCrsr->gotoEnd( true );
3249 [ # # ][ # # ]: 0 : xToInsert->attach( uno::Reference< text::XTextRange >( xCrsr, uno::UNO_QUERY_THROW ));
[ # # ]
3250 : : }
3251 : : else
3252 : : {
3253 [ + - ][ + - ]: 39 : xToInsert = uno::Reference< text::XTextContent >(pContext->GetTC(), uno::UNO_QUERY);
[ + - ]
3254 [ + - ]: 39 : if( !xToInsert.is() )
3255 [ + - ][ + - ]: 39 : xToInsert = uno::Reference< text::XTextContent >(pContext->GetTextField(), uno::UNO_QUERY);
[ + - ]
3256 [ + + ]: 39 : if( xToInsert.is() )
3257 : : {
3258 [ + - ]: 21 : uno::Reference< text::XTextAppendAndConvert > xTextAppendAndConvert( xTextAppend, uno::UNO_QUERY_THROW );
3259 [ + - ]: 21 : uno::Sequence<beans::PropertyValue> aValues;
3260 : : // Character properties of the field show up here the
3261 : : // last (always empty) run. Inherit character
3262 : : // properties from there.
3263 [ + - ]: 21 : if (m_pLastCharacterContext.get())
3264 [ + - ][ + - ]: 21 : aValues = m_pLastCharacterContext->GetPropertyValues();
[ + - ]
3265 [ + - ][ + - ]: 21 : xTextAppendAndConvert->appendTextContent(xToInsert, aValues);
[ + - ]
3266 : : }
3267 : : else
3268 : : {
3269 [ + - ]: 18 : FormControlHelper::Pointer_t pFormControlHelper(pContext->getFormControlHelper());
3270 [ + + ][ + - ]: 18 : if (pFormControlHelper.get() != NULL && pFormControlHelper->hasFFDataHandler() )
[ + - ][ + + ]
3271 : : {
3272 [ + - ]: 3 : uno::Reference< text::XFormField > xFormField( pContext->GetFormField() );
3273 [ + - ]: 3 : xToInsert.set(xFormField, uno::UNO_QUERY);
3274 [ + - ][ + - ]: 3 : if ( xFormField.is() && xToInsert.is() )
[ + - ]
3275 : : {
3276 [ + - ][ + - ]: 3 : xCrsr->gotoEnd( true );
3277 [ + - ][ + - ]: 3 : xToInsert->attach( uno::Reference< text::XTextRange >( xCrsr, uno::UNO_QUERY_THROW ));
[ + - ]
3278 [ + - ]: 3 : pFormControlHelper->processField( xFormField );
3279 : : }
3280 : : else
3281 : : {
3282 [ # # ]: 0 : uno::Reference<text::XTextRange> xTxtRange(xCrsr, uno::UNO_QUERY);
3283 [ # # ]: 0 : pFormControlHelper->insertControl(xTxtRange);
3284 : 3 : }
3285 : : }
3286 [ + + ]: 15 : else if(!pContext->GetHyperlinkURL().isEmpty())
3287 : : {
3288 [ + - ]: 3 : PropertyNameSupplier& rPropNameSupplier = PropertyNameSupplier::GetPropertyNameSupplier();
3289 [ + - ][ + - ]: 3 : xCrsr->gotoEnd( true );
3290 : :
3291 [ + - ]: 3 : uno::Reference< beans::XPropertySet > xCrsrProperties( xCrsr, uno::UNO_QUERY_THROW );
3292 [ + - ][ + - ]: 6 : xCrsrProperties->setPropertyValue(rPropNameSupplier.GetName(PROP_HYPER_LINK_U_R_L), uno::
3293 [ + - ][ + - ]: 6 : makeAny(pContext->GetHyperlinkURL()));
3294 [ + - ]: 18 : }
3295 : : }
3296 [ # # # ]: 39 : }
3297 : : }
3298 [ # # ]: 0 : catch(const lang::IllegalArgumentException&)
3299 : : {
3300 : : OSL_FAIL( "IllegalArgumentException in PopFieldContext()" );
3301 : : }
3302 [ # # ]: 0 : catch(const uno::Exception&)
3303 : : {
3304 : : OSL_FAIL( "exception in PopFieldContext()" );
3305 : : }
3306 : 39 : }
3307 : : //
3308 : : //TOCs have to include all the imported content
3309 : : //...
3310 : : }
3311 : : //remove the field context
3312 [ + - ][ + - ]: 39 : m_aFieldStack.pop();
3313 : : }
3314 : :
3315 : :
3316 : 42 : void DomainMapper_Impl::AddBookmark( const OUString& rBookmarkName, const OUString& rId )
3317 : : {
3318 [ + - ]: 42 : if (m_aTextAppendStack.empty())
3319 : 42 : return;
3320 [ + - ]: 42 : uno::Reference< text::XTextAppend > xTextAppend = m_aTextAppendStack.top().xTextAppend;
3321 [ + - ]: 42 : BookmarkMap_t::iterator aBookmarkIter = m_aBookmarkMap.find( rId );
3322 : : //is the bookmark name already registered?
3323 : : try
3324 : : {
3325 [ + + ]: 42 : if( aBookmarkIter != m_aBookmarkMap.end() )
3326 : : {
3327 [ + + ][ + - ]: 21 : static const OUString sBookmarkService("com.sun.star.text.Bookmark");
3328 [ + - ]: 21 : if (m_xTextFactory.is())
3329 : : {
3330 [ + - ][ + - ]: 21 : uno::Reference< text::XTextContent > xBookmark( m_xTextFactory->createInstance( sBookmarkService ), uno::UNO_QUERY_THROW );
[ + - ]
3331 : 21 : uno::Reference< text::XTextCursor > xCursor;
3332 [ + - ][ + - ]: 21 : uno::Reference< text::XText > xText = aBookmarkIter->second.m_xTextRange->getText();
3333 [ + + ]: 21 : if( aBookmarkIter->second.m_bIsStartOfText )
3334 [ + - ][ + - ]: 15 : xCursor = xText->createTextCursorByRange( xText->getStart() );
[ + - ][ + - ]
[ + - ]
3335 : : else
3336 : : {
3337 [ + - ][ + - ]: 6 : xCursor = xText->createTextCursorByRange( aBookmarkIter->second.m_xTextRange );
[ + - ]
3338 [ + - ][ + - ]: 6 : xCursor->goRight( 1, false );
3339 : : }
3340 : :
3341 [ + - ][ + - ]: 21 : xCursor->gotoRange( xTextAppend->getEnd(), true );
[ + - ][ + - ]
3342 [ + - ]: 21 : uno::Reference< container::XNamed > xBkmNamed( xBookmark, uno::UNO_QUERY_THROW );
3343 : : //todo: make sure the name is not used already!
3344 [ + - ]: 21 : if ( !aBookmarkIter->second.m_sBookmarkName.isEmpty() )
3345 [ + - ][ + - ]: 21 : xBkmNamed->setName( aBookmarkIter->second.m_sBookmarkName );
3346 : : else
3347 [ # # ][ # # ]: 0 : xBkmNamed->setName( rBookmarkName );
3348 [ + - ][ + - ]: 21 : xTextAppend->insertTextContent( uno::Reference< text::XTextRange >( xCursor, uno::UNO_QUERY_THROW), xBookmark, !xCursor->isCollapsed() );
[ + - ][ + - ]
[ + - ]
3349 : : }
3350 [ + - ]: 21 : m_aBookmarkMap.erase( aBookmarkIter );
3351 : : }
3352 : : else
3353 : : {
3354 : : //otherwise insert a text range as marker
3355 : 21 : bool bIsStart = true;
3356 : 21 : uno::Reference< text::XTextRange > xCurrent;
3357 [ + - ]: 21 : if (xTextAppend.is())
3358 : : {
3359 [ + - ][ + - ]: 21 : uno::Reference< text::XTextCursor > xCursor = xTextAppend->createTextCursorByRange( xTextAppend->getEnd() );
[ + - ][ + - ]
3360 [ + - ][ + - ]: 21 : bIsStart = !xCursor->goLeft(1, false);
3361 [ + - ][ + - ]: 21 : xCurrent = xCursor->getStart();
[ + - ]
3362 : : }
3363 [ + - ][ + - ]: 21 : m_aBookmarkMap.insert(BookmarkMap_t::value_type( rId, BookmarkInsertPosition( bIsStart, rBookmarkName, xCurrent ) ));
[ + - ][ + - ]
[ + - ][ # # ]
3364 : : }
3365 : : }
3366 [ # # ]: 0 : catch( const uno::Exception& )
3367 : : {
3368 : : //TODO: What happens to bookmarks where start and end are at different XText objects?
3369 : 42 : }
3370 : : }
3371 : :
3372 : 24 : void DomainMapper_Impl::AddAnnotationPosition(const bool bStart)
3373 : : {
3374 [ + - ]: 24 : if (m_aTextAppendStack.empty())
3375 : 24 : return;
3376 : :
3377 : : // Create a cursor, pointing to the current position.
3378 [ + - ]: 24 : uno::Reference<text::XTextAppend> xTextAppend = m_aTextAppendStack.top().xTextAppend;
3379 : 24 : uno::Reference<text::XTextRange> xCurrent;
3380 [ + - ]: 24 : if (xTextAppend.is())
3381 : : {
3382 [ + - ][ + - ]: 24 : uno::Reference<text::XTextCursor> xCursor = xTextAppend->createTextCursorByRange(xTextAppend->getEnd());
[ + - ][ + - ]
3383 [ + - ][ + - ]: 24 : xCurrent = xCursor->getStart();
[ + - ]
3384 : : }
3385 : :
3386 : : // And save it, to be used by PopAnnotation() later.
3387 [ + + ]: 24 : if (bStart)
3388 [ + - ]: 12 : m_aAnnotationPosition.m_xStart = xCurrent;
3389 : : else
3390 [ + - ]: 24 : m_aAnnotationPosition.m_xEnd = xCurrent;
3391 : : }
3392 : :
3393 : 60 : GraphicImportPtr DomainMapper_Impl::GetGraphicImport(GraphicImportType eGraphicImportType)
3394 : : {
3395 [ + + ]: 60 : if(!m_pGraphicImport)
3396 [ + - ][ + - ]: 30 : m_pGraphicImport.reset( new GraphicImport( m_xComponentContext, m_xTextFactory, m_rDMapper, eGraphicImportType ) );
[ + - ]
3397 : 60 : return m_pGraphicImport;
3398 : : }
3399 : : /*-------------------------------------------------------------------------
3400 : : reset graphic import if the last import resulted in a shape, not a graphic
3401 : : -----------------------------------------------------------------------*/
3402 : 0 : void DomainMapper_Impl::ResetGraphicImport()
3403 : : {
3404 : 0 : m_pGraphicImport.reset();
3405 : 0 : }
3406 : :
3407 : :
3408 : 30 : void DomainMapper_Impl::ImportGraphic(writerfilter::Reference< Properties >::Pointer_t ref, GraphicImportType eGraphicImportType)
3409 : : {
3410 [ + - ][ + - ]: 30 : GetGraphicImport(eGraphicImportType);
3411 [ + + ][ - + ]: 30 : if( eGraphicImportType != IMPORT_AS_DETECTED_INLINE && eGraphicImportType != IMPORT_AS_DETECTED_ANCHOR )
3412 : : {
3413 : : //create the graphic
3414 [ # # ]: 0 : ref->resolve( *m_pGraphicImport );
3415 : : }
3416 : :
3417 : : //insert it into the document at the current cursor position
3418 : :
3419 : : uno::Reference<text::XTextContent> xTextContent
3420 [ + - ]: 30 : (m_pGraphicImport->GetGraphicObject());
3421 : :
3422 : : //insert it into the document at the current cursor position
3423 : : OSL_ENSURE( xTextContent.is(), "DomainMapper_Impl::ImportGraphic");
3424 [ + - ]: 30 : if( xTextContent.is())
3425 [ + - ][ + - ]: 30 : appendTextContent( xTextContent, uno::Sequence< beans::PropertyValue >() );
[ + - ]
3426 : :
3427 [ + - ]: 30 : m_pGraphicImport.reset();
3428 : 30 : }
3429 : :
3430 : :
3431 : :
3432 : 0 : void DomainMapper_Impl::SetLineNumbering( sal_Int32 nLnnMod, sal_Int32 nLnc, sal_Int32 ndxaLnn )
3433 : : {
3434 [ # # ]: 0 : if( !m_bLineNumberingSet )
3435 : : {
3436 : 0 : const PropertyNameSupplier& rPropNameSupplier = PropertyNameSupplier::GetPropertyNameSupplier();
3437 : :
3438 : : try
3439 : : {
3440 [ # # ]: 0 : uno::Reference< text::XLineNumberingProperties > xLineProperties( m_xTextDocument, uno::UNO_QUERY_THROW );
3441 [ # # ][ # # ]: 0 : uno::Reference< beans::XPropertySet > xProperties = xLineProperties->getLineNumberingProperties();
3442 [ # # ]: 0 : uno::Any aTrue( uno::makeAny( true ));
3443 [ # # ][ # # ]: 0 : xProperties->setPropertyValue( rPropNameSupplier.GetName( PROP_IS_ON ), aTrue);
[ # # ]
3444 [ # # ][ # # ]: 0 : xProperties->setPropertyValue( rPropNameSupplier.GetName( PROP_COUNT_EMPTY_LINES ), aTrue );
[ # # ]
3445 [ # # ][ # # ]: 0 : xProperties->setPropertyValue( rPropNameSupplier.GetName( PROP_COUNT_LINES_IN_FRAMES ), uno::makeAny( false ) );
[ # # ][ # # ]
3446 [ # # ][ # # ]: 0 : xProperties->setPropertyValue( rPropNameSupplier.GetName( PROP_INTERVAL ), uno::makeAny( static_cast< sal_Int16 >( nLnnMod )));
[ # # ][ # # ]
3447 [ # # ][ # # ]: 0 : xProperties->setPropertyValue( rPropNameSupplier.GetName( PROP_DISTANCE ), uno::makeAny( ConversionHelper::convertTwipToMM100(ndxaLnn) ));
[ # # ][ # # ]
[ # # ]
3448 [ # # ][ # # ]: 0 : xProperties->setPropertyValue( rPropNameSupplier.GetName( PROP_NUMBER_POSITION ), uno::makeAny( style::LineNumberPosition::LEFT));
[ # # ][ # # ]
3449 [ # # ][ # # ]: 0 : xProperties->setPropertyValue( rPropNameSupplier.GetName( PROP_NUMBERING_TYPE ), uno::makeAny( style::NumberingType::ARABIC));
[ # # ][ # # ]
3450 [ # # ][ # # ]: 0 : xProperties->setPropertyValue( rPropNameSupplier.GetName( PROP_RESTART_AT_EACH_PAGE ), uno::makeAny( nLnc == 0 ));
[ # # ][ # # ]
[ # # ]
3451 : : }
3452 : 0 : catch( const uno::Exception& )
3453 : : {}
3454 : : }
3455 : 0 : m_bLineNumberingSet = true;
3456 : 0 : }
3457 : :
3458 : :
3459 : 1946 : void DomainMapper_Impl::SetPageMarginTwip( PageMarElement eElement, sal_Int32 nValue )
3460 : : {
3461 : 1946 : nValue = ConversionHelper::convertTwipToMM100(nValue);
3462 [ + + + + : 1946 : switch(eElement)
+ + + - ]
3463 : : {
3464 : 323 : case PAGE_MAR_TOP : m_aPageMargins.top = nValue; break;
3465 : 329 : case PAGE_MAR_RIGHT : m_aPageMargins.right = nValue; break;
3466 : 323 : case PAGE_MAR_BOTTOM : m_aPageMargins.bottom = nValue; break;
3467 : 329 : case PAGE_MAR_LEFT : m_aPageMargins.left = nValue; break;
3468 : 218 : case PAGE_MAR_HEADER : m_aPageMargins.header = nValue; break;
3469 : 215 : case PAGE_MAR_FOOTER : m_aPageMargins.footer = nValue; break;
3470 : 209 : case PAGE_MAR_GUTTER : m_aPageMargins.gutter = nValue; break;
3471 : : }
3472 : 1946 : }
3473 : :
3474 : :
3475 : :
3476 : 838 : _PageMar::_PageMar()
3477 : : {
3478 : 838 : header = footer = ConversionHelper::convertTwipToMM100(sal_Int32(720));
3479 : 838 : top = bottom = ConversionHelper::convertTwipToMM100( sal_Int32(1440));
3480 : 838 : right = left = ConversionHelper::convertTwipToMM100( sal_Int32(1800));
3481 : 838 : gutter = 0;
3482 : 838 : }
3483 : :
3484 : :
3485 : :
3486 : 15 : void DomainMapper_Impl::RegisterFrameConversion(
3487 : : uno::Reference< text::XTextRange > xFrameStartRange,
3488 : : uno::Reference< text::XTextRange > xFrameEndRange,
3489 : : uno::Sequence< beans::PropertyValue > aFrameProperties
3490 : : )
3491 : : {
3492 : : OSL_ENSURE(
3493 : : !m_aFrameProperties.getLength() && !m_xFrameStartRange.is() && !m_xFrameEndRange.is(),
3494 : : "frame properties not removed");
3495 : 15 : m_aFrameProperties = aFrameProperties;
3496 : 15 : m_xFrameStartRange = xFrameStartRange;
3497 : 15 : m_xFrameEndRange = xFrameEndRange;
3498 : 15 : }
3499 : :
3500 : :
3501 : 3079 : bool DomainMapper_Impl::ExecuteFrameConversion()
3502 : : {
3503 : 3079 : bool bRet = false;
3504 [ + + ][ + - ]: 3079 : if( m_xFrameStartRange.is() && m_xFrameEndRange.is() )
[ + + ]
3505 : : {
3506 : 15 : bRet = true;
3507 : : try
3508 : : {
3509 [ + - ][ + - ]: 15 : uno::Reference< text::XTextAppendAndConvert > xTextAppendAndConvert( GetTopTextAppend(), uno::UNO_QUERY_THROW );
3510 [ + - ]: 15 : xTextAppendAndConvert->convertToTextFrame(
3511 : : m_xFrameStartRange,
3512 : : m_xFrameEndRange,
3513 [ + - ][ # # ]: 15 : m_aFrameProperties );
3514 : : }
3515 : 0 : catch( const uno::Exception& rEx)
3516 : : {
3517 : : #if OSL_DEBUG_LEVEL > 1
3518 : : fprintf( stderr, "Exception caught when converting to frame: %s\n",
3519 : : OUStringToOString( rEx.Message, RTL_TEXTENCODING_UTF8 ).getStr() );
3520 : : #endif
3521 : : (void)rEx;
3522 : 0 : bRet = false;
3523 : : }
3524 : 15 : m_xFrameStartRange = 0;
3525 : 15 : m_xFrameEndRange = 0;
3526 : 15 : m_aFrameProperties.realloc( 0 );
3527 : : }
3528 : 3079 : return bRet;
3529 : : }
3530 : :
3531 : 0 : void DomainMapper_Impl::AddNewRedline( )
3532 : : {
3533 [ # # ][ # # ]: 0 : RedlineParamsPtr pNew( new RedlineParams );
3534 : 0 : pNew->m_nToken = ooxml::OOXML_mod;
3535 [ # # ]: 0 : if ( !m_bIsParaChange )
3536 : : {
3537 [ # # ]: 0 : m_aRedlines.push_back( pNew );
3538 : : }
3539 : : else
3540 : : {
3541 : 0 : m_pParaRedline.swap( pNew );
3542 [ # # ]: 0 : }
3543 : 0 : }
3544 : :
3545 : 12 : RedlineParamsPtr DomainMapper_Impl::GetTopRedline( )
3546 : : {
3547 : 12 : RedlineParamsPtr pResult;
3548 [ - + ][ - + ]: 12 : if ( !m_bIsParaChange && m_aRedlines.size( ) > 0 )
[ + - ]
3549 [ # # ][ # # ]: 0 : pResult = m_aRedlines.back( );
3550 [ - + ]: 12 : else if ( m_bIsParaChange )
3551 [ # # ]: 0 : pResult = m_pParaRedline;
3552 : 12 : return pResult;
3553 : : }
3554 : :
3555 : 0 : sal_Int32 DomainMapper_Impl::GetCurrentRedlineToken( )
3556 : : {
3557 : 0 : sal_Int32 nToken = 0;
3558 [ # # ]: 0 : RedlineParamsPtr pCurrent( GetTopRedline( ) );
3559 [ # # ]: 0 : if ( pCurrent.get( ) )
3560 : 0 : nToken = pCurrent->m_nToken;
3561 [ # # ]: 0 : return nToken;
3562 : : }
3563 : :
3564 : 12 : void DomainMapper_Impl::SetCurrentRedlineAuthor( OUString sAuthor )
3565 : : {
3566 [ - + ]: 12 : if (!m_xAnnotationField.is())
3567 : : {
3568 [ # # ]: 0 : RedlineParamsPtr pCurrent( GetTopRedline( ) );
3569 [ # # ]: 0 : if ( pCurrent.get( ) )
3570 [ # # ]: 0 : pCurrent->m_sAuthor = sAuthor;
3571 : : }
3572 : : else
3573 [ + - ]: 12 : m_xAnnotationField->setPropertyValue("Author", uno::makeAny(sAuthor));
3574 : 12 : }
3575 : :
3576 : 12 : void DomainMapper_Impl::SetCurrentRedlineInitials( OUString sInitials )
3577 : : {
3578 [ + - ]: 12 : if (m_xAnnotationField.is())
3579 [ + - ]: 12 : m_xAnnotationField->setPropertyValue("Initials", uno::makeAny(sInitials));
3580 : 12 : }
3581 : :
3582 : 12 : void DomainMapper_Impl::SetCurrentRedlineDate( OUString sDate )
3583 : : {
3584 [ - + ]: 12 : if (!m_xAnnotationField.is())
3585 : : {
3586 [ # # ]: 0 : RedlineParamsPtr pCurrent( GetTopRedline( ) );
3587 [ # # ]: 0 : if ( pCurrent.get( ) )
3588 [ # # ]: 0 : pCurrent->m_sDate = sDate;
3589 : : }
3590 : : else
3591 [ + - ][ + - ]: 12 : m_xAnnotationField->setPropertyValue("DateTimeValue", uno::makeAny(lcl_DateStringToDateTime(sDate)));
3592 : 12 : }
3593 : :
3594 : 12 : void DomainMapper_Impl::SetCurrentRedlineId( sal_Int32 sId )
3595 : : {
3596 [ + - ]: 12 : RedlineParamsPtr pCurrent( GetTopRedline( ) );
3597 [ - + ]: 12 : if ( pCurrent.get( ) )
3598 [ + - ]: 12 : pCurrent->m_nId = sId;
3599 : 12 : }
3600 : :
3601 : 0 : void DomainMapper_Impl::SetCurrentRedlineToken( sal_Int32 nToken )
3602 : : {
3603 [ # # ]: 0 : RedlineParamsPtr pCurrent( GetTopRedline( ) );
3604 [ # # ]: 0 : if ( pCurrent.get( ) )
3605 [ # # ]: 0 : pCurrent->m_nToken = nToken;
3606 : 0 : }
3607 : :
3608 : :
3609 : :
3610 : 0 : void DomainMapper_Impl::RemoveCurrentRedline( )
3611 : : {
3612 [ # # ]: 0 : if ( m_aRedlines.size( ) > 0 )
3613 : : {
3614 : 0 : m_aRedlines.pop_back( );
3615 : : }
3616 : 0 : }
3617 : :
3618 : 0 : void DomainMapper_Impl::ResetParaRedline( )
3619 : : {
3620 [ # # ]: 0 : if ( m_pParaRedline.get( ) )
3621 : : {
3622 [ # # ]: 0 : RedlineParamsPtr pEmpty;
3623 [ # # ]: 0 : m_pParaRedline.swap( pEmpty );
3624 : : }
3625 : 0 : }
3626 : :
3627 : :
3628 : :
3629 : 479 : void DomainMapper_Impl::ApplySettingsTable()
3630 : : {
3631 [ + - ][ + + ]: 479 : if( m_pSettingsTable && m_xTextFactory.is() )
[ + + ]
3632 : : {
3633 : : try
3634 : : {
3635 [ + - ][ + - ]: 455 : uno::Reference< beans::XPropertySet > xTextDefaults(m_xTextFactory->createInstance("com.sun.star.text.Defaults"), uno::UNO_QUERY_THROW );
[ + - ]
3636 [ + - ]: 455 : sal_Int32 nDefTab = m_pSettingsTable->GetDefaultTabStop();
3637 [ + - ][ + - ]: 455 : xTextDefaults->setPropertyValue( PropertyNameSupplier::GetPropertyNameSupplier().GetName( PROP_TAB_STOP_DISTANCE ), uno::makeAny(nDefTab) );
[ + - ][ + - ]
[ + - ]
3638 [ + + ][ + - ]: 455 : if (m_pSettingsTable->GetLinkStyles())
3639 : : {
3640 [ + - ]: 3 : PropertyNameSupplier& rSupplier = PropertyNameSupplier::GetPropertyNameSupplier();
3641 : : // If linked styles are enabled, set paragraph defaults from Word's default template
3642 [ + - ][ + - ]: 3 : xTextDefaults->setPropertyValue(rSupplier.GetName(PROP_PARA_BOTTOM_MARGIN), uno::makeAny(ConversionHelper::convertTwipToMM100(200)));
[ + - ][ + - ]
[ + - ]
3643 : 3 : style::LineSpacing aSpacing;
3644 : 3 : aSpacing.Mode = style::LineSpacingMode::PROP;
3645 : 3 : aSpacing.Height = sal_Int16(115);
3646 [ + - ][ + - ]: 3 : xTextDefaults->setPropertyValue(rSupplier.GetName(PROP_PARA_LINE_SPACING), uno::makeAny(aSpacing));
[ + - ][ + - ]
3647 : : }
3648 : :
3649 [ + - ][ + + ]: 455 : if (m_pSettingsTable->GetZoomFactor())
3650 : : {
3651 [ + - ]: 248 : uno::Sequence<beans::PropertyValue> aViewProps(3);
3652 [ + - ]: 248 : aViewProps[0].Name = "ZoomFactor";
3653 [ + - ][ + - ]: 248 : aViewProps[0].Value <<= m_pSettingsTable->GetZoomFactor();
[ + - ]
3654 [ + - ]: 248 : aViewProps[1].Name = "VisibleBottom";
3655 [ + - ][ + - ]: 248 : aViewProps[1].Value <<= sal_Int32(0);
3656 [ + - ]: 248 : aViewProps[2].Name = "ZoomType";
3657 [ + - ][ + - ]: 248 : aViewProps[2].Value <<= sal_Int16(0);
3658 : :
3659 [ + - ][ + - ]: 496 : uno::Reference<container::XIndexContainer> xBox(m_xComponentContext->getServiceManager()->createInstanceWithContext("com.sun.star.document.IndexedPropertyValues",
[ + - ]
3660 [ + - ][ + - ]: 248 : m_xComponentContext), uno::UNO_QUERY );
3661 [ + - ][ + - ]: 248 : xBox->insertByIndex(sal_Int32(0), uno::makeAny(aViewProps));
[ + - ]
3662 [ + - ]: 248 : uno::Reference<container::XIndexAccess> xIndexAccess(xBox, uno::UNO_QUERY);
3663 [ + - ]: 248 : uno::Reference<document::XViewDataSupplier> xViewDataSupplier(m_xTextDocument, uno::UNO_QUERY);
3664 [ + - ][ + - ]: 248 : xViewDataSupplier->setViewData(xIndexAccess);
[ + - ]
3665 [ # # ]: 455 : }
3666 : : }
3667 : 0 : catch(const uno::Exception&)
3668 : : {
3669 : : }
3670 : : }
3671 : 479 : }
3672 : :
3673 : 13541 : uno::Reference<beans::XPropertySet> DomainMapper_Impl::GetCurrentNumberingCharStyle()
3674 : : {
3675 : 13541 : uno::Reference<beans::XPropertySet> xRet;
3676 : : try
3677 : : {
3678 : 13541 : OUString aStyle = GetCurrentParaStyleId();
3679 [ + - ][ + + ]: 13541 : if (aStyle.isEmpty() || GetTopContextType() != CONTEXT_PARAGRAPH)
[ + + ][ + + ]
3680 : : return xRet;
3681 [ + - ][ + - ]: 312 : const StyleSheetEntryPtr pEntry = GetStyleSheetTable()->FindStyleSheetByISTD(aStyle);
[ + - ]
3682 [ + + ]: 312 : if (!pEntry)
3683 : : return xRet;
3684 [ + - ][ - + ]: 180 : const StyleSheetPropertyMap* pStyleSheetProperties = dynamic_cast<const StyleSheetPropertyMap*>(pEntry ? pEntry->pProperties.get() : 0);
3685 : 180 : sal_Int32 nListId = pStyleSheetProperties->GetListId();
3686 : 180 : sal_Int32 nListLevel = pStyleSheetProperties->GetListLevel();
3687 [ - + ][ + + ]: 180 : if (nListId < 0 || nListLevel < 0)
3688 : : return xRet;
3689 : :
3690 : : // So we are in a paragraph style and it has numbering. Look up the relevant character style.
3691 [ + - ]: 6 : OUString aListName = ListDef::GetStyleName(nListId);
3692 [ + - ][ + - ]: 6 : uno::Reference< style::XStyleFamiliesSupplier > xStylesSupplier(GetTextDocument(), uno::UNO_QUERY);
3693 [ + - ][ + - ]: 6 : uno::Reference< container::XNameAccess > xStyleFamilies = xStylesSupplier->getStyleFamilies();
3694 : 6 : uno::Reference<container::XNameAccess> xNumberingStyles;
3695 [ + - ][ + - ]: 6 : xStyleFamilies->getByName("NumberingStyles") >>= xNumberingStyles;
[ + - ]
3696 [ + - ][ + - ]: 6 : uno::Reference<beans::XPropertySet> xStyle(xNumberingStyles->getByName(aListName), uno::UNO_QUERY);
[ + - ]
3697 [ + - ][ + - ]: 6 : uno::Reference<container::XIndexAccess> xLevels(xStyle->getPropertyValue("NumberingRules"), uno::UNO_QUERY);
[ + - ]
3698 [ + - ]: 6 : uno::Sequence<beans::PropertyValue> aProps;
3699 [ + - ][ + - ]: 6 : xLevels->getByIndex(nListLevel) >>= aProps;
[ + - ]
3700 [ + - ]: 30 : for (int i = 0; i < aProps.getLength(); ++i)
3701 : : {
3702 [ + - ]: 30 : const beans::PropertyValue& rProp = aProps[i];
3703 : :
3704 [ + + ]: 30 : if (rProp.Name == "CharStyleName")
3705 : : {
3706 : 6 : OUString aCharStyle;
3707 : 6 : rProp.Value >>= aCharStyle;
3708 : 6 : uno::Reference<container::XNameAccess> xCharacterStyles;
3709 [ + - ][ + - ]: 6 : xStyleFamilies->getByName("CharacterStyles") >>= xCharacterStyles;
[ + - ]
3710 [ + - ][ + - ]: 6 : xRet.set(xCharacterStyles->getByName(aCharStyle), uno::UNO_QUERY_THROW);
[ + - ]
3711 : 6 : break;
3712 : : }
3713 [ + - ][ + - ]: 13541 : }
[ + + ][ + + ]
[ # # ]
3714 : : }
3715 [ # # ]: 0 : catch( const uno::Exception& )
3716 : : {
3717 : : }
3718 : 13541 : return xRet;
3719 : : }
3720 : :
3721 : 73015 : SectionPropertyMap * DomainMapper_Impl::GetSectionContext()
3722 : : {
3723 : 73015 : SectionPropertyMap* pSectionContext = 0;
3724 : : //the section context is not availabe before the first call of startSectionGroup()
3725 [ + + ]: 73015 : if( !IsAnyTableImport() )
3726 : : {
3727 [ + - ]: 56068 : PropertyMapPtr pContext = GetTopContextOfType(CONTEXT_SECTION);
3728 : : OSL_ENSURE(pContext.get(), "Section context is not in the stack!");
3729 [ + + ][ + - ]: 56068 : pSectionContext = dynamic_cast< SectionPropertyMap* >( pContext.get() );
3730 : : }
3731 : :
3732 : 73015 : return pSectionContext;
3733 : : }
3734 : :
3735 : 14842 : void DomainMapper_Impl::deferCharacterProperty( sal_Int32 id, com::sun::star::uno::Any value )
3736 : : {
3737 : 14842 : deferredCharacterProperties[ id ] = value;
3738 : 14842 : }
3739 : :
3740 : 12033 : void DomainMapper_Impl::processDeferredCharacterProperties()
3741 : : {
3742 : : // ACtually process in DomainMapper, so that it's the same source file like normal processing.
3743 [ + - ]: 12033 : if( !deferredCharacterProperties.empty())
3744 : : {
3745 : 12033 : m_rDMapper.processDeferredCharacterProperties( deferredCharacterProperties );
3746 : 12033 : deferredCharacterProperties.clear();
3747 : : }
3748 : 12033 : }
3749 : :
3750 : 36 : sal_Int32 DomainMapper_Impl::getCurrentNumberingProperty(OUString aProp)
3751 : : {
3752 : 36 : sal_Int32 nRet = 0;
3753 : :
3754 [ + - ]: 36 : PropertyMap::iterator it = m_pTopContext->find(PropertyDefinition( PROP_NUMBERING_RULES, true ) );
3755 : 36 : uno::Reference<container::XIndexAccess> xNumberingRules;
3756 [ + + ]: 36 : if (it != m_pTopContext->end())
3757 [ + - ]: 9 : xNumberingRules.set(it->second, uno::UNO_QUERY);
3758 [ + - ]: 36 : it = m_pTopContext->find(PropertyDefinition( PROP_NUMBERING_LEVEL, true ) );
3759 : 36 : sal_Int32 nNumberingLevel = -1;
3760 [ + + ]: 36 : if (it != m_pTopContext->end())
3761 : 9 : it->second >>= nNumberingLevel;
3762 [ + + ][ + - ]: 36 : if (xNumberingRules.is() && nNumberingLevel != -1)
[ + + ]
3763 : : {
3764 [ + - ]: 9 : uno::Sequence<beans::PropertyValue> aProps;
3765 [ + - ][ + - ]: 9 : xNumberingRules->getByIndex(nNumberingLevel) >>= aProps;
[ + - ]
3766 [ + - ]: 93 : for (int i = 0; i < aProps.getLength(); ++i)
3767 : : {
3768 [ + - ]: 93 : const beans::PropertyValue& rProp = aProps[i];
3769 : :
3770 [ + + ]: 93 : if (rProp.Name == aProp)
3771 : : {
3772 : 9 : rProp.Value >>= nRet;
3773 : 9 : break;
3774 : : }
3775 [ + - ]: 9 : }
3776 : : }
3777 : :
3778 : 36 : return nRet;
3779 : : }
3780 : :
3781 [ + - ][ + - ]: 60 : }}
3782 : :
3783 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|