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 .
22 #include <xmlscript/xmldlg_imexp.hxx>
23 #include <xmlscript/xml_helper.hxx>
24 #include <osl/diagnose.h>
25 #include <com/sun/star/xml/sax/XAttributeList.hpp>
26 #include <com/sun/star/beans/XPropertySet.hpp>
27 #include <com/sun/star/beans/XPropertyState.hpp>
28 #include <com/sun/star/awt/FontDescriptor.hpp>
29 #include <com/sun/star/awt/FontEmphasisMark.hpp>
30 #include <com/sun/star/awt/FontRelief.hpp>
40 sal_uInt32 _backgroundColor
;
41 sal_uInt32 _textColor
;
42 sal_uInt32 _textLineColor
;
44 sal_Int32 _borderColor
;
45 css::awt::FontDescriptor _descr
;
46 sal_uInt16 _fontRelief
;
47 sal_uInt16 _fontEmphasisMark
;
48 sal_uInt32 _fillColor
;
49 sal_Int16 _visualEffect
;
51 // current highest mask: 0x40
57 explicit Style( short all_
)
63 , _fontRelief(css::awt::FontRelief::NONE
)
64 , _fontEmphasisMark(css::awt::FontEmphasisMark::NONE
)
72 css::uno::Reference
< css::xml::sax::XAttributeList
> createElement();
76 ::std::vector
< std::unique_ptr
<Style
> > _styles
;
81 OUString
getStyleId( Style
const & rStyle
);
83 void dump( css::uno::Reference
< css::xml::sax::XExtendedDocumentHandler
>
87 class ElementDescriptor
88 : public ::xmlscript::XMLElement
90 css::uno::Reference
< css::beans::XPropertySet
> _xProps
;
91 css::uno::Reference
< css::beans::XPropertyState
> _xPropState
;
92 css::uno::Reference
< css::frame::XModel
> _xDocument
;
96 css::uno::Reference
< css::beans::XPropertySet
> const & xProps
,
97 css::uno::Reference
< css::beans::XPropertyState
> const & xPropState
,
98 OUString
const & name
, css::uno::Reference
< css::frame::XModel
> const & xDocument
)
101 , _xPropState( xPropState
)
102 , _xDocument( xDocument
)
104 explicit ElementDescriptor(
105 OUString
const & name
)
111 OUString
const & propName
, OUString
const & attrName
,
112 bool forceAttribute
= false );
115 inline bool readProp( T
* ret
, OUString
const & rPropName
);
116 css::uno::Any
readProp( OUString
const & rPropName
);
117 void readScrollableSettings();
118 void readDefaults( bool supportPrintable
= true, bool supportVisible
= true );
120 OUString
const & rPropName
, OUString
const & rAttrName
);
122 OUString
const & rPropName
, OUString
const & rAttrName
)
123 { read
<double>( rPropName
, rAttrName
); }
125 OUString
const & rPropName
, OUString
const & rAttrName
,
126 bool forceAttribute
= false )
127 { read
<sal_Int32
>( rPropName
, rAttrName
, forceAttribute
); }
128 void readHexLongAttr(
129 OUString
const & rPropName
, OUString
const & rAttrName
);
131 OUString
const & rPropName
, OUString
const & rAttrName
)
132 { read
<sal_Int32
>( rPropName
, rAttrName
); }
133 inline void readBoolAttr(
134 OUString
const & rPropName
, OUString
const & rAttrName
);
137 OUString
const & rPropName
, OUString
const & rAttrName
);
138 void readVerticalAlignAttr(
139 OUString
const & rPropName
, OUString
const & rAttrName
);
140 void readImageAlignAttr(
141 OUString
const & rPropName
, OUString
const & rAttrName
);
142 void readImagePositionAttr(
143 OUString
const & rPropName
, OUString
const & rAttrName
);
145 OUString
const & rPropName
, OUString
const & rAttrName
);
146 void readDateFormatAttr(
147 OUString
const & rPropName
, OUString
const & rAttrName
);
149 OUString
const & rPropName
, OUString
const & rAttrName
);
150 void readTimeFormatAttr(
151 OUString
const & rPropName
, OUString
const & rAttrName
);
152 void readOrientationAttr(
153 OUString
const & rPropName
, OUString
const & rAttrName
);
154 void readButtonTypeAttr(
155 OUString
const & rPropName
, OUString
const & rAttrName
);
156 void readLineEndFormatAttr(
157 OUString
const & rPropName
, OUString
const & rAttrName
);
158 void readSelectionTypeAttr(
159 OUString
const & rPropName
, OUString
const & rAttrName
);
160 void readImageScaleModeAttr(
161 OUString
const & rPropName
, OUString
const & rAttrName
);
163 void readDataAwareAttr(OUString
const & rAttrName
);
164 void readImageOrGraphicAttr(OUString
const & rAttrName
);
167 OUString
const & rAttrName
, bool bValue
)
168 { addAttribute( rAttrName
, OUString::boolean(bValue
) ); }
169 void addNumberFormatAttr(
170 css::uno::Reference
< css::beans::XPropertySet
>
171 const & xFormatProperties
);
174 void readDialogModel( StyleBag
* all_styles
);
175 void readBullitinBoard( StyleBag
* all_styles
);
176 void readMultiPageModel( StyleBag
* all_styles
);
177 void readFrameModel( StyleBag
* all_styles
);
178 void readPageModel( StyleBag
* all_styles
);
179 void readButtonModel( StyleBag
* all_styles
);
180 void readEditModel( StyleBag
* all_styles
);
181 void readCheckBoxModel( StyleBag
* all_styles
);
182 void readRadioButtonModel( StyleBag
* all_styles
);
183 void readComboBoxModel( StyleBag
* all_styles
);
184 void readCurrencyFieldModel( StyleBag
* all_styles
);
185 void readDateFieldModel( StyleBag
* all_styles
);
186 void readFileControlModel( StyleBag
* all_styles
);
187 void readTreeControlModel( StyleBag
* all_styles
);
188 void readFixedTextModel( StyleBag
* all_styles
);
189 void readGroupBoxModel( StyleBag
* all_styles
);
190 void readImageControlModel( StyleBag
* all_styles
);
191 void readListBoxModel( StyleBag
* all_styles
);
192 void readNumericFieldModel( StyleBag
* all_styles
);
193 void readPatternFieldModel( StyleBag
* all_styles
);
194 void readFormattedFieldModel( StyleBag
* all_styles
);
195 void readTimeFieldModel( StyleBag
* all_styles
);
196 void readFixedLineModel( StyleBag
* all_styles
);
197 void readProgressBarModel( StyleBag
* all_styles
);
198 void readScrollBarModel( StyleBag
* all_styles
);
199 void readSpinButtonModel( StyleBag
* all_styles
);
200 void readFixedHyperLinkModel( StyleBag
* all_styles
);
201 void readGridControlModel( StyleBag
* all_styles
);
205 inline void ElementDescriptor::read(
206 OUString
const & propName
, OUString
const & attrName
,
207 bool forceAttribute
)
209 if (forceAttribute
||
210 css::beans::PropertyState_DEFAULT_VALUE
!=
211 _xPropState
->getPropertyState( propName
))
213 css::uno::Any
a( _xProps
->getPropertyValue( propName
) );
216 addAttribute( attrName
, OUString::number(v
) );
218 OSL_FAIL( "### unexpected property type!" );
223 inline void ElementDescriptor::read
<sal_Bool
>(
224 OUString
const & propName
, OUString
const & attrName
,
225 bool forceAttribute
)
227 if (forceAttribute
||
228 css::beans::PropertyState_DEFAULT_VALUE
!=
229 _xPropState
->getPropertyState( propName
))
231 css::uno::Any
a( _xProps
->getPropertyValue( propName
) );
234 addAttribute( attrName
, OUString::boolean(v
) );
236 OSL_FAIL( "### unexpected property type!" );
240 inline void ElementDescriptor::readBoolAttr(
241 OUString
const & rPropName
, OUString
const & rAttrName
)
243 read
<sal_Bool
>( rPropName
, rAttrName
);
247 inline bool ElementDescriptor::readProp(
248 T
* ret
, OUString
const & rPropName
)
250 _xProps
->getPropertyValue( rPropName
) >>= *ret
;
251 return css::beans::PropertyState_DEFAULT_VALUE
!=
252 _xPropState
->getPropertyState( rPropName
);
258 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */