1*b1cdbd2cSJim Jagielski /************************************************************** 2*b1cdbd2cSJim Jagielski * 3*b1cdbd2cSJim Jagielski * Licensed to the Apache Software Foundation (ASF) under one 4*b1cdbd2cSJim Jagielski * or more contributor license agreements. See the NOTICE file 5*b1cdbd2cSJim Jagielski * distributed with this work for additional information 6*b1cdbd2cSJim Jagielski * regarding copyright ownership. The ASF licenses this file 7*b1cdbd2cSJim Jagielski * to you under the Apache License, Version 2.0 (the 8*b1cdbd2cSJim Jagielski * "License"); you may not use this file except in compliance 9*b1cdbd2cSJim Jagielski * with the License. You may obtain a copy of the License at 10*b1cdbd2cSJim Jagielski * 11*b1cdbd2cSJim Jagielski * http://www.apache.org/licenses/LICENSE-2.0 12*b1cdbd2cSJim Jagielski * 13*b1cdbd2cSJim Jagielski * Unless required by applicable law or agreed to in writing, 14*b1cdbd2cSJim Jagielski * software distributed under the License is distributed on an 15*b1cdbd2cSJim Jagielski * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*b1cdbd2cSJim Jagielski * KIND, either express or implied. See the License for the 17*b1cdbd2cSJim Jagielski * specific language governing permissions and limitations 18*b1cdbd2cSJim Jagielski * under the License. 19*b1cdbd2cSJim Jagielski * 20*b1cdbd2cSJim Jagielski *************************************************************/ 21*b1cdbd2cSJim Jagielski 22*b1cdbd2cSJim Jagielski 23*b1cdbd2cSJim Jagielski 24*b1cdbd2cSJim Jagielski #ifndef _XMLOFF_FORMS_PROPERTYEXPORT_HXX_ 25*b1cdbd2cSJim Jagielski #define _XMLOFF_FORMS_PROPERTYEXPORT_HXX_ 26*b1cdbd2cSJim Jagielski 27*b1cdbd2cSJim Jagielski #include "formattributes.hxx" 28*b1cdbd2cSJim Jagielski #include <comphelper/stl_types.hxx> 29*b1cdbd2cSJim Jagielski #include <com/sun/star/beans/XPropertySet.hpp> 30*b1cdbd2cSJim Jagielski #include <com/sun/star/beans/XPropertyState.hpp> 31*b1cdbd2cSJim Jagielski #include <callbacks.hxx> 32*b1cdbd2cSJim Jagielski #include <xmloff/xmlexp.hxx> 33*b1cdbd2cSJim Jagielski #include "callbacks.hxx" 34*b1cdbd2cSJim Jagielski #include "strings.hxx" 35*b1cdbd2cSJim Jagielski 36*b1cdbd2cSJim Jagielski //......................................................................... 37*b1cdbd2cSJim Jagielski namespace xmloff 38*b1cdbd2cSJim Jagielski { 39*b1cdbd2cSJim Jagielski //......................................................................... 40*b1cdbd2cSJim Jagielski 41*b1cdbd2cSJim Jagielski #define BOOLATTR_DEFAULT_FALSE 0x00 42*b1cdbd2cSJim Jagielski #define BOOLATTR_DEFAULT_TRUE 0x01 43*b1cdbd2cSJim Jagielski #define BOOLATTR_DEFAULT_VOID 0x02 44*b1cdbd2cSJim Jagielski #define BOOLATTR_DEFAULT_MASK 0x03 45*b1cdbd2cSJim Jagielski 46*b1cdbd2cSJim Jagielski #define BOOLATTR_INVERSE_SEMANTICS 0x04 47*b1cdbd2cSJim Jagielski // if sal_True, indicates that the semantic of the property refered by <arg>_pPropertyName</arg> 48*b1cdbd2cSJim Jagielski // is inverse to the semantic of the XML attribute.<br/> 49*b1cdbd2cSJim Jagielski // I.e. if the property value is <TRUE/>, <FALSE/> has to be written and vice versa. 50*b1cdbd2cSJim Jagielski // <p>Be careful with <arg>_bDefault</arg> and <arg>_bInverseSemantics</arg>: if <arg>_bInverseSemantics</arg> 51*b1cdbd2cSJim Jagielski // is <TRUE/>, the current property value is inverted <em>before</em> comparing it to the default.</p> 52*b1cdbd2cSJim Jagielski 53*b1cdbd2cSJim Jagielski class IFormsExportContext; 54*b1cdbd2cSJim Jagielski //===================================================================== 55*b1cdbd2cSJim Jagielski //= OPropertyExport 56*b1cdbd2cSJim Jagielski //===================================================================== 57*b1cdbd2cSJim Jagielski /** provides export related tools for attribute handling 58*b1cdbd2cSJim Jagielski 59*b1cdbd2cSJim Jagielski <p>(The name is somewhat misleading. It's not only a PropertyExport, but in real a ElementExport. 60*b1cdbd2cSJim Jagielski Anyway.)</p> 61*b1cdbd2cSJim Jagielski */ 62*b1cdbd2cSJim Jagielski class OPropertyExport 63*b1cdbd2cSJim Jagielski { 64*b1cdbd2cSJim Jagielski private: 65*b1cdbd2cSJim Jagielski DECLARE_STL_STDKEY_SET(::rtl::OUString, StringSet); 66*b1cdbd2cSJim Jagielski StringSet m_aRemainingProps; 67*b1cdbd2cSJim Jagielski // see examinePersistence 68*b1cdbd2cSJim Jagielski 69*b1cdbd2cSJim Jagielski void exportRelativeTargetLocation(const ConstAsciiString& _sPropertyName,sal_Int32 _nProperty,bool _bAddType); 70*b1cdbd2cSJim Jagielski 71*b1cdbd2cSJim Jagielski protected: 72*b1cdbd2cSJim Jagielski IFormsExportContext& m_rContext; 73*b1cdbd2cSJim Jagielski 74*b1cdbd2cSJim Jagielski const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > 75*b1cdbd2cSJim Jagielski m_xProps; 76*b1cdbd2cSJim Jagielski const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > 77*b1cdbd2cSJim Jagielski m_xPropertyInfo; 78*b1cdbd2cSJim Jagielski const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyState > 79*b1cdbd2cSJim Jagielski m_xPropertyState; 80*b1cdbd2cSJim Jagielski 81*b1cdbd2cSJim Jagielski // caching 82*b1cdbd2cSJim Jagielski ::rtl::OUString m_sValueTrue; 83*b1cdbd2cSJim Jagielski ::rtl::OUString m_sValueFalse; 84*b1cdbd2cSJim Jagielski 85*b1cdbd2cSJim Jagielski public: 86*b1cdbd2cSJim Jagielski /** constructs an object capable of handling attributes for export 87*b1cdbd2cSJim Jagielski @param _rContext 88*b1cdbd2cSJim Jagielski the export context to which's attribute list the property translation should be added 89*b1cdbd2cSJim Jagielski @param m_xControl 90*b1cdbd2cSJim Jagielski the property set to be exported 91*b1cdbd2cSJim Jagielski */ 92*b1cdbd2cSJim Jagielski OPropertyExport(IFormsExportContext& _rContext, 93*b1cdbd2cSJim Jagielski const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxProps); 94*b1cdbd2cSJim Jagielski 95*b1cdbd2cSJim Jagielski protected: 96*b1cdbd2cSJim Jagielski /** examines a property set given for all properties which's value are to made persistent 97*b1cdbd2cSJim Jagielski 98*b1cdbd2cSJim Jagielski <p>upon return the <method>m_aRemainingProps</method> will be filled with the names of all properties 99*b1cdbd2cSJim Jagielski which need to be stored</p> 100*b1cdbd2cSJim Jagielski */ 101*b1cdbd2cSJim Jagielski void examinePersistence(); 102*b1cdbd2cSJim Jagielski 103*b1cdbd2cSJim Jagielski /** 104*b1cdbd2cSJim Jagielski */ 105*b1cdbd2cSJim Jagielski void exportRemainingProperties(); 106*b1cdbd2cSJim Jagielski 107*b1cdbd2cSJim Jagielski /** indicates that a property has been handled by a derived class, without using the helper methods of this 108*b1cdbd2cSJim Jagielski class. 109*b1cdbd2cSJim Jagielski 110*b1cdbd2cSJim Jagielski <p>Calling this method is necessary in case you use the suggested mechanism for the generic export of 111*b1cdbd2cSJim Jagielski properties. This means that you want to use <method>exportRemainingProperties</method>, which exports 112*b1cdbd2cSJim Jagielski all properties which need to ('cause they haven't been exported with one of the other type-specific 113*b1cdbd2cSJim Jagielski methods).</p> 114*b1cdbd2cSJim Jagielski 115*b1cdbd2cSJim Jagielski <p>In this case you should call exportedProperty for every property you export yourself, so the property 116*b1cdbd2cSJim Jagielski will be flagged as <em>already handled</em></p> 117*b1cdbd2cSJim Jagielski */ exportedProperty(const::rtl::OUString & _rPropertyName)118*b1cdbd2cSJim Jagielski void exportedProperty(const ::rtl::OUString& _rPropertyName) 119*b1cdbd2cSJim Jagielski { m_aRemainingProps.erase(_rPropertyName); } 120*b1cdbd2cSJim Jagielski 121*b1cdbd2cSJim Jagielski /** add an attribute which is represented by a string property to the export context 122*b1cdbd2cSJim Jagielski 123*b1cdbd2cSJim Jagielski @param _nNamespaceKey 124*b1cdbd2cSJim Jagielski the key of the namespace to use for the attribute name. Is used with the namespace map 125*b1cdbd2cSJim Jagielski provided by the export context. 126*b1cdbd2cSJim Jagielski @param _pAttributeName 127*b1cdbd2cSJim Jagielski the name of the attribute to add. Must not contain any namespace 128*b1cdbd2cSJim Jagielski @param _pPropertyName 129*b1cdbd2cSJim Jagielski the name of the property to ask the control for 130*b1cdbd2cSJim Jagielski */ 131*b1cdbd2cSJim Jagielski void exportStringPropertyAttribute( 132*b1cdbd2cSJim Jagielski const sal_uInt16 _nNamespaceKey, 133*b1cdbd2cSJim Jagielski const sal_Char* _pAttributeName, 134*b1cdbd2cSJim Jagielski const ::rtl::OUString& _rPropertyName 135*b1cdbd2cSJim Jagielski ); 136*b1cdbd2cSJim Jagielski 137*b1cdbd2cSJim Jagielski /** add an attribute which is represented by a boolean property to the export context 138*b1cdbd2cSJim Jagielski 139*b1cdbd2cSJim Jagielski @param _nNamespaceKey 140*b1cdbd2cSJim Jagielski the key of the namespace to use for the attribute name. Is used with the namespace map 141*b1cdbd2cSJim Jagielski provided by the export context. 142*b1cdbd2cSJim Jagielski @param _pAttributeName 143*b1cdbd2cSJim Jagielski the name of the attribute to add. Must not contain any namespace (it's added automatically) 144*b1cdbd2cSJim Jagielski @param _pPropertyName 145*b1cdbd2cSJim Jagielski the name of the property to ask the control for 146*b1cdbd2cSJim Jagielski @param _nBooleanAttributeFlags 147*b1cdbd2cSJim Jagielski specifies the default and the "alignment" (inverse semantics) of the boolean property 148*b1cdbd2cSJim Jagielski */ 149*b1cdbd2cSJim Jagielski void exportBooleanPropertyAttribute( 150*b1cdbd2cSJim Jagielski const sal_uInt16 _nNamespaceKey, 151*b1cdbd2cSJim Jagielski const sal_Char* _pAttributeName, 152*b1cdbd2cSJim Jagielski const ::rtl::OUString& _rPropertyName, 153*b1cdbd2cSJim Jagielski const sal_Int8 _nBooleanAttributeFlags); 154*b1cdbd2cSJim Jagielski 155*b1cdbd2cSJim Jagielski /** add an attribute which is represented by a sal_Int16 property to the export context 156*b1cdbd2cSJim Jagielski 157*b1cdbd2cSJim Jagielski @param _nNamespaceKey 158*b1cdbd2cSJim Jagielski the key of the namespace to use for the attribute name. Is used with the namespace map 159*b1cdbd2cSJim Jagielski provided by the export context. 160*b1cdbd2cSJim Jagielski @param _pAttributeName 161*b1cdbd2cSJim Jagielski the name of the attribute to add. Must not contain any namespace (it's added automatically) 162*b1cdbd2cSJim Jagielski @param _pPropertyName 163*b1cdbd2cSJim Jagielski the name of the property to ask the control for 164*b1cdbd2cSJim Jagielski @param _nDefault 165*b1cdbd2cSJim Jagielski the default of the attribute. If the current property value equals this default, no 166*b1cdbd2cSJim Jagielski attribute is added. 167*b1cdbd2cSJim Jagielski */ 168*b1cdbd2cSJim Jagielski void exportInt16PropertyAttribute( 169*b1cdbd2cSJim Jagielski const sal_uInt16 _nNamespaceKey, 170*b1cdbd2cSJim Jagielski const sal_Char* _pAttributeName, 171*b1cdbd2cSJim Jagielski const ::rtl::OUString& _rPropertyName, 172*b1cdbd2cSJim Jagielski const sal_Int16 _nDefault); 173*b1cdbd2cSJim Jagielski 174*b1cdbd2cSJim Jagielski /** add an attribute which is represented by a sal_Int32 property to the export context 175*b1cdbd2cSJim Jagielski 176*b1cdbd2cSJim Jagielski @param _nNamespaceKey 177*b1cdbd2cSJim Jagielski the key of the namespace to use for the attribute name. Is used with the namespace map 178*b1cdbd2cSJim Jagielski provided by the export context. 179*b1cdbd2cSJim Jagielski @param _pAttributeName 180*b1cdbd2cSJim Jagielski the name of the attribute to add. Must not contain any namespace (it's added automatically) 181*b1cdbd2cSJim Jagielski @param _pPropertyName 182*b1cdbd2cSJim Jagielski the name of the property to ask the control for 183*b1cdbd2cSJim Jagielski @param _nDefault 184*b1cdbd2cSJim Jagielski the default of the attribute. If the current property value equals this default, no 185*b1cdbd2cSJim Jagielski attribute is added. 186*b1cdbd2cSJim Jagielski */ 187*b1cdbd2cSJim Jagielski void exportInt32PropertyAttribute( 188*b1cdbd2cSJim Jagielski const sal_uInt16 _nNamespaceKey, 189*b1cdbd2cSJim Jagielski const sal_Char* _pAttributeName, 190*b1cdbd2cSJim Jagielski const ::rtl::OUString& _rPropertyName, 191*b1cdbd2cSJim Jagielski const sal_Int32 _nDefault); 192*b1cdbd2cSJim Jagielski 193*b1cdbd2cSJim Jagielski /** add an attribute which is represented by a enum property to the export context 194*b1cdbd2cSJim Jagielski 195*b1cdbd2cSJim Jagielski @param _nNamespaceKey 196*b1cdbd2cSJim Jagielski the key of the namespace to use for the attribute name. Is used with the namespace map 197*b1cdbd2cSJim Jagielski provided by the export context. 198*b1cdbd2cSJim Jagielski @param _pAttributeName 199*b1cdbd2cSJim Jagielski the name of the attribute to add. Must not contain any namespace (it's added automatically) 200*b1cdbd2cSJim Jagielski @param _pPropertyName 201*b1cdbd2cSJim Jagielski the name of the property to ask the control for 202*b1cdbd2cSJim Jagielski @param _pValueMap 203*b1cdbd2cSJim Jagielski the map to use when converting the property value to an attribute value 204*b1cdbd2cSJim Jagielski @param _nDefault 205*b1cdbd2cSJim Jagielski the default of the attribute. If the current property value equals this default, no 206*b1cdbd2cSJim Jagielski attribute is added. 207*b1cdbd2cSJim Jagielski */ 208*b1cdbd2cSJim Jagielski void exportEnumPropertyAttribute( 209*b1cdbd2cSJim Jagielski const sal_uInt16 _nNamespaceKey, 210*b1cdbd2cSJim Jagielski const sal_Char* _pAttributeName, 211*b1cdbd2cSJim Jagielski const sal_Char* _pPropertyName, 212*b1cdbd2cSJim Jagielski const SvXMLEnumMapEntry* _pValueMap, 213*b1cdbd2cSJim Jagielski const sal_Int32 _nDefault, 214*b1cdbd2cSJim Jagielski const sal_Bool _bVoidDefault = sal_False); 215*b1cdbd2cSJim Jagielski 216*b1cdbd2cSJim Jagielski // some very special methods for some very special attribute/property pairs 217*b1cdbd2cSJim Jagielski 218*b1cdbd2cSJim Jagielski /** add the hlink:target-frame attribute to the export context. 219*b1cdbd2cSJim Jagielski 220*b1cdbd2cSJim Jagielski <p>The value of this attribute is extracted from the TargetFrame property of the object given.</p> 221*b1cdbd2cSJim Jagielski 222*b1cdbd2cSJim Jagielski <p>The property needs a special handling because conflicts between the default values for the attribute 223*b1cdbd2cSJim Jagielski and the property.</p> 224*b1cdbd2cSJim Jagielski */ 225*b1cdbd2cSJim Jagielski void exportTargetFrameAttribute(); 226*b1cdbd2cSJim Jagielski 227*b1cdbd2cSJim Jagielski /** add the form:href attribute to the export context. 228*b1cdbd2cSJim Jagielski 229*b1cdbd2cSJim Jagielski <p>The value of this attribute is extracted from the TargetURL property of the object given.</p> 230*b1cdbd2cSJim Jagielski 231*b1cdbd2cSJim Jagielski <p>The property needs a special handling because the URL's need to be made relative</p> 232*b1cdbd2cSJim Jagielski 233*b1cdbd2cSJim Jagielski <p>If _bAddType is set, an additional xlink:type="simple" attribute is also added.</p> 234*b1cdbd2cSJim Jagielski */ exportTargetLocationAttribute(bool _bAddType)235*b1cdbd2cSJim Jagielski inline void exportTargetLocationAttribute(bool _bAddType) { exportRelativeTargetLocation(PROPERTY_TARGETURL,CCA_TARGET_LOCATION,_bAddType); } 236*b1cdbd2cSJim Jagielski 237*b1cdbd2cSJim Jagielski /** add the form:image attribute to the export context. 238*b1cdbd2cSJim Jagielski 239*b1cdbd2cSJim Jagielski <p>The value of this attribute is extracted from the ImageURL property of the object given.</p> 240*b1cdbd2cSJim Jagielski 241*b1cdbd2cSJim Jagielski <p>The property needs a special handling because the URL's need to be made relative</p> 242*b1cdbd2cSJim Jagielski */ exportImageDataAttribute()243*b1cdbd2cSJim Jagielski inline void exportImageDataAttribute() { exportRelativeTargetLocation(PROPERTY_IMAGEURL,CCA_IMAGE_DATA,false); } 244*b1cdbd2cSJim Jagielski 245*b1cdbd2cSJim Jagielski /** flag the style properties as 'already exported' 246*b1cdbd2cSJim Jagielski 247*b1cdbd2cSJim Jagielski <p>We don't have style support right now, so the only thing the method does is removing the style-relevant 248*b1cdbd2cSJim Jagielski properties from the list of yet-to-be-exported properties (<member>m_aRemainingProps</member>)</p> 249*b1cdbd2cSJim Jagielski */ 250*b1cdbd2cSJim Jagielski void flagStyleProperties(); 251*b1cdbd2cSJim Jagielski 252*b1cdbd2cSJim Jagielski /** add an arbitrary attribute extracted from an arbitrary property to the export context 253*b1cdbd2cSJim Jagielski 254*b1cdbd2cSJim Jagielski <p>The current value of the property specified wiht <arg>_pPropertyName</arg> is taken and converted 255*b1cdbd2cSJim Jagielski into a string, no matter what type it has. (Okay, there are the usual limitations: We know Date, Datetime, 256*b1cdbd2cSJim Jagielski double, integer ... to name just a few).</p> 257*b1cdbd2cSJim Jagielski 258*b1cdbd2cSJim Jagielski <p>In case the property value is <NULL/> (void), no attribute is added</p> 259*b1cdbd2cSJim Jagielski 260*b1cdbd2cSJim Jagielski <p>In case the property value is an empty string, and the property is a not allowed to be <NULL/> (void), 261*b1cdbd2cSJim Jagielski no attribute is added</p> 262*b1cdbd2cSJim Jagielski 263*b1cdbd2cSJim Jagielski <p>In case the property value is a sequence of any type, no attribute is added, 'cause sequences can't be 264*b1cdbd2cSJim Jagielski transported as attribute. In the debug version, an additional assertion will occur if you nonetheless try 265*b1cdbd2cSJim Jagielski to do this.</p> 266*b1cdbd2cSJim Jagielski 267*b1cdbd2cSJim Jagielski @param _nNamespaceKey 268*b1cdbd2cSJim Jagielski the key of the namespace to use for the attribute name. Is used with the namespace map 269*b1cdbd2cSJim Jagielski provided by the export context. 270*b1cdbd2cSJim Jagielski @param _pAttributeName 271*b1cdbd2cSJim Jagielski the name of the attribute to add. Must not contain any namespace (it's added automatically) 272*b1cdbd2cSJim Jagielski @param _pPropertyName 273*b1cdbd2cSJim Jagielski the name of the property to ask the object for 274*b1cdbd2cSJim Jagielski */ 275*b1cdbd2cSJim Jagielski void exportGenericPropertyAttribute( 276*b1cdbd2cSJim Jagielski const sal_uInt16 _nAttributeNamespaceKey, 277*b1cdbd2cSJim Jagielski const sal_Char* _pAttributeName, 278*b1cdbd2cSJim Jagielski const sal_Char* _pPropertyName); 279*b1cdbd2cSJim Jagielski 280*b1cdbd2cSJim Jagielski /** exports a property value, which is a string sequence, as attribute 281*b1cdbd2cSJim Jagielski 282*b1cdbd2cSJim Jagielski <p>The elements of the string sequence given are quoted and concatenated, with the characters used for 283*b1cdbd2cSJim Jagielski this to be choosen by the caller</p> 284*b1cdbd2cSJim Jagielski 285*b1cdbd2cSJim Jagielski <p>If you use the quote character, no check (except assertions) is made if one of the list items 286*b1cdbd2cSJim Jagielski containes the quote character</p> 287*b1cdbd2cSJim Jagielski 288*b1cdbd2cSJim Jagielski <p>If you don't use the quote character, no check (except assertions) is made if one of the list items 289*b1cdbd2cSJim Jagielski containes the separator character (which would be deadly when reimporting the string)</p> 290*b1cdbd2cSJim Jagielski 291*b1cdbd2cSJim Jagielski @param _nNamespaceKey 292*b1cdbd2cSJim Jagielski the key of the namespace to use for the attribute name. Is used with the namespace map 293*b1cdbd2cSJim Jagielski provided by the export context. 294*b1cdbd2cSJim Jagielski @param _pAttributeName 295*b1cdbd2cSJim Jagielski the name of the attribute to add. Must not contain any namespace (it's added automatically) 296*b1cdbd2cSJim Jagielski @param _pPropertyName 297*b1cdbd2cSJim Jagielski the name of the property to ask the object for 298*b1cdbd2cSJim Jagielski @param _aQuoteCharacter 299*b1cdbd2cSJim Jagielski the character to use to quote the sequence elements with. May be 0, in this case no quoting happens 300*b1cdbd2cSJim Jagielski @param _aListSeparator 301*b1cdbd2cSJim Jagielski the character to use to separate the list entries 302*b1cdbd2cSJim Jagielski */ 303*b1cdbd2cSJim Jagielski void exportStringSequenceAttribute( 304*b1cdbd2cSJim Jagielski const sal_uInt16 _nAttributeNamespaceKey, 305*b1cdbd2cSJim Jagielski const sal_Char* _pAttributeName, 306*b1cdbd2cSJim Jagielski const ::rtl::OUString& _rPropertyName, 307*b1cdbd2cSJim Jagielski const sal_Unicode _aQuoteCharacter = '"', 308*b1cdbd2cSJim Jagielski const sal_Unicode _aListSeparator = ','); 309*b1cdbd2cSJim Jagielski 310*b1cdbd2cSJim Jagielski /** determines whether the given property is to be exported 311*b1cdbd2cSJim Jagielski 312*b1cdbd2cSJim Jagielski <p>Currently, the method simply checks whether the property's state is <em>not</em> PropertyState.DEFAULT, 313*b1cdbd2cSJim Jagielski or whether the property is a dynamic property (i.e. added via an <code>XPropertyContainer</code>). 314*b1cdbd2cSJim Jagielski So, take care when using the method - the heuristics is not applicable for all properties.</p> 315*b1cdbd2cSJim Jagielski */ 316*b1cdbd2cSJim Jagielski bool shouldExportProperty( const ::rtl::OUString& i_propertyName ) const; 317*b1cdbd2cSJim Jagielski 318*b1cdbd2cSJim Jagielski /** tries to convert an arbitrary <type scope="com.sun:star.uno">Any</type> into an string 319*b1cdbd2cSJim Jagielski 320*b1cdbd2cSJim Jagielski <p>If the type contained in the Any is not supported, the returned string will be empty. In the 321*b1cdbd2cSJim Jagielski debug version, an additional assertion occurs.</p> 322*b1cdbd2cSJim Jagielski 323*b1cdbd2cSJim Jagielski @param _rValue 324*b1cdbd2cSJim Jagielski the value to convert 325*b1cdbd2cSJim Jagielski */ 326*b1cdbd2cSJim Jagielski ::rtl::OUString implConvertAny( 327*b1cdbd2cSJim Jagielski const ::com::sun::star::uno::Any& _rValue); 328*b1cdbd2cSJim Jagielski 329*b1cdbd2cSJim Jagielski /** 330*b1cdbd2cSJim Jagielski @return 331*b1cdbd2cSJim Jagielski token which can be used in the <code>form:property</code> element's <code>type</code> attribute 332*b1cdbd2cSJim Jagielski to describe the type of a value.<br/> 333*b1cdbd2cSJim Jagielski Possible types returned are 334*b1cdbd2cSJim Jagielski <ul> 335*b1cdbd2cSJim Jagielski <li><b>boolean</b>: <arg>_rValue</arg> was interpreted as boolean value before converting 336*b1cdbd2cSJim Jagielski it into a string</li> 337*b1cdbd2cSJim Jagielski <li><b>float</b>: <arg>_rValue</arg> was interpreted as 64 bit floating point 16bit integer, 32bit integer or 64 bit integer value before 338*b1cdbd2cSJim Jagielski converting it into a string</li> 339*b1cdbd2cSJim Jagielski <li><b>string</b>: <arg>_rValue</arg> did not need any conversion as it already was a string</li> 340*b1cdbd2cSJim Jagielski </ul> 341*b1cdbd2cSJim Jagielski If the type is not convertable, float is returned 342*b1cdbd2cSJim Jagielski */ 343*b1cdbd2cSJim Jagielski ::xmloff::token::XMLTokenEnum implGetPropertyXMLType(const ::com::sun::star::uno::Type& _rType); 344*b1cdbd2cSJim Jagielski 345*b1cdbd2cSJim Jagielski #ifdef DBG_UTIL 346*b1cdbd2cSJim Jagielski void AddAttribute(sal_uInt16 _nPrefix, const sal_Char* _pName, const ::rtl::OUString& _rValue); 347*b1cdbd2cSJim Jagielski void AddAttribute( sal_uInt16 _nPrefix, const ::rtl::OUString& _rName, const ::rtl::OUString& _rValue ); 348*b1cdbd2cSJim Jagielski void AddAttributeASCII( sal_uInt16 nPrefix, const sal_Char *pName, const sal_Char *pValue ); 349*b1cdbd2cSJim Jagielski void AddAttribute(sal_uInt16 _nPrefix, ::xmloff::token::XMLTokenEnum _eName, const ::rtl::OUString& _rValue); 350*b1cdbd2cSJim Jagielski void AddAttribute(sal_uInt16 _nPrefix, ::xmloff::token::XMLTokenEnum _eName, ::xmloff::token::XMLTokenEnum _eValue ); 351*b1cdbd2cSJim Jagielski #else 352*b1cdbd2cSJim Jagielski // in the product version, inline this, so it does not cost us extra time calling into our method AddAttribute(sal_uInt16 _nPrefix,const sal_Char * _pName,const::rtl::OUString & _rValue)353*b1cdbd2cSJim Jagielski inline void AddAttribute(sal_uInt16 _nPrefix, const sal_Char* _pName, const ::rtl::OUString& _rValue) 354*b1cdbd2cSJim Jagielski { m_rContext.getGlobalContext().AddAttribute(_nPrefix, _pName, _rValue); } AddAttribute(sal_uInt16 _nPrefix,const::rtl::OUString & _rName,const::rtl::OUString & _rValue)355*b1cdbd2cSJim Jagielski inline void AddAttribute( sal_uInt16 _nPrefix, const ::rtl::OUString& _rName, const ::rtl::OUString& _rValue ) 356*b1cdbd2cSJim Jagielski { m_rContext.getGlobalContext().AddAttribute( _nPrefix, _rName, _rValue ); } AddAttributeASCII(sal_uInt16 _nPrefix,const sal_Char * _pName,const sal_Char * pValue)357*b1cdbd2cSJim Jagielski inline void AddAttributeASCII( sal_uInt16 _nPrefix, const sal_Char* _pName, const sal_Char *pValue ) 358*b1cdbd2cSJim Jagielski { m_rContext.getGlobalContext().AddAttributeASCII(_nPrefix, _pName, pValue); } AddAttribute(sal_uInt16 _nPrefix,::xmloff::token::XMLTokenEnum _eName,const::rtl::OUString & _rValue)359*b1cdbd2cSJim Jagielski inline void AddAttribute(sal_uInt16 _nPrefix, ::xmloff::token::XMLTokenEnum _eName, const ::rtl::OUString& _rValue) 360*b1cdbd2cSJim Jagielski { m_rContext.getGlobalContext().AddAttribute(_nPrefix, _eName, _rValue); } AddAttribute(sal_uInt16 _nPrefix,::xmloff::token::XMLTokenEnum _eName,::xmloff::token::XMLTokenEnum _eValue)361*b1cdbd2cSJim Jagielski inline void AddAttribute(sal_uInt16 _nPrefix, ::xmloff::token::XMLTokenEnum _eName, ::xmloff::token::XMLTokenEnum _eValue ) 362*b1cdbd2cSJim Jagielski { m_rContext.getGlobalContext().AddAttribute(_nPrefix, _eName, _eValue); } 363*b1cdbd2cSJim Jagielski #endif 364*b1cdbd2cSJim Jagielski 365*b1cdbd2cSJim Jagielski #ifdef DBG_UTIL 366*b1cdbd2cSJim Jagielski protected: 367*b1cdbd2cSJim Jagielski /** check a given property set for the existence and type correctness of a given property 368*b1cdbd2cSJim Jagielski 369*b1cdbd2cSJim Jagielski <p>This method is available in the non-product version only.</p> 370*b1cdbd2cSJim Jagielski 371*b1cdbd2cSJim Jagielski @param _rPropertyName 372*b1cdbd2cSJim Jagielski the name of the property to ask the control model for 373*b1cdbd2cSJim Jagielski @param _pType 374*b1cdbd2cSJim Jagielski the expected type of the property. May be NULL, in this case no type check is made. 375*b1cdbd2cSJim Jagielski @return sal_True, if the property exists and is of the correct type 376*b1cdbd2cSJim Jagielski */ 377*b1cdbd2cSJim Jagielski void dbg_implCheckProperty( 378*b1cdbd2cSJim Jagielski const ::rtl::OUString& _rPropertyName, 379*b1cdbd2cSJim Jagielski const ::com::sun::star::uno::Type* _pType); 380*b1cdbd2cSJim Jagielski 381*b1cdbd2cSJim Jagielski // void dbg_implCheckProperty( 382*b1cdbd2cSJim Jagielski // const sal_Char* _rPropertyName, 383*b1cdbd2cSJim Jagielski // const ::com::sun::star::uno::Type* _pType) 384*b1cdbd2cSJim Jagielski // { 385*b1cdbd2cSJim Jagielski // dbg_implCheckProperty(::rtl::OUString::createFromAscii(_rPropertyName), _pType); 386*b1cdbd2cSJim Jagielski // } 387*b1cdbd2cSJim Jagielski #endif 388*b1cdbd2cSJim Jagielski }; 389*b1cdbd2cSJim Jagielski 390*b1cdbd2cSJim Jagielski //===================================================================== 391*b1cdbd2cSJim Jagielski //= helper 392*b1cdbd2cSJim Jagielski //===================================================================== 393*b1cdbd2cSJim Jagielski #ifdef DBG_UTIL 394*b1cdbd2cSJim Jagielski #define DBG_CHECK_PROPERTY(name, type) \ 395*b1cdbd2cSJim Jagielski dbg_implCheckProperty(name, &::getCppuType(static_cast< type* >(NULL))) 396*b1cdbd2cSJim Jagielski 397*b1cdbd2cSJim Jagielski #define DBG_CHECK_PROPERTY_NO_TYPE(name) \ 398*b1cdbd2cSJim Jagielski dbg_implCheckProperty(name, NULL) 399*b1cdbd2cSJim Jagielski 400*b1cdbd2cSJim Jagielski #define DBG_CHECK_PROPERTY_ASCII( name, type ) \ 401*b1cdbd2cSJim Jagielski dbg_implCheckProperty( ::rtl::OUString::createFromAscii( name ), &::getCppuType(static_cast< type* >(NULL))) 402*b1cdbd2cSJim Jagielski 403*b1cdbd2cSJim Jagielski #define DBG_CHECK_PROPERTY_ASCII_NO_TYPE( name ) \ 404*b1cdbd2cSJim Jagielski dbg_implCheckProperty( ::rtl::OUString::createFromAscii( name ), NULL ) 405*b1cdbd2cSJim Jagielski #else 406*b1cdbd2cSJim Jagielski #define DBG_CHECK_PROPERTY(name, type) 407*b1cdbd2cSJim Jagielski #define DBG_CHECK_PROPERTY_NO_TYPE(name) 408*b1cdbd2cSJim Jagielski #define DBG_CHECK_PROPERTY_ASCII_NO_TYPE( name ) 409*b1cdbd2cSJim Jagielski #endif 410*b1cdbd2cSJim Jagielski 411*b1cdbd2cSJim Jagielski //......................................................................... 412*b1cdbd2cSJim Jagielski } // namespace xmloff 413*b1cdbd2cSJim Jagielski //......................................................................... 414*b1cdbd2cSJim Jagielski 415*b1cdbd2cSJim Jagielski #endif // _XMLOFF_FORMS_PROPERTYEXPORT_HXX_ 416*b1cdbd2cSJim Jagielski 417*b1cdbd2cSJim Jagielski 418