1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: exp_share.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
33 #include <xmlscript/xmldlg_imexp.hxx>
34 #include <xmlscript/xml_helper.hxx>
35 #include <osl/diagnose.h>
36 #include <com/sun/star/xml/sax/XAttributeList.hpp>
37 #include <com/sun/star/beans/XPropertySet.hpp>
38 #include <com/sun/star/beans/XPropertyState.hpp>
39 #include <com/sun/star/awt/FontDescriptor.hpp>
40 #include <com/sun/star/awt/FontEmphasisMark.hpp>
41 #include <com/sun/star/awt/FontRelief.hpp>
45 namespace css
= ::com::sun::star
;
52 sal_uInt32 _backgroundColor
;
53 sal_uInt32 _textColor
;
54 sal_uInt32 _textLineColor
;
56 sal_Int32 _borderColor
;
57 css::awt::FontDescriptor _descr
;
58 sal_uInt16 _fontRelief
;
59 sal_uInt16 _fontEmphasisMark
;
60 sal_uInt32 _fillColor
;
61 sal_Int16 _visualEffect
;
63 // current highest mask: 0x40
69 inline Style( short all_
) SAL_THROW( () )
70 : _fontRelief( css::awt::FontRelief::NONE
)
71 , _fontEmphasisMark( css::awt::FontEmphasisMark::NONE
)
76 css::uno::Reference
< css::xml::sax::XAttributeList
> createElement();
80 ::std::vector
< Style
* > _styles
;
83 ~StyleBag() SAL_THROW( () );
85 ::rtl::OUString
getStyleId( Style
const & rStyle
) SAL_THROW( () );
87 void dump( css::uno::Reference
< css::xml::sax::XExtendedDocumentHandler
>
91 class ElementDescriptor
92 : public ::xmlscript::XMLElement
94 css::uno::Reference
< css::beans::XPropertySet
> _xProps
;
95 css::uno::Reference
< css::beans::XPropertyState
> _xPropState
;
98 inline ElementDescriptor(
99 css::uno::Reference
< css::beans::XPropertySet
> const & xProps
,
100 css::uno::Reference
< css::beans::XPropertyState
> const & xPropState
,
101 ::rtl::OUString
const & name
)
105 , _xPropState( xPropState
)
107 inline ElementDescriptor(
108 ::rtl::OUString
const & name
)
115 ::rtl::OUString
const & propName
, ::rtl::OUString
const & attrName
,
116 bool forceAttribute
= false );
120 inline bool readProp( T
* ret
, ::rtl::OUString
const & rPropName
);
121 css::uno::Any
readProp( ::rtl::OUString
const & rPropName
);
123 void readDefaults( bool supportPrintable
= true );
126 ::rtl::OUString
const & rPropName
, ::rtl::OUString
const & rAttrName
);
127 inline void readDoubleAttr(
128 ::rtl::OUString
const & rPropName
, ::rtl::OUString
const & rAttrName
)
129 { read
<double>( rPropName
, rAttrName
); }
130 inline void readLongAttr(
131 ::rtl::OUString
const & rPropName
, ::rtl::OUString
const & rAttrName
,
132 bool forceAttribute
= false )
133 { read
<sal_Int32
>( rPropName
, rAttrName
, forceAttribute
); }
134 void readHexLongAttr(
135 ::rtl::OUString
const & rPropName
, ::rtl::OUString
const & rAttrName
);
136 inline void readShortAttr(
137 ::rtl::OUString
const & rPropName
, ::rtl::OUString
const & rAttrName
)
138 { read
<sal_Int32
>( rPropName
, rAttrName
); }
139 inline void readBoolAttr(
140 ::rtl::OUString
const & rPropName
, ::rtl::OUString
const & rAttrName
)
141 { read
<sal_Bool
>( rPropName
, rAttrName
); }
144 ::rtl::OUString
const & rPropName
, ::rtl::OUString
const & rAttrName
);
145 void readVerticalAlignAttr(
146 ::rtl::OUString
const & rPropName
, ::rtl::OUString
const & rAttrName
);
147 void readImageAlignAttr(
148 ::rtl::OUString
const & rPropName
, ::rtl::OUString
const & rAttrName
);
149 void readImagePositionAttr(
150 ::rtl::OUString
const & rPropName
, ::rtl::OUString
const & rAttrName
);
151 void readDateFormatAttr(
152 ::rtl::OUString
const & rPropName
, ::rtl::OUString
const & rAttrName
);
153 void readTimeFormatAttr(
154 ::rtl::OUString
const & rPropName
, ::rtl::OUString
const & rAttrName
);
155 void readOrientationAttr(
156 ::rtl::OUString
const & rPropName
, ::rtl::OUString
const & rAttrName
);
157 void readButtonTypeAttr(
158 ::rtl::OUString
const & rPropName
, ::rtl::OUString
const & rAttrName
);
159 void readLineEndFormatAttr(
160 ::rtl::OUString
const & rPropName
, ::rtl::OUString
const & rAttrName
);
161 void readSelectionTypeAttr(
162 ::rtl::OUString
const & rPropName
, ::rtl::OUString
const & rAttrName
);
164 inline void addBoolAttr(
165 ::rtl::OUString
const & rAttrName
, sal_Bool bValue
)
166 { addAttribute( rAttrName
, ::rtl::OUString::valueOf(bValue
) ); }
167 void addNumberFormatAttr(
168 css::uno::Reference
< css::beans::XPropertySet
>
169 const & xFormatProperties
,
170 ::rtl::OUString
const & rAttrName
);
173 void readEvents() SAL_THROW( (css::uno::Exception
) );
175 void readDialogModel( StyleBag
* all_styles
)
176 SAL_THROW( (css::uno::Exception
) );
177 void readMultiPageModel( StyleBag
* all_styles
)
178 SAL_THROW( (css::uno::Exception
) );
179 void readButtonModel( StyleBag
* all_styles
)
180 SAL_THROW( (css::uno::Exception
) );
181 void readEditModel( StyleBag
* all_styles
)
182 SAL_THROW( (css::uno::Exception
) );
183 void readCheckBoxModel( StyleBag
* all_styles
)
184 SAL_THROW( (css::uno::Exception
) );
185 void readRadioButtonModel( StyleBag
* all_styles
, com::sun::star::uno::Reference
< com::sun::star::frame::XModel
> const & xDocument
)
186 SAL_THROW( (css::uno::Exception
) );
187 void readComboBoxModel( StyleBag
* all_styles
, com::sun::star::uno::Reference
< com::sun::star::frame::XModel
> const & xDocument
)
188 SAL_THROW( (css::uno::Exception
) );
189 void readCurrencyFieldModel( StyleBag
* all_styles
)
190 SAL_THROW( (css::uno::Exception
) );
191 void readDateFieldModel( StyleBag
* all_styles
)
192 SAL_THROW( (css::uno::Exception
) );
193 void readFileControlModel( StyleBag
* all_styles
)
194 SAL_THROW( (css::uno::Exception
) );
195 void readTreeControlModel( StyleBag
* all_styles
)
196 SAL_THROW( (css::uno::Exception
) );
197 void readFixedTextModel( StyleBag
* all_styles
)
198 SAL_THROW( (css::uno::Exception
) );
199 void readGroupBoxModel( StyleBag
* all_styles
)
200 SAL_THROW( (css::uno::Exception
) );
201 void readImageControlModel( StyleBag
* all_styles
, com::sun::star::uno::Reference
< com::sun::star::frame::XModel
> const & xDocument
)
202 SAL_THROW( (css::uno::Exception
) );
203 void readListBoxModel( StyleBag
* all_styles
, com::sun::star::uno::Reference
< com::sun::star::frame::XModel
> const & xDocument
)
204 SAL_THROW( (css::uno::Exception
) );
205 void readNumericFieldModel( StyleBag
* all_styles
)
206 SAL_THROW( (css::uno::Exception
) );
207 void readPatternFieldModel( StyleBag
* all_styles
)
208 SAL_THROW( (css::uno::Exception
) );
209 void readFormattedFieldModel( StyleBag
* all_styles
)
210 SAL_THROW( (css::uno::Exception
) );
211 void readTimeFieldModel( StyleBag
* all_styles
)
212 SAL_THROW( (css::uno::Exception
) );
213 void readFixedLineModel( StyleBag
* all_styles
)
214 SAL_THROW( (css::uno::Exception
) );
215 void readProgressBarModel( StyleBag
* all_styles
)
216 SAL_THROW( (css::uno::Exception
) );
217 void readScrollBarModel( StyleBag
* all_styles
, com::sun::star::uno::Reference
< com::sun::star::frame::XModel
> const & xDocument
)
218 SAL_THROW( (css::uno::Exception
) );
219 void readSpinButtonModel( StyleBag
* all_styles
, com::sun::star::uno::Reference
< com::sun::star::frame::XModel
> const & xDocument
)
220 SAL_THROW( (css::uno::Exception
) );
221 void readFixedHyperLinkModel( StyleBag
* all_styles
)
222 SAL_THROW( (css::uno::Exception
) );
226 inline void ElementDescriptor::read(
227 ::rtl::OUString
const & propName
, ::rtl::OUString
const & attrName
,
228 bool forceAttribute
)
230 if (forceAttribute
||
231 css::beans::PropertyState_DEFAULT_VALUE
!=
232 _xPropState
->getPropertyState( propName
))
234 css::uno::Any
a( _xProps
->getPropertyValue( propName
) );
237 addAttribute( attrName
, ::rtl::OUString::valueOf(v
) );
239 OSL_ENSURE( 0, "### unexpected property type!" );
244 inline bool ElementDescriptor::readProp(
245 T
* ret
, ::rtl::OUString
const & rPropName
)
247 _xProps
->getPropertyValue( rPropName
) >>= *ret
;
248 return css::beans::PropertyState_DEFAULT_VALUE
!=
249 _xPropState
->getPropertyState( rPropName
);