bump product version to 5.0.4.1
[LibreOffice.git] / xmlscript / source / xmldlg_imexp / exp_share.hxx
blobc67853ce6ffe2a99c298dc22b1a1bdf85fbc78a9
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 .
20 #ifndef INCLUDED_XMLSCRIPT_SOURCE_XMLDLG_IMEXP_EXP_SHARE_HXX
21 #define INCLUDED_XMLSCRIPT_SOURCE_XMLDLG_IMEXP_EXP_SHARE_HXX
23 #include "common.hxx"
24 #include "misc.hxx"
25 #include <xmlscript/xmldlg_imexp.hxx>
26 #include <xmlscript/xml_helper.hxx>
27 #include <osl/diagnose.h>
28 #include <com/sun/star/xml/sax/XAttributeList.hpp>
29 #include <com/sun/star/beans/XPropertySet.hpp>
30 #include <com/sun/star/beans/XPropertyState.hpp>
31 #include <com/sun/star/awt/FontDescriptor.hpp>
32 #include <com/sun/star/awt/FontEmphasisMark.hpp>
33 #include <com/sun/star/awt/FontRelief.hpp>
34 #include <vector>
37 namespace xmlscript
40 struct Style
42 sal_uInt32 _backgroundColor;
43 sal_uInt32 _textColor;
44 sal_uInt32 _textLineColor;
45 sal_Int16 _border;
46 sal_Int32 _borderColor;
47 css::awt::FontDescriptor _descr;
48 sal_uInt16 _fontRelief;
49 sal_uInt16 _fontEmphasisMark;
50 sal_uInt32 _fillColor;
51 sal_Int16 _visualEffect;
53 // current highest mask: 0x40
54 short _all;
55 short _set;
57 OUString _id;
59 Style( short all_ )
60 : _backgroundColor(0)
61 , _textColor(0)
62 , _textLineColor(0)
63 , _border(0)
64 , _borderColor(0)
65 , _fontRelief(css::awt::FontRelief::NONE)
66 , _fontEmphasisMark(css::awt::FontEmphasisMark::NONE)
67 , _fillColor(0)
68 , _visualEffect(0)
69 , _all(all_)
70 , _set(0)
74 css::uno::Reference< css::xml::sax::XAttributeList > createElement();
76 class StyleBag
78 ::std::vector< Style * > _styles;
80 public:
81 ~StyleBag() ;
83 OUString getStyleId( Style const & rStyle );
85 void dump( css::uno::Reference< css::xml::sax::XExtendedDocumentHandler >
86 const & xOut );
89 class ElementDescriptor
90 : public ::xmlscript::XMLElement
92 css::uno::Reference< css::beans::XPropertySet > _xProps;
93 css::uno::Reference< css::beans::XPropertyState > _xPropState;
94 css::uno::Reference< css::frame::XModel > _xDocument;
96 public:
97 inline ElementDescriptor(
98 css::uno::Reference< css::beans::XPropertySet > const & xProps,
99 css::uno::Reference< css::beans::XPropertyState > const & xPropState,
100 OUString const & name, css::uno::Reference< css::frame::XModel > const & xDocument )
101 : XMLElement( name )
102 , _xProps( xProps )
103 , _xPropState( xPropState )
104 , _xDocument( xDocument )
106 inline ElementDescriptor(
107 OUString const & name )
108 : XMLElement( name )
111 template<typename T>
112 inline void read(
113 OUString const & propName, OUString const & attrName,
114 bool forceAttribute = false );
116 template<typename T>
117 inline bool readProp( T * ret, OUString const & rPropName );
118 css::uno::Any readProp( OUString const & rPropName );
119 void readScrollableSettings();
120 void readDefaults( bool supportPrintable = true, bool supportVisible = true );
121 void readStringAttr(
122 OUString const & rPropName, OUString const & rAttrName );
123 inline void readDoubleAttr(
124 OUString const & rPropName, OUString const & rAttrName )
125 { read<double>( rPropName, rAttrName ); }
126 inline void readLongAttr(
127 OUString const & rPropName, OUString const & rAttrName,
128 bool forceAttribute = false )
129 { read<sal_Int32>( rPropName, rAttrName, forceAttribute ); }
130 void readHexLongAttr(
131 OUString const & rPropName, OUString const & rAttrName );
132 inline void readShortAttr(
133 OUString const & rPropName, OUString const & rAttrName )
134 { read<sal_Int32>( rPropName, rAttrName ); }
135 inline void readBoolAttr(
136 OUString const & rPropName, OUString const & rAttrName );
138 void readAlignAttr(
139 OUString const & rPropName, OUString const & rAttrName );
140 void readVerticalAlignAttr(
141 OUString const & rPropName, OUString const & rAttrName );
142 void readImageURLAttr(
143 OUString const & rPropName, OUString const & rAttrName );
144 void readImageAlignAttr(
145 OUString const & rPropName, OUString const & rAttrName );
146 void readImagePositionAttr(
147 OUString const & rPropName, OUString const & rAttrName );
148 void readDateAttr(
149 OUString const & rPropName, OUString const & rAttrName );
150 void readDateFormatAttr(
151 OUString const & rPropName, OUString const & rAttrName );
152 void readTimeAttr(
153 OUString const & rPropName, OUString const & rAttrName );
154 void readTimeFormatAttr(
155 OUString const & rPropName, OUString const & rAttrName );
156 void readOrientationAttr(
157 OUString const & rPropName, OUString const & rAttrName );
158 void readButtonTypeAttr(
159 OUString const & rPropName, OUString const & rAttrName );
160 void readLineEndFormatAttr(
161 OUString const & rPropName, OUString const & rAttrName );
162 void readSelectionTypeAttr(
163 OUString const & rPropName, OUString const & rAttrName );
164 void readImageScaleModeAttr(
165 OUString const & rPropName, OUString const & rAttrName );
166 void readDataAwareAttr(
167 OUString const & rAttrName );
168 inline void addBoolAttr(
169 OUString const & rAttrName, bool bValue )
170 { addAttribute( rAttrName, OUString::boolean(bValue) ); }
171 void addNumberFormatAttr(
172 css::uno::Reference< css::beans::XPropertySet >
173 const & xFormatProperties );
175 void readEvents();
176 void readDialogModel( StyleBag * all_styles );
177 void readBullitinBoard( StyleBag * all_styles );
178 void readMultiPageModel( StyleBag * all_styles );
179 void readFrameModel( StyleBag * all_styles );
180 void readPageModel( StyleBag * all_styles );
181 void readButtonModel( StyleBag * all_styles );
182 void readEditModel( StyleBag * all_styles );
183 void readCheckBoxModel( StyleBag * all_styles );
184 void readRadioButtonModel( StyleBag * all_styles );
185 void readComboBoxModel( StyleBag * all_styles );
186 void readCurrencyFieldModel( StyleBag * all_styles );
187 void readDateFieldModel( StyleBag * all_styles );
188 void readFileControlModel( StyleBag * all_styles );
189 void readTreeControlModel( StyleBag * all_styles );
190 void readFixedTextModel( StyleBag * all_styles );
191 void readGroupBoxModel( StyleBag * all_styles );
192 void readImageControlModel( StyleBag * all_styles );
193 void readListBoxModel( StyleBag * all_styles );
194 void readNumericFieldModel( StyleBag * all_styles );
195 void readPatternFieldModel( StyleBag * all_styles );
196 void readFormattedFieldModel( StyleBag * all_styles );
197 void readTimeFieldModel( StyleBag * all_styles );
198 void readFixedLineModel( StyleBag * all_styles );
199 void readProgressBarModel( StyleBag * all_styles );
200 void readScrollBarModel( StyleBag * all_styles );
201 void readSpinButtonModel( StyleBag * all_styles );
202 void readFixedHyperLinkModel( StyleBag * all_styles );
205 template<typename T>
206 inline void ElementDescriptor::read(
207 OUString const & propName, OUString const & attrName,
208 bool forceAttribute )
210 if (forceAttribute ||
211 css::beans::PropertyState_DEFAULT_VALUE !=
212 _xPropState->getPropertyState( propName ))
214 css::uno::Any a( _xProps->getPropertyValue( propName ) );
215 T v = T();
216 if (a >>= v)
217 addAttribute( attrName, OUString::number(v) );
218 else
219 OSL_FAIL( "### unexpected property type!" );
223 template<>
224 inline void ElementDescriptor::read<sal_Bool>(
225 OUString const & propName, OUString const & attrName,
226 bool forceAttribute )
228 if (forceAttribute ||
229 css::beans::PropertyState_DEFAULT_VALUE !=
230 _xPropState->getPropertyState( propName ))
232 css::uno::Any a( _xProps->getPropertyValue( propName ) );
233 bool v;
234 if (a >>= v)
235 addAttribute( attrName, OUString::boolean(v) );
236 else
237 OSL_FAIL( "### unexpected property type!" );
241 inline void ElementDescriptor::readBoolAttr(
242 OUString const & rPropName, OUString const & rAttrName )
244 read<sal_Bool>( rPropName, rAttrName );
247 template<typename T>
248 inline bool ElementDescriptor::readProp(
249 T * ret, OUString const & rPropName )
251 _xProps->getPropertyValue( rPropName ) >>= *ret;
252 return css::beans::PropertyState_DEFAULT_VALUE !=
253 _xPropState->getPropertyState( rPropName );
258 #endif // INCLUDED_XMLSCRIPT_SOURCE_XMLDLG_IMEXP_EXP_SHARE_HXX
260 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */