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 
33 class SvXMLTokenMap;
34 
35 namespace com::sun::star {
36 namespace container { class XNameContainer; }
37 namespace 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  bool mbHidden;
48 
50 
51  bool mbValid : 1; // Set this to false in CreateAndInsert
52  // if the style shouldn't be processed
53  // by Finish() or si somehow invalid.
54  bool mbNew : 1; // Set this to false in CreateAnsInsert
55  // if the style is already existing.
56  bool mbDefaultStyle : 1;
57 
58 protected:
59 
60  virtual void SetAttribute( sal_uInt16 nPrefixKey,
61  const OUString& rLocalName,
62  const OUString& rValue );
63 
64  void SetFamily( XmlStyleFamily nSet ) { mnFamily = nSet; }
65  void SetAutoName( const OUString& rName ) { maAutoName = rName; }
66 
67 public:
68 
71  bool bDefaultStyle = false );
72 
73  virtual ~SvXMLStyleContext() override;
74 
75  virtual void SAL_CALL startFastElement(
76  sal_Int32 nElement,
77  const css::uno::Reference< css::xml::sax::XFastAttributeList >& ) override;
78 
79  const OUString& GetName() const { return maName; }
80  const OUString& GetDisplayName() const { return maDisplayName.getLength() ? maDisplayName : maName; }
81  const OUString& GetAutoName() const { return maAutoName; }
82  const OUString& GetParentName() const { return maParentName; }
83  const OUString& GetFollow() const { return maFollow; }
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 
142  SvXMLStylesContext(SvXMLStylesContext const &) = delete;
143  SvXMLStylesContext& operator =(SvXMLStylesContext const &) = delete;
144 
145 protected:
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 
165 public:
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( const OUString& 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 maAutoName
Definition: xmlstyle.hxx:44
css::uno::Reference< css::style::XAutoStyleFamily > mxTextAutoStyles
Definition: xmlstyle.hxx:134
XmlStyleFamily GetFamily() const
Definition: xmlstyle.hxx:85
OUString maParentName
Definition: xmlstyle.hxx:45
rtl::Reference< SvXMLImportPropertyMapper > mxParaImpPropMapper
Definition: xmlstyle.hxx:136
void SetNew(bool b)
Definition: xmlstyle.hxx:91
virtual void SAL_CALL startFastElement(sal_Int32 Element, const css::uno::Reference< css::xml::sax::XFastAttributeList > &Attribs) override
Definition: xmlictxt.cxx:68
css::uno::Reference< css::container::XNameContainer > mxParaStyles
Definition: xmlstyle.hxx:128
bool IsNew() const
Definition: xmlstyle.hxx:90
bool IsDefaultStyle() const
Definition: xmlstyle.hxx:110
exports com.sun.star. container
css::uno::Any const & rValue
Definition: ImageStyle.hxx:38
XmlStyleFamily
Definition: families.hxx:47
bool IsValid() const
Definition: xmlstyle.hxx:87
const OUString & GetAutoName() const
Definition: xmlstyle.hxx:81
OUString maDisplayName
Definition: xmlstyle.hxx:43
bool IsHidden() const
Definition: xmlstyle.hxx:93
const OUString & GetDisplayName() const
Definition: xmlstyle.hxx:80
void SetFamily(XmlStyleFamily nSet)
Definition: xmlstyle.hxx:64
rtl::Reference< SvXMLImportPropertyMapper > mxChartImpPropMapper
Definition: xmlstyle.hxx:139
std::unique_ptr< SvXMLStylesContext_Impl > mpImpl
Definition: xmlstyle.hxx:125
exports com.sun.star. style
void SetValid(bool b)
Definition: xmlstyle.hxx:88
This class deliberately does not support XWeak, to improve performance when loading large documents...
Definition: xmlictxt.hxx:45
const OUString & GetParentName() const
Definition: xmlstyle.hxx:82
rtl::Reference< SvXMLImportPropertyMapper > mxTextImpPropMapper
Definition: xmlstyle.hxx:137
const OUString & GetName() const
Definition: xmlstyle.hxx:79
OUString maName
Definition: xmlstyle.hxx:42
XmlStyleFamily mnFamily
Definition: xmlstyle.hxx:49
OUString maFollow
Definition: xmlstyle.hxx:46
virtual css::uno::Reference< XFastContextHandler > SAL_CALL createFastChildContext(sal_Int32 Element, const css::uno::Reference< css::xml::sax::XFastAttributeList > &Attribs) override
Definition: xmlictxt.cxx:108
void SetAutoName(const OUString &rName)
Definition: xmlstyle.hxx:65
const OUString & GetFollow() const
Definition: xmlstyle.hxx:83
css::uno::Reference< css::style::XAutoStyleFamily > mxParaAutoStyles
Definition: xmlstyle.hxx:132
css::uno::Reference< css::container::XNameContainer > mxTextStyles
Definition: xmlstyle.hxx:130
void dispose()
rtl::Reference< SvXMLImportPropertyMapper > mxPageImpPropMapper
Definition: xmlstyle.hxx:140
rtl::Reference< SvXMLImportPropertyMapper > mxShapeImpPropMapper
Definition: xmlstyle.hxx:138
#define XMLOFF_DLLPUBLIC
Definition: dllapi.h:29
bool mbValid