1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
21 #include <dmapper/DomainMapperFactory.hxx>
22 #include "LoggedResources.hxx"
23 #include "PropertyMap.hxx"
24 #include "SettingsTable.hxx"
25 #include <com/sun/star/lang/XComponent.hpp>
26 #include <com/sun/star/style/TabAlign.hpp>
32 namespace com::sun::star
{
40 class XComponentContext
;
43 class XMultiServiceFactory
;
52 class MediaDescriptor
;
55 typedef std::vector
<css::beans::PropertyValue
> PropertyValueVector_t
;
57 namespace writerfilter::dmapper
61 class DomainMapper_Impl
;
63 class StyleSheetTable
;
64 class GraphicZOrderHelper
;
66 typedef tools::SvRef
<StyleSheetTable
> StyleSheetTablePtr
;
68 class DomainMapper
: public LoggedProperties
, public LoggedTable
,
69 public BinaryObj
, public LoggedStream
71 std::unique_ptr
<DomainMapper_Impl
> m_pImpl
;
74 DomainMapper(const css::uno::Reference
<css::uno::XComponentContext
>& xContext
,
75 css::uno::Reference
<css::io::XInputStream
> const& xInputStream
,
76 css::uno::Reference
<css::lang::XComponent
> const& xModel
,
78 SourceDocumentType eDocumentType
,
79 utl::MediaDescriptor
const & rMediaDesc
);
80 virtual ~DomainMapper() override
;
82 virtual void setDocumentReference(writerfilter::ooxml::OOXMLDocument
* pDocument
) override
;
85 virtual void markLastParagraphInSection() override
;
86 virtual void markLastSectionGroup() override
;
89 virtual void data(const sal_uInt8
* buf
, size_t len
) override
;
91 void sprmWithProps( Sprm
& sprm
, const PropertyMapPtr
& pContext
);
93 void PushStyleSheetProperties( const PropertyMapPtr
& pStyleProperties
, bool bAffectTableMngr
= false );
94 void PopStyleSheetProperties( bool bAffectTableMngr
= false );
96 void PushListProperties( const ::tools::SvRef
<PropertyMap
>& pListProperties
);
97 void PopListProperties();
98 OUString
GetListStyleName(sal_Int32 nListId
) const;
99 void ValidateListLevel(const OUString
& sStyleIdentifierD
);
101 bool IsOOXMLImport() const;
102 bool IsRTFImport() const;
103 css::uno::Reference
<css::lang::XMultiServiceFactory
> const & GetTextFactory() const;
104 css::uno::Reference
<css::text::XTextRange
> GetCurrentTextRange();
106 OUString
getOrCreateCharStyle( PropertyValueVector_t
& rCharProperties
, bool bAlwaysCreate
);
107 StyleSheetTablePtr
const & GetStyleSheetTable( );
108 SettingsTablePtr
const & GetSettingsTable();
109 GraphicZOrderHelper
* graphicZOrderHelper();
111 /// Return the first from the pending (not inserted to the document) shapes, if there are any.
112 css::uno::Reference
<css::drawing::XShape
> PopPendingShape();
114 bool IsInHeaderFooter() const;
115 bool IsInTable() const;
116 void SetDocDefaultsImport(bool bSet
);
117 bool IsStyleSheetImport() const;
118 bool IsNumberingImport() const;
119 bool IsInShape() const;
121 void hasControls( const bool bSet
) { mbHasControls
= bSet
; }
124 @see DomainMapper_Impl::processDeferredCharacterProperties()
126 void processDeferredCharacterProperties(
127 const std::map
<sal_Int32
, css::uno::Any
>& rDeferredCharacterProperties
,
128 bool bCharContext
= true);
130 void ProcessDeferredStyleCharacterProperties();
132 /// Enable storing of seen tokens in a named grab bag.
133 void enableInteropGrabBag(const OUString
& aName
);
134 /// Get the stored tokens and clear the internal storage.
135 css::beans::PropertyValue
getInteropGrabBag();
137 void HandleRedline( Sprm
& rSprm
);
139 virtual void commentProps(const OUString
& sId
, const CommentProperties
& rProps
) override
;
141 css::uno::Reference
<css::container::XNameContainer
> const & GetCharacterStyles();
142 OUString
GetUnusedCharacterStyleName();
146 virtual void lcl_startSectionGroup() override
;
147 virtual void lcl_endSectionGroup() override
;
148 virtual void lcl_startParagraphGroup() override
;
149 virtual void lcl_endParagraphGroup() override
;
150 virtual void lcl_startCharacterGroup() override
;
151 virtual void lcl_endCharacterGroup() override
;
152 virtual void lcl_startShape(css::uno::Reference
<css::drawing::XShape
> const& xShape
) override
;
153 virtual void lcl_endShape( ) override
;
154 virtual void lcl_startTextBoxContent() override
;
155 virtual void lcl_endTextBoxContent() override
;
156 virtual void lcl_text(const sal_uInt8
* data
, size_t len
) override
;
157 virtual void lcl_utext(const sal_uInt8
* data
, size_t len
) override
;
158 virtual void lcl_positionOffset(const OUString
& rText
, bool bVertical
) override
;
159 virtual css::awt::Point
getPositionOffset() override
;
160 virtual void lcl_align(const OUString
& rText
, bool bVertical
) override
;
161 virtual void lcl_positivePercentage(const OUString
& rText
) override
;
162 virtual void lcl_props(writerfilter::Reference
<Properties
>::Pointer_t ref
) override
;
163 virtual void lcl_table(Id name
,
164 writerfilter::Reference
<Table
>::Pointer_t ref
) override
;
165 virtual void lcl_substream(Id name
,
166 ::writerfilter::Reference
<Stream
>::Pointer_t ref
) override
;
167 virtual void lcl_startGlossaryEntry() override
;
168 virtual void lcl_endGlossaryEntry() override
;
169 virtual void lcl_checkId(const sal_Int32 nId
) override
;
172 virtual void lcl_attribute(Id Name
, Value
& val
) override
;
173 virtual void lcl_sprm(Sprm
& sprm
) override
;
176 virtual void lcl_entry(writerfilter::Reference
<Properties
>::Pointer_t ref
) override
;
178 void finishParagraph(const bool bRemove
= false, const bool bNoNumbering
= false);
180 static void handleUnderlineType(const Id nId
, const ::tools::SvRef
<PropertyMap
>& rContext
);
181 void handleParaJustification(const sal_Int32 nIntValue
, const ::tools::SvRef
<PropertyMap
>& rContext
, const bool bExchangeLeftRight
);
182 static bool getColorFromId(const Id
, sal_Int32
&nColor
);
183 static sal_Int16
getEmphasisValue(const sal_Int32 nIntValue
);
184 static OUString
getBracketStringFromEnum(const sal_Int32 nIntValue
, const bool bIsPrefix
= true);
185 static css::style::TabAlign
getTabAlignFromValue(const sal_Int32 nIntValue
);
186 static sal_Unicode
getFillCharFromValue(const sal_Int32 nIntValue
);
189 bool mbWasShapeInPara
;
190 std::unique_ptr
< GraphicZOrderHelper
> m_zOrderHelper
;
191 OUString m_sGlossaryEntryName
;
194 } // namespace writerfilter::dmapper
196 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */