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 : #ifndef INCLUDED_DMAPPER_DOMAINMAPPER_IMPL_HXX
20 : #define INCLUDED_DMAPPER_DOMAINMAPPER_IMPL_HXX
21 :
22 : #include <com/sun/star/text/XParagraphCursor.hpp>
23 : #include <com/sun/star/text/XTextDocument.hpp>
24 : #include <com/sun/star/text/XTextCursor.hpp>
25 : #include <com/sun/star/text/XTextAppend.hpp>
26 : #include <com/sun/star/text/XTextAppendAndConvert.hpp>
27 : #include <com/sun/star/text/XTextFrame.hpp>
28 : #include <com/sun/star/style/TabStop.hpp>
29 : #include <com/sun/star/container/XNameContainer.hpp>
30 : #include <vector>
31 : #include <stack>
32 : #include <boost/optional.hpp>
33 :
34 : #ifndef INCLUDED_RESOURCESIDS
35 : #include <doctok/resourceids.hxx>
36 : #include <ooxml/resourceids.hxx>
37 : #endif
38 : #include <dmapper/DomainMapper.hxx>
39 : #include <DomainMapperTableManager.hxx>
40 : #include <PropertyMap.hxx>
41 : #include <FontTable.hxx>
42 : #include <NumberingManager.hxx>
43 : #include <StyleSheetTable.hxx>
44 : #include <SettingsTable.hxx>
45 : #include <ThemeTable.hxx>
46 : #include <GraphicImport.hxx>
47 : #include <OLEHandler.hxx>
48 : #include <FFDataHandler.hxx>
49 : #include <FormControlHelper.hxx>
50 : #include <map>
51 :
52 : #include <string.h>
53 :
54 : namespace com{ namespace sun{ namespace star{
55 : namespace awt{
56 : struct Size;
57 : }
58 : namespace lang{
59 : class XMultiServiceFactory;
60 : struct Locale;
61 : }
62 : namespace text
63 : {
64 : class XTextField;
65 : class XFormField;
66 : }
67 : namespace beans{ class XPropertySet;}
68 : }}}
69 :
70 : namespace writerfilter {
71 : namespace dmapper {
72 :
73 : using namespace com::sun::star;
74 :
75 : class SdtHelper;
76 :
77 : struct _PageMar
78 : {
79 : sal_Int32 top;
80 : sal_Int32 right;
81 : sal_Int32 bottom;
82 : sal_Int32 left;
83 : sal_Int32 header;
84 : sal_Int32 footer;
85 : sal_Int32 gutter;
86 : public:
87 : _PageMar();
88 : };
89 : enum PageMarElement
90 : {
91 : PAGE_MAR_TOP,
92 : PAGE_MAR_RIGHT,
93 : PAGE_MAR_BOTTOM,
94 : PAGE_MAR_LEFT,
95 : PAGE_MAR_HEADER,
96 : PAGE_MAR_FOOTER,
97 : PAGE_MAR_GUTTER
98 : };
99 :
100 : /*-------------------------------------------------------------------------
101 : property stack element
102 : -----------------------------------------------------------------------*/
103 : enum ContextType
104 : {
105 : CONTEXT_SECTION,
106 : CONTEXT_PARAGRAPH,
107 : CONTEXT_CHARACTER,
108 : CONTEXT_STYLESHEET,
109 : CONTEXT_LIST,
110 : NUMBER_OF_CONTEXTS
111 : };
112 :
113 : enum BreakType
114 : {
115 : PAGE_BREAK,
116 : COLUMN_BREAK
117 : };
118 : /*--------------------------------------------------
119 : field stack element
120 : * --------------------------------------------------*/
121 : class FieldContext
122 : {
123 : bool m_bFieldCommandCompleted;
124 : ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > m_xStartRange;
125 :
126 : OUString m_sCommand;
127 :
128 : ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextField > m_xTextField;
129 : ::com::sun::star::uno::Reference< ::com::sun::star::text::XFormField > m_xFormField;
130 : ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > m_xTOC;//TOX
131 : ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > m_xTC;//TOX entry
132 : OUString m_sHyperlinkURL;
133 : FFDataHandler::Pointer_t m_pFFDataHandler;
134 : FormControlHelper::Pointer_t m_pFormControlHelper;
135 :
136 : public:
137 : FieldContext(::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > xStart);
138 : ~FieldContext();
139 :
140 27 : ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > GetStartRange() const { return m_xStartRange; }
141 :
142 : void AppendCommand(const OUString& rPart);
143 71 : const OUString& GetCommand() const {return m_sCommand; }
144 :
145 27 : void SetCommandCompleted() { m_bFieldCommandCompleted = true; }
146 110 : bool IsCommandCompleted() const { return m_bFieldCommandCompleted; }
147 :
148 56 : ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextField > GetTextField() const { return m_xTextField;}
149 27 : void SetTextField(::com::sun::star::uno::Reference< ::com::sun::star::text::XTextField > xTextField) { m_xTextField = xTextField;}
150 5 : ::com::sun::star::uno::Reference< ::com::sun::star::text::XFormField > GetFormField() const { return m_xFormField;}
151 5 : void SetFormField(::com::sun::star::uno::Reference< ::com::sun::star::text::XFormField > xFormField) { m_xFormField = xFormField;}
152 :
153 0 : void SetTOC( ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > xTOC ) { m_xTOC = xTOC; }
154 27 : ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > GetTOC() { return m_xTOC; }
155 :
156 0 : void SetTC( ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > xTC ) { m_xTC = xTC; }
157 27 : ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > GetTC( ) { return m_xTC; }
158 :
159 8 : void SetHyperlinkURL( const OUString& rURL ) { m_sHyperlinkURL = rURL; }
160 20 : const OUString& GetHyperlinkURL() { return m_sHyperlinkURL; }
161 :
162 14 : void setFFDataHandler(FFDataHandler::Pointer_t pFFDataHandler) { m_pFFDataHandler = pFFDataHandler; }
163 5 : FFDataHandler::Pointer_t getFFDataHandler() const { return m_pFFDataHandler; }
164 :
165 5 : void setFormControlHelper(FormControlHelper::Pointer_t pFormControlHelper) { m_pFormControlHelper = pFormControlHelper; }
166 17 : FormControlHelper::Pointer_t getFormControlHelper() const { return m_pFormControlHelper; }
167 :
168 : ::std::vector<OUString> GetCommandParts() const;
169 : };
170 :
171 1560 : struct TextAppendContext
172 : {
173 : ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextAppend > xTextAppend;
174 : ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > xInsertPosition;
175 : ::com::sun::star::uno::Reference< ::com::sun::star::text::XParagraphCursor > xCursor;
176 : ParagraphPropertiesPtr pLastParagraphProperties;
177 :
178 520 : TextAppendContext( const ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextAppend >& xAppend,
179 : const ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextCursor >& xCur ) :
180 520 : xTextAppend( xAppend )
181 : {
182 520 : xCursor.set(xCur, uno::UNO_QUERY);
183 520 : xInsertPosition.set(xCursor, uno::UNO_QUERY);
184 520 : }
185 : };
186 :
187 264 : struct AnchoredContext
188 : {
189 : ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextContent > xTextContent;
190 : bool bToRemove;
191 :
192 88 : AnchoredContext( const ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextContent >& xContent ) :
193 88 : xTextContent( xContent ), bToRemove( false ) {}
194 : };
195 :
196 : typedef boost::shared_ptr<FieldContext> FieldContextPtr;
197 :
198 : typedef std::stack<ContextType> ContextStack;
199 : typedef std::stack<PropertyMapPtr> PropertyStack;
200 : typedef std::stack< TextAppendContext > TextAppendStack;
201 : typedef std::stack<FieldContextPtr> FieldStack;
202 : typedef std::stack< AnchoredContext > TextContentStack;
203 :
204 :
205 :
206 : class FIB
207 : {
208 : sal_Int32 aFIBData[ NS_rtf::LN_LCBSTTBFUSSR - NS_rtf::LN_WIDENT + 1];
209 : sal_Int32 nLNCHS;
210 : public:
211 357 : FIB() :
212 357 : nLNCHS( 0 )
213 : {
214 357 : memset(&aFIBData, 0x00, sizeof(aFIBData));
215 357 : }
216 :
217 : sal_Int32 GetLNCHS() const {return nLNCHS;}
218 0 : void SetLNCHS(sal_Int32 nValue) {nLNCHS = nValue;}
219 : void SetData( Id nName, sal_Int32 nValue );
220 : };
221 :
222 : /*-------------------------------------------------------------------------
223 : extended tab stop struct
224 : -----------------------------------------------------------------------*/
225 : struct DeletableTabStop : public ::com::sun::star::style::TabStop
226 : {
227 : bool bDeleted;
228 726 : DeletableTabStop() :
229 726 : bDeleted( false ){}
230 0 : DeletableTabStop( const ::com::sun::star::style::TabStop& rTabStop ) :
231 : TabStop( rTabStop ),
232 0 : bDeleted( false ){}
233 : };
234 : /*-------------------------------------------------------------------------
235 : /// helper to remember bookmark start position
236 : -----------------------------------------------------------------------*/
237 230 : struct BookmarkInsertPosition
238 : {
239 : bool m_bIsStartOfText;
240 : OUString m_sBookmarkName;
241 : ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > m_xTextRange;
242 46 : BookmarkInsertPosition(bool bIsStartOfText, const OUString& rName, ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > xTextRange):
243 : m_bIsStartOfText( bIsStartOfText ),
244 : m_sBookmarkName( rName ),
245 46 : m_xTextRange( xTextRange )
246 46 : {}
247 : };
248 :
249 : /// Stores the start/end positions of an annotation before its insertion.
250 714 : struct AnnotationPosition
251 : {
252 : ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > m_xStart;
253 : ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > m_xEnd;
254 : };
255 :
256 18 : struct RedlineParams
257 : {
258 : OUString m_sAuthor;
259 : OUString m_sDate;
260 : sal_Int32 m_nId;
261 : sal_Int32 m_nToken;
262 : };
263 : typedef boost::shared_ptr< RedlineParams > RedlineParamsPtr;
264 :
265 :
266 :
267 : struct LineNumberSettings
268 : {
269 : bool bIsOn;
270 : sal_Int32 nDistance;
271 : sal_Int32 nInterval;
272 : sal_Int32 bRestartAtEachPage;
273 : sal_Int32 nStartValue;
274 357 : LineNumberSettings() :
275 : bIsOn(false)
276 : ,nDistance(0)
277 : ,nInterval(0)
278 : ,bRestartAtEachPage(true)
279 357 : ,nStartValue(1)
280 357 : {}
281 :
282 : };
283 :
284 :
285 : class DomainMapper;
286 : class WRITERFILTER_DLLPRIVATE DomainMapper_Impl
287 : {
288 : public:
289 : typedef TableManager< ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange >, PropertyMapPtr > TableManager_t;
290 : typedef TableDataHandler< ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange >, TablePropertyMapPtr > TableDataHandler_t;
291 : typedef std::map < OUString, BookmarkInsertPosition > BookmarkMap_t;
292 :
293 : private:
294 : SourceDocumentType m_eDocumentType;
295 : DomainMapper& m_rDMapper;
296 : ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextDocument > m_xTextDocument;
297 : ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > m_xDocumentSettings;
298 : ::com::sun::star::uno::Reference < ::com::sun::star::lang::XMultiServiceFactory > m_xTextFactory;
299 : ::com::sun::star::uno::Reference < com::sun::star::uno::XComponentContext > m_xComponentContext;
300 : ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer > m_xPageStyles;
301 : ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > m_xBodyText;
302 :
303 : TextAppendStack m_aTextAppendStack;
304 :
305 : TextContentStack m_aAnchoredStack;
306 :
307 : FieldStack m_aFieldStack;
308 : bool m_bSetUserFieldContent;
309 : bool m_bIsFirstSection;
310 : bool m_bIsColumnBreakDeferred;
311 : bool m_bIsPageBreakDeferred;
312 :
313 : LineNumberSettings m_aLineNumberSettings;
314 :
315 : BookmarkMap_t m_aBookmarkMap;
316 :
317 : _PageMar m_aPageMargins;
318 :
319 :
320 : // TableManagers are stacked: one for each stream to avoid any confusion
321 : std::stack< boost::shared_ptr< DomainMapperTableManager > > m_aTableManagers;
322 : TableDataHandler_t::Pointer_t m_pTableHandler;
323 :
324 : //each context needs a stack of currently used attributes
325 : FIB m_aFIB;
326 : PropertyStack m_aPropertyStacks[NUMBER_OF_CONTEXTS];
327 : ContextStack m_aContextStack;
328 : FontTablePtr m_pFontTable;
329 : ListsManager::Pointer m_pListTable;
330 : std::deque< com::sun::star::uno::Reference< com::sun::star::drawing::XShape > > m_aPendingShapes;
331 : StyleSheetTablePtr m_pStyleSheetTable;
332 : ThemeTablePtr m_pThemeTable;
333 : SettingsTablePtr m_pSettingsTable;
334 : GraphicImportPtr m_pGraphicImport;
335 :
336 :
337 : PropertyMapPtr m_pTopContext;
338 : PropertyMapPtr m_pLastSectionContext;
339 : PropertyMapPtr m_pLastCharacterContext;
340 :
341 : ::std::vector<DeletableTabStop> m_aCurrentTabStops;
342 : sal_uInt32 m_nCurrentTabStopIndex;
343 : OUString m_sCurrentParaStyleId;
344 : bool m_bInStyleSheetImport; //in import of fonts, styles, lists or lfos
345 : bool m_bInAnyTableImport; //in import of fonts, styles, lists or lfos
346 : bool m_bInHeaderFooterImport;
347 : bool m_bDiscardHeaderFooter;
348 :
349 : bool m_bLineNumberingSet;
350 : bool m_bIsInFootnoteProperties;
351 : bool m_bIsCustomFtnMark;
352 :
353 : //registered frame properties
354 : ::com::sun::star::uno::Sequence< beans::PropertyValue > m_aFrameProperties;
355 : ::com::sun::star::uno::Reference< text::XTextRange > m_xFrameStartRange;
356 : ::com::sun::star::uno::Reference< text::XTextRange > m_xFrameEndRange;
357 :
358 : // Redline stack
359 : std::vector< RedlineParamsPtr > m_aRedlines;
360 : RedlineParamsPtr m_pParaRedline;
361 : bool m_bIsParaChange;
362 :
363 : /// If the current paragraph has any runs.
364 : bool m_bParaChanged;
365 : bool m_bIsFirstParaInSection;
366 : bool m_bIsLastParaInSection;
367 : bool m_bIsInComments;
368 : /// If the current paragraph contains section property definitions.
369 : bool m_bParaSectpr;
370 : bool m_bUsingEnhancedFields;
371 : /// If the current paragraph is inside a structured document element.
372 : bool m_bSdt;
373 :
374 : //annotation import
375 : uno::Reference< beans::XPropertySet > m_xAnnotationField;
376 : AnnotationPosition m_aAnnotationPosition;
377 :
378 : void GetCurrentLocale(::com::sun::star::lang::Locale& rLocale);
379 : void SetNumberFormat( const OUString& rCommand,
380 : ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xPropertySet );
381 : ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >
382 : FindOrCreateFieldMaster( const sal_Char* pFieldMasterService,
383 : const OUString& rFieldMasterName )
384 : throw(::com::sun::star::uno::Exception);
385 : ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > GetDocumentSettings();
386 :
387 : std::map< sal_Int32, com::sun::star::uno::Any > deferredCharacterProperties;
388 :
389 : public:
390 : ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > m_xInsertTextRange;
391 : private:
392 : bool m_bIsNewDoc;
393 :
394 : public:
395 : DomainMapper_Impl(
396 : DomainMapper& rDMapper,
397 : uno::Reference < uno::XComponentContext > xContext,
398 : uno::Reference< lang::XComponent > xModel,
399 : SourceDocumentType eDocumentType,
400 : uno::Reference< text::XTextRange > xInsertTextRange,
401 : bool bIsNewDoc );
402 : virtual ~DomainMapper_Impl();
403 :
404 471 : SectionPropertyMap* GetLastSectionContext( )
405 : {
406 471 : return dynamic_cast< SectionPropertyMap* >( m_pLastSectionContext.get( ) );
407 : }
408 :
409 : ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer > GetPageStyles();
410 : ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > GetBodyText();
411 894 : ::com::sun::star::uno::Reference < ::com::sun::star::lang::XMultiServiceFactory > GetTextFactory() const
412 : {
413 894 : return m_xTextFactory;
414 : }
415 : ::com::sun::star::uno::Reference < com::sun::star::uno::XComponentContext > GetComponentContext() const
416 : {
417 : return m_xComponentContext;
418 : }
419 2236 : ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextDocument > GetTextDocument() const
420 : {
421 2236 : return m_xTextDocument;
422 : }
423 : void SetDocumentSettingsProperty( const OUString& rPropName, const uno::Any& rValue );
424 :
425 : void CreateRedline( ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > xRange, RedlineParamsPtr& pRedline );
426 :
427 : void CheckParaRedline( ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > xRange );
428 :
429 : void CheckRedline( ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > xRange );
430 :
431 : void StartParaChange( );
432 : void EndParaChange( );
433 :
434 : void RemoveLastParagraph( );
435 : void SetIsLastParagraphInSection( bool bIsLast );
436 : bool GetIsLastParagraphInSection();
437 : void SetIsFirstParagraphInSection( bool bIsFirst );
438 : bool GetIsFirstParagraphInSection();
439 : void SetParaSectpr(bool bParaSectpr);
440 : bool GetParaSectpr();
441 : /// Setter method for m_bSdt.
442 : void SetSdt(bool bSdt);
443 : /// Getter method for m_bSdt.
444 : bool GetSdt();
445 : bool GetParaChanged();
446 :
447 : void deferBreak( BreakType deferredBreakType );
448 : bool isBreakDeferred( BreakType deferredBreakType );
449 : void clearDeferredBreaks();
450 : void clearDeferredBreak(BreakType deferredBreakType);
451 : void finishParagraph( PropertyMapPtr pPropertyMap );
452 : void appendTextPortion( const OUString& rString, PropertyMapPtr pPropertyMap );
453 : void appendTextContent( const ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextContent >,
454 : const uno::Sequence< beans::PropertyValue > );
455 : void appendOLE( const OUString& rStreamName, OLEHandlerPtr pOleHandler );
456 : void appendStarMath( const Value& v );
457 : ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > appendTextSectionAfter(
458 : ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange >& xBefore );
459 :
460 0 : FIB& GetFIB() {return m_aFIB;}
461 : // push the new properties onto the stack and make it the 'current' property map
462 : void PushProperties(ContextType eId);
463 : void PushStyleProperties(PropertyMapPtr pStyleProperties);
464 : void PushListProperties(PropertyMapPtr pListProperties);
465 : void PopProperties(ContextType eId);
466 :
467 5428 : ContextType GetTopContextType() const { return m_aContextStack.top(); }
468 57778 : PropertyMapPtr GetTopContext()
469 : {
470 57778 : return m_pTopContext;
471 : }
472 : PropertyMapPtr GetTopContextOfType(ContextType eId);
473 :
474 : ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextAppend > GetTopTextAppend();
475 :
476 5381 : FontTablePtr GetFontTable()
477 : {
478 5381 : if(!m_pFontTable)
479 274 : m_pFontTable.reset(new FontTable());
480 5381 : return m_pFontTable;
481 : }
482 2515 : StyleSheetTablePtr GetStyleSheetTable()
483 : {
484 2515 : if(!m_pStyleSheetTable)
485 350 : m_pStyleSheetTable.reset(new StyleSheetTable( m_rDMapper, m_xTextDocument, m_bIsNewDoc ));
486 2515 : return m_pStyleSheetTable;
487 : }
488 : ListsManager::Pointer GetListTable();
489 641 : ThemeTablePtr GetThemeTable()
490 : {
491 641 : if(!m_pThemeTable)
492 91 : m_pThemeTable.reset( new ThemeTable );
493 641 : return m_pThemeTable;
494 : }
495 :
496 2217 : SettingsTablePtr GetSettingsTable()
497 : {
498 2217 : if( !m_pSettingsTable )
499 356 : m_pSettingsTable.reset( new SettingsTable( m_rDMapper, m_xTextFactory ) );
500 2217 : return m_pSettingsTable;
501 : }
502 :
503 : GraphicImportPtr GetGraphicImport( GraphicImportType eGraphicImportType );
504 : void ResetGraphicImport();
505 : // this method deletes the current m_pGraphicImport after import
506 : void ImportGraphic(writerfilter::Reference< Properties>::Pointer_t, GraphicImportType eGraphicImportType );
507 :
508 : void InitTabStopFromStyle( const ::com::sun::star::uno::Sequence< ::com::sun::star::style::TabStop >& rInitTabStops );
509 : void ModifyCurrentTabStop( Id nId, sal_Int32 nValue);
510 : void IncorporateTabStop( const DeletableTabStop &aTabStop );
511 : ::com::sun::star::uno::Sequence< ::com::sun::star::style::TabStop > GetCurrentTabStopAndClear();
512 0 : void NextTabStop() {++m_nCurrentTabStopIndex;}
513 :
514 2910 : void SetCurrentParaStyleId(OUString sStringValue) {m_sCurrentParaStyleId = sStringValue;}
515 5856 : OUString GetCurrentParaStyleId() const {return m_sCurrentParaStyleId;}
516 :
517 : ::com::sun::star::uno::Any GetPropertyFromStyleSheet(PropertyIds eId);
518 452 : void SetStyleSheetImport( bool bSet ) { m_bInStyleSheetImport = bSet;}
519 6995 : bool IsStyleSheetImport()const { return m_bInStyleSheetImport;}
520 1874 : void SetAnyTableImport( bool bSet ) { m_bInAnyTableImport = bSet;}
521 45274 : bool IsAnyTableImport()const { return m_bInAnyTableImport;}
522 2307 : bool IsInShape()const { return m_aAnchoredStack.size() > 0;}
523 :
524 : void PushShapeContext( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > xShape );
525 : void PopShapeContext();
526 : /// Add a pending shape: it's currently inserted into the document, but it should be removed before the import finishes.
527 : void PushPendingShape( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > xShape );
528 : /// Get the first pending shape, if there are any.
529 : ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > PopPendingShape();
530 :
531 : void PushPageHeader(SectionPropertyMap::PageType eType);
532 : void PushPageFooter(SectionPropertyMap::PageType eType);
533 :
534 : void PopPageHeaderFooter();
535 9 : bool IsInHeaderFooter() const { return m_bInHeaderFooterImport; }
536 :
537 : void PushFootOrEndnote( bool bIsFootnote );
538 : void PopFootOrEndnote();
539 :
540 : void PushAnnotation();
541 : void PopAnnotation();
542 :
543 : //field context starts with a 0x13
544 : void PushFieldContext();
545 : //the current field context waits for the completion of the command
546 : bool IsOpenFieldCommand() const;
547 : bool IsOpenField() const;
548 : //collect the pieces of the command
549 : void AppendFieldCommand(OUString& rPartOfCommand);
550 : void handleFieldAsk
551 : (FieldContextPtr pContext,
552 : PropertyNameSupplier& rPropNameSupplier,
553 : uno::Reference< uno::XInterface > & xFieldInterface,
554 : uno::Reference< beans::XPropertySet > xFieldProperties);
555 : void handleAutoNum
556 : (FieldContextPtr pContext,
557 : PropertyNameSupplier& rPropNameSupplier,
558 : uno::Reference< uno::XInterface > & xFieldInterface,
559 : uno::Reference< beans::XPropertySet > xFieldProperties);
560 : void handleAuthor
561 : (FieldContextPtr pContext,
562 : PropertyNameSupplier& rPropNameSupplier,
563 : uno::Reference< uno::XInterface > & xFieldInterface,
564 : uno::Reference< beans::XPropertySet > xFieldProperties,
565 : FieldId eFieldId);
566 : void handleDocProperty
567 : (FieldContextPtr pContext,
568 : PropertyNameSupplier& rPropNameSupplier,
569 : uno::Reference< uno::XInterface > & xFieldInterface,
570 : uno::Reference< beans::XPropertySet > xFieldProperties);
571 : void handleToc
572 : (FieldContextPtr pContext,
573 : PropertyNameSupplier& rPropNameSupplier,
574 : uno::Reference< uno::XInterface > & xFieldInterface,
575 : uno::Reference< beans::XPropertySet > xFieldProperties,
576 : const OUString & sTOCServiceName);
577 : //the field command has to be closed (0x14 appeared)
578 : void CloseFieldCommand();
579 : //the _current_ fields require a string type result while TOCs accept richt results
580 : bool IsFieldResultAsString();
581 : //apply the result text to the related field
582 : void SetFieldResult( OUString& rResult );
583 : // set FFData of top field context
584 : void SetFieldFFData( FFDataHandler::Pointer_t pFFDataHandler );
585 : //the end of field is reached (0x15 appeared) - the command might still be open
586 : void PopFieldContext();
587 :
588 : void AddBookmark( const OUString& rBookmarkName, const OUString& rId );
589 :
590 : void AddAnnotationPosition(const bool bStart);
591 :
592 53069 : DomainMapperTableManager& getTableManager()
593 : {
594 53069 : boost::shared_ptr< DomainMapperTableManager > pMngr = m_aTableManagers.top();
595 53069 : return *pMngr.get( );
596 : }
597 :
598 540 : void appendTableManager( )
599 : {
600 : boost::shared_ptr< DomainMapperTableManager > pMngr(
601 540 : new DomainMapperTableManager( m_eDocumentType == DOCUMENT_OOXML || m_eDocumentType == DOCUMENT_RTF ) );
602 540 : m_aTableManagers.push( pMngr );
603 540 : }
604 :
605 183 : void appendTableHandler( )
606 : {
607 183 : if (m_pTableHandler.get())
608 183 : m_aTableManagers.top()->setHandler(m_pTableHandler);
609 183 : }
610 :
611 539 : void popTableManager( )
612 : {
613 539 : if ( m_aTableManagers.size( ) > 0 )
614 539 : m_aTableManagers.pop( );
615 539 : }
616 :
617 : void SetLineNumbering( sal_Int32 nLnnMod, sal_Int32 nLnc, sal_Int32 ndxaLnn );
618 3 : bool IsLineNumberingSet() const {return m_bLineNumberingSet;}
619 :
620 : DeletableTabStop m_aCurrentTabStop;
621 :
622 2310 : bool IsOOXMLImport() const { return m_eDocumentType == DOCUMENT_OOXML; }
623 :
624 18 : bool IsRTFImport() const { return m_eDocumentType == DOCUMENT_RTF; }
625 :
626 258 : void InitPageMargins() { m_aPageMargins = _PageMar(); }
627 : void SetPageMarginTwip( PageMarElement eElement, sal_Int32 nValue );
628 258 : const _PageMar& GetPageMargins() const {return m_aPageMargins;}
629 :
630 10 : const LineNumberSettings& GetLineNumberSettings() const { return m_aLineNumberSettings;}
631 10 : void SetLineNumberSettings(const LineNumberSettings& rSet) { m_aLineNumberSettings = rSet;}
632 :
633 322 : void SetInFootnoteProperties(bool bSet) { m_bIsInFootnoteProperties = bSet;}
634 790 : bool IsInFootnoteProperties() const { return m_bIsInFootnoteProperties;}
635 :
636 0 : void SetCustomFtnMark(bool bSet) { m_bIsCustomFtnMark = bSet; }
637 0 : bool IsCustomFtnMark() const { return m_bIsCustomFtnMark; }
638 :
639 66 : bool IsInComments() const { return m_bIsInComments; };
640 :
641 : void CheckUnregisteredFrameConversion( );
642 :
643 : void RegisterFrameConversion(
644 : ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > xFrameStartRange,
645 : ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > xFrameEndRange,
646 : ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > aFrameProperties
647 : );
648 : bool ExecuteFrameConversion();
649 :
650 : void AddNewRedline( );
651 :
652 : RedlineParamsPtr GetTopRedline( );
653 :
654 : sal_Int32 GetCurrentRedlineToken( );
655 : void SetCurrentRedlineAuthor( OUString sAuthor );
656 : void SetCurrentRedlineDate( OUString sDate );
657 : void SetCurrentRedlineId( sal_Int32 nId );
658 : void SetCurrentRedlineToken( sal_Int32 nToken );
659 : void RemoveCurrentRedline( );
660 : void ResetParaRedline( );
661 : void SetCurrentRedlineInitials( OUString sInitials );
662 :
663 : void ApplySettingsTable();
664 : SectionPropertyMap * GetSectionContext();
665 : /// If the current paragraph has a numbering style associated, this method returns its character style (part of the numbering rules)
666 : com::sun::star::uno::Reference<com::sun::star::beans::XPropertySet> GetCurrentNumberingCharStyle();
667 : /// If the current paragraph has a numbering style associated, this method returns its numbering rules
668 : com::sun::star::uno::Reference<com::sun::star::container::XIndexAccess> GetCurrentNumberingRules(sal_Int32* pListLevel = 0);
669 :
670 : /**
671 : Used for attributes/sprms which cannot be evaluated immediatelly (e.g. they depend
672 : on another one that comes in the same CONTEXT_CHARACTER). The property will be processed
673 : again in DomainMapper::processDeferredCharacterProperties().
674 : */
675 : void deferCharacterProperty( sal_Int32 id, com::sun::star::uno::Any value );
676 : /**
677 : Processes properties deferred using deferCharacterProperty(). To be called whenever the top
678 : CONTEXT_CHARACTER is going to be used (e.g. by appendText()).
679 : */
680 : void processDeferredCharacterProperties();
681 :
682 : /// Get a property of the current numbering style's current level.
683 : sal_Int32 getCurrentNumberingProperty(OUString aProp);
684 :
685 : /// If we're importing into a new document, or just pasting to an existing one.
686 : bool IsNewDoc();
687 :
688 : /// If we're inside <w:rPr>, inside <w:style w:type="table">
689 : bool m_bInTableStyleRunProps;
690 :
691 : SdtHelper* m_pSdtHelper;
692 :
693 : /// Document background color, applied to every page style.
694 : boost::optional<sal_Int32> m_oBackgroundColor;
695 : };
696 : } //namespace dmapper
697 : } //namespace writerfilter
698 : #endif
699 :
700 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|