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 markLastParagraph() override
{ mbIsLastPara
= true; }
87 virtual void markLastSectionGroup() override
;
90 virtual void data(const sal_uInt8
* buf
, size_t len
) override
;
92 void sprmWithProps( Sprm
& sprm
, const PropertyMapPtr
& pContext
);
94 void PushStyleSheetProperties( const PropertyMapPtr
& pStyleProperties
, bool bAffectTableMngr
= false );
95 void PopStyleSheetProperties( bool bAffectTableMngr
= false );
97 void PushListProperties( const ::tools::SvRef
<PropertyMap
>& pListProperties
);
98 void PopListProperties();
99 OUString
GetListStyleName(sal_Int32 nListId
) const;
100 void ValidateListLevel(const OUString
& sStyleIdentifierD
);
102 bool IsOOXMLImport() const;
103 bool IsRTFImport() const;
104 css::uno::Reference
<css::lang::XMultiServiceFactory
> const & GetTextFactory() const;
105 css::uno::Reference
<css::text::XTextRange
> GetCurrentTextRange();
107 OUString
getOrCreateCharStyle( PropertyValueVector_t
& rCharProperties
, bool bAlwaysCreate
);
108 StyleSheetTablePtr
const & GetStyleSheetTable( );
109 SettingsTablePtr
const & GetSettingsTable();
110 GraphicZOrderHelper
* graphicZOrderHelper();
112 /// Return the first from the pending (not inserted to the document) shapes, if there are any.
113 css::uno::Reference
<css::drawing::XShape
> PopPendingShape();
115 bool IsInHeaderFooter() const;
116 bool IsInTable() const;
117 void SetDocDefaultsImport(bool bSet
);
118 bool IsStyleSheetImport() const;
119 bool IsNumberingImport() const;
120 bool IsInShape() const;
122 void hasControls( const bool bSet
) { mbHasControls
= bSet
; }
125 @see DomainMapper_Impl::processDeferredCharacterProperties()
127 void processDeferredCharacterProperties(
128 const std::map
<sal_Int32
, css::uno::Any
>& rDeferredCharacterProperties
,
129 bool bCharContext
= true);
131 void ProcessDeferredStyleCharacterProperties();
133 /// Enable storing of seen tokens in a named grab bag.
134 void enableInteropGrabBag(const OUString
& aName
);
135 /// Get the stored tokens and clear the internal storage.
136 css::beans::PropertyValue
getInteropGrabBag();
138 void HandleRedline( Sprm
& rSprm
);
140 virtual void commentProps(const OUString
& sId
, const CommentProperties
& rProps
) override
;
142 css::uno::Reference
<css::container::XNameContainer
> const & GetCharacterStyles();
143 OUString
GetUnusedCharacterStyleName();
147 virtual void lcl_startSectionGroup() override
;
148 virtual void lcl_endSectionGroup() override
;
149 virtual void lcl_startParagraphGroup() override
;
150 virtual void lcl_endParagraphGroup() override
;
151 virtual void lcl_startCharacterGroup() override
;
152 virtual void lcl_endCharacterGroup() override
;
153 virtual void lcl_startShape(css::uno::Reference
<css::drawing::XShape
> const& xShape
) override
;
154 virtual void lcl_endShape( ) override
;
155 virtual void lcl_startTextBoxContent() override
;
156 virtual void lcl_endTextBoxContent() override
;
157 virtual void lcl_text(const sal_uInt8
* data
, size_t len
) override
;
158 virtual void lcl_utext(const sal_Unicode
* data
, size_t len
) override
;
159 virtual void lcl_positionOffset(const OUString
& rText
, bool bVertical
) override
;
160 virtual css::awt::Point
getPositionOffset() override
;
161 virtual void lcl_align(const OUString
& rText
, bool bVertical
) override
;
162 virtual void lcl_positivePercentage(const OUString
& rText
) override
;
163 virtual void lcl_props(writerfilter::Reference
<Properties
>::Pointer_t ref
) override
;
164 virtual void lcl_table(Id name
,
165 writerfilter::Reference
<Table
>::Pointer_t ref
) override
;
166 virtual void lcl_substream(Id name
,
167 ::writerfilter::Reference
<Stream
>::Pointer_t ref
) override
;
168 virtual void lcl_startGlossaryEntry() override
;
169 virtual void lcl_endGlossaryEntry() override
;
170 virtual void lcl_checkId(const sal_Int32 nId
) override
;
173 virtual void lcl_attribute(Id Name
, Value
& val
) override
;
174 virtual void lcl_sprm(Sprm
& sprm
) override
;
177 virtual void lcl_entry(writerfilter::Reference
<Properties
>::Pointer_t ref
) override
;
179 void ResetStyleProperties();
180 void finishParagraph(const bool bRemove
= false, const bool bNoNumbering
= false);
182 static void handleUnderlineType(const Id nId
, const ::tools::SvRef
<PropertyMap
>& rContext
);
183 void handleParaJustification(const sal_Int32 nIntValue
, const ::tools::SvRef
<PropertyMap
>& rContext
, const bool bExchangeLeftRight
);
184 static bool getColorFromId(const Id
, sal_Int32
&nColor
);
185 static sal_Int16
getEmphasisValue(const sal_Int32 nIntValue
);
186 static OUString
getBracketStringFromEnum(const sal_Int32 nIntValue
, const bool bIsPrefix
= true);
187 static css::style::TabAlign
getTabAlignFromValue(const sal_Int32 nIntValue
);
188 static sal_Unicode
getFillCharFromValue(const sal_Int32 nIntValue
);
191 bool mbWasShapeInPara
;
192 bool mbIsLastPara
= false;
193 std::unique_ptr
< GraphicZOrderHelper
> m_zOrderHelper
;
194 OUString m_sGlossaryEntryName
;
197 } // namespace writerfilter::dmapper
199 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */