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 <queue>
33 : #include <boost/optional.hpp>
34 :
35 : #ifndef INCLUDED_RESOURCESIDS
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 : OUString m_sResult;
128 :
129 : ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextField > m_xTextField;
130 : ::com::sun::star::uno::Reference< ::com::sun::star::text::XFormField > m_xFormField;
131 : ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > m_xTOC;//TOX
132 : ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > m_xTC;//TOX entry
133 : OUString m_sHyperlinkURL;
134 : FFDataHandler::Pointer_t m_pFFDataHandler;
135 : FormControlHelper::Pointer_t m_pFormControlHelper;
136 :
137 : public:
138 : FieldContext(::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > xStart);
139 : ~FieldContext();
140 :
141 1942 : ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > GetStartRange() const { return m_xStartRange; }
142 :
143 : void AppendCommand(const OUString& rPart);
144 6582 : const OUString& GetCommand() const {return m_sCommand; }
145 :
146 282 : void AppendResult(OUString const& rResult) { m_sResult += rResult; }
147 2105 : const OUString& GetResult() const { return m_sResult; }
148 :
149 1864 : void SetCommandCompleted() { m_bFieldCommandCompleted = true; }
150 7216 : bool IsCommandCompleted() const { return m_bFieldCommandCompleted; }
151 :
152 3954 : ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextField > GetTextField() const { return m_xTextField;}
153 1863 : void SetTextField(::com::sun::star::uno::Reference< ::com::sun::star::text::XTextField > xTextField) { m_xTextField = xTextField;}
154 8 : ::com::sun::star::uno::Reference< ::com::sun::star::text::XFormField > GetFormField() const { return m_xFormField;}
155 87 : void SetFormField(::com::sun::star::uno::Reference< ::com::sun::star::text::XFormField > xFormField) { m_xFormField = xFormField;}
156 :
157 74 : void SetTOC( ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > xTOC ) { m_xTOC = xTOC; }
158 1882 : ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > GetTOC() { return m_xTOC; }
159 :
160 0 : void SetTC( ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > xTC ) { m_xTC = xTC; }
161 1789 : ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > GetTC( ) { return m_xTC; }
162 :
163 931 : void SetHyperlinkURL( const OUString& rURL ) { m_sHyperlinkURL = rURL; }
164 2458 : const OUString& GetHyperlinkURL() { return m_sHyperlinkURL; }
165 :
166 19 : void setFFDataHandler(FFDataHandler::Pointer_t pFFDataHandler) { m_pFFDataHandler = pFFDataHandler; }
167 8 : FFDataHandler::Pointer_t getFFDataHandler() const { return m_pFFDataHandler; }
168 :
169 8 : void setFormControlHelper(FormControlHelper::Pointer_t pFormControlHelper) { m_pFormControlHelper = pFormControlHelper; }
170 1536 : FormControlHelper::Pointer_t getFormControlHelper() const { return m_pFormControlHelper; }
171 :
172 : ::std::vector<OUString> GetCommandParts() const;
173 : };
174 :
175 8877 : struct TextAppendContext
176 : {
177 : ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextAppend > xTextAppend;
178 : ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > xInsertPosition;
179 : ::com::sun::star::uno::Reference< ::com::sun::star::text::XParagraphCursor > xCursor;
180 : ParagraphPropertiesPtr pLastParagraphProperties;
181 :
182 2959 : TextAppendContext( const ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextAppend >& xAppend,
183 : const ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextCursor >& xCur ) :
184 2959 : xTextAppend( xAppend )
185 : {
186 2959 : xCursor.set(xCur, uno::UNO_QUERY);
187 2959 : xInsertPosition.set(xCursor, uno::UNO_QUERY);
188 2959 : }
189 : };
190 :
191 2850 : struct AnchoredContext
192 : {
193 : ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextContent > xTextContent;
194 : bool bToRemove;
195 :
196 950 : AnchoredContext( const ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextContent >& xContent ) :
197 950 : xTextContent( xContent ), bToRemove( false ) {}
198 : };
199 :
200 : typedef boost::shared_ptr<FieldContext> FieldContextPtr;
201 :
202 : typedef std::stack<ContextType> ContextStack;
203 : typedef std::stack<PropertyMapPtr> PropertyStack;
204 : typedef std::stack< TextAppendContext > TextAppendStack;
205 : typedef std::stack<FieldContextPtr> FieldStack;
206 : typedef std::stack< AnchoredContext > TextContentStack;
207 :
208 : /*-------------------------------------------------------------------------
209 : extended tab stop struct
210 : -----------------------------------------------------------------------*/
211 : struct DeletableTabStop : public ::com::sun::star::style::TabStop
212 : {
213 : bool bDeleted;
214 5233 : DeletableTabStop() :
215 5233 : bDeleted( false ){}
216 135 : DeletableTabStop( const ::com::sun::star::style::TabStop& rTabStop ) :
217 : TabStop( rTabStop ),
218 135 : bDeleted( false ){}
219 : };
220 : /*-------------------------------------------------------------------------
221 : /// helper to remember bookmark start position
222 : -----------------------------------------------------------------------*/
223 8045 : struct BookmarkInsertPosition
224 : {
225 : bool m_bIsStartOfText;
226 : OUString m_sBookmarkName;
227 : ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > m_xTextRange;
228 1609 : BookmarkInsertPosition(bool bIsStartOfText, const OUString& rName, ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > xTextRange):
229 : m_bIsStartOfText( bIsStartOfText ),
230 : m_sBookmarkName( rName ),
231 1609 : m_xTextRange( xTextRange )
232 1609 : {}
233 : };
234 :
235 : /// Stores the start/end positions of an annotation before its insertion.
236 66 : struct AnnotationPosition
237 : {
238 : ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > m_xStart;
239 : ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > m_xEnd;
240 : };
241 : typedef boost::unordered_map< sal_Int32, AnnotationPosition > AnnotationPositions_t;
242 :
243 1892 : struct RedlineParams
244 : {
245 : OUString m_sAuthor;
246 : OUString m_sDate;
247 : sal_Int32 m_nId;
248 : sal_Int32 m_nToken;
249 :
250 : /// This can hold properties of runs that had formatted 'track changes' properties
251 : uno::Sequence<beans::PropertyValue> m_aRevertProperties;
252 : };
253 : typedef boost::shared_ptr< RedlineParams > RedlineParamsPtr;
254 :
255 :
256 :
257 : struct LineNumberSettings
258 : {
259 : bool bIsOn;
260 : sal_Int32 nDistance;
261 : sal_Int32 nInterval;
262 : bool bRestartAtEachPage;
263 : sal_Int32 nStartValue;
264 1192 : LineNumberSettings() :
265 : bIsOn(false)
266 : ,nDistance(0)
267 : ,nInterval(0)
268 : ,bRestartAtEachPage(true)
269 1192 : ,nStartValue(1)
270 1192 : {}
271 :
272 : };
273 :
274 : /// Contains information about a table that will be potentially converted to a floating one at the section end.
275 105 : struct FloatingTableInfo
276 : {
277 : uno::Reference<text::XTextRange> m_xStart;
278 : uno::Reference<text::XTextRange> m_xEnd;
279 : uno::Sequence<beans::PropertyValue> m_aFrameProperties;
280 : sal_Int32 m_nTableWidth;
281 :
282 29 : FloatingTableInfo(uno::Reference<text::XTextRange> xStart, uno::Reference<text::XTextRange> xEnd, uno::Sequence<beans::PropertyValue> aFrameProperties, sal_Int32 nTableWidth)
283 : : m_xStart(xStart),
284 : m_xEnd(xEnd),
285 : m_aFrameProperties(aFrameProperties),
286 29 : m_nTableWidth(nTableWidth)
287 : {
288 29 : }
289 : uno::Any getPropertyValue(const OUString &propertyName);
290 : };
291 :
292 : class DomainMapper;
293 : class DomainMapper_Impl
294 : {
295 : public:
296 : typedef TableManager< ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange >, PropertyMapPtr > TableManager_t;
297 : typedef TableDataHandler< ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange >, TablePropertyMapPtr > TableDataHandler_t;
298 : typedef std::map < OUString, BookmarkInsertPosition > BookmarkMap_t;
299 :
300 : private:
301 : SourceDocumentType m_eDocumentType;
302 : DomainMapper& m_rDMapper;
303 : ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextDocument > m_xTextDocument;
304 : ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > m_xDocumentSettings;
305 : ::com::sun::star::uno::Reference < ::com::sun::star::lang::XMultiServiceFactory > m_xTextFactory;
306 : ::com::sun::star::uno::Reference < com::sun::star::uno::XComponentContext > m_xComponentContext;
307 : ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer > m_xPageStyles;
308 : ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > m_xBodyText;
309 : ::com::sun::star::uno::Reference<text::XTextContent> m_xEmbedded;
310 :
311 : TextAppendStack m_aTextAppendStack;
312 :
313 : TextContentStack m_aAnchoredStack;
314 :
315 : FieldStack m_aFieldStack;
316 : bool m_bSetUserFieldContent;
317 : bool m_bSetCitation;
318 : bool m_bIsFirstSection;
319 : bool m_bIsColumnBreakDeferred;
320 : bool m_bIsPageBreakDeferred;
321 : bool m_bStartTOC;
322 : /// If we got any text that is the pre-rendered result of the TOC field.
323 : bool m_bStartedTOC;
324 : bool m_bStartIndex;
325 : bool m_bStartBibliography;
326 : bool m_bTOCPageRef;
327 : bool m_bStartGenericField;
328 : bool m_bTextInserted;
329 : LineNumberSettings m_aLineNumberSettings;
330 :
331 : BookmarkMap_t m_aBookmarkMap;
332 :
333 : _PageMar m_aPageMargins;
334 :
335 :
336 : // TableManagers are stacked: one for each stream to avoid any confusion
337 : std::stack< boost::shared_ptr< DomainMapperTableManager > > m_aTableManagers;
338 : TableDataHandler_t::Pointer_t m_pTableHandler;
339 :
340 : //each context needs a stack of currently used attributes
341 : PropertyStack m_aPropertyStacks[NUMBER_OF_CONTEXTS];
342 : ContextStack m_aContextStack;
343 : FontTablePtr m_pFontTable;
344 : ListsManager::Pointer m_pListTable;
345 : std::deque< com::sun::star::uno::Reference< com::sun::star::drawing::XShape > > m_aPendingShapes;
346 : StyleSheetTablePtr m_pStyleSheetTable;
347 : ThemeTablePtr m_pThemeTable;
348 : SettingsTablePtr m_pSettingsTable;
349 : GraphicImportPtr m_pGraphicImport;
350 :
351 :
352 : PropertyMapPtr m_pTopContext;
353 : PropertyMapPtr m_pLastSectionContext;
354 : PropertyMapPtr m_pLastCharacterContext;
355 :
356 : ::std::vector<DeletableTabStop> m_aCurrentTabStops;
357 : sal_uInt32 m_nCurrentTabStopIndex;
358 : OUString m_sCurrentParaStyleId;
359 : bool m_bInStyleSheetImport; //in import of fonts, styles, lists or lfos
360 : bool m_bInAnyTableImport; //in import of fonts, styles, lists or lfos
361 : bool m_bInHeaderFooterImport;
362 : bool m_bDiscardHeaderFooter;
363 :
364 : bool m_bLineNumberingSet;
365 : bool m_bIsInFootnoteProperties;
366 : bool m_bIsCustomFtnMark;
367 :
368 : //registered frame properties
369 : ::com::sun::star::uno::Sequence< beans::PropertyValue > m_aFrameProperties;
370 : ::com::sun::star::uno::Reference< text::XTextRange > m_xFrameStartRange;
371 : ::com::sun::star::uno::Reference< text::XTextRange > m_xFrameEndRange;
372 :
373 : // Redline stack
374 : std::stack< std::vector< RedlineParamsPtr > > m_aRedlines;
375 : RedlineParamsPtr m_pParaMarkerRedline;
376 : bool m_bIsParaMarkerChange;
377 :
378 : /// If the current paragraph has any runs.
379 : bool m_bParaChanged;
380 : bool m_bIsFirstParaInSection;
381 : bool m_bIsLastParaInSection;
382 : bool m_bIsInComments;
383 : /// If the current paragraph contains section property definitions.
384 : bool m_bParaSectpr;
385 : bool m_bUsingEnhancedFields;
386 : /// If the current paragraph is inside a structured document element.
387 : bool m_bSdt;
388 : bool m_bIsFirstRun;
389 :
390 : uno::Reference< text::XTextCursor > xTOCMarkerCursor;
391 : uno::Reference< text::XTextCursor > mxTOCTextCursor;
392 :
393 : //annotation import
394 : uno::Reference< beans::XPropertySet > m_xAnnotationField;
395 : sal_Int32 m_nAnnotationId;
396 : AnnotationPositions_t m_aAnnotationPositions;
397 :
398 : void GetCurrentLocale(::com::sun::star::lang::Locale& rLocale);
399 : void SetNumberFormat( const OUString& rCommand,
400 : ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xPropertySet );
401 : ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >
402 : FindOrCreateFieldMaster( const sal_Char* pFieldMasterService,
403 : const OUString& rFieldMasterName )
404 : throw(::com::sun::star::uno::Exception);
405 : ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > GetDocumentSettings();
406 :
407 : std::map< sal_Int32, com::sun::star::uno::Any > deferredCharacterProperties;
408 :
409 : public:
410 : ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > m_xInsertTextRange;
411 : private:
412 : bool m_bIsNewDoc;
413 : public:
414 : DomainMapper_Impl(
415 : DomainMapper& rDMapper,
416 : uno::Reference < uno::XComponentContext > xContext,
417 : uno::Reference< lang::XComponent > xModel,
418 : SourceDocumentType eDocumentType,
419 : uno::Reference< text::XTextRange > xInsertTextRange,
420 : bool bIsNewDoc );
421 : virtual ~DomainMapper_Impl();
422 :
423 1839 : SectionPropertyMap* GetLastSectionContext( )
424 : {
425 1839 : return dynamic_cast< SectionPropertyMap* >( m_pLastSectionContext.get( ) );
426 : }
427 :
428 : ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer > GetPageStyles();
429 : ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > GetBodyText();
430 3899 : ::com::sun::star::uno::Reference < ::com::sun::star::lang::XMultiServiceFactory > GetTextFactory() const
431 : {
432 3899 : return m_xTextFactory;
433 : }
434 : ::com::sun::star::uno::Reference < com::sun::star::uno::XComponentContext > GetComponentContext() const
435 : {
436 : return m_xComponentContext;
437 : }
438 7619 : ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextDocument > GetTextDocument() const
439 : {
440 7619 : return m_xTextDocument;
441 : }
442 : void SetDocumentSettingsProperty( const OUString& rPropName, const uno::Any& rValue );
443 :
444 : void CreateRedline( ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > xRange, RedlineParamsPtr& pRedline );
445 :
446 : void CheckParaMarkerRedline( ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > xRange );
447 :
448 : void CheckRedline( ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > xRange );
449 :
450 : void StartParaMarkerChange( );
451 : void EndParaMarkerChange( );
452 :
453 : void RemoveLastParagraph( );
454 : void SetIsLastParagraphInSection( bool bIsLast );
455 : bool GetIsLastParagraphInSection();
456 : void SetIsFirstParagraphInSection( bool bIsFirst );
457 : bool GetIsFirstParagraphInSection();
458 : void SetParaSectpr(bool bParaSectpr);
459 : bool GetParaSectpr();
460 : /// Setter method for m_bSdt.
461 : void SetSdt(bool bSdt);
462 : /// Getter method for m_bSdt.
463 : bool GetSdt();
464 : bool GetParaChanged();
465 :
466 : void deferBreak( BreakType deferredBreakType );
467 : bool isBreakDeferred( BreakType deferredBreakType );
468 : void clearDeferredBreaks();
469 : void clearDeferredBreak(BreakType deferredBreakType);
470 : void finishParagraph( PropertyMapPtr pPropertyMap );
471 : void appendTextPortion( const OUString& rString, PropertyMapPtr pPropertyMap );
472 : void appendTextContent( const ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextContent >,
473 : const uno::Sequence< beans::PropertyValue > );
474 : void appendOLE( const OUString& rStreamName, OLEHandlerPtr pOleHandler );
475 : void appendStarMath( const Value& v );
476 : ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > appendTextSectionAfter(
477 : ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange >& xBefore );
478 :
479 : // push the new properties onto the stack and make it the 'current' property map
480 : void PushProperties(ContextType eId);
481 : void PushStyleProperties(PropertyMapPtr pStyleProperties);
482 : void PushListProperties(PropertyMapPtr pListProperties);
483 : void PopProperties(ContextType eId);
484 :
485 46304 : ContextType GetTopContextType() const { return m_aContextStack.top(); }
486 702125 : PropertyMapPtr GetTopContext()
487 : {
488 702125 : return m_pTopContext;
489 : }
490 : PropertyMapPtr GetTopContextOfType(ContextType eId);
491 :
492 : ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextAppend > GetTopTextAppend();
493 : FieldContextPtr GetTopFieldContext();
494 :
495 2025 : FontTablePtr GetFontTable()
496 : {
497 2025 : if(!m_pFontTable)
498 1018 : m_pFontTable.reset(new FontTable());
499 2025 : return m_pFontTable;
500 : }
501 40068 : StyleSheetTablePtr GetStyleSheetTable()
502 : {
503 40068 : if(!m_pStyleSheetTable)
504 1184 : m_pStyleSheetTable.reset(new StyleSheetTable( m_rDMapper, m_xTextDocument, m_bIsNewDoc ));
505 40068 : return m_pStyleSheetTable;
506 : }
507 : ListsManager::Pointer GetListTable();
508 10040 : ThemeTablePtr GetThemeTable()
509 : {
510 10040 : if(!m_pThemeTable)
511 809 : m_pThemeTable.reset( new ThemeTable );
512 10040 : return m_pThemeTable;
513 : }
514 :
515 30709 : SettingsTablePtr GetSettingsTable()
516 : {
517 30709 : if( !m_pSettingsTable )
518 1191 : m_pSettingsTable.reset( new SettingsTable( m_rDMapper, m_xTextFactory ) );
519 30709 : return m_pSettingsTable;
520 : }
521 :
522 : GraphicImportPtr GetGraphicImport( GraphicImportType eGraphicImportType );
523 : void ResetGraphicImport();
524 : // this method deletes the current m_pGraphicImport after import
525 : void ImportGraphic(writerfilter::Reference< Properties>::Pointer_t, GraphicImportType eGraphicImportType );
526 :
527 : void InitTabStopFromStyle( const ::com::sun::star::uno::Sequence< ::com::sun::star::style::TabStop >& rInitTabStops );
528 : void IncorporateTabStop( const DeletableTabStop &aTabStop );
529 : ::com::sun::star::uno::Sequence< ::com::sun::star::style::TabStop > GetCurrentTabStopAndClear();
530 : void NextTabStop() {++m_nCurrentTabStopIndex;}
531 :
532 29186 : void SetCurrentParaStyleId(const OUString& sStringValue) {m_sCurrentParaStyleId = sStringValue;}
533 51136 : OUString GetCurrentParaStyleId() const {return m_sCurrentParaStyleId;}
534 :
535 : ::com::sun::star::uno::Any GetPropertyFromStyleSheet(PropertyIds eId);
536 1970 : void SetStyleSheetImport( bool bSet ) { m_bInStyleSheetImport = bSet;}
537 61321 : bool IsStyleSheetImport()const { return m_bInStyleSheetImport;}
538 8274 : void SetAnyTableImport( bool bSet ) { m_bInAnyTableImport = bSet;}
539 480670 : bool IsAnyTableImport()const { return m_bInAnyTableImport;}
540 22723 : bool IsInShape()const { return m_aAnchoredStack.size() > 0;}
541 :
542 : void PushShapeContext( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > xShape );
543 : void PopShapeContext();
544 : void UpdateEmbeddedShapeProps( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > xShape );
545 : /// Add a pending shape: it's currently inserted into the document, but it should be removed before the import finishes.
546 : void PushPendingShape( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > xShape );
547 : /// Get the first pending shape, if there are any.
548 : ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > PopPendingShape();
549 :
550 : void PushPageHeader(SectionPropertyMap::PageType eType);
551 : void PushPageFooter(SectionPropertyMap::PageType eType);
552 :
553 : void PopPageHeaderFooter();
554 596 : bool IsInHeaderFooter() const { return m_bInHeaderFooterImport; }
555 :
556 : void PushFootOrEndnote( bool bIsFootnote );
557 : void PopFootOrEndnote();
558 :
559 : void PushAnnotation();
560 : void PopAnnotation();
561 :
562 : //field context starts with a 0x13
563 : void PushFieldContext();
564 : //the current field context waits for the completion of the command
565 : bool IsOpenFieldCommand() const;
566 : bool IsOpenField() const;
567 : //collect the pieces of the command
568 : void AppendFieldCommand(OUString& rPartOfCommand);
569 : void handleFieldAsk
570 : (FieldContextPtr pContext,
571 : PropertyNameSupplier& rPropNameSupplier,
572 : uno::Reference< uno::XInterface > & xFieldInterface,
573 : uno::Reference< beans::XPropertySet > xFieldProperties);
574 : void handleAutoNum
575 : (FieldContextPtr pContext,
576 : PropertyNameSupplier& rPropNameSupplier,
577 : uno::Reference< uno::XInterface > & xFieldInterface,
578 : uno::Reference< beans::XPropertySet > xFieldProperties);
579 : void handleAuthor
580 : (OUString const& rFirstParam,
581 : PropertyNameSupplier& rPropNameSupplier,
582 : uno::Reference< uno::XInterface > & xFieldInterface,
583 : uno::Reference< beans::XPropertySet > xFieldProperties,
584 : FieldId eFieldId);
585 : void handleDocProperty
586 : (FieldContextPtr pContext,
587 : OUString const& rFirstParam,
588 : PropertyNameSupplier& rPropNameSupplier,
589 : uno::Reference< uno::XInterface > & xFieldInterface,
590 : uno::Reference< beans::XPropertySet > xFieldProperties);
591 : void handleToc
592 : (FieldContextPtr pContext,
593 : PropertyNameSupplier& rPropNameSupplier,
594 : uno::Reference< uno::XInterface > & xFieldInterface,
595 : uno::Reference< beans::XPropertySet > xFieldProperties,
596 : const OUString & sTOCServiceName);
597 : void handleIndex
598 : (FieldContextPtr pContext,
599 : PropertyNameSupplier& rPropNameSupplier,
600 : uno::Reference< uno::XInterface > & xFieldInterface,
601 : uno::Reference< beans::XPropertySet > xFieldProperties,
602 : const OUString & sTOCServiceName);
603 :
604 : void handleBibliography
605 : (FieldContextPtr pContext,
606 : PropertyNameSupplier& rPropNameSupplier,
607 : const OUString & sTOCServiceName);
608 : //the field command has to be closed (0x14 appeared)
609 : void CloseFieldCommand();
610 : //the _current_ fields require a string type result while TOCs accept richt results
611 : bool IsFieldResultAsString();
612 : void AppendFieldResult(OUString const& rResult);
613 : //apply the result text to the related field
614 : void SetFieldResult(OUString const& rResult);
615 : // set FFData of top field context
616 : void SetFieldFFData( FFDataHandler::Pointer_t pFFDataHandler );
617 : //the end of field is reached (0x15 appeared) - the command might still be open
618 : void PopFieldContext();
619 :
620 : void AddBookmark( const OUString& rBookmarkName, const OUString& rId );
621 :
622 : void AddAnnotationPosition(
623 : const bool bStart,
624 : const sal_Int32 nAnnotationId );
625 :
626 518179 : DomainMapperTableManager& getTableManager()
627 : {
628 518179 : boost::shared_ptr< DomainMapperTableManager > pMngr = m_aTableManagers.top();
629 518179 : return *pMngr.get( );
630 : }
631 :
632 3009 : void appendTableManager( )
633 : {
634 : boost::shared_ptr< DomainMapperTableManager > pMngr(
635 3009 : new DomainMapperTableManager( m_eDocumentType == DOCUMENT_OOXML || m_eDocumentType == DOCUMENT_RTF ) );
636 3009 : m_aTableManagers.push( pMngr );
637 3009 : }
638 :
639 1817 : void appendTableHandler( )
640 : {
641 1817 : if (m_pTableHandler.get())
642 1817 : m_aTableManagers.top()->setHandler(m_pTableHandler);
643 1817 : }
644 :
645 3008 : void popTableManager( )
646 : {
647 3008 : if ( m_aTableManagers.size( ) > 0 )
648 3008 : m_aTableManagers.pop( );
649 3008 : }
650 :
651 : void SetLineNumbering( sal_Int32 nLnnMod, sal_Int32 nLnc, sal_Int32 ndxaLnn );
652 7 : bool IsLineNumberingSet() const {return m_bLineNumberingSet;}
653 :
654 : DeletableTabStop m_aCurrentTabStop;
655 :
656 31017 : bool IsOOXMLImport() const { return m_eDocumentType == DOCUMENT_OOXML; }
657 :
658 36 : bool IsRTFImport() const { return m_eDocumentType == DOCUMENT_RTF; }
659 :
660 1116 : void InitPageMargins() { m_aPageMargins = _PageMar(); }
661 : void SetPageMarginTwip( PageMarElement eElement, sal_Int32 nValue );
662 1116 : const _PageMar& GetPageMargins() const {return m_aPageMargins;}
663 :
664 25 : const LineNumberSettings& GetLineNumberSettings() const { return m_aLineNumberSettings;}
665 25 : void SetLineNumberSettings(const LineNumberSettings& rSet) { m_aLineNumberSettings = rSet;}
666 :
667 458 : void SetInFootnoteProperties(bool bSet) { m_bIsInFootnoteProperties = bSet;}
668 1092 : bool IsInFootnoteProperties() const { return m_bIsInFootnoteProperties;}
669 :
670 0 : void SetCustomFtnMark(bool bSet) { m_bIsCustomFtnMark = bSet; }
671 0 : bool IsCustomFtnMark() const { return m_bIsCustomFtnMark; }
672 :
673 574 : bool IsInComments() const { return m_bIsInComments; };
674 :
675 : void CheckUnregisteredFrameConversion( );
676 :
677 : void RegisterFrameConversion(
678 : ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > xFrameStartRange,
679 : ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > xFrameEndRange,
680 : ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > aFrameProperties
681 : );
682 : bool ExecuteFrameConversion();
683 :
684 : void AddNewRedline( );
685 :
686 : RedlineParamsPtr GetTopRedline( );
687 :
688 : sal_Int32 GetCurrentRedlineToken( );
689 : void SetCurrentRedlineAuthor( const OUString& sAuthor );
690 : void SetCurrentRedlineDate( const OUString& sDate );
691 : void SetCurrentRedlineId( sal_Int32 nId );
692 : void SetCurrentRedlineToken( sal_Int32 nToken );
693 : void SetCurrentRedlineRevertProperties( uno::Sequence<beans::PropertyValue> aProperties );
694 : void RemoveCurrentRedline( );
695 : void ResetParaMarkerRedline( );
696 : void SetCurrentRedlineInitials( const OUString& sInitials );
697 6 : bool IsFirstRun() { return m_bIsFirstRun;}
698 81554 : void SetIsFirstRun(bool bval) { m_bIsFirstRun = bval;}
699 :
700 : void ApplySettingsTable();
701 : SectionPropertyMap * GetSectionContext();
702 : /// If the current paragraph has a numbering style associated, this method returns its character style (part of the numbering rules)
703 : com::sun::star::uno::Reference<com::sun::star::beans::XPropertySet> GetCurrentNumberingCharStyle();
704 : /// If the current paragraph has a numbering style associated, this method returns its numbering rules
705 : com::sun::star::uno::Reference<com::sun::star::container::XIndexAccess> GetCurrentNumberingRules(sal_Int32* pListLevel = 0);
706 :
707 : /**
708 : Used for attributes/sprms which cannot be evaluated immediatelly (e.g. they depend
709 : on another one that comes in the same CONTEXT_CHARACTER). The property will be processed
710 : again in DomainMapper::processDeferredCharacterProperties().
711 : */
712 : void deferCharacterProperty( sal_Int32 id, com::sun::star::uno::Any value );
713 : /**
714 : Processes properties deferred using deferCharacterProperty(). To be called whenever the top
715 : CONTEXT_CHARACTER is going to be used (e.g. by appendText()).
716 : */
717 : void processDeferredCharacterProperties();
718 :
719 : /// Get a property of the current numbering style's current level.
720 : sal_Int32 getCurrentNumberingProperty(const OUString& aProp);
721 :
722 : /// If we're importing into a new document, or just pasting to an existing one.
723 : bool IsNewDoc();
724 :
725 : /// If we're inside <w:rPr>, inside <w:style w:type="table">
726 : bool m_bInTableStyleRunProps;
727 :
728 : SdtHelper* m_pSdtHelper;
729 :
730 : /// Document background color, applied to every page style.
731 : boost::optional<sal_Int32> m_oBackgroundColor;
732 :
733 : /**
734 : * This contains the raw table depth. m_nTableDepth > 0 is the same as
735 : * getTableManager().isInTable(), unless we're in the first paragraph of a
736 : * table, or first paragraph after a table, as the table manager is only
737 : * updated once we ended the paragraph (and know if the para has the
738 : * inTbl SPRM or not).
739 : */
740 : sal_Int32 m_nTableDepth;
741 :
742 : /// If the document has a footnote separator.
743 : bool m_bHasFtnSep;
744 :
745 : /// If the next newline should be ignored, used by the special footnote separator paragraph.
746 : bool m_bIgnoreNextPara;
747 : /// If the next tab should be ignored, used for footnotes.
748 : bool m_bIgnoreNextTab;
749 : bool m_bFrameBtLr; ///< Bottom to top, left to right text frame direction is requested for the current text frame.
750 : /// Pending floating tables: they may be converted to text frames at the section end.
751 : std::vector<FloatingTableInfo> m_aPendingFloatingTables;
752 :
753 : /// Append a property to a sub-grabbag if necessary (e.g. 'lineRule', 'auto')
754 : void appendGrabBag(std::vector<beans::PropertyValue>& rInteropGrabBag, const OUString& aKey, const OUString& aValue);
755 : void appendGrabBag(std::vector<beans::PropertyValue>& rInteropGrabBag, const OUString& aKey, std::vector<beans::PropertyValue>& rValue);
756 :
757 : /// Enable, disable an check status of grabbags
758 : void enableInteropGrabBag(const OUString& aName);
759 : void disableInteropGrabBag();
760 : bool isInteropGrabBagEnabled();
761 :
762 : /// Name of m_aInteropGrabBag.
763 : OUString m_aInteropGrabBagName;
764 :
765 : /// A toplevel dmapper grabbag, like 'pPr'.
766 : std::vector<beans::PropertyValue> m_aInteropGrabBag;
767 :
768 : /// A sub-grabbag of m_aInteropGrabBag, like 'spacing'.
769 : std::vector<beans::PropertyValue> m_aSubInteropGrabBag;
770 :
771 : /// ST_PositivePercentage values we received
772 : std::queue<OUString> m_aPositivePercentages;
773 3346 : bool isInIndexContext() { return m_bStartIndex;}
774 2667 : bool isInBibliographyContext() { return m_bStartBibliography;}
775 :
776 : void substream(Id rName, ::writerfilter::Reference<Stream>::Pointer_t const& ref);
777 :
778 : private:
779 : void PushPageHeaderFooter(bool bHeader, SectionPropertyMap::PageType eType);
780 : };
781 : } //namespace dmapper
782 : } //namespace writerfilter
783 : #endif
784 :
785 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|