LibreOffice Module xmloff (master) 1
xmlstyle.hxx
Go to the documentation of this file.
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#ifndef INCLUDED_XMLOFF_XMLSTYLE_HXX
21#define INCLUDED_XMLOFF_XMLSTYLE_HXX
22
23#include <rtl/ref.hxx>
24#include <sal/config.h>
25#include <xmloff/dllapi.h>
26#include <sal/types.h>
27#include <xmloff/xmlictxt.hxx>
28#include <xmloff/families.hxx>
29#include <memory>
30
33class SvXMLTokenMap;
34
35namespace com::sun::star {
36namespace container { class XNameContainer; }
37namespace style { class XAutoStyleFamily; }
38}
39
41{
42 OUString maName;
43 OUString maDisplayName;
44 OUString maAutoName;
45 OUString maParentName;// Will be moved to XMLPropStyle soon!!!!
46 OUString maFollow; // Will be moved to XMLPropStyle soon!!!!
47 OUString maLinked;
49
51
52 bool mbValid : 1; // Set this to false in CreateAndInsert
53 // if the style shouldn't be processed
54 // by Finish() or si somehow invalid.
55 bool mbNew : 1; // Set this to false in CreateAnsInsert
56 // if the style is already existing.
58
59protected:
60
61 virtual void SetAttribute( sal_Int32 nElement, const OUString& rValue );
62
63 void SetFamily( XmlStyleFamily nSet ) { mnFamily = nSet; }
64 void SetAutoName( const OUString& rName ) { maAutoName = rName; }
65
66public:
67
70 bool bDefaultStyle = false );
71
72 virtual ~SvXMLStyleContext() override;
73
74 virtual void SAL_CALL startFastElement(
75 sal_Int32 nElement,
76 const css::uno::Reference< css::xml::sax::XFastAttributeList >& ) override;
77
78 const OUString& GetName() const { return maName; }
79 const OUString& GetDisplayName() const { return maDisplayName.getLength() ? maDisplayName : maName; }
80 const OUString& GetAutoName() const { return maAutoName; }
81 const OUString& GetParentName() const { return maParentName; }
82 const OUString& GetFollow() const { return maFollow; }
83 const OUString& GetLinked() const { return maLinked; }
84
85 XmlStyleFamily GetFamily() const { return mnFamily; }
86
87 bool IsValid() const { return mbValid; }
88 void SetValid( bool b ) { mbValid = b; }
89
90 bool IsNew() const { return mbNew; }
91 void SetNew( bool b ) { mbNew = b; }
92
93 bool IsHidden() const { return mbHidden; }
94
95 // This method is called for every default style
96 virtual void SetDefaults();
97
98 // This method is called for every style. It must create it and insert
99 // it into the document.
100 virtual void CreateAndInsert( bool bOverwrite );
101
102 // This method is called for every style. It must create it and insert
103 // it into the document if this hasn't happened already in CreateAndInsert().
104 virtual void CreateAndInsertLate( bool bOverwrite );
105
106 // This method is called for every style after all styles have been
107 // inserted into the document.
108 virtual void Finish( bool bOverwrite );
109
110 bool IsDefaultStyle() const { return mbDefaultStyle; }
111
120 virtual bool IsTransient() const;
121};
122
124{
125 std::unique_ptr<SvXMLStylesContext_Impl> mpImpl;
126
127
128 css::uno::Reference< css::container::XNameContainer > mxParaStyles;
129
130 css::uno::Reference< css::container::XNameContainer > mxTextStyles;
131
132 css::uno::Reference< css::style::XAutoStyleFamily > mxParaAutoStyles;
133
134 css::uno::Reference< css::style::XAutoStyleFamily > mxTextAutoStyles;
135
141
143 SvXMLStylesContext& operator =(SvXMLStylesContext const &) = delete;
144
145protected:
146
147 sal_uInt32 GetStyleCount() const;
148 SvXMLStyleContext *GetStyle( sal_uInt32 i );
149 const SvXMLStyleContext *GetStyle( sal_uInt32 i ) const;
150
151 virtual SvXMLStyleContext *CreateStyleChildContext(
152 sal_Int32 nElement,
153 const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList );
154
155 virtual SvXMLStyleContext *CreateStyleStyleChildContext( XmlStyleFamily nFamily,
156 sal_Int32 nElement,
157 const css::uno::Reference< css::xml::sax::XFastAttributeList > & xAttrList );
158
159 virtual SvXMLStyleContext *CreateDefaultStyleStyleChildContext(
160 XmlStyleFamily nFamily, sal_Int32 nElement,
161 const css::uno::Reference< css::xml::sax::XFastAttributeList > & xAttrList );
162
163 virtual bool InsertStyleFamily( XmlStyleFamily nFamily ) const;
164
165public:
166
168 bool bAutomatic = false );
169
170 virtual ~SvXMLStylesContext() override;
171
172 // Create child element.
173 virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(
174 sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList >& AttrList ) override;
175
176 // This allows to add an SvXMLStyleContext to this context from extern
177 void AddStyle(SvXMLStyleContext& rNew);
178
179 const SvXMLStyleContext *FindStyleChildContext(
180 XmlStyleFamily nFamily,
181 const OUString& rName,
182 bool bCreateIndex = false ) const;
183 static XmlStyleFamily GetFamily( std::u16string_view rFamily );
184 virtual rtl::Reference < SvXMLImportPropertyMapper > GetImportPropertyMapper(
185 XmlStyleFamily nFamily ) const;
186
187 virtual css::uno::Reference< css::container::XNameContainer >
188 GetStylesContainer( XmlStyleFamily nFamily ) const;
189 virtual OUString GetServiceName( XmlStyleFamily nFamily ) const;
190
191 css::uno::Reference< css::style::XAutoStyleFamily >
192 GetAutoStyles( XmlStyleFamily nFamily ) const;
193 void CopyAutoStylesToDoc();
194 void CopyStylesToDoc( bool bOverwrite, bool bFinish = true );
195 void FinishStyles( bool bOverwrite );
196
197 // This method must be called to release the references to all styles
198 // that are stored in the context.
199 void dispose();
200 bool IsAutomaticStyle() const;
201};
202
203#endif // INCLUDED_XMLOFF_XMLSTYLE_HXX
204
205/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
OUString maDisplayName
OUString maName
This class deliberately does not support XWeak, to improve performance when loading large documents.
Definition: xmlictxt.hxx:48
virtual void SAL_CALL startFastElement(sal_Int32 Element, const css::uno::Reference< css::xml::sax::XFastAttributeList > &Attribs) override
Definition: xmlictxt.cxx:45
virtual css::uno::Reference< XFastContextHandler > SAL_CALL createFastChildContext(sal_Int32 Element, const css::uno::Reference< css::xml::sax::XFastAttributeList > &Attribs) override
Definition: xmlictxt.cxx:59
OUString maParentName
Definition: xmlstyle.hxx:45
void SetFamily(XmlStyleFamily nSet)
Definition: xmlstyle.hxx:63
const OUString & GetName() const
Definition: xmlstyle.hxx:78
OUString maName
Definition: xmlstyle.hxx:42
OUString maFollow
Definition: xmlstyle.hxx:46
const OUString & GetFollow() const
Definition: xmlstyle.hxx:82
void SetAutoName(const OUString &rName)
Definition: xmlstyle.hxx:64
const OUString & GetLinked() const
Definition: xmlstyle.hxx:83
XmlStyleFamily mnFamily
Definition: xmlstyle.hxx:50
bool IsHidden() const
Definition: xmlstyle.hxx:93
void SetValid(bool b)
Definition: xmlstyle.hxx:88
XmlStyleFamily GetFamily() const
Definition: xmlstyle.hxx:85
void SetNew(bool b)
Definition: xmlstyle.hxx:91
const OUString & GetParentName() const
Definition: xmlstyle.hxx:81
bool IsNew() const
Definition: xmlstyle.hxx:90
OUString maLinked
Definition: xmlstyle.hxx:47
bool IsDefaultStyle() const
Definition: xmlstyle.hxx:110
OUString maAutoName
Definition: xmlstyle.hxx:44
bool IsValid() const
Definition: xmlstyle.hxx:87
OUString maDisplayName
Definition: xmlstyle.hxx:43
const OUString & GetDisplayName() const
Definition: xmlstyle.hxx:79
const OUString & GetAutoName() const
Definition: xmlstyle.hxx:80
std::unique_ptr< SvXMLStylesContext_Impl > mpImpl
Definition: xmlstyle.hxx:125
css::uno::Reference< css::container::XNameContainer > mxTextStyles
Definition: xmlstyle.hxx:130
rtl::Reference< SvXMLImportPropertyMapper > mxPageImpPropMapper
Definition: xmlstyle.hxx:140
rtl::Reference< SvXMLImportPropertyMapper > mxParaImpPropMapper
Definition: xmlstyle.hxx:136
rtl::Reference< SvXMLImportPropertyMapper > mxChartImpPropMapper
Definition: xmlstyle.hxx:139
css::uno::Reference< css::style::XAutoStyleFamily > mxParaAutoStyles
Definition: xmlstyle.hxx:132
rtl::Reference< SvXMLImportPropertyMapper > mxShapeImpPropMapper
Definition: xmlstyle.hxx:138
SvXMLStylesContext(SvXMLStylesContext const &)=delete
css::uno::Reference< css::container::XNameContainer > mxParaStyles
Definition: xmlstyle.hxx:128
css::uno::Reference< css::style::XAutoStyleFamily > mxTextAutoStyles
Definition: xmlstyle.hxx:134
rtl::Reference< SvXMLImportPropertyMapper > mxTextImpPropMapper
Definition: xmlstyle.hxx:137
#define XMLOFF_DLLPUBLIC
Definition: dllapi.h:29
XmlStyleFamily
Definition: families.hxx:50
void dispose()
bool mbValid