Files
libreoffice/xmloff/source/forms/layerexport.hxx

319 lines
14 KiB
C++
Raw Normal View History

2010-10-27 13:11:31 +01:00
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* This file is part of OpenOffice.org.
*
* OpenOffice.org is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 3
* only, as published by the Free Software Foundation.
*
* OpenOffice.org is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License version 3 for more details
* (a copy is included in the LICENSE file that accompanied this code).
*
* You should have received a copy of the GNU Lesser General Public License
* version 3 along with OpenOffice.org. If not, see
* <http://www.openoffice.org/license.html>
* for a copy of the LGPLv3 License.
*
************************************************************************/
#ifndef _XMLOFF_FORMS_LAYEREXPORT_HXX_
#define _XMLOFF_FORMS_LAYEREXPORT_HXX_
#include <com/sun/star/container/XIndexAccess.hpp>
2001-01-02 14:58:22 +00:00
#include <com/sun/star/script/ScriptEventDescriptor.hpp>
#include <com/sun/star/util/XNumberFormats.hpp>
#include <com/sun/star/awt/XControlModel.hpp>
#include "callbacks.hxx"
#include "ifacecompare.hxx"
2010-10-15 12:10:06 -05:00
#include <rtl/ref.hxx>
class SvXMLExport;
class SvXMLNumFmtExport;
class XMLPropertyHandlerFactory;
class SvXMLExportPropertyMapper;
//.........................................................................
namespace xmloff
{
//.........................................................................
typedef ::std::set < ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >
, OPropertySetCompare
> PropertySetBag;
// maps objects (property sets) to strings, e.g. control ids.
typedef ::std::map < ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >
, ::rtl::OUString
, OPropertySetCompare
> MapPropertySet2String;
// map pages to maps (of property sets to strings)
typedef ::std::map < ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPage >
, MapPropertySet2String
, ODrawPageCompare
> MapPropertySet2Map;
//=====================================================================
//= OFormLayerXMLExport_Impl
//=====================================================================
/** the implementation class for OFormLayerXMLExport
*/
class OFormLayerXMLExport_Impl
:public IFormsExportContext
{
friend class OFormLayerXMLExport;
protected:
SvXMLExport& m_rContext;
SvXMLNumFmtExport* m_pControlNumberStyles;
// ignore list for control models
PropertySetBag m_aIgnoreList;
// style handling
2010-10-15 12:10:06 -05:00
::rtl::Reference< XMLPropertyHandlerFactory > m_xPropertyHandlerFactory;
::rtl::Reference< SvXMLExportPropertyMapper > m_xStyleExportMapper;
// we need our own number formats supplier:
// Controls which have a number formats do not work with the formats supplier of the document they reside
// in, instead they use the formats of the data source their form is associated with. If there is no
// such form or no such data source, they work with an own formatter.
// Even more, time and date fields do not work with a central formatter at all, they have their own one
// (which is shared internally, but this is a (hidden) implementation detail.)
//
// To not contaminate the global (document) number formats supplier (which could be obtained from the context),
// we have an own one.
// (Contaminate means: If a user adds a user-defined format to a formatted field, this format is stored in
// in the data source's formats supplier. To export this _and_ reuse existing structures, we would need to
// add this format to the global (document) formats supplier.
// In case of an export we could do some cleanup afterwards, but in case of an import, there is no such
// chance, as (if other user-defined formats exist in the document as well) we can't distinguish
CWS-TOOLING: integrate CWS dba31e 2008-11-19 12:36:23 +0100 msc r263980 : i96104 2008-11-19 12:31:19 +0100 msc r263979 : i96104 2008-11-19 12:21:55 +0100 msc r263977 : i96104 2008-11-19 12:18:53 +0100 msc r263976 : i96104 2008-11-18 09:09:45 +0100 oj r263746 : disable color entry when area is set 2008-11-18 08:37:52 +0100 oj r263741 : #remove sub report entry 2008-11-17 11:20:25 +0100 fs r263708 : #i10000# 2008-11-17 11:06:52 +0100 fs r263706 : minimal version now is 3.1 2008-11-12 22:25:59 +0100 fs r263621 : #i96150# 2008-11-12 22:20:02 +0100 fs r263620 : rebased to m34 2008-11-12 21:39:41 +0100 fs r263618 : MANUAL REBASE: rebase CWS dba31d to DEV300_m34 2008-11-12 13:54:58 +0100 fs r263597 : #i96134# MediaDescriptor.URL is to be preferred over MediaDescriptor.FileName. Nonetheless, ensure both are handled 2008-11-12 13:53:40 +0100 fs r263596 : #i96134# re-enabled the code for #i41897#, a better fix is to come 2008-11-12 12:48:21 +0100 fs r263585 : #i96134# disable saving URLs of file-base databases relatively 2008-11-11 16:11:11 +0100 msc r263566 : #i96104# 2008-11-05 09:09:47 +0100 oj r263342 : #i88727# color noe added 2008-11-05 08:41:43 +0100 oj r263341 : #i77916# zoom added 2008-11-04 21:24:15 +0100 fs r263339 : disposing: call disposeAndClear without own mutex locked - some of our listeners insist on locking the SolarMutex, which sometimes led to deadlocks on the complex test cases 2008-11-04 21:23:15 +0100 fs r263338 : remove SolarMutex locking - this happned in CWS dba31c (in the CVS version), which this CWS was created from, but seems to got lost during resync 2008-11-04 20:49:50 +0100 fs r263335 : docu formatting 2008-11-04 20:06:39 +0100 fs r263334 : #i95826# use m_aMutex, not a DocumentGuard (wrongly resolved merge conflicts) 2008-11-04 17:36:29 +0100 fs r263332 : #i92688# properly revoke as XEventListener from m_xActiveController when disposing 2008-11-04 14:49:34 +0100 fs r263324 : #i92322# enable Input Required if EmptyIsNULL does not exist at the control 2008-10-31 11:10:04 +0100 oj r262857 : merge from cvs to svn 2008-10-31 09:46:45 +0100 oj r262853 : merge from cvs to svn 2008-10-31 08:46:37 +0100 oj r262849 : merge from cvs to svn 2008-10-31 08:44:24 +0100 oj r262848 : merge from cvs to svn 2008-10-31 08:43:33 +0100 oj r262847 : merge from cvs to svn 2008-10-31 08:42:28 +0100 oj r262846 : merge from cvs to svn 2008-10-31 08:41:58 +0100 oj r262845 : merge from cvs to svn 2008-10-31 08:41:32 +0100 oj r262844 : merge from cvs to svn 2008-10-28 12:19:50 +0100 oj r262733 : #iXXXXX#: migrate CWS dba31e to SVN 2008-10-28 12:19:42 +0100 oj r262732 : #iXXXXX#: migrate CWS dba31e to SVN 2008-10-28 12:19:36 +0100 oj r262731 : #iXXXXX#: migrate CWS dba31e to SVN 2008-10-28 12:19:31 +0100 oj r262730 : #iXXXXX#: migrate CWS dba31e to SVN 2008-10-28 12:19:22 +0100 oj r262729 : #iXXXXX#: migrate CWS dba31e to SVN 2008-10-28 12:19:18 +0100 oj r262728 : #iXXXXX#: migrate CWS dba31e to SVN 2008-10-28 12:19:10 +0100 oj r262727 : #iXXXXX#: migrate CWS dba31e to SVN 2008-10-28 12:19:06 +0100 oj r262726 : #iXXXXX#: migrate CWS dba31e to SVN 2008-10-28 12:19:05 +0100 oj r262725 : #iXXXXX#: migrate CWS dba31e to SVN 2008-10-28 12:19:01 +0100 oj r262724 : #iXXXXX#: migrate CWS dba31e to SVN 2008-10-28 12:18:50 +0100 oj r262723 : #iXXXXX#: migrate CWS dba31e to SVN 2008-10-28 12:18:41 +0100 oj r262722 : #iXXXXX#: migrate CWS dba31e to SVN 2008-10-28 12:18:40 +0100 oj r262721 : #iXXXXX#: migrate CWS dba31e to SVN 2008-10-28 12:18:27 +0100 oj r262720 : #iXXXXX#: migrate CWS dba31e to SVN 2008-10-28 12:18:10 +0100 oj r262719 : #iXXXXX#: migrate CWS dba31e to SVN 2008-10-28 12:18:01 +0100 oj r262718 : #iXXXXX#: migrate CWS dba31e to SVN 2008-10-28 12:17:39 +0100 oj r262717 : #iXXXXX#: migrate CWS dba31e to SVN
2008-12-01 12:31:27 +00:00
// between user-defined formats really needed for the doc (i.e. in a calc cell) and formats only added
// to the supplier because the controls needed it.
::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormats >
m_xControlNumberFormats;
MapPropertySet2Map m_aControlIds;
// the control ids of all controls on all pages we ever examined
MapPropertySet2Map m_aReferringControls;
// for a given page (iter->first), and a given control (iter->second->first), this is the comma-separated
// lists of ids of the controls refering to the control given.
MapPropertySet2Map::iterator
m_aCurrentPageIds;
// the iterator for the control id map for the page beeing handled
MapPropertySet2Map::iterator
m_aCurrentPageReferring;
// the same for the map of referring controls
// TODO: To avoid this construct above, and to have a cleaner implementation, an class encapsulating the
// export of a single page should be introduced.
DECLARE_STL_MAP( ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >, sal_Int32, OPropertySetCompare, MapPropertySet2Int);
MapPropertySet2Int m_aControlNumberFormats;
// maps controls to format keys, which are relative to our own formats supplier
MapPropertySet2String m_aGridColumnStyles;
// style names of grid columns
public:
OFormLayerXMLExport_Impl(SvXMLExport& _rContext);
virtual ~OFormLayerXMLExport_Impl();
protected:
/** exports one single grid column
*/
void exportGridColumn(
2001-01-02 14:58:22 +00:00
const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxColumn,
const ::com::sun::star::uno::Sequence< ::com::sun::star::script::ScriptEventDescriptor >& _rEvents
);
/** exports one single control
*/
void exportControl(
2001-01-02 14:58:22 +00:00
const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxControl,
const ::com::sun::star::uno::Sequence< ::com::sun::star::script::ScriptEventDescriptor >& _rEvents
);
/** exports one single form
*/
2001-01-02 14:58:22 +00:00
void exportForm(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxProps,
const ::com::sun::star::uno::Sequence< ::com::sun::star::script::ScriptEventDescriptor >& _rEvents
);
2011-08-20 21:15:04 +01:00
/** seek to the page given.
<p>This must be called before you can retrieve any ids for controls on the page.</p>
@see
getControlId
*/
sal_Bool seekPage(
const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPage >& _rxDrawPage);
/** get the id of the given control.
<p>You must have sought to the page of the control before calling this.</p>
*/
::rtl::OUString
getControlId(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxControl);
/** retrieves the style name for the control's number style.
<p>For performance reasons, this method is allowed to be called for any controls, even those which
do not have a number style. In this case, an empty string is returned.</p>
*/
::rtl::OUString
getControlNumberStyle( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxControl );
// IFormsExportContext
virtual void exportCollectionElements(const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess >& _rxCollection);
virtual SvXMLExport& getGlobalContext();
virtual ::rtl::OUString getObjectStyleName(
const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxObject );
2010-10-15 12:10:06 -05:00
virtual ::rtl::Reference< SvXMLExportPropertyMapper > getStylePropertyMapper();
/** clear any structures which have been build in the recent <method>examine</method> calls.
*/
void clear();
/** examine a forms collection.
<p>The method will collect control ids and add styles to the export context as necessary.</p>
<p>Every control in the object hierarchy given will be assigned to a unique id, which is stored for later
use.</p>
<p>In addition, any references the controls may have between each other, are collected and stored for
later use.</p>
<p>Upon calling this method, the id map will be cleared before collecting the new ids, so any ids
you collected previously will be lost</p>
@param _rxDrawPage
the draw page which's forms collection should be examined
@see getControlId
@see exportControl
@see exportForms
*/
void examineForms(
const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPage >& _rxDrawPage);
/** export a forms collection of a draw page
<p>The method will obtain the forms collection of the page and call
<method>exportCollectionElements</method>.</p>
*/
void exportForms(
const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPage >& _rxDrawPage);
/** exports the XForms model data
*/
void exportXForms() const;
/** determines whether the given page contains logical forms
*/
bool pageContainsForms( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPage >& _rxDrawPage ) const;
/** determines whether the given page contains XForm instances
*/
bool documentContainsXForms() const;
/** exports the automatic control number styles
*/
void exportAutoControlNumberStyles();
/** exports the auto-styles collected during the examineForms calls
*/
void exportAutoStyles();
protected:
sal_Bool impl_isFormPageContainingForms(
const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPage >& _rxDrawPage,
::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess >& _rxForms);
/** moves the m_aCurrentPage* members to the positions specifying the given page.
@return <TRUE/> if there already were structures for the given page
*/
sal_Bool implMoveIterators(
const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPage >& _rxDrawPage,
sal_Bool _bClear);
/** check the object given if it's a control, if so, examine it.
@return <TRUE/> if the object has been handled
*/
sal_Bool checkExamineControl(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxObject);
/** examines the control's number format, so later the format style can be referred
<p>remembers the format key for the control, so it can later be asked for in getControlNumberStyle</p>
*/
void examineControlNumberFormat(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxControl);
/** examines the control's number format, so later the format style can be referred
<p>does not remember the information returned in any way</p>
*/
sal_Int32 implExamineControlNumberFormat( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxObject );
/** collects AutoStyles for grid columns
*/
void collectGridColumnStylesAndIds( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxControl );
/** ensures that the number format of the given control exist in our own formats supplier.
<p>The given control is examined for it's format (i.e. it's FormatKey/FormatsSupplier properties),
and the format is added (if necessary) to m_xControlNumberFormats</p>.
@return
the format key of the control's format relative to our own formats supplier
*/
sal_Int32 ensureTranslateFormat(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxFormattedControl);
/// returns the instance exporting our control's number styles
SvXMLNumFmtExport* getControlNumberStyleExport();
/// ensures that the instance exporting our control's number styles exists
void ensureControlNumberStyleExport();
/** determines the number format style for the given object without remembering it
*/
::rtl::OUString
getImmediateNumberStyle( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxObject );
/** returns the prefix to be used for control number styles
*/
static const ::rtl::OUString& getControlNumberStyleNamePrefix();
/** exclude the given control (model) from export.
<p>If your document contains form controls which are not to be exported for whatever reason,
you need to announce the models of these controls (can be retrieved from XControlShape::getControl)
to the form layer exporter.<br/>
Of course you have to do this before calling <member>exportForms</member></p>
*/
void excludeFromExport( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel > _rxControl );
};
//.........................................................................
} // namespace xmloff
//.........................................................................
#endif // _XMLOFF_FORMS_LAYEREXPORT_HXX_
2010-10-27 13:11:31 +01:00
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */