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 .
23 #include <xmlscript/xmldlg_imexp.hxx>
24 #include <xmlscript/xml_helper.hxx>
25 #include <osl/diagnose.h>
26 #include <com/sun/star/xml/sax/XAttributeList.hpp>
27 #include <com/sun/star/beans/XPropertySet.hpp>
28 #include <com/sun/star/beans/XPropertyState.hpp>
29 #include <com/sun/star/awt/FontDescriptor.hpp>
30 #include <com/sun/star/awt/FontEmphasisMark.hpp>
31 #include <com/sun/star/awt/FontRelief.hpp>
41 sal_uInt32 _backgroundColor
;
42 sal_uInt32 _textColor
;
43 sal_uInt32 _textLineColor
;
45 sal_Int32 _borderColor
;
46 css::awt::FontDescriptor _descr
;
47 sal_uInt16 _fontRelief
;
48 sal_uInt16 _fontEmphasisMark
;
49 sal_uInt32 _fillColor
;
50 sal_Int16 _visualEffect
;
52 // current highest mask: 0x40
58 explicit Style( short all_
)
64 , _fontRelief(css::awt::FontRelief::NONE
)
65 , _fontEmphasisMark(css::awt::FontEmphasisMark::NONE
)
73 css::uno::Reference
< css::xml::sax::XAttributeList
> createElement();
77 ::std::vector
<Style
> _styles
;
82 OUString
getStyleId( Style
const & rStyle
);
84 void dump( css::uno::Reference
< css::xml::sax::XExtendedDocumentHandler
>
88 class ElementDescriptor
89 : public ::xmlscript::XMLElement
91 css::uno::Reference
< css::beans::XPropertySet
> _xProps
;
92 css::uno::Reference
< css::beans::XPropertyState
> _xPropState
;
93 css::uno::Reference
< css::frame::XModel
> _xDocument
;
97 css::uno::Reference
< css::beans::XPropertySet
> xProps
,
98 css::uno::Reference
< css::beans::XPropertyState
> xPropState
,
99 OUString
const & name
, css::uno::Reference
< css::frame::XModel
> xDocument
)
101 , _xProps(std::move( xProps
))
102 , _xPropState(std::move( xPropState
))
103 , _xDocument(std::move( xDocument
))
105 explicit ElementDescriptor(
106 OUString
const & name
)
112 OUString
const & propName
, OUString
const & attrName
,
113 bool forceAttribute
= false );
116 inline bool readProp( T
* ret
, OUString
const & rPropName
);
117 css::uno::Any
readProp( OUString
const & rPropName
);
118 void readScrollableSettings();
119 void readDefaults( bool supportPrintable
= true, bool supportVisible
= true );
121 OUString
const & rPropName
, OUString
const & rAttrName
);
123 OUString
const & rPropName
, OUString
const & rAttrName
)
124 { read
<double>( rPropName
, rAttrName
); }
126 OUString
const & rPropName
, OUString
const & rAttrName
,
127 bool forceAttribute
= false )
128 { read
<sal_Int32
>( rPropName
, rAttrName
, forceAttribute
); }
129 void readHexLongAttr(
130 OUString
const & rPropName
, OUString
const & rAttrName
);
132 OUString
const & rPropName
, OUString
const & rAttrName
)
133 { read
<sal_Int32
>( rPropName
, rAttrName
); }
134 inline void readBoolAttr(
135 OUString
const & rPropName
, OUString
const & rAttrName
);
138 OUString
const & rPropName
, OUString
const & rAttrName
);
139 void readVerticalAlignAttr(
140 OUString
const & rPropName
, OUString
const & rAttrName
);
141 void readImageAlignAttr(
142 OUString
const & rPropName
, OUString
const & rAttrName
);
143 void readImagePositionAttr(
144 OUString
const & rPropName
, OUString
const & rAttrName
);
146 OUString
const & rPropName
, OUString
const & rAttrName
);
147 void readDateFormatAttr(
148 OUString
const & rPropName
, OUString
const & rAttrName
);
150 OUString
const & rPropName
, OUString
const & rAttrName
);
151 void readTimeFormatAttr(
152 OUString
const & rPropName
, OUString
const & rAttrName
);
153 void readOrientationAttr(
154 OUString
const & rPropName
, OUString
const & rAttrName
);
155 void readButtonTypeAttr(
156 OUString
const & rPropName
, OUString
const & rAttrName
);
157 void readLineEndFormatAttr(
158 OUString
const & rPropName
, OUString
const & rAttrName
);
159 void readSelectionTypeAttr(
160 OUString
const & rPropName
, OUString
const & rAttrName
);
161 void readImageScaleModeAttr(
162 OUString
const & rPropName
, OUString
const & rAttrName
);
164 void readDataAwareAttr(OUString
const & rAttrName
);
165 void readImageOrGraphicAttr(OUString
const & rAttrName
);
168 OUString
const & rAttrName
, bool bValue
)
169 { addAttribute( rAttrName
, OUString::boolean(bValue
) ); }
170 void addNumberFormatAttr(
171 css::uno::Reference
< css::beans::XPropertySet
>
172 const & xFormatProperties
);
175 void readDialogModel( StyleBag
* all_styles
);
176 void readBullitinBoard( StyleBag
* all_styles
);
177 void readMultiPageModel( StyleBag
* all_styles
);
178 void readFrameModel( StyleBag
* all_styles
);
179 void readPageModel( StyleBag
* all_styles
);
180 void readButtonModel( StyleBag
* all_styles
);
181 void readEditModel( StyleBag
* all_styles
);
182 void readCheckBoxModel( StyleBag
* all_styles
);
183 void readRadioButtonModel( StyleBag
* all_styles
);
184 void readComboBoxModel( StyleBag
* all_styles
);
185 void readCurrencyFieldModel( StyleBag
* all_styles
);
186 void readDateFieldModel( StyleBag
* all_styles
);
187 void readFileControlModel( StyleBag
* all_styles
);
188 void readTreeControlModel( StyleBag
* all_styles
);
189 void readFixedTextModel( StyleBag
* all_styles
);
190 void readGroupBoxModel( StyleBag
* all_styles
);
191 void readImageControlModel( StyleBag
* all_styles
);
192 void readListBoxModel( StyleBag
* all_styles
);
193 void readNumericFieldModel( StyleBag
* all_styles
);
194 void readPatternFieldModel( StyleBag
* all_styles
);
195 void readFormattedFieldModel( StyleBag
* all_styles
);
196 void readTimeFieldModel( StyleBag
* all_styles
);
197 void readFixedLineModel( StyleBag
* all_styles
);
198 void readProgressBarModel( StyleBag
* all_styles
);
199 void readScrollBarModel( StyleBag
* all_styles
);
200 void readSpinButtonModel( StyleBag
* all_styles
);
201 void readFixedHyperLinkModel( StyleBag
* all_styles
);
202 void readGridControlModel( StyleBag
* all_styles
);
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
) );
217 addAttribute( attrName
, OUString::number(v
) );
219 OSL_FAIL( "### unexpected property type!" );
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
) );
235 addAttribute( attrName
, OUString::boolean(v
) );
237 OSL_FAIL( "### unexpected property type!" );
241 inline void ElementDescriptor::readBoolAttr(
242 OUString
const & rPropName
, OUString
const & rAttrName
)
244 read
<sal_Bool
>( rPropName
, rAttrName
);
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
);
259 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */