summaryrefslogtreecommitdiff
path: root/svtools/source/dialogs
diff options
context:
space:
mode:
Diffstat (limited to 'svtools/source/dialogs')
-rw-r--r--svtools/source/dialogs/addresstemplate.cxx1320
-rw-r--r--svtools/source/dialogs/addresstemplate.hrc91
-rw-r--r--svtools/source/dialogs/addresstemplate.src361
-rw-r--r--svtools/source/dialogs/colctrl.cxx693
-rw-r--r--svtools/source/dialogs/colrdlg.cxx331
-rw-r--r--svtools/source/dialogs/colrdlg.hrc70
-rw-r--r--svtools/source/dialogs/colrdlg.src311
-rw-r--r--svtools/source/dialogs/filedlg.cxx151
-rw-r--r--svtools/source/dialogs/filedlg2.cxx1365
-rw-r--r--svtools/source/dialogs/filedlg2.hrc44
-rw-r--r--svtools/source/dialogs/filedlg2.hxx222
-rw-r--r--svtools/source/dialogs/filedlg2.src129
-rw-r--r--svtools/source/dialogs/formats.src297
-rw-r--r--svtools/source/dialogs/insdlg.cxx392
-rw-r--r--svtools/source/dialogs/logindlg.cxx315
-rw-r--r--svtools/source/dialogs/logindlg.hrc60
-rw-r--r--svtools/source/dialogs/logindlg.src203
-rw-r--r--svtools/source/dialogs/makefile.mk81
-rw-r--r--svtools/source/dialogs/mcvmath.cxx308
-rw-r--r--svtools/source/dialogs/mcvmath.hxx231
-rw-r--r--svtools/source/dialogs/printdlg.cxx801
-rw-r--r--svtools/source/dialogs/printdlg.hrc77
-rw-r--r--svtools/source/dialogs/printdlg.src336
-rw-r--r--svtools/source/dialogs/prnsetup.cxx406
-rw-r--r--svtools/source/dialogs/prnsetup.hrc51
-rw-r--r--svtools/source/dialogs/prnsetup.src281
-rw-r--r--svtools/source/dialogs/propctrl.cxx506
-rw-r--r--svtools/source/dialogs/property.cxx1563
-rw-r--r--svtools/source/dialogs/roadmapwizard.cxx708
-rw-r--r--svtools/source/dialogs/so3res.src318
-rw-r--r--svtools/source/dialogs/wizardmachine.cxx727
-rw-r--r--svtools/source/dialogs/wizardmachine.src53
-rw-r--r--svtools/source/dialogs/wizdlg.cxx709
33 files changed, 13511 insertions, 0 deletions
diff --git a/svtools/source/dialogs/addresstemplate.cxx b/svtools/source/dialogs/addresstemplate.cxx
new file mode 100644
index 000000000000..ddb34d5d4fd2
--- /dev/null
+++ b/svtools/source/dialogs/addresstemplate.cxx
@@ -0,0 +1,1320 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: addresstemplate.cxx,v $
+ * $Revision: 1.28 $
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_svtools.hxx"
+
+#include <stdio.h>
+
+
+#include "addresstemplate.hxx"
+#ifndef _SVT_ADDRESSTEMPLATE_HRC_
+#include "addresstemplate.hrc"
+#endif
+#ifndef _SVTOOLS_HRC
+#include <svtools/svtools.hrc>
+#endif
+#ifndef _SVT_HELPID_HRC
+#include <svtools/helpid.hrc>
+#endif
+#include <svtools/svtdata.hxx>
+#include <tools/debug.hxx>
+#include <comphelper/processfactory.hxx>
+#include <comphelper/stl_types.hxx>
+#include <vcl/stdtext.hxx>
+#include <vcl/waitobj.hxx>
+#include <vcl/msgbox.hxx>
+#include <toolkit/helper/vclunohelper.hxx>
+#ifndef _CPPUHELPER_EXTRACT_HXX_
+#include <cppuhelper/extract.hxx>
+#endif
+#include <comphelper/interaction.hxx>
+#include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
+#include <com/sun/star/awt/XWindow.hpp>
+#include <com/sun/star/beans/PropertyValue.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/sdb/XCompletedConnection.hpp>
+#include <com/sun/star/sdb/SQLContext.hpp>
+#include <com/sun/star/sdbc/SQLWarning.hpp>
+#include <com/sun/star/sdbc/XConnection.hpp>
+#include <com/sun/star/task/XInteractionHandler.hpp>
+#include <com/sun/star/sdbcx/XTablesSupplier.hpp>
+#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
+#include <com/sun/star/sdb/CommandType.hpp>
+#include "localresaccess.hxx"
+#ifndef SVTOOLS_FILENOTATION_HXX_
+#include "filenotation.hxx"
+#endif
+#include <tools/urlobj.hxx>
+
+#include <algorithm>
+
+// .......................................................................
+namespace svt
+{
+// .......................................................................
+
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::lang;
+ using namespace ::com::sun::star::container;
+ using namespace ::com::sun::star::ui::dialogs;
+ using namespace ::com::sun::star::util;
+ using namespace ::com::sun::star::beans;
+ using namespace ::com::sun::star::sdb;
+ using namespace ::com::sun::star::sdbc;
+ using namespace ::com::sun::star::sdbcx;
+ using namespace ::com::sun::star::task;
+ using namespace ::comphelper;
+ using namespace ::utl;
+
+ DECLARE_STL_VECTOR( String, StringArray );
+ DECLARE_STL_STDKEY_SET( ::rtl::OUString, StringBag );
+ DECLARE_STL_USTRINGACCESS_MAP( ::rtl::OUString, MapString2String );
+ // ===================================================================
+ // = IAssigmentData
+ // ===================================================================
+ class IAssigmentData
+ {
+ public:
+ virtual ~IAssigmentData();
+
+ /// the data source to use for the address book
+ virtual ::rtl::OUString getDatasourceName() const = 0;
+
+ /// the command to use for the address book
+ virtual ::rtl::OUString getCommand() const = 0;
+
+ /** the command type to use for the address book
+ @return
+ a <type scope="com.sun.star.sdb">CommandType</type> value
+ */
+ virtual sal_Int32 getCommandType() const = 0;
+
+ /// checks whether or not there is an assignment for a given logical field
+ virtual sal_Bool hasFieldAssignment(const ::rtl::OUString& _rLogicalName) = 0;
+ /// retrieves the assignment for a given logical field
+ virtual ::rtl::OUString getFieldAssignment(const ::rtl::OUString& _rLogicalName) = 0;
+
+ /// set the assignment for a given logical field
+ virtual void setFieldAssignment(const ::rtl::OUString& _rLogicalName, const ::rtl::OUString& _rAssignment) = 0;
+ /// clear the assignment for a given logical field
+ virtual void clearFieldAssignment(const ::rtl::OUString& _rLogicalName) = 0;
+
+ virtual void setDatasourceName(const ::rtl::OUString& _rName) = 0;
+ virtual void setCommand(const ::rtl::OUString& _rCommand) = 0;
+ };
+
+ // -------------------------------------------------------------------
+ IAssigmentData::~IAssigmentData()
+ {
+ }
+
+ // ===================================================================
+ // = AssigmentTransientData
+ // ===================================================================
+ class AssigmentTransientData : public IAssigmentData
+ {
+ protected:
+ Reference< XDataSource > m_xDataSource;
+ ::rtl::OUString m_sDSName;
+ ::rtl::OUString m_sTableName;
+ MapString2String m_aAliases;
+
+public:
+ AssigmentTransientData(
+ const Reference< XDataSource >& _rxDataSource,
+ const ::rtl::OUString& _rDataSourceName,
+ const ::rtl::OUString& _rTableName,
+ const Sequence< AliasProgrammaticPair >& _rFields
+ );
+
+ // IAssigmentData overridables
+ virtual ::rtl::OUString getDatasourceName() const;
+ virtual ::rtl::OUString getCommand() const;
+ virtual sal_Int32 getCommandType() const;
+
+ virtual sal_Bool hasFieldAssignment(const ::rtl::OUString& _rLogicalName);
+ virtual ::rtl::OUString getFieldAssignment(const ::rtl::OUString& _rLogicalName);
+ virtual void setFieldAssignment(const ::rtl::OUString& _rLogicalName, const ::rtl::OUString& _rAssignment);
+ virtual void clearFieldAssignment(const ::rtl::OUString& _rLogicalName);
+
+ virtual void setDatasourceName(const ::rtl::OUString& _rName);
+ virtual void setCommand(const ::rtl::OUString& _rCommand);
+ };
+
+ // -------------------------------------------------------------------
+ AssigmentTransientData::AssigmentTransientData( const Reference< XDataSource >& _rxDataSource,
+ const ::rtl::OUString& _rDataSourceName, const ::rtl::OUString& _rTableName,
+ const Sequence< AliasProgrammaticPair >& _rFields )
+ :m_xDataSource( _rxDataSource )
+ ,m_sDSName( _rDataSourceName )
+ ,m_sTableName( _rTableName )
+ {
+ // fill our aliaes structure
+ // first collect all known programmatic names
+ StringBag aKnownNames;
+
+ String sLogicalFieldNames( SvtResId( STR_LOCAGICAL_FIELD_NAMES ) );
+ sal_Int32 nTokenCount = sLogicalFieldNames.GetTokenCount(';');
+ for (sal_Int32 i = 0; i<nTokenCount; ++i)
+ aKnownNames.insert(sLogicalFieldNames.GetToken((sal_uInt16)i, ';'));
+
+ // loop throuzh the given names
+ const AliasProgrammaticPair* pFields = _rFields.getConstArray();
+ for (;pFields != pFields; ++pFields)
+ {
+ StringBagIterator aKnownPos = aKnownNames.find( pFields->ProgrammaticName );
+ if ( aKnownNames.end() != aKnownPos )
+ {
+ m_aAliases[ pFields->ProgrammaticName ] = pFields->Alias;
+ }
+ else
+ {
+ DBG_ERROR ( ( ::rtl::OString("AssigmentTransientData::AssigmentTransientData: unknown programmatic name (")
+ += ::rtl::OString(pFields->ProgrammaticName.getStr(), pFields->ProgrammaticName.getLength(), RTL_TEXTENCODING_ASCII_US)
+ += ::rtl::OString(")!")
+ ).getStr()
+ );
+ }
+ }
+ }
+
+ // -------------------------------------------------------------------
+ ::rtl::OUString AssigmentTransientData::getDatasourceName() const
+ {
+ return m_sDSName;
+ }
+
+ // -------------------------------------------------------------------
+ ::rtl::OUString AssigmentTransientData::getCommand() const
+ {
+ return m_sTableName;
+ }
+
+ // -------------------------------------------------------------------
+ sal_Int32 AssigmentTransientData::getCommandType() const
+ {
+ return CommandType::TABLE;
+ }
+
+ // -------------------------------------------------------------------
+ sal_Bool AssigmentTransientData::hasFieldAssignment(const ::rtl::OUString& _rLogicalName)
+ {
+ ConstMapString2StringIterator aPos = m_aAliases.find( _rLogicalName );
+ return ( m_aAliases.end() != aPos )
+ && ( aPos->second.getLength() );
+ }
+
+ // -------------------------------------------------------------------
+ ::rtl::OUString AssigmentTransientData::getFieldAssignment(const ::rtl::OUString& _rLogicalName)
+ {
+ ::rtl::OUString sReturn;
+ ConstMapString2StringIterator aPos = m_aAliases.find( _rLogicalName );
+ if ( m_aAliases.end() != aPos )
+ sReturn = aPos->second;
+
+ return sReturn;
+ }
+
+ // -------------------------------------------------------------------
+ void AssigmentTransientData::setFieldAssignment(const ::rtl::OUString& _rLogicalName, const ::rtl::OUString& _rAssignment)
+ {
+ m_aAliases[ _rLogicalName ] = _rAssignment;
+ }
+
+ // -------------------------------------------------------------------
+ void AssigmentTransientData::clearFieldAssignment(const ::rtl::OUString& _rLogicalName)
+ {
+ MapString2StringIterator aPos = m_aAliases.find( _rLogicalName );
+ if ( m_aAliases.end() != aPos )
+ m_aAliases.erase( aPos );
+ }
+
+ // -------------------------------------------------------------------
+ void AssigmentTransientData::setDatasourceName(const ::rtl::OUString&)
+ {
+ DBG_ERROR( "AssigmentTransientData::setDatasourceName: cannot be implemented for transient data!" );
+ }
+
+ // -------------------------------------------------------------------
+ void AssigmentTransientData::setCommand(const ::rtl::OUString&)
+ {
+ DBG_ERROR( "AssigmentTransientData::setCommand: cannot be implemented for transient data!" );
+ }
+
+ // ===================================================================
+ // = AssignmentPersistentData
+ // ===================================================================
+ class AssignmentPersistentData
+ :public ::utl::ConfigItem
+ ,public IAssigmentData
+ {
+ protected:
+ StringBag m_aStoredFields;
+
+ protected:
+ ::com::sun::star::uno::Any
+ getProperty(const ::rtl::OUString& _rLocalName) const;
+ ::com::sun::star::uno::Any
+ getProperty(const sal_Char* _pLocalName) const;
+
+ ::rtl::OUString getStringProperty(const sal_Char* _pLocalName) const;
+ sal_Int32 getInt32Property(const sal_Char* _pLocalName) const;
+
+ ::rtl::OUString getStringProperty(const ::rtl::OUString& _rLocalName) const;
+
+ void setStringProperty(const sal_Char* _pLocalName, const ::rtl::OUString& _rValue);
+
+ public:
+ AssignmentPersistentData();
+ ~AssignmentPersistentData();
+
+ // IAssigmentData overridables
+ virtual ::rtl::OUString getDatasourceName() const;
+ virtual ::rtl::OUString getCommand() const;
+ virtual sal_Int32 getCommandType() const;
+
+ virtual sal_Bool hasFieldAssignment(const ::rtl::OUString& _rLogicalName);
+ virtual ::rtl::OUString getFieldAssignment(const ::rtl::OUString& _rLogicalName);
+ virtual void setFieldAssignment(const ::rtl::OUString& _rLogicalName, const ::rtl::OUString& _rAssignment);
+ virtual void clearFieldAssignment(const ::rtl::OUString& _rLogicalName);
+
+ virtual void setDatasourceName(const ::rtl::OUString& _rName);
+ virtual void setCommand(const ::rtl::OUString& _rCommand);
+ };
+
+ // -------------------------------------------------------------------
+ AssignmentPersistentData::AssignmentPersistentData()
+ :ConfigItem( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Office.DataAccess/AddressBook" )))
+ {
+ Sequence< ::rtl::OUString > aStoredNames = GetNodeNames(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Fields")));
+ const ::rtl::OUString* pStoredNames = aStoredNames.getConstArray();
+ for (sal_Int32 i=0; i<aStoredNames.getLength(); ++i, ++pStoredNames)
+ m_aStoredFields.insert(*pStoredNames);
+ }
+
+ // -------------------------------------------------------------------
+ AssignmentPersistentData::~AssignmentPersistentData()
+ {
+ }
+
+ // -------------------------------------------------------------------
+ sal_Bool AssignmentPersistentData::hasFieldAssignment(const ::rtl::OUString& _rLogicalName)
+ {
+ return (m_aStoredFields.end() != m_aStoredFields.find(_rLogicalName));
+ }
+
+ // -------------------------------------------------------------------
+ ::rtl::OUString AssignmentPersistentData::getFieldAssignment(const ::rtl::OUString& _rLogicalName)
+ {
+ ::rtl::OUString sAssignment;
+ if (hasFieldAssignment(_rLogicalName))
+ {
+ ::rtl::OUString sFieldPath(RTL_CONSTASCII_USTRINGPARAM("Fields/"));
+ sFieldPath += _rLogicalName;
+ sFieldPath += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/AssignedFieldName"));
+ sAssignment = getStringProperty(sFieldPath);
+ }
+ return sAssignment;
+ }
+
+ // -------------------------------------------------------------------
+ Any AssignmentPersistentData::getProperty(const sal_Char* _pLocalName) const
+ {
+ return getProperty(::rtl::OUString::createFromAscii(_pLocalName));
+ }
+
+ // -------------------------------------------------------------------
+ Any AssignmentPersistentData::getProperty(const ::rtl::OUString& _rLocalName) const
+ {
+ Sequence< ::rtl::OUString > aProperties(&_rLocalName, 1);
+ Sequence< Any > aValues = const_cast<AssignmentPersistentData*>(this)->GetProperties(aProperties);
+ DBG_ASSERT(aValues.getLength() == 1, "AssignmentPersistentData::getProperty: invalid sequence length!");
+ return aValues[0];
+ }
+
+ // -------------------------------------------------------------------
+ ::rtl::OUString AssignmentPersistentData::getStringProperty(const ::rtl::OUString& _rLocalName) const
+ {
+ ::rtl::OUString sReturn;
+ getProperty( _rLocalName ) >>= sReturn;
+ return sReturn;
+ }
+
+ // -------------------------------------------------------------------
+ ::rtl::OUString AssignmentPersistentData::getStringProperty(const sal_Char* _pLocalName) const
+ {
+ ::rtl::OUString sReturn;
+ getProperty( _pLocalName ) >>= sReturn;
+ return sReturn;
+ }
+
+ // -------------------------------------------------------------------
+ sal_Int32 AssignmentPersistentData::getInt32Property(const sal_Char* _pLocalName) const
+ {
+ sal_Int32 nReturn = 0;
+ getProperty( _pLocalName ) >>= nReturn;
+ return nReturn;
+ }
+
+ // -------------------------------------------------------------------
+ void AssignmentPersistentData::setStringProperty(const sal_Char* _pLocalName, const ::rtl::OUString& _rValue)
+ {
+ Sequence< ::rtl::OUString > aNames(1);
+ Sequence< Any > aValues(1);
+ aNames[0] = ::rtl::OUString::createFromAscii(_pLocalName);
+ aValues[0] <<= _rValue;
+ PutProperties(aNames, aValues);
+ }
+
+ // -------------------------------------------------------------------
+ void AssignmentPersistentData::setFieldAssignment(const ::rtl::OUString& _rLogicalName, const ::rtl::OUString& _rAssignment)
+ {
+ if (!_rAssignment.getLength())
+ {
+ if (hasFieldAssignment(_rLogicalName))
+ // the assignment exists but it should be reset
+ clearFieldAssignment(_rLogicalName);
+ return;
+ }
+
+ // Fields
+ ::rtl::OUString sDescriptionNodePath(RTL_CONSTASCII_USTRINGPARAM("Fields"));
+
+ // Fields/<field>
+ ::rtl::OUString sFieldElementNodePath(sDescriptionNodePath);
+ sFieldElementNodePath += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/"));
+ sFieldElementNodePath += _rLogicalName;
+
+ Sequence< PropertyValue > aNewFieldDescription(2);
+ // Fields/<field>/ProgrammaticFieldName
+ aNewFieldDescription[0].Name = sFieldElementNodePath;
+ aNewFieldDescription[0].Name += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/ProgrammaticFieldName"));
+ aNewFieldDescription[0].Value <<= _rLogicalName;
+ // Fields/<field>/AssignedFieldName
+ aNewFieldDescription[1].Name = sFieldElementNodePath;
+ aNewFieldDescription[1].Name += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/AssignedFieldName"));
+ aNewFieldDescription[1].Value <<= _rAssignment;
+
+ // just set the new value
+#ifdef DBG_UTIL
+ sal_Bool bSuccess =
+#endif
+ SetSetProperties(sDescriptionNodePath, aNewFieldDescription);
+ DBG_ASSERT(bSuccess, "AssignmentPersistentData::setFieldAssignment: could not commit the changes a field!");
+ }
+
+ // -------------------------------------------------------------------
+ void AssignmentPersistentData::clearFieldAssignment(const ::rtl::OUString& _rLogicalName)
+ {
+ if (!hasFieldAssignment(_rLogicalName))
+ // nothing to do
+ return;
+
+ ::rtl::OUString sDescriptionNodePath(RTL_CONSTASCII_USTRINGPARAM("Fields"));
+ Sequence< ::rtl::OUString > aNames(&_rLogicalName, 1);
+ ClearNodeElements(sDescriptionNodePath, aNames);
+ }
+
+ // -------------------------------------------------------------------
+ ::rtl::OUString AssignmentPersistentData::getDatasourceName() const
+ {
+ return getStringProperty( "DataSourceName" );
+ }
+
+ // -------------------------------------------------------------------
+ ::rtl::OUString AssignmentPersistentData::getCommand() const
+ {
+ return getStringProperty( "Command" );
+ }
+
+ // -------------------------------------------------------------------
+ void AssignmentPersistentData::setDatasourceName(const ::rtl::OUString& _rName)
+ {
+ setStringProperty( "DataSourceName", _rName );
+ }
+
+ // -------------------------------------------------------------------
+ void AssignmentPersistentData::setCommand(const ::rtl::OUString& _rCommand)
+ {
+ setStringProperty( "Command", _rCommand );
+ }
+
+ // -------------------------------------------------------------------
+ sal_Int32 AssignmentPersistentData::getCommandType() const
+ {
+ return getInt32Property( "CommandType" );
+ }
+
+ // ===================================================================
+ // = AddressBookSourceDialogData
+ // ===================================================================
+ struct AddressBookSourceDialogData
+ {
+ FixedText* pFieldLabels[FIELD_PAIRS_VISIBLE * 2];
+ ListBox* pFields[FIELD_PAIRS_VISIBLE * 2];
+
+ /// when working transient, we need the data source
+ Reference< XDataSource >
+ m_xTransientDataSource;
+ /// current scroll pos in the field list
+ sal_Int32 nFieldScrollPos;
+ /// the index within m_pFields of the last visible list box. This is redundant, it could be extracted from other members
+ sal_Int32 nLastVisibleListIndex;
+ /// indicates that we've an odd field number. This member is for efficiency only, it's redundant.
+ sal_Bool bOddFieldNumber : 1;
+ /// indicates that we're working with the real persistent configuration
+ sal_Bool bWorkingPersistent : 1;
+
+ /// the strings to use as labels for the field selection listboxes
+ StringArray aFieldLabels;
+ // the current field assignment
+ StringArray aFieldAssignments;
+ /// the logical field names
+ StringArray aLogicalFieldNames;
+
+ IAssigmentData* pConfigData;
+
+ // ................................................................
+ AddressBookSourceDialogData( )
+ :nFieldScrollPos(0)
+ ,nLastVisibleListIndex(0)
+ ,bOddFieldNumber(sal_False)
+ ,bWorkingPersistent( sal_True )
+ ,pConfigData( new AssignmentPersistentData )
+ {
+ }
+
+ // ................................................................
+ AddressBookSourceDialogData( const Reference< XDataSource >& _rxTransientDS, const ::rtl::OUString& _rDataSourceName,
+ const ::rtl::OUString& _rTableName, const Sequence< AliasProgrammaticPair >& _rFields )
+ :m_xTransientDataSource( _rxTransientDS )
+ ,nFieldScrollPos(0)
+ ,nLastVisibleListIndex(0)
+ ,bOddFieldNumber(sal_False)
+ ,bWorkingPersistent( sal_False )
+ ,pConfigData( new AssigmentTransientData( m_xTransientDataSource, _rDataSourceName, _rTableName, _rFields ) )
+ {
+ }
+
+ ~AddressBookSourceDialogData()
+ {
+ delete pConfigData;
+ }
+
+ };
+
+ // ===================================================================
+ // = AddressBookSourceDialog
+ // ===================================================================
+#define INIT_FIELDS() \
+ ModalDialog(_pParent, SvtResId( DLG_ADDRESSBOOKSOURCE ))\
+ ,m_aDatasourceFrame (this, SvtResId(FL_DATASOURCEFRAME))\
+ ,m_aDatasourceLabel (this, SvtResId(FT_DATASOURCE))\
+ ,m_aDatasource (this, SvtResId(CB_DATASOURCE))\
+ ,m_aAdministrateDatasources (this, SvtResId(PB_ADMINISTATE_DATASOURCES))\
+ ,m_aTableLabel (this, SvtResId(FT_TABLE))\
+ ,m_aTable (this, SvtResId(CB_TABLE))\
+ ,m_aFieldsTitle (this, SvtResId(FT_FIELDS))\
+ ,m_aFieldsFrame (this, SvtResId(CT_BORDER))\
+ ,m_aFieldScroller (&m_aFieldsFrame, SvtResId(SB_FIELDSCROLLER))\
+ ,m_aOK (this, SvtResId(PB_OK))\
+ ,m_aCancel (this, SvtResId(PB_CANCEL))\
+ ,m_aHelp (this, SvtResId(PB_HELP))\
+ ,m_sNoFieldSelection(SvtResId(STR_NO_FIELD_SELECTION))\
+ ,m_xORB(_rxORB)
+
+ // -------------------------------------------------------------------
+ AddressBookSourceDialog::AddressBookSourceDialog(Window* _pParent,
+ const Reference< XMultiServiceFactory >& _rxORB )
+ :INIT_FIELDS()
+ ,m_pImpl( new AddressBookSourceDialogData )
+ {
+ implConstruct();
+ }
+
+ // -------------------------------------------------------------------
+ AddressBookSourceDialog::AddressBookSourceDialog( Window* _pParent, const Reference< XMultiServiceFactory >& _rxORB,
+ const Reference< XDataSource >& _rxTransientDS, const ::rtl::OUString& _rDataSourceName,
+ const ::rtl::OUString& _rTable, const Sequence< AliasProgrammaticPair >& _rMapping )
+ :INIT_FIELDS()
+ ,m_pImpl( new AddressBookSourceDialogData( _rxTransientDS, _rDataSourceName, _rTable, _rMapping ) )
+ {
+ implConstruct();
+ }
+
+ // -------------------------------------------------------------------
+ void AddressBookSourceDialog::implConstruct()
+ {
+ for (sal_Int32 row=0; row<FIELD_PAIRS_VISIBLE; ++row)
+ {
+ for (sal_Int32 column=0; column<2; ++column)
+ {
+ // the label
+ m_pImpl->pFieldLabels[row * 2 + column] = new FixedText(&m_aFieldsFrame, SvtResId((USHORT)(FT_FIELD_BASE + row * 2 + column)));
+ // the listbox
+ m_pImpl->pFields[row * 2 + column] = new ListBox(&m_aFieldsFrame, SvtResId((USHORT)(LB_FIELD_BASE + row * 2 + column)));
+ m_pImpl->pFields[row * 2 + column]->SetDropDownLineCount(15);
+ m_pImpl->pFields[row * 2 + column]->SetSelectHdl(LINK(this, AddressBookSourceDialog, OnFieldSelect));
+
+ m_pImpl->pFields[row * 2 + column]->SetHelpId(HID_ADDRTEMPL_FIELD_ASSIGNMENT);
+ }
+ }
+
+ m_aFieldsFrame.SetStyle((m_aFieldsFrame.GetStyle() | WB_TABSTOP | WB_DIALOGCONTROL) & ~WB_NODIALOGCONTROL);
+
+ // correct the z-order
+ m_aFieldScroller.SetZOrder(m_pImpl->pFields[FIELD_CONTROLS_VISIBLE - 1], WINDOW_ZORDER_BEHIND);
+ m_aOK.SetZOrder(&m_aFieldsFrame, WINDOW_ZORDER_BEHIND);
+ m_aCancel.SetZOrder(&m_aOK, WINDOW_ZORDER_BEHIND);
+
+ initializeDatasources();
+
+ // for the moment, we have a hard coded list of all known fields.
+ // A better solution would be to store all known field translations in the configuration, which could be
+ // extensible by the user in an arbitrary way.
+ // But for the moment we need a quick solution ...
+ // (the main thing would be to store the translations to use here in the user interface, besides that, the code
+ // should be adjustable with a rather small effort.)
+
+ // initialize the strings for the field labels
+ m_pImpl->aFieldLabels.push_back( String(SvtResId( STR_FIELD_FIRSTNAME )) );
+ m_pImpl->aFieldLabels.push_back( String(SvtResId( STR_FIELD_LASTNAME )) );
+ m_pImpl->aFieldLabels.push_back( String(SvtResId( STR_FIELD_COMPANY)) );
+ m_pImpl->aFieldLabels.push_back( String(SvtResId( STR_FIELD_DEPARTMENT )) );
+ m_pImpl->aFieldLabels.push_back( String(SvtResId( STR_FIELD_STREET )) );
+ m_pImpl->aFieldLabels.push_back( String(SvtResId( STR_FIELD_ZIPCODE )) );
+ m_pImpl->aFieldLabels.push_back( String(SvtResId( STR_FIELD_CITY )) );
+ m_pImpl->aFieldLabels.push_back( String(SvtResId( STR_FIELD_STATE)) );
+ m_pImpl->aFieldLabels.push_back( String(SvtResId( STR_FIELD_COUNTRY )) );
+ m_pImpl->aFieldLabels.push_back( String(SvtResId( STR_FIELD_HOMETEL )) );
+ m_pImpl->aFieldLabels.push_back( String(SvtResId( STR_FIELD_WORKTEL )) );
+ m_pImpl->aFieldLabels.push_back( String(SvtResId( STR_FIELD_OFFICETEL)) );
+ m_pImpl->aFieldLabels.push_back( String(SvtResId( STR_FIELD_MOBILE)) );
+ m_pImpl->aFieldLabels.push_back( String(SvtResId( STR_FIELD_TELOTHER)) );
+ m_pImpl->aFieldLabels.push_back( String(SvtResId( STR_FIELD_PAGER)) );
+ m_pImpl->aFieldLabels.push_back( String(SvtResId( STR_FIELD_FAX )) );
+ m_pImpl->aFieldLabels.push_back( String(SvtResId( STR_FIELD_EMAIL )) );
+ m_pImpl->aFieldLabels.push_back( String(SvtResId( STR_FIELD_URL )) );
+ m_pImpl->aFieldLabels.push_back( String(SvtResId( STR_FIELD_TITLE )) );
+ m_pImpl->aFieldLabels.push_back( String(SvtResId( STR_FIELD_POSITION )) );
+ m_pImpl->aFieldLabels.push_back( String(SvtResId( STR_FIELD_INITIALS )) );
+ m_pImpl->aFieldLabels.push_back( String(SvtResId( STR_FIELD_ADDRFORM )) );
+ m_pImpl->aFieldLabels.push_back( String(SvtResId( STR_FIELD_SALUTATION )) );
+ m_pImpl->aFieldLabels.push_back( String(SvtResId( STR_FIELD_ID)) );
+ m_pImpl->aFieldLabels.push_back( String(SvtResId( STR_FIELD_CALENDAR)) );
+ m_pImpl->aFieldLabels.push_back( String(SvtResId( STR_FIELD_INVITE)) );
+ m_pImpl->aFieldLabels.push_back( String(SvtResId( STR_FIELD_NOTE)) );
+ m_pImpl->aFieldLabels.push_back( String(SvtResId( STR_FIELD_USER1)) );
+ m_pImpl->aFieldLabels.push_back( String(SvtResId( STR_FIELD_USER2)) );
+ m_pImpl->aFieldLabels.push_back( String(SvtResId( STR_FIELD_USER3)) );
+ m_pImpl->aFieldLabels.push_back( String(SvtResId( STR_FIELD_USER4)) );
+
+ // force a even number of known fields
+ m_pImpl->bOddFieldNumber = (m_pImpl->aFieldLabels.size() % 2) != 0;
+ if (m_pImpl->bOddFieldNumber)
+ m_pImpl->aFieldLabels.push_back( String() );
+
+ // limit the scrollbar range accordingly
+ sal_Int32 nOverallFieldPairs = m_pImpl->aFieldLabels.size() / 2;
+ m_aFieldScroller.SetRange( Range(0, nOverallFieldPairs - FIELD_PAIRS_VISIBLE) );
+ m_aFieldScroller.SetLineSize(1);
+ m_aFieldScroller.SetPageSize(FIELD_PAIRS_VISIBLE);
+
+ // reset the current field assignments
+ m_pImpl->aFieldAssignments.resize(m_pImpl->aFieldLabels.size());
+ // (empty strings mean "no assignment")
+
+ // some knittings
+ m_aFieldScroller.SetScrollHdl(LINK(this, AddressBookSourceDialog, OnFieldScroll));
+ m_aAdministrateDatasources.SetClickHdl(LINK(this, AddressBookSourceDialog, OnAdministrateDatasources));
+ m_aDatasource.EnableAutocomplete(sal_True);
+ m_aTable.EnableAutocomplete(sal_True);
+ m_aTable.SetGetFocusHdl(LINK(this, AddressBookSourceDialog, OnComboGetFocus));
+ m_aDatasource.SetGetFocusHdl(LINK(this, AddressBookSourceDialog, OnComboGetFocus));
+ m_aTable.SetLoseFocusHdl(LINK(this, AddressBookSourceDialog, OnComboLoseFocus));
+ m_aDatasource.SetLoseFocusHdl(LINK(this, AddressBookSourceDialog, OnComboLoseFocus));
+ m_aTable.SetSelectHdl(LINK(this, AddressBookSourceDialog, OnComboSelect));
+ m_aDatasource.SetSelectHdl(LINK(this, AddressBookSourceDialog, OnComboSelect));
+ m_aOK.SetClickHdl(LINK(this, AddressBookSourceDialog, OnOkClicked));
+
+ m_aDatasource.SetDropDownLineCount(15);
+
+ // initialize the field controls
+ resetFields();
+ m_aFieldScroller.SetThumbPos(0);
+ m_pImpl->nFieldScrollPos = -1;
+ implScrollFields(0, sal_False, sal_False);
+
+ // the logical names
+ String sLogicalFieldNames(SvtResId(STR_LOCAGICAL_FIELD_NAMES));
+ sal_Int32 nAdjustedTokenCount = sLogicalFieldNames.GetTokenCount(';') + (m_pImpl->bOddFieldNumber ? 1 : 0);
+ DBG_ASSERT(nAdjustedTokenCount == (sal_Int32)m_pImpl->aFieldLabels.size(),
+ "AddressBookSourceDialog::AddressBookSourceDialog: inconsistence between logical and UI field names!");
+ m_pImpl->aLogicalFieldNames.reserve(nAdjustedTokenCount);
+ for (sal_Int32 i = 0; i<nAdjustedTokenCount; ++i)
+ m_pImpl->aLogicalFieldNames.push_back(sLogicalFieldNames.GetToken((sal_uInt16)i, ';'));
+
+ PostUserEvent(LINK(this, AddressBookSourceDialog, OnDelayedInitialize));
+ // so the dialog will at least show up before we do the loading of the
+ // configuration data and the (maybe time consuming) analysis of the data source/table to select
+
+ FreeResource();
+
+ if ( !m_pImpl->bWorkingPersistent )
+ {
+ StyleSettings aSystemStyle = GetSettings().GetStyleSettings();
+ const Color& rNewColor = aSystemStyle.GetDialogColor();
+
+ m_aDatasource.SetReadOnly( sal_True );
+ m_aDatasource.SetBackground( Wallpaper( rNewColor ) );
+ m_aDatasource.SetControlBackground( rNewColor );
+
+ m_aTable.SetReadOnly( sal_True );
+ m_aTable.SetBackground( Wallpaper( rNewColor ) );
+ m_aTable.SetControlBackground( rNewColor );
+
+ m_aAdministrateDatasources.Hide( );
+ }
+ }
+
+ // -------------------------------------------------------------------
+ void AddressBookSourceDialog::getFieldMapping(Sequence< AliasProgrammaticPair >& _rMapping) const
+ {
+ _rMapping.realloc( m_pImpl->aLogicalFieldNames.size() );
+ AliasProgrammaticPair* pPair = _rMapping.getArray();
+
+ ::rtl::OUString sCurrent;
+ for ( ConstStringArrayIterator aProgrammatic = m_pImpl->aLogicalFieldNames.begin();
+ aProgrammatic != m_pImpl->aLogicalFieldNames.end();
+ ++aProgrammatic
+ )
+ {
+ sCurrent = *aProgrammatic;
+ if ( m_pImpl->pConfigData->hasFieldAssignment( sCurrent ) )
+ {
+ // the user gave us an assignment for this field
+ pPair->ProgrammaticName = *aProgrammatic;
+ pPair->Alias = m_pImpl->pConfigData->getFieldAssignment( *aProgrammatic );
+ ++pPair;
+ }
+ }
+
+ _rMapping.realloc( pPair - _rMapping.getArray() );
+ }
+
+ // -------------------------------------------------------------------
+ void AddressBookSourceDialog::loadConfiguration()
+ {
+ ::rtl::OUString sName = m_pImpl->pConfigData->getDatasourceName();
+ INetURLObject aURL( sName );
+ if( aURL.GetProtocol() != INET_PROT_NOT_VALID )
+ {
+ OFileNotation aFileNotation( aURL.GetMainURL( INetURLObject::NO_DECODE ) );
+ sName = aFileNotation.get(OFileNotation::N_SYSTEM);
+ }
+
+ m_aDatasource.SetText(sName);
+ m_aTable.SetText(m_pImpl->pConfigData->getCommand());
+ // we ignore the CommandType: only tables are supported
+
+ // the logical names for the fields
+ DBG_ASSERT(m_pImpl->aLogicalFieldNames.size() == m_pImpl->aFieldAssignments.size(),
+ "AddressBookSourceDialog::loadConfiguration: inconsistence between field names and field assignments!");
+
+ ConstStringArrayIterator aLogical = m_pImpl->aLogicalFieldNames.begin();
+ StringArrayIterator aAssignment = m_pImpl->aFieldAssignments.begin();
+ for ( ;
+ aLogical < m_pImpl->aLogicalFieldNames.end();
+ ++aLogical, ++aAssignment
+ )
+ *aAssignment = m_pImpl->pConfigData->getFieldAssignment(*aLogical);
+ }
+
+ // -------------------------------------------------------------------
+ AddressBookSourceDialog::~AddressBookSourceDialog()
+ {
+ sal_Int32 i;
+ for (i=0; i<FIELD_CONTROLS_VISIBLE; ++i)
+ {
+ delete m_pImpl->pFieldLabels[i];
+ delete m_pImpl->pFields[i];
+ }
+
+ delete m_pImpl;
+ }
+
+ // -------------------------------------------------------------------
+ void AddressBookSourceDialog::initializeDatasources()
+ {
+ if (!m_xDatabaseContext.is())
+ {
+ DBG_ASSERT(m_xORB.is(), "AddressBookSourceDialog::initializeDatasources: no service factory!");
+ if (!m_xORB.is())
+ return;
+
+ const String sContextServiceName = String::CreateFromAscii("com.sun.star.sdb.DatabaseContext");
+ try
+ {
+ m_xDatabaseContext = Reference< XNameAccess >(m_xORB->createInstance(sContextServiceName), UNO_QUERY);
+ }
+ catch(Exception&) { }
+ if (!m_xDatabaseContext.is())
+ {
+ ShowServiceNotAvailableError( this, sContextServiceName, sal_False);
+ return;
+ }
+ }
+ m_aDatasource.Clear();
+
+ // fill the datasources listbox
+ Sequence< ::rtl::OUString > aDatasourceNames;
+ try
+ {
+ aDatasourceNames = m_xDatabaseContext->getElementNames();
+ }
+ catch(Exception&)
+ {
+ DBG_ERROR("AddressBookSourceDialog::initializeDatasources: caught an exception while asking for the data source names!");
+ }
+ const ::rtl::OUString* pDatasourceNames = aDatasourceNames.getConstArray();
+ const ::rtl::OUString* pEnd = pDatasourceNames + aDatasourceNames.getLength();
+ for (; pDatasourceNames < pEnd; ++pDatasourceNames)
+ m_aDatasource.InsertEntry(*pDatasourceNames);
+ }
+
+ // -------------------------------------------------------------------
+ IMPL_LINK(AddressBookSourceDialog, OnFieldScroll, ScrollBar*, _pScrollBar)
+ {
+ implScrollFields( _pScrollBar->GetThumbPos(), sal_True, sal_True );
+ return 0L;
+ }
+
+ // -------------------------------------------------------------------
+ void AddressBookSourceDialog::resetTables()
+ {
+ if (!m_xDatabaseContext.is())
+ return;
+
+ WaitObject aWaitCursor(this);
+
+ // no matter what we do here, we handled the currently selected data source (no matter if successfull or not)
+ m_aDatasource.SaveValue();
+
+ // create an interaction handler (may be needed for connecting)
+ const String sInteractionHandlerServiceName = String::CreateFromAscii("com.sun.star.sdb.InteractionHandler");
+ Reference< XInteractionHandler > xHandler;
+ try
+ {
+ xHandler = Reference< XInteractionHandler >(m_xORB->createInstance(sInteractionHandlerServiceName), UNO_QUERY);
+ }
+ catch(Exception&) { }
+ if (!xHandler.is())
+ {
+ ShowServiceNotAvailableError(this, sInteractionHandlerServiceName, sal_True);
+ return;
+ }
+
+ // the currently selected table
+ ::rtl::OUString sOldTable = m_aTable.GetText();
+
+ m_aTable.Clear();
+
+ m_xCurrentDatasourceTables= NULL;
+
+ // get the tables of the connection
+ Sequence< ::rtl::OUString > aTableNames;
+ Any aException;
+ try
+ {
+ Reference< XCompletedConnection > xDS;
+ if ( m_pImpl->bWorkingPersistent )
+ {
+ String sSelectedDS = m_aDatasource.GetText();
+ OFileNotation aFileNotation( sSelectedDS ,OFileNotation::N_SYSTEM);
+ sSelectedDS = aFileNotation.get(OFileNotation::N_URL);
+
+ // get the data source the user has chosen and let it build a connection
+ INetURLObject aURL( sSelectedDS );
+ if ( aURL.GetProtocol() != INET_PROT_NOT_VALID || m_xDatabaseContext->hasByName(sSelectedDS) )
+ m_xDatabaseContext->getByName( sSelectedDS ) >>= xDS;
+ }
+ else
+ {
+ xDS = xDS.query( m_pImpl->m_xTransientDataSource );
+ }
+
+ // build the connection
+ Reference< XConnection > xConn;
+ if (xDS.is())
+ xConn = xDS->connectWithCompletion(xHandler);
+
+ // get the table names
+ Reference< XTablesSupplier > xSupplTables(xConn, UNO_QUERY);
+ if (xSupplTables.is())
+ {
+ m_xCurrentDatasourceTables = Reference< XNameAccess >(xSupplTables->getTables(), UNO_QUERY);
+ if (m_xCurrentDatasourceTables.is())
+ aTableNames = m_xCurrentDatasourceTables->getElementNames();
+ }
+ }
+ catch(SQLContext& e) { aException <<= e; }
+ catch(SQLWarning& e) { aException <<= e; }
+ catch(SQLException& e) { aException <<= e; }
+ catch(Exception&)
+ {
+ DBG_ERROR("AddressBookSourceDialog::resetTables: could not retrieve the table!");
+ }
+
+ if (aException.hasValue())
+ {
+ Reference< XInteractionRequest > xRequest = new OInteractionRequest(aException);
+ try
+ {
+ xHandler->handle(xRequest);
+ }
+ catch(Exception&) { }
+ return;
+ }
+
+ sal_Bool bKnowOldTable = sal_False;
+ // fill the table list
+ const ::rtl::OUString* pTableNames = aTableNames.getConstArray();
+ const ::rtl::OUString* pEnd = pTableNames + aTableNames.getLength();
+ for (;pTableNames != pEnd; ++pTableNames)
+ {
+ m_aTable.InsertEntry(*pTableNames);
+ if (0 == pTableNames->compareTo(sOldTable))
+ bKnowOldTable = sal_True;
+ }
+
+ // set the old table, if the new data source knows a table with this name, too. Else reset the tables edit field.
+ if (!bKnowOldTable)
+ sOldTable = ::rtl::OUString();
+ m_aTable.SetText(sOldTable);
+
+ resetFields();
+ }
+
+ // -------------------------------------------------------------------
+ void AddressBookSourceDialog::resetFields()
+ {
+ WaitObject aWaitCursor(this);
+
+ // no matter what we do here, we handled the currently selected table (no matter if successfull or not)
+ m_aDatasource.SaveValue();
+
+ String sSelectedTable = m_aTable.GetText();
+ Sequence< ::rtl::OUString > aColumnNames;
+ try
+ {
+ if (m_xCurrentDatasourceTables.is())
+ {
+ // get the table and the columns
+ Reference< XColumnsSupplier > xSuppTableCols;
+ if (m_xCurrentDatasourceTables->hasByName(sSelectedTable))
+ ::cppu::extractInterface(xSuppTableCols, m_xCurrentDatasourceTables->getByName(sSelectedTable));
+ Reference< XNameAccess > xColumns;
+ if (xSuppTableCols.is())
+ xColumns = xSuppTableCols->getColumns();
+ if (xColumns.is())
+ aColumnNames = xColumns->getElementNames();
+ }
+ }
+ catch(Exception&)
+ {
+ DBG_ERROR("AddressBookSourceDialog::resetFields: could not retrieve the table columns!");
+ }
+
+
+ const ::rtl::OUString* pColumnNames = aColumnNames.getConstArray();
+ const ::rtl::OUString* pEnd = pColumnNames + aColumnNames.getLength();
+
+ // for quicker access
+ ::std::set< String > aColumnNameSet;
+ for (pColumnNames = aColumnNames.getConstArray(); pColumnNames != pEnd; ++pColumnNames)
+ aColumnNameSet.insert(*pColumnNames);
+
+ std::vector<String>::iterator aInitialSelection = m_pImpl->aFieldAssignments.begin() + m_pImpl->nFieldScrollPos;
+
+ ListBox** pListbox = m_pImpl->pFields;
+ String sSaveSelection;
+ for (sal_Int32 i=0; i<FIELD_CONTROLS_VISIBLE; ++i, ++pListbox, ++aInitialSelection)
+ {
+ sSaveSelection = (*pListbox)->GetSelectEntry();
+
+ (*pListbox)->Clear();
+
+ // the one entry for "no selection"
+ (*pListbox)->InsertEntry(m_sNoFieldSelection, 0);
+ // as it's entry data, set the index of the list box in our array
+ (*pListbox)->SetEntryData(0, reinterpret_cast<void*>(i));
+
+ // the field names
+ for (pColumnNames = aColumnNames.getConstArray(); pColumnNames != pEnd; ++pColumnNames)
+ (*pListbox)->InsertEntry(*pColumnNames);
+
+ if (aInitialSelection->Len() && (aColumnNameSet.end() != aColumnNameSet.find(*aInitialSelection)))
+ // we can select the entry as specified in our field assignment array
+ (*pListbox)->SelectEntry(*aInitialSelection);
+ else
+ // try to restore the selection
+ if (aColumnNameSet.end() != aColumnNameSet.find(sSaveSelection))
+ // the old selection is a valid column name
+ (*pListbox)->SelectEntry(sSaveSelection);
+ else
+ // select the <none> entry
+ (*pListbox)->SelectEntryPos(0);
+ }
+
+ // adjust m_pImpl->aFieldAssignments
+ for ( StringArrayIterator aAdjust = m_pImpl->aFieldAssignments.begin();
+ aAdjust != m_pImpl->aFieldAssignments.end();
+ ++aAdjust
+ )
+ if (aAdjust->Len())
+ if (aColumnNameSet.end() == aColumnNameSet.find(*aAdjust))
+ aAdjust->Erase();
+ }
+
+ // -------------------------------------------------------------------
+ IMPL_LINK(AddressBookSourceDialog, OnFieldSelect, ListBox*, _pListbox)
+ {
+ // the index of the affected list box in our array
+ sal_IntPtr nListBoxIndex = reinterpret_cast<sal_IntPtr>(_pListbox->GetEntryData(0));
+ DBG_ASSERT(nListBoxIndex >= 0 && nListBoxIndex < FIELD_CONTROLS_VISIBLE,
+ "AddressBookSourceDialog::OnFieldScroll: invalid list box entry!");
+
+ // update the array where we remember the field selections
+ if (0 == _pListbox->GetSelectEntryPos())
+ // it's the "no field selection" entry
+ m_pImpl->aFieldAssignments[m_pImpl->nFieldScrollPos * 2 + nListBoxIndex] = String();
+ else
+ // it's a regular field entry
+ m_pImpl->aFieldAssignments[m_pImpl->nFieldScrollPos * 2 + nListBoxIndex] = _pListbox->GetSelectEntry();
+
+ return 0L;
+ }
+
+ // -------------------------------------------------------------------
+ void AddressBookSourceDialog::implScrollFields(sal_Int32 _nPos, sal_Bool _bAdjustFocus, sal_Bool _bAdjustScrollbar)
+ {
+ if (_nPos == m_pImpl->nFieldScrollPos)
+ // nothing to do
+ return;
+
+ // loop through our field control rows and do some adjustments
+ // for the new texts
+ FixedText** pLeftLabelControl = m_pImpl->pFieldLabels;
+ FixedText** pRightLabelControl = pLeftLabelControl + 1;
+ ConstStringArrayIterator pLeftColumnLabel = m_pImpl->aFieldLabels.begin() + 2 * _nPos;
+ ConstStringArrayIterator pRightColumnLabel = pLeftColumnLabel + 1;
+
+ // for the focus movement and the selection scroll
+ ListBox** pLeftListControl = m_pImpl->pFields;
+ ListBox** pRightListControl = pLeftListControl + 1;
+
+ // for the focus movement
+ sal_Int32 nOldFocusRow = -1;
+ sal_Int32 nOldFocusColumn = 0;
+
+ // for the selection scroll
+ ConstStringArrayIterator pLeftAssignment = m_pImpl->aFieldAssignments.begin() + 2 * _nPos;
+ ConstStringArrayIterator pRightAssignment = pLeftAssignment + 1;
+
+ m_pImpl->nLastVisibleListIndex = -1;
+ // loop
+ for (sal_Int32 i=0; i<FIELD_PAIRS_VISIBLE; ++i)
+ {
+ if ((*pLeftListControl)->HasChildPathFocus())
+ {
+ nOldFocusRow = i;
+ nOldFocusColumn = 0;
+ }
+ else if ((*pRightListControl)->HasChildPathFocus())
+ {
+ nOldFocusRow = i;
+ nOldFocusColumn = 1;
+ }
+
+ // the new texts of the label controls
+ (*pLeftLabelControl)->SetText(*pLeftColumnLabel);
+ (*pRightLabelControl)->SetText(*pRightColumnLabel);
+
+ // we may have to hide the controls in the right column, if we have no label text for it
+ // (which means we have an odd number of fields, though we forced our internal arrays to
+ // be even-sized for easier handling)
+ // (If sometimes we support an arbitrary number of field assignments, we would have to care for
+ // an invisible left hand side column, too. But right now, the left hand side controls are always
+ // visible)
+ sal_Bool bHideRightColumn = (0 == pRightColumnLabel->Len());
+ (*pRightLabelControl)->Show(!bHideRightColumn);
+ (*pRightListControl)->Show(!bHideRightColumn);
+ // the new selections of the listboxes
+ implSelectField(*pLeftListControl, *pLeftAssignment);
+ implSelectField(*pRightListControl, *pRightAssignment);
+
+ // the index of the last visible list box
+ ++m_pImpl->nLastVisibleListIndex; // the left hand side box is always visible
+ if (!bHideRightColumn)
+ ++m_pImpl->nLastVisibleListIndex;
+
+ // increment ...
+ if ( i < FIELD_PAIRS_VISIBLE - 1 )
+ { // (not in the very last round, here the +=2 could result in an invalid
+ // iterator position, which causes an abort in a non-product version
+ pLeftLabelControl += 2;
+ pRightLabelControl += 2;
+ pLeftColumnLabel += 2;
+ pRightColumnLabel += 2;
+
+ pLeftListControl += 2;
+ pRightListControl += 2;
+ pLeftAssignment += 2;
+ pRightAssignment += 2;
+ }
+ }
+
+ if (_bAdjustFocus && (nOldFocusRow >= 0))
+ { // we have to adjust the focus and one of the list boxes has the focus
+ sal_Int32 nDelta = m_pImpl->nFieldScrollPos - _nPos;
+ // the new row for the focus
+ sal_Int32 nNewFocusRow = nOldFocusRow + nDelta;
+ // normalize
+ nNewFocusRow = std::min(nNewFocusRow, (sal_Int32)(FIELD_PAIRS_VISIBLE - 1), ::std::less< sal_Int32 >());
+ nNewFocusRow = std::max(nNewFocusRow, (sal_Int32)0, ::std::less< sal_Int32 >());
+ // set the new focus (in the same column)
+ m_pImpl->pFields[nNewFocusRow * 2 + nOldFocusColumn]->GrabFocus();
+ }
+
+ m_pImpl->nFieldScrollPos = _nPos;
+
+ if (_bAdjustScrollbar)
+ m_aFieldScroller.SetThumbPos(m_pImpl->nFieldScrollPos);
+ }
+
+ // -------------------------------------------------------------------
+ void AddressBookSourceDialog::implSelectField(ListBox* _pBox, const String& _rText)
+ {
+ if (_rText.Len())
+ // a valid field name
+ _pBox->SelectEntry(_rText);
+ else
+ // no selection for this item
+ _pBox->SelectEntryPos(0);
+ }
+
+ // -------------------------------------------------------------------
+ IMPL_LINK(AddressBookSourceDialog, OnDelayedInitialize, void*, EMPTYARG)
+ {
+ // load the initial data from the configuration
+ loadConfiguration();
+ resetTables();
+ // will reset the tables/fields implicitly
+
+ if ( !m_pImpl->bWorkingPersistent )
+ if ( m_pImpl->pFields[0] )
+ m_pImpl->pFields[0]->GrabFocus();
+
+ return 0L;
+ }
+
+ // -------------------------------------------------------------------
+ IMPL_LINK(AddressBookSourceDialog, OnComboSelect, ComboBox*, _pBox)
+ {
+ if (_pBox == &m_aDatasource)
+ resetTables();
+ else
+ resetFields();
+ return 0;
+ }
+
+ // -------------------------------------------------------------------
+ IMPL_LINK(AddressBookSourceDialog, OnComboGetFocus, ComboBox*, _pBox)
+ {
+ _pBox->SaveValue();
+ return 0L;
+ }
+
+ // -------------------------------------------------------------------
+ IMPL_LINK(AddressBookSourceDialog, OnComboLoseFocus, ComboBox*, _pBox)
+ {
+ if (_pBox->GetSavedValue() != _pBox->GetText())
+ {
+ if (_pBox == &m_aDatasource)
+ resetTables();
+ else
+ resetFields();
+ }
+ return 0L;
+ }
+
+ // -------------------------------------------------------------------
+ IMPL_LINK(AddressBookSourceDialog, OnOkClicked, Button*, EMPTYARG)
+ {
+ String sSelectedDS = m_aDatasource.GetText();
+ OFileNotation aFileNotation( sSelectedDS ,OFileNotation::N_SYSTEM);
+ sSelectedDS = aFileNotation.get(OFileNotation::N_URL);
+ if ( m_pImpl->bWorkingPersistent )
+ {
+ m_pImpl->pConfigData->setDatasourceName(sSelectedDS);
+ m_pImpl->pConfigData->setCommand(m_aTable.GetText());
+ }
+
+ // set the field assignments
+ ConstStringArrayIterator aLogical = m_pImpl->aLogicalFieldNames.begin();
+ ConstStringArrayIterator aAssignment = m_pImpl->aFieldAssignments.begin();
+ for ( ;
+ aLogical < m_pImpl->aLogicalFieldNames.end();
+ ++aLogical, ++aAssignment
+ )
+ m_pImpl->pConfigData->setFieldAssignment(*aLogical, *aAssignment);
+
+
+ EndDialog(RET_OK);
+ return 0L;
+ }
+
+ // -------------------------------------------------------------------
+ IMPL_LINK(AddressBookSourceDialog, OnAdministrateDatasources, void*, EMPTYARG)
+ {
+ // collect some initial arguments for the dialog
+ Sequence< Any > aArgs(1);
+ aArgs[0] <<= PropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ParentWindow")), 0, makeAny(VCLUnoHelper::GetInterface(this)), PropertyState_DIRECT_VALUE);
+
+ // create the dialog object
+ const String sDialogServiceName = String::CreateFromAscii("com.sun.star.ui.dialogs.AddressBookSourcePilot");
+ Reference< XExecutableDialog > xAdminDialog;
+ try
+ {
+ xAdminDialog = Reference< XExecutableDialog >(m_xORB->createInstanceWithArguments(sDialogServiceName, aArgs), UNO_QUERY);
+ }
+ catch(Exception&) { }
+ if (!xAdminDialog.is())
+ {
+ ShowServiceNotAvailableError(this, sDialogServiceName, sal_True);
+ return 1L;
+ }
+
+ // excute the dialog
+ try
+ {
+ if ( xAdminDialog->execute() == RET_OK )
+ {
+ Reference<XPropertySet> xProp(xAdminDialog,UNO_QUERY);
+ if ( xProp.is() )
+ {
+ String sOldDS = m_aDatasource.GetText();
+ ::rtl::OUString sName;
+ xProp->getPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DataSourceName"))) >>= sName;
+
+ INetURLObject aURL( sName );
+ if( aURL.GetProtocol() != INET_PROT_NOT_VALID )
+ {
+ OFileNotation aFileNotation( aURL.GetMainURL( INetURLObject::NO_DECODE ) );
+ sName = aFileNotation.get(OFileNotation::N_SYSTEM);
+ }
+ m_aDatasource.InsertEntry(sName);
+ delete m_pImpl->pConfigData;
+ m_pImpl->pConfigData = new AssignmentPersistentData();
+ loadConfiguration();
+ resetTables();
+ // will reset the fields implicitly
+ }
+ }
+ }
+ catch(Exception&)
+ {
+ DBG_ERROR("AddressBookSourceDialog::OnAdministrateDatasources: an error occured while executing the administration dialog!");
+ }
+
+ // re-fill the data source list
+ // try to preserve the current selection
+
+// initializeDatasources();
+
+ return 0L;
+ }
+
+ // -------------------------------------------------------------------
+ long AddressBookSourceDialog::PreNotify( NotifyEvent& _rNEvt )
+ {
+ switch (_rNEvt.GetType())
+ {
+ case EVENT_KEYINPUT:
+ {
+ const KeyEvent* pKeyEvent = _rNEvt.GetKeyEvent();
+ sal_uInt16 nCode = pKeyEvent->GetKeyCode().GetCode();
+ sal_Bool bShift = pKeyEvent->GetKeyCode().IsShift();
+ sal_Bool bCtrl = pKeyEvent->GetKeyCode().IsMod1();
+ sal_Bool bAlt = pKeyEvent->GetKeyCode().IsMod2();
+
+ if (KEY_TAB == nCode)
+ { // somebody pressed the tab key
+ if (!bAlt && !bCtrl && !bShift)
+ { // it's really the only the key (no modifiers)
+ if (m_pImpl->pFields[m_pImpl->nLastVisibleListIndex]->HasChildPathFocus())
+ // the last of our visible list boxes has the focus
+ if (m_pImpl->nFieldScrollPos < m_aFieldScroller.GetRangeMax())
+ { // we can still scroll down
+ sal_Int32 nNextFocusList = m_pImpl->nLastVisibleListIndex + 1 - 2;
+ // -> scroll down
+ implScrollFields(m_pImpl->nFieldScrollPos + 1, sal_False, sal_True);
+ // give the left control in the "next" line the focus
+ m_pImpl->pFields[nNextFocusList]->GrabFocus();
+ // return saying "have handled this"
+ return 1;
+ }
+ }
+ else if (!bAlt && !bCtrl && bShift)
+ { // it's shift-tab
+ if (m_pImpl->pFields[0]->HasChildPathFocus())
+ // our first list box has the focus
+ if (m_pImpl->nFieldScrollPos > 0)
+ { // we can still scroll up
+ // -> scroll up
+ implScrollFields(m_pImpl->nFieldScrollPos - 1, sal_False, sal_True);
+ // give the right control in the "prebious" line the focus
+ m_pImpl->pFields[0 - 1 + 2]->GrabFocus();
+ // return saying "have handled this"
+ return 1;
+ }
+ }
+ }
+ }
+ break;
+ }
+ return ModalDialog::PreNotify(_rNEvt);
+ }
+
+// .......................................................................
+} // namespace svt
+// .......................................................................
+
diff --git a/svtools/source/dialogs/addresstemplate.hrc b/svtools/source/dialogs/addresstemplate.hrc
new file mode 100644
index 000000000000..8c4a6b9fbd27
--- /dev/null
+++ b/svtools/source/dialogs/addresstemplate.hrc
@@ -0,0 +1,91 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: addresstemplate.hrc,v $
+ * $Revision: 1.5 $
+ *
+ * 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 _SVT_ADDRESSTEMPLATE_HRC_
+#define _SVT_ADDRESSTEMPLATE_HRC_
+
+
+#define FIELD_PAIRS_VISIBLE 5
+#define FIELD_CONTROLS_VISIBLE 2 * FIELD_PAIRS_VISIBLE
+
+#define FL_DATASOURCEFRAME 1
+#define FT_DATASOURCE 2
+#define CB_DATASOURCE 3
+#define CT_BORDER 1
+#define PB_ADMINISTATE_DATASOURCES 4
+#define FT_TABLE 5
+#define CB_TABLE 6
+#define FT_FIELDS 7
+#define SB_FIELDSCROLLER 8
+#define PB_OK 9
+#define PB_CANCEL 10
+#define PB_HELP 11
+
+#define FT_FIELD_BASE 50
+#define LB_FIELD_BASE 50
+
+#define STR_NO_FIELD_SELECTION 1
+#define STR_FIELD_COMPANY 2
+#define STR_FIELD_DEPARTMENT 3
+#define STR_FIELD_FIRSTNAME 4
+#define STR_FIELD_LASTNAME 5
+#define STR_FIELD_STREET 6
+#define STR_FIELD_COUNTRY 7
+#define STR_FIELD_ZIPCODE 8
+#define STR_FIELD_CITY 9
+#define STR_FIELD_TITLE 10
+#define STR_FIELD_POSITION 11
+#define STR_FIELD_ADDRFORM 12
+#define STR_FIELD_INITIALS 13
+#define STR_FIELD_SALUTATION 14
+#define STR_FIELD_HOMETEL 15
+#define STR_FIELD_WORKTEL 16
+#define STR_FIELD_FAX 17
+#define STR_FIELD_EMAIL 18
+#define STR_FIELD_URL 19
+#define STR_FIELD_NOTE 20
+#define STR_FIELD_USER1 21
+#define STR_FIELD_USER2 22
+#define STR_FIELD_USER3 23
+#define STR_FIELD_USER4 24
+#define STR_FIELD_ID 25
+#define STR_FIELD_STATE 26
+#define STR_FIELD_OFFICETEL 27
+#define STR_FIELD_PAGER 28
+#define STR_FIELD_MOBILE 29
+#define STR_FIELD_TELOTHER 30
+#define STR_FIELD_CALENDAR 31
+#define STR_FIELD_INVITE 32
+
+#define STR_LOCAGICAL_FIELD_NAMES 33
+
+
+#endif // _SVT_ADDRESSTEMPLATE_HRC_
+
diff --git a/svtools/source/dialogs/addresstemplate.src b/svtools/source/dialogs/addresstemplate.src
new file mode 100644
index 000000000000..9c4997cae9d2
--- /dev/null
+++ b/svtools/source/dialogs/addresstemplate.src
@@ -0,0 +1,361 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: addresstemplate.src,v $
+ * $Revision: 1.55 $
+ *
+ * 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 _SVTOOLS_HRC
+#include <svtools/svtools.hrc>
+#endif
+#ifndef _SVT_ADDRESSTEMPLATE_HRC_
+#include "addresstemplate.hrc"
+#endif
+#ifndef _SVT_CONTROLDIMS_HRC_
+#include "controldims.hrc"
+#endif
+
+#define FIELD_ROW_HEIGHT 17
+
+ModalDialog DLG_ADDRESSBOOKSOURCE
+{
+ SVLook = TRUE ;
+ OutputSize = TRUE ;
+ Size = MAP_APPFONT ( 300 , 88 + FIELD_ROW_HEIGHT * FIELD_PAIRS_VISIBLE ) ;
+ Hide = TRUE ;
+ Moveable = TRUE ;
+ Text [ en-US ] = "Templates: Address Book Assignment";
+
+ FixedLine FL_DATASOURCEFRAME
+ {
+ Text [ en-US ] = "Address Book Source";
+ SVLook = TRUE ;
+ Pos = MAP_APPFONT ( 6 , 2 ) ;
+ Size = MAP_APPFONT ( 288 , RSC_CD_FIXEDLINE_HEIGHT ) ;
+ };
+ FixedText FT_DATASOURCE
+ {
+ Text [ en-US ] = "Data source";
+ SVLook = TRUE ;
+ Pos = MAP_APPFONT ( 12 , 15 ) ;
+ Size = MAP_APPFONT ( 90 , 10 ) ;
+
+ Group = TRUE;
+ };
+ ComboBox CB_DATASOURCE
+ {
+ SVLook = TRUE ;
+ Pos = MAP_APPFONT ( 105, 13 ) ;
+ Size = MAP_APPFONT ( 96, 55 ) ;
+
+ DropDown = TRUE;
+ TabStop = TRUE;
+ };
+ PushButton PB_ADMINISTATE_DATASOURCES
+ {
+ Text [ en-US ] = "~Address Data Source...";
+ SVLook = TRUE ;
+ Pos = MAP_APPFONT ( 204, 13 ) ;
+ Size = MAP_APPFONT ( 90, 14 ) ;
+ TabStop = TRUE;
+ };
+ FixedText FT_TABLE
+ {
+ Text [ en-US ] = "Table";
+ SVLook = TRUE ;
+ Pos = MAP_APPFONT ( 12 , 32 ) ;
+ Size = MAP_APPFONT ( 90 , 10 ) ;
+
+ Group = TRUE;
+ };
+ ComboBox CB_TABLE
+ {
+ SVLook = TRUE ;
+ Pos = MAP_APPFONT ( 105, 30 ) ;
+ Size = MAP_APPFONT ( 96, 55 ) ;
+
+ DropDown = TRUE;
+ TabStop = TRUE;
+ };
+ FixedText FT_FIELDS
+ {
+ Text [ en-US ] = "Field assignment";
+ SVLook = TRUE ;
+ Pos = MAP_APPFONT ( 6, 30 + RSC_CD_DROPDOWN_HEIGHT + RSC_SP_CTRL_Y ) ;
+ Size = MAP_APPFONT ( 248 , RSC_CD_FIXEDTEXT_HEIGHT ) ;
+ };
+ Window CT_BORDER
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 6, 30 + RSC_CD_DROPDOWN_HEIGHT + RSC_SP_CTRL_Y + RSC_CD_FIXEDTEXT_HEIGHT + RSC_SP_CTRL_DESC_Y ) ;
+ Size = MAP_APPFONT ( 288 , 5 + FIELD_ROW_HEIGHT * FIELD_PAIRS_VISIBLE ) ;
+ };
+
+#define DECLARE_FIELD( row, column ) \
+ FixedText FT_FIELD_BASE + row * 2 + column \
+ { \
+ SVLook = TRUE ; \
+ Pos = MAP_APPFONT ( 3 + column * 134, RSC_SP_CTRL_GROUP_Y + 2 + row * FIELD_ROW_HEIGHT ) ; \
+ Size = MAP_APPFONT ( 79 , 10 ) ; \
+ Group = TRUE; \
+ }; \
+ ListBox LB_FIELD_BASE + row * 2 + column \
+ { \
+ SVLook = TRUE; \
+ Pos = MAP_APPFONT ( 89 + column * 134, RSC_SP_CTRL_GROUP_Y + row * FIELD_ROW_HEIGHT ) ; \
+ Size = MAP_APPFONT ( 42 , 14 ) ; \
+ Border = TRUE; \
+ DropDown = TRUE; \
+ TabStop = TRUE; \
+ }
+
+#if FIELD_PAIRS_VISIBLE > 0
+ DECLARE_FIELD( 0, 0 );
+ DECLARE_FIELD( 0, 1 );
+#endif
+#if FIELD_PAIRS_VISIBLE > 1
+ DECLARE_FIELD( 1, 0 );
+ DECLARE_FIELD( 1, 1 );
+#endif
+#if FIELD_PAIRS_VISIBLE > 2
+ DECLARE_FIELD( 3, 0 );
+ DECLARE_FIELD( 3, 1 );
+#endif
+#if FIELD_PAIRS_VISIBLE > 3
+ DECLARE_FIELD( 2, 0 );
+ DECLARE_FIELD( 2, 1 );
+#endif
+#if FIELD_PAIRS_VISIBLE > 4
+ DECLARE_FIELD( 4, 0 );
+ DECLARE_FIELD( 4, 1 );
+#endif
+#if FIELD_PAIRS_VISIBLE > 5
+ DECLARE_FIELD( 5, 0 );
+ DECLARE_FIELD( 5, 1 );
+#endif
+
+ ScrollBar SB_FIELDSCROLLER
+ {
+ SVLook = TRUE;
+ Pos = MAP_APPFONT ( 275, RSC_SP_CTRL_GROUP_Y ) ;
+ Size = MAP_APPFONT ( 8 , 16 - RSC_SP_CTRL_GROUP_Y + FIELD_ROW_HEIGHT * (FIELD_PAIRS_VISIBLE - 1) ) ;
+ };
+
+ OKButton PB_OK
+ {
+ SVLook = TRUE;
+ DefButton = TRUE;
+ Pos = MAP_APPFONT ( 137, 70 + FIELD_ROW_HEIGHT * FIELD_PAIRS_VISIBLE ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ };
+
+ CancelButton PB_CANCEL
+ {
+ SVLook = TRUE;
+ Pos = MAP_APPFONT ( 190, 70 + FIELD_ROW_HEIGHT * FIELD_PAIRS_VISIBLE ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ };
+
+ HelpButton PB_HELP
+ {
+ SVLook = TRUE;
+ Pos = MAP_APPFONT ( 244, 70 + FIELD_ROW_HEIGHT * FIELD_PAIRS_VISIBLE ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ };
+
+ String STR_LOCAGICAL_FIELD_NAMES
+ {
+ Text = "FirstName;LastName;Company;Department;Street;Zip;City;State;Country;PhonePriv;PhoneComp;PhoneOffice;PhoneCell;PhoneOther;Pager;Fax;EMail;URL;Title;Position;Code;AddrForm;AddrFormMail;Id;CalendarURL;InviteParticipant;Note;Altfield1;Altfield2;Altfield3;Altfield4";
+ // no need to translate this
+ // the items in this string have to be in the same order as the STR_FIELD_* strings are added to the
+ // field label list of the dialog
+ };
+
+ String STR_NO_FIELD_SELECTION
+ {
+ Text [ en-US ] = "<none>";
+ };
+
+ String STR_FIELD_COMPANY
+ {
+ Text [ en-US ] = "Company";
+ };
+ String STR_FIELD_DEPARTMENT
+ {
+ Text [ en-US ] = "Department";
+ };
+ String STR_FIELD_FIRSTNAME
+ {
+ Text [ en-US ] = "First name";
+ };
+ String STR_FIELD_LASTNAME
+ {
+ Text [ en-US ] = "Last name";
+ };
+ String STR_FIELD_STREET
+ {
+ Text [ en-US ] = "Street";
+ };
+ String STR_FIELD_COUNTRY
+ {
+ Text [ en-US ] = "Country";
+ };
+ String STR_FIELD_ZIPCODE
+ {
+ Text [ en-US ] = "ZIP Code";
+ };
+ String STR_FIELD_CITY
+ {
+ Text [ en-US ] = "City";
+ };
+ String STR_FIELD_TITLE
+ {
+ Text [ en-US ] = "Title";
+ };
+ String STR_FIELD_POSITION
+ {
+ Text [ en-US ] = "Position";
+ };
+ String STR_FIELD_ADDRFORM
+ {
+ Text [ en-US ] = "Addr. Form";
+ };
+ String STR_FIELD_INITIALS
+ {
+ Text [ en-US ] = "Initials";
+ };
+ String STR_FIELD_SALUTATION
+ {
+ Text [ en-US ] = "Complimentary close";
+ };
+ String STR_FIELD_HOMETEL
+ {
+ Text [ en-US ] = "Tel: Home";
+ };
+ String STR_FIELD_WORKTEL
+ {
+ Text [ en-US ] = "Tel: Work";
+ };
+ String STR_FIELD_FAX
+ {
+ Text [ en-US ] = "FAX";
+ };
+ String STR_FIELD_EMAIL
+ {
+ Text [ en-US ] = "E-mail";
+ };
+ String STR_FIELD_URL
+ {
+ Text [ en-US ] = "URL";
+ };
+ String STR_FIELD_NOTE
+ {
+ Text [ en-US ] = "Note";
+ };
+ String STR_FIELD_USER1
+ {
+ Text [ en-US ] = "User 1";
+ };
+ String STR_FIELD_USER2
+ {
+ Text [ en-US ] = "User 2";
+ };
+ String STR_FIELD_USER3
+ {
+ Text [ en-US ] = "User 3";
+ };
+ String STR_FIELD_USER4
+ {
+ Text [ en-US ] = "User 4";
+ };
+
+ String STR_FIELD_ID
+ {
+ Text [ en-US ] = "ID";
+ };
+ String STR_FIELD_STATE
+ {
+ Text [ en-US ] = "State";
+ };
+ String STR_FIELD_OFFICETEL
+ {
+ Text [ en-US ] = "Tel: Office";
+ };
+ String STR_FIELD_PAGER
+ {
+ Text [ en-US ] = "Pager";
+ };
+ String STR_FIELD_MOBILE
+ {
+ Text [ en-US ] = "Mobile";
+ };
+ String STR_FIELD_TELOTHER
+ {
+ Text [ en-US ] = "Tel: Other";
+ };
+ String STR_FIELD_CALENDAR
+ {
+ Text [ en-US ] = "Calendar";
+ };
+ String STR_FIELD_INVITE
+ {
+ Text [ en-US ] = "Invite";
+ };
+};
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/svtools/source/dialogs/colctrl.cxx b/svtools/source/dialogs/colctrl.cxx
new file mode 100644
index 000000000000..06fb689cd2ce
--- /dev/null
+++ b/svtools/source/dialogs/colctrl.cxx
@@ -0,0 +1,693 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: colctrl.cxx,v $
+ * $Revision: 1.10 $
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_svtools.hxx"
+
+
+#include <vcl/salbtype.hxx>
+#include <vcl/bmpacc.hxx>
+
+#include <svtools/colctrl.hxx>
+
+// ----------------
+// - ColorControl -
+// ----------------
+
+SvColorControl::SvColorControl( Window* pParent, WinBits nStyle ) :
+ Control ( pParent, nStyle ),
+ mpBitmap ( NULL ),
+ mpReadAccess ( NULL ),
+ mnLuminance ( 50 )
+{
+ Initialize();
+}
+
+// -----------------------------------------------------------------------
+SvColorControl::SvColorControl( Window* pParent, const ResId& rResId ) :
+ Control ( pParent, rResId ),
+ mpBitmap ( NULL ),
+ mpReadAccess ( NULL ),
+ mnLuminance ( 50 )
+{
+ Initialize();
+}
+
+
+// -----------------------------------------------------------------------
+SvColorControl::~SvColorControl()
+{
+ delete mpBitmap;
+}
+
+// -----------------------------------------------------------------------
+void SvColorControl::Initialize()
+{
+ SetLineColor( Color( COL_BLACK ) );
+}
+
+// -----------------------------------------------------------------------
+void SvColorControl::CreateBitmap()
+{
+ const Size aSize( GetOutputSizePixel() );
+
+ if( mpBitmap && mpBitmap->GetSizePixel() != aSize )
+ delete mpBitmap, mpBitmap = NULL;
+
+ if( !mpBitmap )
+ mpBitmap = new Bitmap( aSize, 24 );
+
+ BitmapWriteAccess* pWriteAccess = mpBitmap->AcquireWriteAccess();
+
+ if( pWriteAccess )
+ {
+ USHORT nX = (USHORT) aSize.Width();
+ USHORT nY = (USHORT) aSize.Height();
+
+ UINT16 nHue, nSat;
+ ColorHSB aColHSB( 0, 0, mnLuminance );
+
+ for( USHORT i = 0; i < nY; i++ )
+ {
+ nSat = (UINT16) FRound( 100 - ( 100.0 * i + 0.5 ) / nY );
+
+ for( USHORT j = 0; j < nX; j++ )
+ {
+ nHue = (UINT16) FRound( ( 360.0 * j + 0.5 ) / nX );
+
+ aColHSB.SetHue( nHue );
+ aColHSB.SetSat( nSat );
+
+ // mpBitmap always has a bit count of 24 => use of SetPixel(...) is safe
+ pWriteAccess->SetPixel( i, j, BitmapColor( aColHSB.GetRGB() ) );
+ }
+ }
+
+ mpBitmap->ReleaseAccess( pWriteAccess );
+ }
+
+ SetColor( maColor );
+}
+
+// -----------------------------------------------------------------------
+void SvColorControl::ShowPosition( const Point& rPos )
+{
+ // Explizites Abfragen des Bereichs, da schon mal ein Wert < 0 vorhanden ist
+ if( mpBitmap )
+ {
+ long nX = rPos.X();
+ long nY = rPos.Y();
+ if( nX < 0L )
+ nX = 0L;
+ else if( nX >= mpBitmap->GetSizePixel().Width() )
+ nX = mpBitmap->GetSizePixel().Width() - 1L;
+
+ if( nY < 0L )
+ nY= 0L;
+ else if( nY >= mpBitmap->GetSizePixel().Height() )
+ nY = mpBitmap->GetSizePixel().Height() - 1L;
+
+ Point aPos = maPosition;
+ maPosition.X() = nX - 2;
+ maPosition.Y() = nY - 2;
+ Invalidate( Rectangle( aPos, Size( 5, 5) ) );
+ Invalidate( Rectangle( maPosition, Size( 5, 5) ) );
+
+ if( ( mpReadAccess = mpBitmap->AcquireReadAccess() ) != NULL )
+ {
+ // mpBitmap always has a bit count of 24 => use of GetPixel(...) is safe
+ maColor = mpReadAccess->GetPixel( nY, nX );
+ mpBitmap->ReleaseAccess( mpReadAccess );
+ mpReadAccess = NULL;
+ }
+ }
+}
+// -----------------------------------------------------------------------
+void SvColorControl::MouseMove( const MouseEvent& rMEvt )
+{
+ if( rMEvt.IsLeft() )
+ {
+ ShowPosition( rMEvt.GetPosPixel() );
+ Modify();
+ }
+}
+
+// -----------------------------------------------------------------------
+void SvColorControl::MouseButtonDown( const MouseEvent& rMEvt )
+{
+ if( rMEvt.IsLeft() && !rMEvt.IsShift() )
+ {
+ //ShowPointer( FALSE );
+ CaptureMouse();
+ ShowPosition( rMEvt.GetPosPixel() );
+ Modify();
+ }
+}
+
+// -----------------------------------------------------------------------
+void SvColorControl::MouseButtonUp( const MouseEvent& )
+{
+ //ShowPointer( TRUE );
+ if( IsMouseCaptured() )
+ ReleaseMouse();
+}
+
+// -----------------------------------------------------------------------
+void SvColorControl::Paint( const Rectangle& rRect )
+{
+ if( !mpBitmap )
+ CreateBitmap();
+
+ Bitmap aOutputBitmap( *mpBitmap );
+
+ if( GetBitCount() <= 8 )
+ aOutputBitmap.Dither();
+
+ DrawBitmap( rRect.TopLeft(), rRect.GetSize(), rRect.TopLeft(), rRect.GetSize(), aOutputBitmap );
+
+ // Positions-Control (Fadenkreuz oder Aehnliches)
+ Point aPos1( maPosition );
+ Point aPos2( maPosition );
+ aPos2.X() += 4;
+ DrawLine( aPos1, aPos2 );
+ aPos2.X() -= 4;
+ aPos2.Y() += 4;
+ DrawLine( aPos1, aPos2 );
+ aPos1.Y() += 4;
+ aPos2.X() += 4;
+ DrawLine( aPos1, aPos2 );
+ aPos1.X() += 4;
+ aPos2.Y() -= 4;
+ DrawLine( aPos1, aPos2 );
+}
+
+// -----------------------------------------------------------------------
+void SvColorControl::Resize()
+{
+ CreateBitmap();
+ Control::Resize();
+}
+
+// -----------------------------------------------------------------------
+void SvColorControl::Modify()
+{
+ maModifyHdl.Call( this );
+}
+
+// -----------------------------------------------------------------------
+void SvColorControl::SetColor( const ColorHSB& rCol, BOOL bSetColor )
+{
+ if( bSetColor )
+ maColor = rCol.GetRGB();
+
+ if( mpBitmap )
+ {
+ USHORT nX = (USHORT) mpBitmap->GetSizePixel().Width();
+ USHORT nY = (USHORT) mpBitmap->GetSizePixel().Height();
+ INT16 nZ = rCol.GetBri();
+
+ SetLuminance( nZ );
+ nX = rCol.GetHue() * nX / 360; // Farbe
+ nY = nY - rCol.GetSat() * nY / 100; // Saettigung
+ ShowPosition( Point( nX, nY ) );
+ }
+}
+
+// -----------------------------------------------------------------------
+void SvColorControl::SetColor( const Color& rCol )
+{
+ maColor = rCol;
+
+ if( mpBitmap )
+ {
+ ColorHSB aColHsb( rCol );
+ SetColor( aColHsb, FALSE );
+ }
+}
+
+// -----------------------------------------------------------------------
+void SvColorControl::SetLuminance( short nLum )
+{
+ if( nLum != mnLuminance && nLum >= 0 && nLum <= 100 )
+ {
+ mnLuminance = nLum;
+
+ if( mnLuminance < 40 )
+ SetLineColor( Color( COL_WHITE ) );
+ else
+ SetLineColor( Color( COL_BLACK ) );
+
+ CreateBitmap();
+
+ long nX = maPosition.X() + 2;
+ long nY = maPosition.Y() + 2;
+
+ if( mpBitmap && ( ( mpReadAccess = mpBitmap->AcquireReadAccess() ) != NULL ) )
+ {
+ // mpBitmap always has a bit count of 24 => use of GetPixel(...) is safe
+ maColor = mpReadAccess->GetPixel( nY, nX );
+ mpBitmap->ReleaseAccess( mpReadAccess );
+ mpReadAccess = NULL;
+ }
+
+ Invalidate();
+ }
+}
+
+
+// -----------------------
+// - ColorPreviewControl -
+// -----------------------
+
+
+// -----------------------------------------------------------------------
+ColorPreviewControl::ColorPreviewControl( Window* pParent, WinBits nStyle ) :
+ Control ( pParent, nStyle )
+{
+ SetFillColor( maColor );
+ SetLineColor( maColor );
+}
+
+// -----------------------------------------------------------------------
+ColorPreviewControl::ColorPreviewControl( Window* pParent, const ResId& rResId ) :
+ Control ( pParent, rResId )
+{
+ SetFillColor( maColor );
+ SetLineColor( maColor );
+}
+
+
+// -----------------------------------------------------------------------
+ColorPreviewControl::~ColorPreviewControl()
+{
+}
+
+// -----------------------------------------------------------------------
+void ColorPreviewControl::Paint( const Rectangle& rRect )
+{
+ DrawRect( rRect );
+}
+
+// -----------------------------------------------------------------------
+void ColorPreviewControl::SetColor( const Color& rCol )
+{
+ if( rCol != maColor )
+ {
+ maColor = rCol;
+ SetFillColor( maColor );
+ SetLineColor( maColor );
+ Invalidate();
+ }
+}
+
+
+// -----------------------
+// - ColorMixingControl -
+// -----------------------
+
+
+// -----------------------------------------------------------------------
+ColorMixingControl::ColorMixingControl( Window* pParent, WinBits nStyle,
+ USHORT nRows, USHORT nColumns ) :
+ ValueSet ( pParent, nStyle ),
+ mnRows ( nRows ),
+ mnColumns ( nColumns )
+{
+ Initialize();
+}
+
+// -----------------------------------------------------------------------
+ColorMixingControl::ColorMixingControl( Window* pParent, const ResId& rResId,
+ USHORT nRows, USHORT nColumns ) :
+ ValueSet ( pParent, rResId ),
+ mnRows ( nRows ),
+ mnColumns ( nColumns )
+{
+ Initialize();
+}
+
+
+// -----------------------------------------------------------------------
+ColorMixingControl::~ColorMixingControl()
+{
+}
+
+// -----------------------------------------------------------------------
+void ColorMixingControl::Initialize()
+{
+ SetColCount( mnColumns );
+
+ Color aColor;
+ String aStr;
+ for( USHORT i = 1; i <= mnRows * mnColumns; i++ )
+ {
+ InsertItem( i, aColor, aStr );
+ }
+
+ /*maColor[ 0 ] = Color( COL_LIGHTRED );
+ maColor[ 1 ] = Color( COL_LIGHTGREEN );
+ maColor[ 2 ] = Color( COL_YELLOW );
+ maColor[ 3 ] = Color( COL_LIGHTBLUE );*/
+
+ SetColor( CMC_TOPLEFT, Color( COL_LIGHTRED ) );
+ SetColor( CMC_BOTTOMRIGHT, Color( COL_LIGHTBLUE ) );
+
+ SetColor( CMC_TOPRIGHT, Color( COL_LIGHTGREEN ) );
+ SetColor( CMC_BOTTOMLEFT, Color( COL_YELLOW ) );
+
+ /*FillColumn( 0 );
+ FillColumn( mnColumns - 1 );
+ for( i = 0; i < mnRows; i++ )
+ FillRow( i );*/
+}
+
+// -----------------------------------------------------------------------
+Color ColorMixingControl::CalcDifferenceColor( USHORT nCol1, USHORT nCol2,
+ USHORT nSteps )
+{
+ // Die Berechnung ist noch etwas ungenau, daher sollte besser mit floats
+ // gearbeitet werden... (muss !!!)
+ Color aColor( GetItemColor( nCol1 ) );
+ Color aColor2( GetItemColor( nCol2 ) );
+
+ aColor.SetRed( (UINT8) ( ( aColor2.GetRed() - aColor.GetRed() ) / nSteps ) );
+ aColor.SetGreen( (UINT8) ( ( aColor2.GetGreen() - aColor.GetGreen() ) / nSteps ) );
+ aColor.SetBlue( (UINT8) ( ( aColor2.GetBlue() - aColor.GetBlue() ) / nSteps ) );
+
+ return( aColor );
+}
+
+// -----------------------------------------------------------------------
+void ColorMixingControl::FillRow( USHORT nRow )
+{
+ USHORT nCol1 = nRow * mnColumns + 1;
+ USHORT nCol2 = ( nRow + 1 ) * mnColumns;
+ Color aColor( GetItemColor( nCol1 ) );
+ Color aDiffColor( CalcDifferenceColor( nCol1, nCol2, mnColumns - 1 ) );
+
+ for( USHORT i = nCol1 + 1; i < nCol2; i++ )
+ {
+ aColor.SetRed( aColor.GetRed() + aDiffColor.GetRed() );
+ aColor.SetGreen( aColor.GetGreen() + aDiffColor.GetGreen() );
+ aColor.SetBlue( aColor.GetBlue() + aDiffColor.GetBlue() );
+
+ SetItemColor( i, aColor );
+ SetItemText( i, GetRGBString( aColor ) );
+ }
+}
+
+// -----------------------------------------------------------------------
+void ColorMixingControl::FillColumn( USHORT nColumn )
+{
+ USHORT nCol1 = nColumn + 1;
+ USHORT nCol2 = nColumn + ( mnRows - 1 ) * mnColumns + 1;
+ Color aColor( GetItemColor( nCol1 ) );
+ Color aDiffColor( CalcDifferenceColor( nCol1, nCol2, mnRows - 1 ) );
+
+ for( USHORT i = nCol1 + mnColumns; i < nCol2; i = i + mnColumns )
+ {
+ aColor.SetRed( aColor.GetRed() + aDiffColor.GetRed() );
+ aColor.SetGreen( aColor.GetGreen() + aDiffColor.GetGreen() );
+ aColor.SetBlue( aColor.GetBlue() + aDiffColor.GetBlue() );
+
+ SetItemColor( i, aColor );
+ SetItemText( i, GetRGBString( aColor ) );
+ }
+}
+
+// -----------------------------------------------------------------------
+void ColorMixingControl::SetRows( USHORT nRows )
+{
+ mnRows = nRows;
+}
+
+// -----------------------------------------------------------------------
+void ColorMixingControl::SetColumns( USHORT nColumns )
+{
+ mnColumns = nColumns;
+}
+
+// -----------------------------------------------------------------------
+void ColorMixingControl::SetColor( CMCPosition ePos, const Color& rCol )
+{
+ if( rCol != maColor[ ePos ] )
+ {
+ maColor[ ePos ] = rCol;
+ USHORT nPos = 0;
+ USHORT nColumn = 0;
+ String aStr( GetRGBString( rCol ) );
+
+ switch( ePos )
+ {
+ case CMC_TOPLEFT:
+ nPos = 1;
+ nColumn = 0;
+ break;
+
+ case CMC_TOPRIGHT:
+ nPos = mnColumns;
+ nColumn = mnColumns - 1;
+ break;
+
+ case CMC_BOTTOMLEFT:
+ nPos = ( mnRows - 1 ) * mnColumns + 1;
+ nColumn = 0;
+ break;
+
+ case CMC_BOTTOMRIGHT:
+ nPos = mnRows * mnColumns;
+ nColumn = mnColumns - 1;
+ break;
+ case CMC_OTHER:
+ break; // -Wall not handled.
+ }
+ SetItemColor( nPos, rCol );
+ SetItemText( nPos, aStr );
+ FillColumn( nColumn );
+
+ for( USHORT i = 0; i < mnRows; i++ )
+ FillRow( i );
+ }
+}
+
+// -----------------------------------------------------------------------
+String ColorMixingControl::GetRGBString( const Color& rColor )
+{
+ String aStr( String::CreateFromInt32(rColor.GetRed()) );
+ aStr += ' ';
+ aStr += String::CreateFromInt32(rColor.GetGreen());
+ aStr += ' ';
+ aStr += String::CreateFromInt32(rColor.GetBlue());
+
+ return aStr;
+}
+// -----------------------------------------------------------------------
+CMCPosition ColorMixingControl::GetCMCPosition() const
+{
+ CMCPosition ePos = CMC_OTHER;
+ USHORT nPos = GetSelectItemId();
+
+ if( nPos == 1 )
+ ePos = CMC_TOPLEFT;
+ else if( nPos == mnColumns )
+ ePos = CMC_TOPRIGHT;
+ else if( nPos == ( mnRows - 1 ) * mnColumns + 1 )
+ ePos = CMC_BOTTOMLEFT;
+ else if( nPos == mnRows * mnColumns )
+ ePos = CMC_BOTTOMRIGHT;
+
+ return( ePos );
+}
+
+
+// ------------
+// - ColorHSB -
+// ------------
+
+// Erste Ansaetze gingen auf die Berechnung von Sven Hannover zurueck
+// Der jetzige Algorithmus stammt im weitesten Sinne aus dem Foley/VanDam
+
+
+/**************************************************************************
+|*
+|* ColorHSB::ColorHSB()
+|*
+|* Beschreibung RGB nach HSB
+|* Ersterstellung SOH 02.10.97
+|*
+**************************************************************************/
+
+ColorHSB::ColorHSB( const Color& rColor )
+{
+ UINT8 c[3];
+ UINT8 cMax, cMin;
+
+ c[0] = rColor.GetRed();
+ c[1] = rColor.GetGreen();
+ c[2] = rColor.GetBlue();
+
+ cMax = c[0];
+ if( c[1] > cMax )
+ cMax = c[1];
+ if( c[2] > cMax )
+ cMax = c[2];
+
+ // Brightness = max(R, G, B);
+ mnBri = cMax * 100 / 255;
+
+ cMin = c[0];
+ if( c[1] < cMin )
+ cMin = c[1];
+ if( c[2] < cMin )
+ cMin = c[2];
+
+ UINT8 cDelta = cMax - cMin;
+
+ // Saturation = max - min / max
+ if( mnBri > 0 )
+ mnSat = cDelta * 100 / cMax;
+ else
+ mnSat = 0;
+
+ if( mnSat == 0 )
+ mnHue = 0; // Default = undefined
+ else
+ {
+ double dHue = 0;
+
+ if( c[0] == cMax )
+ {
+ dHue = (double)( c[1] - c[2] ) / (double)cDelta;
+ }
+ else if( c[1] == cMax )
+ {
+ dHue = 2.0 + (double)( c[2] - c[0] ) / (double)cDelta;
+ }
+ else if ( c[2] == cMax )
+ {
+ dHue = 4.0 + (double)( c[0] - c[1] ) / (double)cDelta;
+ }
+ // else dHue = ??? -Wall FIXME
+ dHue *= 60.0;
+
+ if( dHue < 0.0 )
+ dHue += 360.0;
+
+ mnHue = (UINT16) dHue;
+ }
+}
+
+/**************************************************************************
+|*
+|* ColorHSB::GetRGB()
+|*
+|* Beschreibung HSB nach RGB
+|* Ersterstellung SOH 02.10.97
+|*
+**************************************************************************/
+
+Color ColorHSB::GetRGB() const
+{
+ UINT8 cR,cG,cB;
+ UINT8 nB = (UINT8) ( mnBri * 255 / 100 );
+
+ if( mnSat == 0 )
+ {
+ cR = nB;
+ cG = nB;
+ cB = nB;
+ }
+ else
+ {
+ double dH = mnHue;
+ double f;
+ UINT16 n;
+ if( dH == 360.0 )
+ dH = 0.0;
+
+ dH /= 60.0;
+ n = (UINT16) dH;
+ f = dH - n;
+
+ // #107375# Doing the calculation completely in floating
+ // point, the former optimization gave sometimes negative
+ // results for c and was pointless anyway
+ UINT8 a = static_cast<UINT8>( nB * ( 100.0 - mnSat ) / 100.0 );
+ UINT8 b = static_cast<UINT8>( nB * ( 100.0 - mnSat * f ) / 100.0 );
+ UINT8 c = static_cast<UINT8>( nB * ( 100.0 - mnSat * ( 1.0 - f ) ) / 100.0 );
+
+ switch( n )
+ {
+ case 0: cR = nB; cG = c; cB = a; break;
+ case 1: cR = b; cG = nB; cB = a; break;
+ case 2: cR = a; cG = nB; cB = c; break;
+ case 3: cR = a; cG = b; cB = nB; break;
+ case 4: cR = c; cG = a; cB = nB; break;
+ case 5: cR = nB; cG = a; cB = b; break;
+ default: cR = 0; cG = 0; cB = 0; break; // -Wall ????
+ }
+ }
+
+ return( Color( cR, cG, cB ) );
+}
+
+// ------------
+// - ColorCMYK -
+// ------------
+
+
+// -----------------------------------------------------------------------
+ColorCMYK::ColorCMYK( const Color& rColor )
+{
+ mnCyan = 255 - rColor.GetRed();
+ mnMagenta = 255 - rColor.GetGreen();
+ mnYellow = 255 - rColor.GetBlue();
+
+ mnKey = Min( Min( mnCyan, mnMagenta ), mnYellow );
+
+ mnCyan = mnCyan - mnKey;
+ mnMagenta = mnMagenta - mnKey;
+ mnYellow = mnYellow - mnKey;
+}
+
+// -----------------------------------------------------------------------
+Color ColorCMYK::GetRGB() const
+{
+ int nTmp = Max( 0, 255 - ( mnCyan + mnKey ) );
+ UINT8 cR = (UINT8) nTmp;
+ nTmp = Max( 0, 255 - ( mnMagenta + mnKey ) );
+ UINT8 cG = (UINT8) nTmp;
+ nTmp = Max( 0, 255 - ( mnYellow + mnKey ) );
+ UINT8 cB = (UINT8) nTmp;
+
+ return( Color( cR, cG, cB ) );
+}
+
+
diff --git a/svtools/source/dialogs/colrdlg.cxx b/svtools/source/dialogs/colrdlg.cxx
new file mode 100644
index 000000000000..3b40f498c656
--- /dev/null
+++ b/svtools/source/dialogs/colrdlg.cxx
@@ -0,0 +1,331 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: colrdlg.cxx,v $
+ * $Revision: 1.7 $
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_svtools.hxx"
+#ifndef GCC
+#endif
+
+#include <svtools/svtdata.hxx>
+#include "colrdlg.hrc"
+#include <svtools/colrdlg.hxx>
+
+// ---------------
+// - ColorDialog -
+// ---------------
+
+SvColorDialog::SvColorDialog( Window* pWindow ) :
+ ModalDialog ( pWindow, SvtResId( DLG_COLOR ) ),
+ maColMixCtrl ( this, SvtResId( VAL_SET_COLOR ), 8, 8 ),
+ maBtn1 ( this, SvtResId( BTN_1 ) ),
+ maBtn2 ( this, SvtResId( BTN_2 ) ),
+ //maBtn3 ( this, SvtResId( BTN_3 ) ),
+ //maBtn4 ( this, SvtResId( BTN_4 ) ),
+ //maFtRGB ( this, SvtResId( FT_RGB ) ),
+ maCtlColor ( this, SvtResId( CTL_COLOR ) ),
+
+ maFtCyan ( this, SvtResId( FT_CYAN ) ),
+ maNumCyan ( this, SvtResId( NUM_CYAN ) ),
+ maFtMagenta ( this, SvtResId( FT_MAGENTA ) ),
+ maNumMagenta ( this, SvtResId( NUM_MAGENTA ) ),
+ maFtYellow ( this, SvtResId( FT_YELLOW ) ),
+ maNumYellow ( this, SvtResId( NUM_YELLOW ) ),
+ maFtKey ( this, SvtResId( FT_KEY ) ),
+ maNumKey ( this, SvtResId( NUM_KEY ) ),
+
+ maFtRed ( this, SvtResId( FT_RED ) ),
+ maNumRed ( this, SvtResId( NUM_RED ) ),
+ maFtGreen ( this, SvtResId( FT_GREEN ) ),
+ maNumGreen ( this, SvtResId( NUM_GREEN ) ),
+ maFtBlue ( this, SvtResId( FT_BLUE ) ),
+ maNumBlue ( this, SvtResId( NUM_BLUE ) ),
+
+ maFtHue ( this, SvtResId( FT_HUE ) ),
+ maNumHue ( this, SvtResId( NUM_HUE ) ),
+ maFtSaturation ( this, SvtResId( FT_SATURATION ) ),
+ maNumSaturation ( this, SvtResId( NUM_SATURATION ) ),
+ maFtLuminance ( this, SvtResId( FT_LUMINANCE ) ),
+ maNumLuminance ( this, SvtResId( NUM_LUMINANCE ) ),
+
+ maCtlPreview ( this, SvtResId( CTL_PREVIEW ) ),
+ maCtlPreviewOld ( this, SvtResId( CTL_PREVIEW_OLD ) ),
+
+ maBtnOK ( this, SvtResId( BTN_OK ) ),
+ maBtnCancel ( this, SvtResId( BTN_CANCEL ) ),
+ maBtnHelp ( this, SvtResId( BTN_HELP ) )
+{
+ FreeResource();
+
+ maColMixCtrl.SetDoubleClickHdl( LINK( this, SvColorDialog, ClickMixCtrlHdl ) );
+ maColMixCtrl.SetSelectHdl( LINK( this, SvColorDialog, SelectMixCtrlHdl ) );
+
+ Link aLink( LINK( this, SvColorDialog, ColorModifyHdl ) );
+ maCtlColor.SetModifyHdl( aLink );
+
+ maNumRed.SetModifyHdl( aLink );
+ maNumGreen.SetModifyHdl( aLink );
+ maNumBlue.SetModifyHdl( aLink );
+
+ maNumCyan.SetModifyHdl( aLink );
+ maNumMagenta.SetModifyHdl( aLink );
+ maNumYellow.SetModifyHdl( aLink );
+ maNumKey.SetModifyHdl( aLink );
+
+ maNumHue.SetModifyHdl( aLink );
+ maNumSaturation.SetModifyHdl( aLink );
+ maNumLuminance.SetModifyHdl( aLink );
+
+ aLink = ( LINK( this, SvColorDialog, ClickBtnHdl ) );
+ maBtn1.SetClickHdl( aLink );
+ maBtn2.SetClickHdl( aLink );
+ //maBtn3.SetClickHdl( aLink );
+ //maBtn4.SetClickHdl( aLink );
+
+ maColMixCtrl.SetExtraSpacing( 0 );
+}
+
+
+// -----------------------------------------------------------------------
+SvColorDialog::~SvColorDialog()
+{
+}
+
+// -----------------------------------------------------------------------
+void SvColorDialog::Initialize()
+{
+ maNumRed.SetValue( maColor.GetRed() );
+ maNumGreen.SetValue( maColor.GetGreen() );
+ maNumBlue.SetValue( maColor.GetBlue() );
+
+ ColorCMYK aColorCMYK( maColor );
+
+ long aCyan = (long) ( (double)aColorCMYK.GetCyan() * 100.0 / 255.0 + 0.5 );
+ long aMagenta = (long) ( (double)aColorCMYK.GetMagenta() * 100.0 / 255.0 + 0.5 );
+ long aYellow = (long) ( (double)aColorCMYK.GetYellow() * 100.0 / 255.0 + 0.5 );
+ long aKey = (long) ( (double)aColorCMYK.GetKey() * 100.0 / 255.0 + 0.5 );
+ maNumCyan.SetValue( aCyan );
+ maNumMagenta.SetValue( aMagenta );
+ maNumYellow.SetValue( aYellow );
+ maNumKey.SetValue( aKey );
+
+ ColorHSB aColorHSB( maColor );
+ maNumHue.SetValue( aColorHSB.GetHue() );
+ maNumSaturation.SetValue( aColorHSB.GetSat() );
+ maNumLuminance.SetValue( aColorHSB.GetBri() );
+
+ maCtlColor.SetColor( aColorHSB );
+
+ maColMixCtrl.SelectItem( 1 );
+
+ maCtlPreview.SetColor( maColor );
+ maCtlPreviewOld.SetColor( maColor );
+}
+
+// -----------------------------------------------------------------------
+void SvColorDialog::SetColor( const Color& rColor )
+{
+ maColor = rColor;
+}
+
+// -----------------------------------------------------------------------
+const Color& SvColorDialog::GetColor() const
+{
+ return( maColor );
+}
+
+// -----------------------------------------------------------------------
+IMPL_LINK( SvColorDialog, ColorModifyHdl, void *, p )
+{
+ UINT16 n = 0x00; // 1 == RGB, 2 == CMYK, 4 == HSB
+
+ if( p == &maCtlColor )
+ {
+ maColor = maCtlColor.GetColor();
+ maNumRed.SetValue( maColor.GetRed() );
+ maNumGreen.SetValue( maColor.GetGreen() );
+ maNumBlue.SetValue( maColor.GetBlue() );
+
+ n = 7;
+ }
+ else if( p == &maNumRed )
+ {
+ maColor.SetRed( (UINT8)maNumRed.GetValue() );
+ maCtlColor.SetColor( maColor );
+ n = 6;
+ }
+ else if( p == &maNumGreen )
+ {
+ maColor.SetGreen( (UINT8)maNumGreen.GetValue() );
+ maCtlColor.SetColor( maColor );
+ n = 6;
+ }
+ else if( p == &maNumBlue )
+ {
+ maColor.SetBlue( (UINT8)maNumBlue.GetValue() );
+ maCtlColor.SetColor( maColor );
+ n = 6;
+ }
+ else if( p == &maNumHue ||
+ p == &maNumSaturation ||
+ p == &maNumLuminance )
+ {
+
+ ColorHSB aColorHSB( (UINT16) maNumHue.GetValue(),
+ (UINT16) maNumSaturation.GetValue(),
+ (UINT16) maNumLuminance.GetValue() );
+ maCtlColor.SetColor( aColorHSB );
+ maColor = maCtlColor.GetColor();
+ n = 3;
+ }
+ else if( p == &maNumCyan ||
+ p == &maNumMagenta ||
+ p == &maNumYellow ||
+ p == &maNumKey )
+ {
+ long aCyan = (long) ( (double)maNumCyan.GetValue() * 255.0 / 100.0 + 0.5 );
+ long aMagenta = (long) ( (double)maNumMagenta.GetValue() * 255.0 / 100.0 + 0.5 );
+ long aYellow = (long) ( (double)maNumYellow.GetValue() * 255.0 / 100.0 + 0.5 );
+ long aKey = (long) ( (double)maNumKey.GetValue() * 255.0 / 100.0 + 0.5 );
+
+ ColorCMYK aColorCMYK( (UINT16) aCyan,
+ (UINT16) aMagenta,
+ (UINT16) aYellow,
+ (UINT16) aKey );
+ maColor = aColorCMYK.GetRGB();
+ maCtlColor.SetColor( maColor );
+ n = 5;
+ }
+
+ if( n & 1 ) // RGB setzen
+ {
+ maNumRed.SetValue( maColor.GetRed() );
+ maNumGreen.SetValue( maColor.GetGreen() );
+ maNumBlue.SetValue( maColor.GetBlue() );
+ }
+ if( n & 2 ) // CMYK setzen
+ {
+ ColorCMYK aColorCMYK( maColor );
+ long aCyan = (long) ( (double)aColorCMYK.GetCyan() * 100.0 / 255.0 + 0.5 );
+ long aMagenta = (long) ( (double)aColorCMYK.GetMagenta() * 100.0 / 255.0 + 0.5 );
+ long aYellow = (long) ( (double)aColorCMYK.GetYellow() * 100.0 / 255.0 + 0.5 );
+ long aKey = (long) ( (double)aColorCMYK.GetKey() * 100.0 / 255.0 + 0.5 );
+ maNumCyan.SetValue( aCyan );
+ maNumMagenta.SetValue( aMagenta );
+ maNumYellow.SetValue( aYellow );
+ maNumKey.SetValue( aKey );
+ }
+ if( n & 4 ) // HSB setzen
+ {
+ ColorHSB aColorHSB( maColor );
+ maNumHue.SetValue( aColorHSB.GetHue() );
+ maNumSaturation.SetValue( aColorHSB.GetSat() );
+ maNumLuminance.SetValue( aColorHSB.GetBri() );
+ }
+
+ maCtlPreview.SetColor( maColor );
+
+ return 0;
+}
+
+// -----------------------------------------------------------------------
+IMPL_LINK( SvColorDialog, ClickBtnHdl, void *, p )
+{
+ /*
+ Color aColor = maCtlColor.GetColor();
+ if( p == &maBtn1 )
+ maColMixCtrl.SetColor( CMC_TOPLEFT, aColor );
+ if( p == &maBtn2 )
+ maColMixCtrl.SetColor( CMC_TOPRIGHT, aColor );
+ if( p == &maBtn3 )
+ maColMixCtrl.SetColor( CMC_BOTTOMLEFT, aColor );
+ if( p == &maBtn4 )
+ maColMixCtrl.SetColor( CMC_BOTTOMRIGHT, aColor );
+ */
+
+ if( p == &maBtn1 )
+ {
+ CMCPosition ePos = maColMixCtrl.GetCMCPosition();
+ if( ePos != CMC_OTHER )
+ maColMixCtrl.SetColor( ePos, maColor );
+ }
+ else if( p == &maBtn2 )
+ {
+ USHORT nPos = maColMixCtrl.GetSelectItemId();
+ maColor = maColMixCtrl.GetItemColor( nPos );
+ maCtlColor.SetColor( maColor );
+ ColorModifyHdl( &maCtlColor );
+ }
+
+ return 0;
+}
+
+// -----------------------------------------------------------------------
+IMPL_LINK( SvColorDialog, ClickMixCtrlHdl, void *, EMPTYARG )
+{
+ USHORT nPos = maColMixCtrl.GetSelectItemId();
+ CMCPosition ePos = maColMixCtrl.GetCMCPosition();
+
+ if( ePos != CMC_OTHER )
+ maColMixCtrl.SetColor( ePos, maColor );
+ else
+ {
+ maColor = maColMixCtrl.GetItemColor( nPos );
+ maCtlColor.SetColor( maColor );
+ ColorModifyHdl( &maCtlColor );
+ }
+
+ return 0;
+}
+
+// -----------------------------------------------------------------------
+IMPL_LINK( SvColorDialog, SelectMixCtrlHdl, void *, EMPTYARG )
+{
+ //USHORT nPos = maColMixCtrl.GetSelectItemId();
+ //maFtRGB.SetText( maColMixCtrl.GetItemText( nPos ) );
+
+ CMCPosition ePos = maColMixCtrl.GetCMCPosition();
+ if( ePos == CMC_OTHER )
+ maBtn1.Enable( FALSE );
+ else
+ maBtn1.Enable();
+
+ return 0;
+}
+
+// -----------------------------------------------------------------------
+short SvColorDialog::Execute()
+{
+ Initialize();
+
+ short nRet = ModalDialog::Execute();
+
+ return( nRet );
+}
+
diff --git a/svtools/source/dialogs/colrdlg.hrc b/svtools/source/dialogs/colrdlg.hrc
new file mode 100644
index 000000000000..8ffad0ea544e
--- /dev/null
+++ b/svtools/source/dialogs/colrdlg.hrc
@@ -0,0 +1,70 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: colrdlg.hrc,v $
+ * $Revision: 1.3 $
+ *
+ * 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.
+ *
+ ************************************************************************/
+#define DLG_COLOR 996
+
+#define VAL_SET_COLOR 2
+#define BTN_1 1
+#define BTN_2 2
+#define BTN_3 3
+#define BTN_4 4
+#define FT_RGB 12
+
+#define CTL_COLOR 1
+
+#define FT_RED 1
+#define NUM_RED 1
+#define FT_GREEN 2
+#define NUM_GREEN 2
+#define FT_BLUE 3
+#define NUM_BLUE 3
+
+#define FT_CYAN 7
+#define NUM_CYAN 7
+#define FT_MAGENTA 8
+#define NUM_MAGENTA 8
+#define FT_YELLOW 9
+#define NUM_YELLOW 9
+#define FT_KEY 10
+#define NUM_KEY 10
+
+#define FT_HUE 4
+#define NUM_HUE 4
+#define FT_SATURATION 5
+#define NUM_SATURATION 5
+#define FT_LUMINANCE 6
+#define NUM_LUMINANCE 6
+
+#define CTL_PREVIEW 3
+#define CTL_PREVIEW_OLD 4
+
+#define BTN_OK 1
+#define BTN_CANCEL 1
+#define BTN_HELP 1
+
diff --git a/svtools/source/dialogs/colrdlg.src b/svtools/source/dialogs/colrdlg.src
new file mode 100644
index 000000000000..1425f0f28962
--- /dev/null
+++ b/svtools/source/dialogs/colrdlg.src
@@ -0,0 +1,311 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: colrdlg.src,v $
+ * $Revision: 1.29 $
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#include "colrdlg.hrc"
+#define DIFF 3
+ModalDialog DLG_COLOR
+{
+ OutputSize = TRUE ;
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( 260 , 165 + DIFF ) ;
+ Moveable = TRUE ;
+ Text [ en-US ] = "Color" ;
+ OKButton BTN_OK
+ {
+ Pos = MAP_APPFONT ( 205 , 6 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ DefButton = TRUE ;
+ };
+ CancelButton BTN_CANCEL
+ {
+ Pos = MAP_APPFONT ( 205 , 23 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ HelpButton BTN_HELP
+ {
+ Pos = MAP_APPFONT ( 205 , 43 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ Control VAL_SET_COLOR
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 6 , 6 ) ;
+ Size = MAP_APPFONT ( 91 , 100 ) ;
+ TabStop = TRUE ;
+ };
+ Control CTL_COLOR
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 100 , 6 ) ;
+ Size = MAP_APPFONT ( 100 , 100 ) ;
+ TabStop = TRUE ;
+ };
+ FixedText FT_CYAN
+ {
+ Pos = MAP_APPFONT ( 6 , 110 + DIFF ) ;
+ Size = MAP_APPFONT ( 34 , 10 ) ;
+ Text [ en-US ] = "~Cyan" ;
+ };
+ FixedText FT_MAGENTA
+ {
+ Pos = MAP_APPFONT ( 6 , 123 + DIFF ) ;
+ Size = MAP_APPFONT ( 34 , 10 ) ;
+ Text [ en-US ] = "~Magenta" ;
+ };
+ FixedText FT_YELLOW
+ {
+ Pos = MAP_APPFONT ( 6 , 136 + DIFF ) ;
+ Size = MAP_APPFONT ( 34 , 10 ) ;
+ Text [ en-US ] = "~Yellow" ;
+ };
+ FixedText FT_KEY
+ {
+ Pos = MAP_APPFONT ( 6 , 149 + DIFF ) ;
+ Size = MAP_APPFONT ( 34 , 10 ) ;
+ Text [ en-US ] = "~Key" ;
+ };
+ MetricField NUM_CYAN
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 42 , 109 + DIFF ) ;
+ Size = MAP_APPFONT ( 26 , 12 ) ;
+ TabStop = TRUE ;
+ Repeat = TRUE ;
+ Spin = TRUE ;
+ Maximum = 100 ;
+ Last = 100 ;
+ Unit = FUNIT_CUSTOM ;
+ CustomUnitText = " %" ;
+ };
+ MetricField NUM_MAGENTA
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 42 , 122 + DIFF ) ;
+ Size = MAP_APPFONT ( 26 , 12 ) ;
+ TabStop = TRUE ;
+ Repeat = TRUE ;
+ Spin = TRUE ;
+ Maximum = 100 ;
+ Last = 100 ;
+ Unit = FUNIT_CUSTOM ;
+ CustomUnitText = " %" ;
+ };
+ MetricField NUM_YELLOW
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 42 , 135 + DIFF ) ;
+ Size = MAP_APPFONT ( 26 , 12 ) ;
+ TabStop = TRUE ;
+ Repeat = TRUE ;
+ Spin = TRUE ;
+ Maximum = 100 ;
+ Last = 100 ;
+ Unit = FUNIT_CUSTOM ;
+ CustomUnitText = " %" ;
+ };
+ MetricField NUM_KEY
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 42 , 148 + DIFF ) ;
+ Size = MAP_APPFONT ( 26 , 12 ) ;
+ TabStop = TRUE ;
+ Repeat = TRUE ;
+ Spin = TRUE ;
+ Maximum = 100 ;
+ Last = 100 ;
+ Unit = FUNIT_CUSTOM ;
+ CustomUnitText = " %" ;
+ };
+ FixedText FT_RED
+ {
+ Pos = MAP_APPFONT ( 72 , 123 + DIFF ) ;
+ Size = MAP_APPFONT ( 33 , 10 ) ;
+ Text [ en-US ] = "~Red" ;
+ };
+ FixedText FT_GREEN
+ {
+ Pos = MAP_APPFONT ( 72 , 136 + DIFF ) ;
+ Size = MAP_APPFONT ( 33 , 10 ) ;
+ Text [ en-US ] = "~Green" ;
+ };
+ FixedText FT_BLUE
+ {
+ Pos = MAP_APPFONT ( 72 , 149 + DIFF ) ;
+ Size = MAP_APPFONT ( 33 , 10 ) ;
+ Text [ en-US ] = "~Blue" ;
+ };
+ NumericField NUM_RED
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 106 , 122 + DIFF ) ;
+ Size = MAP_APPFONT ( 26 , 12 ) ;
+ TabStop = TRUE ;
+ Repeat = TRUE ;
+ Spin = TRUE ;
+ Maximum = 255 ;
+ Last = 255 ;
+ };
+ NumericField NUM_GREEN
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 106 , 135 + DIFF ) ;
+ Size = MAP_APPFONT ( 26 , 12 ) ;
+ TabStop = TRUE ;
+ Repeat = TRUE ;
+ Spin = TRUE ;
+ Maximum = 255 ;
+ Last = 255 ;
+ };
+ NumericField NUM_BLUE
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 106 , 148 + DIFF ) ;
+ Size = MAP_APPFONT ( 26 , 12 ) ;
+ TabStop = TRUE ;
+ Repeat = TRUE ;
+ Spin = TRUE ;
+ Maximum = 255 ;
+ Last = 255 ;
+ };
+ FixedText FT_HUE
+ {
+ Pos = MAP_APPFONT ( 135 , 123 + DIFF ) ;
+ Size = MAP_APPFONT ( 34 , 10 ) ;
+ Text [ en-US ] = "H~ue" ;
+ };
+ NumericField NUM_HUE
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 171 , 122 + DIFF ) ;
+ Size = MAP_APPFONT ( 26 , 12 ) ;
+ TabStop = TRUE ;
+ Repeat = TRUE ;
+ Spin = TRUE ;
+ Maximum = 359 ;
+ Last = 359 ;
+ };
+ FixedText FT_SATURATION
+ {
+ Pos = MAP_APPFONT ( 135 , 136 + DIFF ) ;
+ Size = MAP_APPFONT ( 34 , 10 ) ;
+ Text [ en-US ] = "~Saturation" ;
+ };
+ NumericField NUM_SATURATION
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 171 , 135 + DIFF ) ;
+ Size = MAP_APPFONT ( 26 , 12 ) ;
+ TabStop = TRUE ;
+ Repeat = TRUE ;
+ Spin = TRUE ;
+ Maximum = 100 ;
+ Last = 100 ;
+ };
+ FixedText FT_LUMINANCE
+ {
+ Pos = MAP_APPFONT ( 135 , 149 + DIFF ) ;
+ Size = MAP_APPFONT ( 34 , 10 ) ;
+ Text [ en-US ] = "Bright~ness" ;
+ };
+ NumericField NUM_LUMINANCE
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 171 , 148 + DIFF ) ;
+ Size = MAP_APPFONT ( 26 , 12 ) ;
+ TabStop = TRUE ;
+ Repeat = TRUE ;
+ Spin = TRUE ;
+ Maximum = 100 ;
+ Last = 100 ;
+ };
+ PushButton BTN_1
+ {
+ Pos = MAP_APPFONT ( 80 , 109 ) ;
+ Size = MAP_APPFONT ( 17 , 12 ) ;
+ Text = "~<--" ;
+ TabStop = TRUE ;
+ };
+ PushButton BTN_2
+ {
+ Pos = MAP_APPFONT ( 100 , 109 ) ;
+ Size = MAP_APPFONT ( 17 , 12 ) ;
+ Text = "--~>" ;
+ TabStop = TRUE ;
+ };
+ Control CTL_PREVIEW_OLD
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 200 , 109 ) ;
+ Size = MAP_APPFONT ( 26 , 51 + DIFF ) ;
+ TabStop = TRUE ;
+ };
+ Control CTL_PREVIEW
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 229 , 109 ) ;
+ Size = MAP_APPFONT ( 26 , 51 + DIFF ) ;
+ TabStop = TRUE ;
+ };
+};
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/svtools/source/dialogs/filedlg.cxx b/svtools/source/dialogs/filedlg.cxx
new file mode 100644
index 000000000000..b543aa895a8e
--- /dev/null
+++ b/svtools/source/dialogs/filedlg.cxx
@@ -0,0 +1,151 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: filedlg.cxx,v $
+ * $Revision: 1.6 $
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_svtools.hxx"
+
+#include <filedlg.hxx>
+#include <filedlg2.hxx>
+
+PathDialog::PathDialog( Window* _pParent, WinBits nStyle, BOOL bCreateDir ) :
+ ModalDialog( _pParent, WB_STDMODAL | nStyle )
+{
+ pImpFileDlg = new ImpSvFileDlg;
+ pImpFileDlg->CreateDialog( this, nStyle, WINDOW_PATHDIALOG, bCreateDir );
+}
+
+PathDialog::~PathDialog()
+{
+ delete pImpFileDlg;
+}
+
+short PathDialog::Execute()
+{
+ pImpFileDlg->GetDialog()->PreExecute();
+ short n = ModalDialog::Execute();
+ return n;
+}
+
+UniString PathDialog::GetPath() const
+{
+ return pImpFileDlg->GetDialog()->GetPath();
+}
+
+void PathDialog::SetPath( const UniString& rPath )
+{
+ pImpFileDlg->GetDialog()->SetPath( rPath );
+}
+
+void PathDialog::SetPath( const Edit& rEdit )
+{
+ pImpFileDlg->GetDialog()->SetPath( rEdit );
+}
+
+long PathDialog::OK()
+{
+ if( aOKHdlLink.IsSet() )
+ return aOKHdlLink.Call( this );
+ else
+ return TRUE;
+}
+
+
+FileDialog::FileDialog( Window* _pParent, WinBits nStyle ) :
+ PathDialog( _pParent, WB_STDMODAL | nStyle )
+{
+ // Dadurch dass hier bei VCL nicht der CTOR mit ResType verwendet wird,
+ // wurde im PathDialog-CTOR leider ein ImpPathDialog angelegt...
+ // So zwar scheisse, aber der Dialog ist eh' nur ein Hack:
+ pImpFileDlg->CreateDialog( this, nStyle, WINDOW_FILEDIALOG, FALSE );
+}
+
+FileDialog::~FileDialog()
+{
+}
+
+void FileDialog::AddFilter( const UniString& rFilter, const UniString& rMask )
+{
+ ((ImpFileDialog*)pImpFileDlg->GetDialog())->AddFilter( rFilter, rMask );
+}
+
+void FileDialog::RemoveFilter( const UniString& rFilter )
+{
+ ((ImpFileDialog*)pImpFileDlg->GetDialog())->RemoveFilter( rFilter );
+}
+
+void FileDialog::RemoveAllFilter()
+{
+ ((ImpFileDialog*)pImpFileDlg->GetDialog())->RemoveAllFilter();
+}
+
+void FileDialog::SetCurFilter( const UniString& rFilter )
+{
+ ((ImpFileDialog*)pImpFileDlg->GetDialog())->SetCurFilter( rFilter );
+}
+
+UniString FileDialog::GetCurFilter() const
+{
+ return ((ImpFileDialog*)pImpFileDlg->GetDialog())->GetCurFilter();
+}
+
+void FileDialog::FileSelect()
+{
+ aFileHdlLink.Call( this );
+}
+
+void FileDialog::FilterSelect()
+{
+ aFilterHdlLink.Call( this );
+}
+
+USHORT FileDialog::GetFilterCount() const
+{
+ return ((ImpFileDialog*)pImpFileDlg->GetDialog())->GetFilterCount();
+}
+
+UniString FileDialog::GetFilterName( USHORT nPos ) const
+{
+ return ((ImpFileDialog*)pImpFileDlg->GetDialog())->GetFilterName( nPos );
+}
+
+UniString FileDialog::GetFilterType( USHORT nPos ) const
+{
+ return ((ImpFileDialog*)pImpFileDlg->GetDialog())->GetFilterType( nPos );
+}
+
+void FileDialog::SetOkButtonText( const UniString& rText )
+{
+ pImpFileDlg->SetOkButtonText( rText );
+}
+
+void FileDialog::SetCancelButtonText( const UniString& rText )
+{
+ pImpFileDlg->SetCancelButtonText( rText );
+}
diff --git a/svtools/source/dialogs/filedlg2.cxx b/svtools/source/dialogs/filedlg2.cxx
new file mode 100644
index 000000000000..5a03ab3885b5
--- /dev/null
+++ b/svtools/source/dialogs/filedlg2.cxx
@@ -0,0 +1,1365 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: filedlg2.cxx,v $
+ * $Revision: 1.15 $
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_svtools.hxx"
+#include <vcl/svapp.hxx>
+#ifndef _SV_BUTTON_HXX //autogen
+#include <vcl/button.hxx>
+#endif
+#include <vcl/fixed.hxx>
+#include <vcl/edit.hxx>
+#include <vcl/lstbox.hxx>
+#include <svtools/svtdata.hxx>
+
+#include <filedlg2.hxx>
+#include <filedlg.hxx>
+#include <filedlg2.hrc>
+#include <vcl/msgbox.hxx>
+#include <vos/security.hxx>
+#include <com/sun/star/i18n/XCollator.hpp>
+
+#include <svtools/stdctrl.hxx>
+
+#ifdef _MSC_VER
+#pragma optimize ("", off)
+#endif
+
+#include <svtools/helpid.hrc>
+
+using namespace com::sun::star;
+using namespace com::sun::star::uno;
+
+
+DECLARE_LIST( UniStringList, UniString* )
+
+#define STD_BTN_WIDTH 80
+#define STD_BTN_HEIGHT 26
+
+#ifndef UNX
+ #define ALLFILES "*.*"
+#else
+ #define ALLFILES "*"
+#endif
+// #define STD_BTN_WIDTH 90
+// #define STD_BTN_HEIGHT 35
+
+#define INITCONTROL( p, ControlClass, nBits, aPos, aSize, aTitel, nHelpId ) \
+ p = new ControlClass( GetPathDialog(), WinBits( nBits ) ); \
+ p->SetHelpId( nHelpId ); \
+ p->SetPosSizePixel( aPos, aSize ); \
+ p->SetText( aTitel ); \
+ p->Show();
+
+
+inline BOOL IsPrintable( sal_Unicode c )
+{
+ return c >= 32 && c != 127 ? TRUE : FALSE;
+}
+
+long
+KbdListBox::PreNotify( NotifyEvent& rNEvt )
+{
+ if ( rNEvt.GetType() == EVENT_KEYINPUT )
+ {
+ KeyEvent aKeyEvt = *rNEvt.GetKeyEvent();
+ sal_Unicode cCharCode = aKeyEvt.GetCharCode();
+
+ if ( IsPrintable ( cCharCode ) )
+ {
+ USHORT nCurrentPos = GetSelectEntryPos();
+ USHORT nEntries = GetEntryCount();
+
+ for ( USHORT i = 1; i < nEntries; i++ )
+ {
+ UniString aEntry = GetEntry ( (i + nCurrentPos) % nEntries );
+ aEntry.EraseLeadingChars( ' ' );
+ aEntry.ToUpperAscii();
+ UniString aCompare( cCharCode );
+ aCompare.ToUpperAscii();
+
+ if ( aEntry.CompareTo( aCompare, 1 ) == COMPARE_EQUAL )
+ {
+ SelectEntryPos ( (i + nCurrentPos) % nEntries );
+ break;
+ }
+ }
+ }
+ else
+ if ( aKeyEvt.GetKeyCode().GetCode() == KEY_RETURN )
+ {
+ DoubleClick();
+ }
+ }
+
+ return ListBox::PreNotify ( rNEvt );
+}
+
+ImpPathDialog::ImpPathDialog( PathDialog* pDlg, RESOURCE_TYPE nType, BOOL bCreateDir )
+{
+ pSvPathDialog = pDlg;
+ nDirCount = 0;
+
+ // initialize Controls if not used as a base class
+ if ( nType == WINDOW_PATHDIALOG )
+ {
+ InitControls();
+ if( pNewDirBtn )
+ pNewDirBtn->Enable( bCreateDir );
+ }
+
+ pDlg->SetHelpId( HID_FILEDLG_PATHDLG );
+
+ lang::Locale aLocale = Application::GetSettings().GetLocale();
+ xCollator = ::vcl::unohelper::CreateCollator();
+ if( xCollator.is() )
+ xCollator->loadDefaultCollator( aLocale, 1 );
+ DBG_ASSERT( xCollator.is(), "not collator service for path dialog" );
+}
+
+ImpPathDialog::~ImpPathDialog()
+{
+ delete pEdit;
+ delete pDirTitel;
+ delete pDirList;
+ delete pDirPath;
+ delete pDriveList;
+ delete pDriveTitle;
+ delete pLoadBtn;
+ delete pOkBtn;
+ delete pCancelBtn;
+ delete pNewDirBtn;
+# if defined(UNX) || defined(OS2)
+ delete pHomeBtn;
+# endif
+}
+
+void ImpPathDialog::InitControls()
+{
+ PathDialog* pDlg = GetPathDialog();
+ pDlg->SetText( UniString( SvtResId( STR_FILEDLG_SELECT ) ) );
+
+ Size a3Siz = pDlg->LogicToPixel( Size( 3, 3 ), MAP_APPFONT );
+ Size a6Siz = pDlg->LogicToPixel( Size( 6, 6 ), MAP_APPFONT );
+ Size aBtnSiz = pDlg->LogicToPixel( Size( 50, 14 ), MAP_APPFONT );
+ Size aFTSiz = pDlg->LogicToPixel( Size( 142, 10 ), MAP_APPFONT );
+ Size aEDSiz = pDlg->LogicToPixel( Size( 142, 12 ), MAP_APPFONT );
+ Point aPnt( a6Siz.Width(), a6Siz.Height() );
+ long nLbH1 = pDlg->LogicToPixel( Size( 0, 93 ), MAP_APPFONT ).Height();
+ long nH = 0;
+ UniString aEmptyStr;
+
+ INITCONTROL( pDirTitel, FixedText, 0,
+ aPnt, aFTSiz, UniString( SvtResId( STR_FILEDLG_DIR ) ), HID_FILEDLG_DIR );
+ aPnt.Y() += aFTSiz.Height() + a3Siz.Height();
+
+ INITCONTROL( pEdit, Edit, WB_BORDER, aPnt, aEDSiz, aPath.GetFull(), HID_FILEDLG_EDIT );
+
+ aPnt.Y() += aEDSiz.Height() + a3Siz.Height();
+#ifndef UNX
+ long nLbH2 = pDlg->LogicToPixel( Size( 0, 60 ), MAP_APPFONT ).Height();
+ INITCONTROL( pDirList, KbdListBox, WB_AUTOHSCROLL | WB_BORDER,
+ aPnt, Size( aEDSiz.Width(), nLbH1 ), aEmptyStr, HID_FILEDLG_DIRS );
+ aPnt.Y() += nLbH1 + a6Siz.Height();
+ INITCONTROL( pDriveTitle, FixedText, 0,
+ aPnt, aFTSiz, UniString( SvtResId( STR_FILEDLG_DRIVES ) ), HID_FILEDLG_DRIVE );
+ aPnt.Y() += aFTSiz.Height() + a3Siz.Height();
+ INITCONTROL( pDriveList, ListBox, WB_DROPDOWN,
+ aPnt, Size( aEDSiz.Width(), nLbH2 ), aEmptyStr, HID_FILEDLG_DRIVES );
+ nH = aPnt.Y() + aEDSiz.Height() + a6Siz.Height();
+#else
+ long nNewH = nLbH1 + 3 * a3Siz.Height() +
+ aFTSiz.Height() + aEDSiz.Height();
+ INITCONTROL( pDirList, KbdListBox, WB_AUTOHSCROLL | WB_BORDER,
+ aPnt, Size( aEDSiz.Width(), nNewH ), aEmptyStr, HID_FILEDLG_DIRS );
+ nH = aPnt.Y() + nNewH + a6Siz.Height();
+ pDriveTitle = NULL;
+ pDriveList = NULL;
+#endif
+
+ long nExtraWidth = pDlg->GetTextWidth( String( RTL_CONSTASCII_USTRINGPARAM( "(W)" ) ) )+10;
+ String aOkStr = Button::GetStandardText( BUTTON_OK );
+ long nTextWidth = pDlg->GetTextWidth( aOkStr )+nExtraWidth;
+ if( nTextWidth > aBtnSiz.Width() )
+ aBtnSiz.Width() = nTextWidth;
+
+ String aCancelStr = Button::GetStandardText( BUTTON_CANCEL );
+ nTextWidth = pDlg->GetTextWidth( aCancelStr )+nExtraWidth;
+ if( nTextWidth > aBtnSiz.Width() )
+ aBtnSiz.Width() = nTextWidth;
+
+ String aNewDirStr( SvtResId( STR_FILEDLG_NEWDIR ) );
+ nTextWidth = pDlg->GetTextWidth( aNewDirStr )+nExtraWidth;
+ if( nTextWidth > aBtnSiz.Width() )
+ aBtnSiz.Width() = nTextWidth;
+#if defined(UNX) || defined(OS2)
+ String aHomeDirStr( SvtResId( STR_FILEDLG_HOME ) );
+ nTextWidth = pDlg->GetTextWidth( aHomeDirStr )+nExtraWidth;
+ if( nTextWidth > aBtnSiz.Width() )
+ aBtnSiz.Width() = nTextWidth;
+#endif
+
+ aPnt.X() = 2 * a6Siz.Width() + aEDSiz.Width();
+ aPnt.Y() = a6Siz.Height();
+ INITCONTROL( pOkBtn, PushButton, WB_DEFBUTTON,
+ aPnt, aBtnSiz, aOkStr, 0 );
+ aPnt.Y() += aBtnSiz.Height() + a3Siz.Height();
+ INITCONTROL( pCancelBtn, CancelButton, 0,
+ aPnt, aBtnSiz, aCancelStr, 0 );
+ aPnt.Y() += aBtnSiz.Height() + a3Siz.Height();
+ INITCONTROL( pNewDirBtn, PushButton, WB_DEFBUTTON,
+ aPnt, aBtnSiz, aNewDirStr, HID_FILEDLG_NEWDIR );
+#if defined(UNX) || defined(OS2)
+ aPnt.Y() += aBtnSiz.Height() + a3Siz.Height();
+ INITCONTROL( pHomeBtn, PushButton, WB_DEFBUTTON,
+ aPnt, aBtnSiz, aHomeDirStr, HID_FILEDLG_HOME );
+#else
+ pHomeBtn = NULL;
+#endif
+
+ pDirPath = 0;
+ pLoadBtn = 0;
+ // Dialogbreite == OKBtn-Position + OKBtn-Breite + Rand
+ long nW = aPnt.X() + aBtnSiz.Width() + a6Siz.Width();
+
+ pDlg->SetOutputSizePixel( Size( nW, nH ) ); // Groesse ggf. auch Resource wird geplaettet?
+
+ if (pDirList)
+ pDirList->SetDoubleClickHdl(LINK( this, ImpPathDialog, DblClickHdl) );
+
+ if (pDirList)
+ pDirList->SetSelectHdl( LINK( this, ImpPathDialog, SelectHdl ) );
+
+ if (pDriveList)
+ pDriveList->SetSelectHdl( LINK( this, ImpPathDialog, SelectHdl ) );
+
+ if (pOkBtn)
+ pOkBtn->SetClickHdl( LINK( this, ImpPathDialog, ClickHdl) );
+
+ if (pCancelBtn)
+ pCancelBtn->SetClickHdl( LINK( this, ImpPathDialog, ClickHdl) );
+
+ if (pHomeBtn)
+ pHomeBtn->SetClickHdl( LINK( this, ImpPathDialog, ClickHdl) );
+
+ if (pNewDirBtn)
+ pNewDirBtn->SetClickHdl( LINK( this, ImpPathDialog, ClickHdl) );
+
+ nOwnChilds = pDlg->GetChildCount();
+}
+
+
+
+IMPL_LINK( ImpPathDialog, SelectHdl, ListBox *, p )
+{
+ if( p == pDriveList )
+ {
+ UniString aDrive( pDriveList->GetSelectEntry(), 0, 2);
+ aDrive += '\\';
+ SetPath( aDrive );
+ }
+ else
+ if( p == pDirList )
+ {
+ // isolate the pure name of the entry
+ // removing trainling stuff and leading spaces
+ UniString aEntry( pDirList->GetSelectEntry() );
+
+ aEntry.EraseLeadingChars( ' ' );
+ USHORT nPos = aEntry.Search( '/' );
+ aEntry.Erase( nPos );
+
+ // build the absolute path to the selected item
+ DirEntry aNewPath;
+ aNewPath.ToAbs();
+
+ USHORT nCurPos = pDirList->GetSelectEntryPos();
+
+ // Wird nach oben gewechselt
+ if( nCurPos < nDirCount )
+ aNewPath = aNewPath[nDirCount-nCurPos-1];
+ else
+ aNewPath += aEntry;
+
+ pEdit->SetText( aNewPath.GetFull() );
+ }
+
+ return 0;
+}
+
+
+IMPL_LINK( ImpPathDialog, ClickHdl, Button*, pBtn )
+{
+ if ( pBtn == pOkBtn || pBtn == pLoadBtn )
+ {
+ DirEntry aFile( pEdit->GetText() );
+
+ // Existiert File / File ueberschreiben
+ if( IsFileOk( aFile ) )
+ {
+ // Ja, dann kompletten Pfad mit Filenamen merken und Dialog beenden
+ aPath = aFile;
+ aPath.ToAbs();
+ GetPathDialog()->EndDialog( TRUE );
+ }
+ else
+ {
+ DirEntry aCheck( aPath );
+ aCheck += aFile;
+ if( aCheck.Exists() )
+ {
+ aCheck.ToAbs();
+ SetPath( aCheck.GetFull() );
+ pEdit->SetSelection( Selection( 0x7FFFFFFF, 0x7FFFFFFF ) );
+ }
+ }
+ }
+ else
+ if ( pBtn == pCancelBtn )
+ {
+ GetPathDialog()->EndDialog( FALSE );
+ }
+ else
+ if ( pBtn == pHomeBtn )
+ {
+ ::rtl::OUString aHomeDir;
+ NAMESPACE_VOS( OSecurity ) aSecurity;
+ if ( aSecurity.getHomeDir( aHomeDir ) )
+ {
+ DirEntry aFile ( aHomeDir );
+ if ( IsFileOk( aFile ) )
+ {
+ aFile.ToAbs();
+ SetPath( aFile.GetFull() );
+ }
+ }
+ }
+ else
+ if ( pBtn == pNewDirBtn )
+ {
+ DirEntry aFile( pEdit->GetText() );
+ if( ! aFile.Exists() && ! FileStat( aFile ).IsKind( FSYS_KIND_WILD ) )
+ aFile.MakeDir();
+
+ if( IsFileOk ( aFile ) )
+ {
+ aFile.ToAbs();
+ SetPath( aFile.GetFull() );
+ }
+ }
+
+ return 0;
+}
+
+
+IMPL_LINK( ImpPathDialog, DblClickHdl, ListBox*, pBox )
+{
+ // isolate the pure name of the entry
+ // removing trainling stuff and leading spaces
+ UniString aEntry( pBox->GetSelectEntry() );
+
+ aEntry.EraseLeadingChars( ' ' );
+ USHORT nPos = aEntry.Search( '/' );
+ aEntry.Erase( nPos );
+
+ // build the absolute path to the selected item
+ DirEntry aNewPath;
+ aNewPath.ToAbs();
+ if( pBox == pDirList )
+ {
+ USHORT nCurPos = pDirList->GetSelectEntryPos();
+
+ // Wenn es schon das aktuelle ist, dann mache nichts
+ if( nCurPos == nDirCount-1 )
+ return 0;
+
+ // Wird nach oben gewechselt
+ if( nCurPos < nDirCount )
+ aNewPath = aNewPath[nDirCount-nCurPos-1];
+ else
+ aNewPath += aEntry;
+ }
+ else
+ aNewPath += aEntry;
+
+ pSvPathDialog->EnterWait();
+
+ if( FileStat( aNewPath ).GetKind() & FSYS_KIND_DIR )
+ {
+ // Neuen Pfad setzen und Listboxen updaten
+ aPath = aNewPath;
+ if( !aPath.SetCWD( TRUE ) )
+ {
+ ErrorBox aBox( GetPathDialog(),
+ WB_OK_CANCEL | WB_DEF_OK,
+ UniString( SvtResId( STR_FILEDLG_CANTCHDIR ) ) );
+ if( aBox.Execute() == RET_CANCEL )
+ GetPathDialog()->EndDialog( FALSE );
+ }
+ UpdateEntries( TRUE );
+ }
+
+ pSvPathDialog->LeaveWait();
+ return 0;
+}
+
+void ImpPathDialog::UpdateEntries( const BOOL )
+{
+ UniString aTabString;
+ DirEntry aTmpPath;
+ aTmpPath.ToAbs();
+
+ nDirCount = aTmpPath.Level();
+
+ pDirList->SetUpdateMode( FALSE );
+ pDirList->Clear();
+
+ for( USHORT i = nDirCount; i > 0; i-- )
+ {
+ UniString aName( aTabString );
+ aName += aTmpPath[i-1].GetName();
+ pDirList->InsertEntry( aName );
+ aTabString.AppendAscii( " ", 2 );
+ }
+
+ // scan the directory
+ DirEntry aCurrent;
+ aCurrent.ToAbs();
+
+ Dir aDir( aCurrent, FSYS_KIND_DIR|FSYS_KIND_FILE );
+
+ USHORT nEntries = aDir.Count();
+ if( nEntries )
+ {
+ UniStringList aSortDirList;
+ for ( USHORT n = 0; n < nEntries; n++ )
+ {
+ DirEntry& rEntry = aDir[n];
+ UniString aName( rEntry.GetName() );
+ if( aName.Len() && ( aName.GetChar(0) != '.' ) && rEntry.Exists() )
+ {
+ if( FileStat( rEntry ).GetKind() & FSYS_KIND_DIR )
+ {
+ ULONG l = 0;
+ if( xCollator.is() )
+ {
+ for( l = 0; l < aSortDirList.Count(); l++ )
+ if( xCollator->compareString( *aSortDirList.GetObject(l), aName ) > 0 )
+ break;
+ }
+ aSortDirList.Insert( new UniString( aName ), l );
+ }
+ }
+ }
+
+ for( ULONG l = 0; l < aSortDirList.Count(); l++ )
+ {
+ UniString aEntryStr( aTabString );
+ aEntryStr += *aSortDirList.GetObject(l);
+ pDirList->InsertEntry( aEntryStr );
+ delete aSortDirList.GetObject(l);
+ }
+ }
+
+ UpdateDirs( aTmpPath );
+}
+
+void ImpPathDialog::UpdateDirs( const DirEntry& rTmpPath )
+{
+ pDirList->SelectEntryPos( nDirCount-1 );
+ pDirList->SetTopEntry( nDirCount > 1
+ ? nDirCount - 2
+ : nDirCount - 1 );
+ pDirList->SetUpdateMode( TRUE );
+ pDirList->Invalidate();
+ pDirList->Update();
+
+ UniString aDirName = rTmpPath.GetFull();
+ if( pDirPath )
+ pDirPath->SetText( aDirName );
+ else
+ pEdit->SetText( aDirName );
+}
+
+BOOL ImpPathDialog::IsFileOk( const DirEntry& rDirEntry )
+{
+ if( FileStat( rDirEntry ).GetKind() & (FSYS_KIND_WILD | FSYS_KIND_DEV) )
+ return FALSE;
+ else
+ {
+ // Datei vorhanden ?
+ if( ! rDirEntry.Exists() )
+ {
+ UniString aQueryTxt( SvtResId( STR_FILEDLG_ASKNEWDIR ) );
+ aQueryTxt.SearchAndReplaceAscii( "%s", rDirEntry.GetFull() );
+ QueryBox aQuery( GetPathDialog(),
+ WB_YES_NO | WB_DEF_YES,
+ aQueryTxt );
+ if( aQuery.Execute() == RET_YES )
+ rDirEntry.MakeDir();
+ else
+ return FALSE;
+ }
+ if( !FileStat( rDirEntry ).IsKind( FSYS_KIND_DIR ) )
+ {
+ UniString aBoxText( SvtResId( STR_FILEDLG_CANTOPENDIR ) );
+ aBoxText.AppendAscii( "\n[" );
+ aBoxText += rDirEntry.GetFull();
+ aBoxText.AppendAscii( "]" );
+ InfoBox aBox( GetPathDialog(), aBoxText );
+ aBox.Execute();
+ return FALSE;
+ }
+ }
+ return GetPathDialog()->OK() != 0;
+}
+
+
+void ImpPathDialog::PreExecute()
+{
+ // Neues Verzeichnis setzen und Listboxen updaten
+ aPath.SetCWD( TRUE );
+ UpdateEntries( TRUE );
+
+ // Zusaetzliche Buttons anordnen
+ Point aPos;
+ Size aSize;
+ long nDY;
+ if( pLoadBtn )
+ {
+ aPos = pLoadBtn->GetPosPixel();
+ aSize = pLoadBtn->GetSizePixel();
+ nDY = pLoadBtn->GetSizePixel().Height() * 2;
+ }
+ else
+ {
+ aPos = pCancelBtn->GetPosPixel();
+ aSize = pCancelBtn->GetSizePixel();
+ nDY = pCancelBtn->GetPosPixel().Y() - pOkBtn->GetPosPixel().Y();
+ }
+
+ // Standard-Controls anpassen
+ long nMaxWidth = 0;
+
+ // Maximale Breite ermitteln
+ USHORT nChilds = GetPathDialog()->GetChildCount();
+ USHORT n;
+ for ( n = nOwnChilds; n < nChilds; n++ )
+ {
+ Window* pChild = GetPathDialog()->GetChild( n );
+ pChild = pChild->GetWindow( WINDOW_CLIENT );
+ if( pChild->GetType() != WINDOW_WINDOW )
+ {
+ long nWidth = pChild->GetTextWidth( pChild->GetText() ) + 12;
+ if( nMaxWidth < nWidth )
+ nMaxWidth = nWidth;
+ nWidth = pChild->GetSizePixel().Width();
+ if( nMaxWidth < nWidth )
+ nMaxWidth = nWidth;
+ }
+ }
+
+ if( nMaxWidth > aSize.Width() )
+ {
+ Size aDlgSize = GetPathDialog()->GetOutputSizePixel();
+ GetPathDialog()->SetOutputSizePixel( Size( aDlgSize.Width()+nMaxWidth-aSize.Width(), aDlgSize.Height() ) );
+ aSize.Width() = nMaxWidth;
+
+ if( pOkBtn )
+ pOkBtn->SetSizePixel( aSize );
+ if( pCancelBtn )
+ pCancelBtn->SetSizePixel( aSize );
+ if( pLoadBtn )
+ pLoadBtn->SetSizePixel( aSize );
+ }
+ else
+ nMaxWidth = aSize.Width();
+
+ for ( n = nOwnChilds; n < nChilds; n++ )
+ {
+ Window* pChild = GetPathDialog()->GetChild( n );
+ pChild = pChild->GetWindow( WINDOW_CLIENT );
+ if( pChild->GetType() != WINDOW_WINDOW )
+ {
+ aPos.Y() += nDY;
+ pChild->SetPosSizePixel( aPos, aSize );
+ }
+ else
+ {
+ Size aDlgSize = GetPathDialog()->GetOutputSizePixel();
+ long nExtra = Min( aDlgSize.Height(), (long)160);
+ GetPathDialog()->SetOutputSizePixel( Size( aDlgSize.Width()+nExtra, aDlgSize.Height() ) );
+ Size aSz( nExtra, nExtra );
+ aSz.Width() -= 8;
+ aSz.Height() -= 8;
+ Point aCtrlPos( aDlgSize.Width() + 2, (aDlgSize.Height()-aSz.Height())/2 );
+ pChild->SetPosSizePixel( aCtrlPos, aSz );
+ }
+ }
+
+ // Laufwerke-LB fuellen
+ if( pDriveList )
+ {
+ DirEntry aTmpDirEntry;
+ Dir aDir( aTmpDirEntry, FSYS_KIND_BLOCK );
+
+ USHORT nCount = aDir.Count(), i;
+ for( i = 0; i < nCount; ++i )
+ {
+ DirEntry& rEntry = aDir[i];
+ UniString aStr = rEntry.GetFull( FSYS_STYLE_HOST, FALSE );
+
+ UniString aVolume = rEntry.GetVolume() ;
+ aStr.ToUpperAscii();
+ if ( aVolume.Len() )
+ {
+ aStr += ' ';
+ aStr += aVolume;
+ }
+ pDriveList->InsertEntry( aStr );
+
+ }
+ UniString aPathStr = aPath.GetFull();
+
+ for ( i = 0; i < pDriveList->GetEntryCount(); ++i )
+ {
+ UniString aEntry = pDriveList->GetEntry(i);
+ xub_StrLen nLen = aEntry.Len();
+ nLen = nLen > 2 ? 2 : nLen;
+ if ( aEntry.CompareIgnoreCaseToAscii( aPathStr, nLen ) == COMPARE_EQUAL )
+ {
+ pDriveList->SelectEntryPos(i);
+ break;
+ }
+ }
+ }
+}
+
+void ImpPathDialog::PostExecute()
+{
+}
+
+void ImpPathDialog::SetPath( UniString const & rPath )
+{
+ aPath = DirEntry( rPath );
+
+ pSvPathDialog->EnterWait();
+
+ DirEntry aFile( rPath );
+ // Falls der Pfad eine Wildcard oder einen Filenamen enthaelt
+ // -> abschneiden und merken
+ if( FileStat( aFile ).GetKind() & (FSYS_KIND_FILE | FSYS_KIND_WILD) || !aFile.Exists() )
+ aFile.CutName();
+
+ // Neue Maske und neues Verzeichnis setzen, und Listboxen updaten
+ pEdit->SetText( rPath );
+ aFile.SetCWD( TRUE );
+ UpdateEntries( TRUE );
+
+ pSvPathDialog->LeaveWait();
+}
+
+void ImpPathDialog::SetPath( Edit const & rEdit )
+{
+ UniString aPresetText = rEdit.GetText();
+ if( aPresetText.Len() )
+ SetPath( aPresetText );
+}
+
+
+UniString ImpPathDialog::GetPath() const
+{
+ DirEntry aFile( pEdit->GetText() );
+ aFile.ToAbs();
+ return aFile.GetFull();
+}
+
+
+ImpFileDialog::ImpFileDialog( PathDialog* pDlg, WinBits nWinBits, RESOURCE_TYPE nType ) :
+ ImpPathDialog( pDlg, nType, FALSE )
+{
+ bOpen = (nWinBits & WB_SAVEAS) == 0;
+
+ SvtResId aSvtResId = bOpen ? STR_FILEDLG_OPEN : STR_FILEDLG_SAVE;
+
+ // Titel setzen
+ GetFileDialog()->SetText( UniString( aSvtResId ) );
+ nDirCount = 0;
+
+ // initialize Controls if not used as a base class
+ if ( nType == WINDOW_FILEDIALOG )
+ InitControls();
+
+ pDlg->SetHelpId( HID_FILEDLG_OPENDLG );
+
+}
+
+ImpFileDialog::~ImpFileDialog()
+{
+ ImpFilterItem* pItem = aFilterList.First();
+ while( pItem )
+ {
+ delete pItem;
+ pItem = aFilterList.Next();
+ }
+
+ delete pFileTitel;
+ if (pFileList && ( pFileList != pDirList ) )
+ delete pFileList;
+
+ delete pTypeTitel;
+ delete pTypeList;
+}
+
+void ImpFileDialog::InitControls()
+{
+ UniString aEmptyStr;
+
+ const int nW = 160;
+ const int nH = 48; // Um den Dialog in eine akzeptable Form zu bringen
+
+ INITCONTROL( pFileTitel, FixedText, 0,
+ Point(10, 12), Size(nW, 18), UniString( SvtResId( STR_FILEDLG_FILE ) ), HID_FILEDLG_FILE );
+ INITCONTROL( pEdit, Edit, WB_BORDER,
+ Point(10, 31), Size(nW, 20), aEmptyStr, HID_FILEDLG_EDIT ); // aMask()
+ INITCONTROL( pFileList, ListBox, WB_SORT | WB_AUTOHSCROLL | WB_BORDER,
+ Point(10, 58), Size(nW, 180-nH), aEmptyStr, HID_FILEDLG_FILES );
+
+ INITCONTROL( pDirTitel, FixedText, 0,
+ Point(nW+20, 12), Size(nW, 18), UniString( SvtResId( STR_FILEDLG_DIR ) ), HID_FILEDLG_DIR );
+ INITCONTROL( pDirPath, FixedInfo, WB_PATHELLIPSIS,
+ Point(nW+20, 33), Size(nW, 20), aPath.GetFull(), HID_FILEDLG_PATH );
+ INITCONTROL( pDirList, KbdListBox, WB_AUTOHSCROLL | WB_BORDER,
+ Point(nW+20, 58), Size(nW, 180-nH ), aEmptyStr, HID_FILEDLG_DIRS );
+
+ INITCONTROL( pTypeTitel, FixedText, 0,
+ Point(10, 246-nH), Size(nW, 18), UniString( SvtResId( STR_FILEDLG_TYPE ) ), HID_FILEDLG_TYPE );
+
+#ifndef UNX
+ INITCONTROL( pTypeList, ListBox, WB_DROPDOWN,
+ Point(10, 265-nH ), Size(nW, 100 ), aEmptyStr, HID_FILEDLG_TYPES );
+
+ INITCONTROL( pDriveTitle, FixedText, 0,
+ Point(nW+20, 246-nH), Size(nW, 18), UniString( SvtResId( STR_FILEDLG_DRIVES ) ), HID_FILEDLG_DRIVE );
+ INITCONTROL( pDriveList, ListBox, WB_DROPDOWN,
+ Point(nW+20, 265-nH ), Size(nW, 100 ), aEmptyStr, HID_FILEDLG_DRIVES );
+ pNewDirBtn = NULL;
+ pHomeBtn = NULL;
+#else
+ INITCONTROL( pTypeList, ListBox, WB_DROPDOWN,
+ Point(10, 265-nH ), Size(2*nW+20, 100 ), aEmptyStr, HID_FILEDLG_TYPES );
+
+ pDriveTitle = NULL;
+ pDriveList = NULL;
+ pNewDirBtn = NULL;
+ pHomeBtn = NULL;
+#endif
+
+ const long nButtonStartX = 2*nW+20+15;
+ INITCONTROL( pOkBtn, PushButton, WB_DEFBUTTON,
+ Point(nButtonStartX, 10), Size(STD_BTN_WIDTH, STD_BTN_HEIGHT),
+ Button::GetStandardText( BUTTON_OK ), 0 );
+ INITCONTROL( pCancelBtn, CancelButton, 0,
+ Point(nButtonStartX, 45 ), Size(STD_BTN_WIDTH, STD_BTN_HEIGHT),
+ Button::GetStandardText( BUTTON_CANCEL ), 0 );
+
+ pLoadBtn = 0;
+
+ GetFileDialog()->SetOutputSizePixel( Size(nButtonStartX+STD_BTN_WIDTH+10, 298-nH) );
+
+ nOwnChilds = GetPathDialog()->GetChildCount();
+
+ // Handler setzen
+ if (pDriveList)
+ pDriveList->SetSelectHdl( LINK( this, ImpFileDialog, SelectHdl ) );
+
+ if (pDirList)
+ pDirList->SetDoubleClickHdl(LINK( this, ImpFileDialog, DblClickHdl) );
+
+ if (pOkBtn)
+ pOkBtn->SetClickHdl( LINK( this, ImpFileDialog, ClickHdl) );
+
+ if (pCancelBtn)
+ pCancelBtn->SetClickHdl( LINK( this, ImpFileDialog, ClickHdl) );
+
+ if( pFileList )
+ {
+ pFileList->SetSelectHdl( LINK( this, ImpFileDialog, SelectHdl ) );
+ pFileList->SetDoubleClickHdl( LINK( this, ImpFileDialog, DblClickHdl ) );
+ }
+
+ if( pTypeList )
+ pTypeList->SetSelectHdl( LINK( this, ImpFileDialog, DblClickHdl ) );
+}
+
+IMPL_LINK( ImpFileDialog, SelectHdl, ListBox *, p )
+{
+ if( p == pDriveList )
+ {
+ UniString aDrive ( pDriveList->GetSelectEntry(), 0, 2);
+ aDrive += '\\';
+ SetPath( aDrive );
+ }
+ else if (p == pFileList)
+ {
+ // Ausgewaehltes File in das Edit stellen
+ pEdit->SetText( pFileList->GetSelectEntry() );
+ GetFileDialog()->FileSelect();
+ }
+ return 0;
+}
+
+
+IMPL_LINK( ImpFileDialog, DblClickHdl, ListBox *, pBox )
+{
+ // isolate the pure name of the entry
+ // removing trailing stuff and leading spaces
+ UniString aEntry( pBox->GetSelectEntry() );
+
+ aEntry.EraseLeadingChars( ' ' );
+ USHORT nPos = aEntry.Search( '/' );
+ aEntry.Erase( nPos );
+
+ // build the absolute path to the selected item
+ DirEntry aNewPath;
+ aNewPath.ToAbs();
+
+ if( ( pDirList != pFileList ) && ( pBox == pDirList ) )
+ {
+ // SVLOOK
+ USHORT nCurPos = pDirList->GetSelectEntryPos();
+
+ // Wenn es schon das aktuelle ist, dann mache nichts
+ if( nCurPos == nDirCount-1 )
+ return 0;
+
+ // Wird nach oben gewechselt
+ if( nCurPos < nDirCount )
+ aNewPath = aNewPath[nDirCount-nCurPos-1];
+ else
+ aNewPath += aEntry;
+ }
+ else
+ {
+ // non-SVLOOK
+ if( aEntry == UniString( SvtResId( STR_FILEDLG_GOUP ) ) )
+ aEntry.AssignAscii( ".." );
+ aNewPath += aEntry;
+ }
+
+ if( pBox == pFileList )
+ {
+ DirEntry aFile( aEntry );
+
+ // Abfrage, ob File ueberschrieben werden soll...
+ if( !FileStat(aFile).IsKind(FSYS_KIND_DIR) && IsFileOk( aFile ) )
+ {
+ // dann kompletten Pfad mit Filenamen merken und Dialog beenden
+ aPath = aNewPath;
+ GetFileDialog()->EndDialog( TRUE );
+ }
+ }
+
+ GetFileDialog()->EnterWait();
+
+ UniString aFull = aNewPath.GetFull();
+
+ if( ( ( pBox == pDirList ) && ( pDirList != pFileList ) ) ||
+ ( ( pDirList == pFileList ) && FileStat( aNewPath ).GetKind() & FSYS_KIND_DIR ) )
+ {
+ // Neuen Pfad setzen und Listboxen updaten
+ aPath = aNewPath;
+ if( !aPath.SetCWD( TRUE ) )
+ {
+ if( ErrorBox( GetFileDialog(), WB_OK_CANCEL|WB_DEF_OK,
+ UniString( SvtResId( STR_FILEDLG_CANTCHDIR ) ) ).Execute() == RET_CANCEL )
+ {
+ GetFileDialog()->EndDialog( FALSE );
+ }
+ }
+ UpdateEntries( TRUE );
+ GetFileDialog()->FileSelect();
+ }
+
+ if( pBox == pTypeList )
+ {
+ // Neue Maske setzen, und Listboxen updaten
+ USHORT nCurPos = pTypeList->GetSelectEntryPos();
+ if( nCurPos+1 > (USHORT)aFilterList.Count() )
+ aMask = UniString::CreateFromAscii( ALLFILES );
+ else
+ {
+ UniString aFilterListMask = aFilterList.GetObject( nCurPos )->aMask;
+// if( aFilterListMask.Search( ';' ) == STRING_NOTFOUND ) // kein ; in der Maske
+// aMask = WildCard( aFilterListMask, '\0' );
+// else // ; muss beruecksichtigt werden
+ aMask = WildCard( aFilterListMask, ';' );
+ }
+
+ pEdit->SetText( aMask() );
+ UpdateEntries( FALSE );
+ GetFileDialog()->FilterSelect();
+ }
+
+ GetFileDialog()->LeaveWait();
+
+ return 0;
+}
+
+IMPL_LINK( ImpFileDialog, ClickHdl, Button*, pBtn )
+{
+ if( ( pBtn == pOkBtn ) || ( pBtn == pLoadBtn ) )
+ {
+ DirEntry aFile( pEdit->GetText() );
+
+ // Existiert File / File ueberschreiben
+ if( IsFileOk( aFile ) )
+ {
+ // Ja, dann kompletten Pfad mit Filenamen merken und Dialog beenden
+ aPath = aFile;
+ aPath.ToAbs();
+ GetFileDialog()->EndDialog( TRUE );
+ }
+ else
+ {
+ GetFileDialog()->EnterWait();
+
+ // Falls der Pfad eine Wildcard oder einen Filenamen enthaelt
+ // -> abschneiden und merken
+ if( FileStat( aFile ).GetKind() & (FSYS_KIND_FILE | FSYS_KIND_WILD) || !aFile.Exists() )
+ {
+ aMask = aFile.CutName();
+ }
+
+ // Neue Maske und neues Verzeichnis setzen, und Listboxen updaten
+ pEdit->SetText( aMask() );
+ aFile.SetCWD( TRUE );
+ UpdateEntries( TRUE );
+
+ GetFileDialog()->LeaveWait();
+ }
+ }
+ else if( pBtn == pCancelBtn )
+ GetFileDialog()->EndDialog( FALSE );
+
+ return 0;
+}
+
+void ImpFileDialog::UpdateEntries( const BOOL bWithDirs )
+{
+ GetFileDialog()->EnterWait();
+
+ UniString aTabString;
+ DirEntry aTmpPath;
+ aTmpPath.ToAbs();
+ nDirCount = aTmpPath.Level();
+
+ if( pFileList )
+ {
+ pFileList->SetUpdateMode( FALSE );
+ pFileList->Clear();
+ }
+
+ if( bWithDirs && (pDirList != pFileList) )
+ {
+ pDirList->SetUpdateMode( FALSE );
+ pDirList->Clear();
+
+ for( USHORT i = nDirCount; i > 0; i-- )
+ {
+ UniString aEntryStr( aTabString );
+ aEntryStr += aTmpPath[i-1].GetName();
+ pDirList->InsertEntry( aEntryStr );
+ aTabString.AppendAscii( " ", 2 );
+ }
+ }
+
+ // for the combined box insert a '..'
+ // (this happens only if WB_3DLOOK is not set)
+
+ if( pDirList == pFileList && nDirCount != 1 )
+ pFileList->InsertEntry( UniString( SvtResId( STR_FILEDLG_GOUP ) ) );
+
+ // scan the directory
+ DirEntry aCurrent;
+ aCurrent.ToAbs();
+ Dir aDir( aCurrent, FSYS_KIND_DIR|FSYS_KIND_FILE );
+ USHORT nEntries = aDir.Count();
+
+ // TempMask, weil Vergleich case-sensitiv
+ BOOL bMatchCase = FALSE; //aCurrent.IsCaseSensitive();
+ UniString aWildCard( aMask.GetWildCard() );
+ if ( !bMatchCase )
+ aWildCard.ToLowerAscii();
+ WildCard aTmpMask( aWildCard, ';' );
+ if ( nEntries )
+ {
+ UniStringList aSortDirList;
+ for ( USHORT n = 0; n < nEntries; n++ )
+ {
+ DirEntry& rEntry = aDir[n];
+ UniString aName( rEntry.GetName() );
+
+ if( aName.Len() &&
+ ( ( ( aName.GetChar(0) != '.' ) ||
+ ( ( aName.GetChar(0) == '.' ) && ( aMask.GetWildCard() ).GetChar(0) == '.' ) )
+ && rEntry.Exists() ) )
+ {
+ FileStat aFileStat( rEntry );
+ UniString aTmpName( aName );
+ if ( !bMatchCase )
+ aTmpName.ToLowerAscii();
+ if( ( aFileStat.GetKind() & FSYS_KIND_FILE ) && aTmpMask.Matches( aTmpName ) )
+ {
+ if( pFileList )
+ pFileList->InsertEntry( aName );
+ }
+ else if( bWithDirs && ( aFileStat.GetKind() & FSYS_KIND_DIR ) )
+ {
+ if( pDirList == pFileList )
+ {
+ UniString aEntryStr( aName );
+ aEntryStr += '/';
+ pDirList->InsertEntry( aEntryStr );
+ }
+ else
+ {
+ ULONG l = 0;
+ if( xCollator.is() )
+ {
+ for( l = 0; l < aSortDirList.Count(); l++ )
+ if( xCollator->compareString( *aSortDirList.GetObject(l), aName ) > 0 )
+ break;
+ }
+ aSortDirList.Insert( new UniString( aName ), l );
+ }
+ }
+ }
+ }
+ for( ULONG l = 0; l < aSortDirList.Count(); l++ )
+ {
+ UniString aEntryStr( aTabString );
+ aEntryStr += *aSortDirList.GetObject(l);
+ pDirList->InsertEntry( aEntryStr );
+ delete aSortDirList.GetObject(l);
+ }
+ }
+
+ if( bWithDirs )
+ UpdateDirs( aTmpPath );
+
+ if( pFileList )
+ {
+ if ( pDirList == pFileList && nDirCount > 1 )
+ pFileList->SelectEntryPos( 1 );
+ else
+ pFileList->SetNoSelection();
+ pFileList->SetUpdateMode( TRUE );
+ pFileList->Invalidate();
+ pFileList->Update();
+ }
+
+ if( pDriveList )
+ {
+ if( pDirList->GetEntryCount() > 0 )
+ {
+ UniString aStr( pDirList->GetEntry( 0 ) );
+ aStr.Erase( 2 );
+ aStr.ToLowerAscii();
+ pDriveList->SelectEntry( aStr );
+ }
+ }
+
+ GetFileDialog()->LeaveWait();
+}
+
+BOOL ImpFileDialog::IsFileOk( const DirEntry& rDirEntry )
+{
+ if( FileStat( rDirEntry ).GetKind() & (FSYS_KIND_WILD | FSYS_KIND_DEV) )
+ return FALSE;
+ if( FileStat( rDirEntry ).GetKind() & FSYS_KIND_DIR )
+ {
+ if( pFileList )
+ return FALSE;
+ }
+ else if( bOpen )
+ {
+ // Datei vorhanden ?
+ if( !FileStat( rDirEntry ).IsKind( FSYS_KIND_FILE ) )
+ {
+ UniString aErrorString( SvtResId( STR_FILEDLG_CANTOPENFILE ) );
+ aErrorString.AppendAscii( "\n[" );
+ aErrorString += rDirEntry.GetFull();
+ aErrorString += ']';
+ InfoBox aBox( GetFileDialog(),
+ aErrorString );
+ aBox.Execute();
+ return FALSE;
+ }
+ }
+ else
+ {
+ // Datei vorhanden ?
+ if( FileStat( ExtendFileName( rDirEntry ) ).IsKind( FSYS_KIND_FILE ) )
+ {
+ UniString aQueryString( SvtResId( STR_FILEDLG_OVERWRITE ) );
+ aQueryString.AppendAscii( "\n[" );
+ aQueryString += rDirEntry.GetFull();
+ aQueryString += ']';
+ QueryBox aBox( GetFileDialog(),
+ WinBits( WB_YES_NO | WB_DEF_NO ),
+ aQueryString );
+ if( aBox.Execute() != RET_YES )
+ return FALSE;
+ }
+ }
+ return GetFileDialog()->OK() != 0;
+}
+
+void ImpFileDialog::SetPath( UniString const & rPath )
+{
+ aPath = DirEntry( rPath );
+ GetFileDialog()->EnterWait();
+
+ DirEntry aFile( rPath );
+
+ // Falls der Pfad eine Wildcard oder einen Filenamen enthaelt
+ // -> abschneiden und merken
+ if( FileStat( aFile ).GetKind() & (FSYS_KIND_FILE | FSYS_KIND_WILD) || !aFile.Exists() )
+ {
+ aMask = aFile.CutName();
+
+ // Neue Maske und neues Verzeichnis setzen, und Listboxen updaten
+ if( pDirList )
+ {
+ UniString aWildCard( aMask.GetWildCard() );
+ pEdit->SetText( aWildCard );
+ }
+ else
+ pEdit->SetText( rPath );
+ }
+
+ aFile.SetCWD( TRUE );
+
+ UpdateEntries( TRUE );
+
+ GetFileDialog()->LeaveWait();
+}
+
+void ImpFileDialog::SetPath( Edit const& rEdit )
+{
+ UniString aPresetText = rEdit.GetText();
+ if( aPresetText.Len() )
+ SetPath( aPresetText );
+}
+
+
+void ImpFileDialog::AddFilter( const UniString& rFilter, const UniString& rMask )
+{
+ aFilterList.Insert( new ImpFilterItem( rFilter, rMask ), LIST_APPEND );
+ if( pTypeList )
+ pTypeList->InsertEntry( rFilter, LISTBOX_APPEND );
+
+ if( !GetCurFilter().Len() )
+ SetCurFilter( rFilter );
+}
+
+void ImpFileDialog::RemoveFilter( const UniString& rFilter )
+{
+ ImpFilterItem* pItem = aFilterList.First();
+ while( pItem && pItem->aName != rFilter )
+ pItem = aFilterList.Next();
+
+ if( pItem )
+ {
+ delete aFilterList.Remove();
+ if( pTypeList )
+ pTypeList->RemoveEntry( rFilter );
+ }
+}
+
+void ImpFileDialog::RemoveAllFilter()
+{
+ ImpFilterItem* pItem = aFilterList.First();
+ while( pItem )
+ {
+ delete pItem;
+ pItem = aFilterList.Next();
+ }
+ aFilterList.Clear();
+
+ if( pTypeList )
+ pTypeList->Clear();
+}
+
+void ImpFileDialog::SetCurFilter( const UniString& rFilter )
+{
+ if( !pTypeList )
+ return;
+
+ ImpFilterItem* pItem = aFilterList.First();
+ while( pItem && pItem->aName != rFilter )
+ pItem = aFilterList.Next();
+
+ if( pItem )
+ pTypeList->SelectEntryPos( (USHORT)aFilterList.GetCurPos() );
+ else
+ pTypeList->SetNoSelection();
+}
+
+UniString ImpFileDialog::GetCurFilter() const
+{
+ UniString aFilter;
+ if ( pTypeList )
+ aFilter = pTypeList->GetSelectEntry();
+ return aFilter;
+}
+
+void ImpFileDialog::PreExecute()
+{
+ // ListBoxen erst unmittelbar vor Execute fuellen
+ // (damit vor Execute der Pfad umgesetzt werden kann, ohne das immer die
+ // Listboxen sofort upgedatet werden)
+
+ GetFileDialog()->EnterWait();
+
+ // Wenn kein Filter vorhanden, dann auch keine FilterBox
+ if( pTypeList && !pTypeList->GetEntryCount() )
+ {
+ // pTypeList->InsertEntry( "* (all files)" );
+ pTypeTitel->Disable();
+ pTypeList->Disable();
+ }
+
+ if( pTypeList )
+ {
+ USHORT nCurType = pTypeList->GetSelectEntryPos();
+ if( nCurType < aFilterList.Count() )
+ {
+ UniString aFilterListMask = aFilterList.GetObject( nCurType )->aMask;
+ if( aFilterListMask.Search( ';' ) == STRING_NOTFOUND ) // kein ; in der Maske
+ aMask = WildCard( aFilterListMask, '\0' );
+ else // ; in der Maske, muss in der Wildcard beruecksichtigt werden
+ aMask = WildCard( aFilterListMask, ';' );
+ }
+ else
+ aMask = UniString::CreateFromAscii( ALLFILES );
+ }
+ else
+ aMask = UniString::CreateFromAscii( ALLFILES );
+
+ // Neue Maske setzen
+ if( pEdit->GetText().Len() == 0 )
+ pEdit->SetText( aMask() );
+
+ ImpPathDialog::PreExecute();
+
+ GetFileDialog()->LeaveWait();
+}
+
+UniString ImpFileDialog::GetPath() const
+{
+ DirEntry aFile( pEdit->GetText() );
+ return ExtendFileName( aFile );
+}
+
+UniString ImpFileDialog::ExtendFileName( DirEntry aEntry ) const
+{
+ aEntry.ToAbs();
+ // das ganze Theater hier ohnehin nur machen, wenn Dateiname
+ // ohne Extension angegeben wurde
+ if( !aEntry.GetExtension().Len() )
+ {
+ UniString aPostfix; // hier kommt die ausgesuchte Extension herein
+
+ // ist ein Filter mit Extension gesetzt?
+ USHORT nChosenFilterPos = pTypeList->GetSelectEntryPos();
+ if( nChosenFilterPos != LISTBOX_ENTRY_NOTFOUND )
+ {
+ UniString aExtensionMask = GetFileDialog()->GetFilterType( nChosenFilterPos );
+ // aExtension ist z.B. *.sdw, alles bis einschliesslich Punkt abschneiden
+ UniString aExtension = aExtensionMask.Copy( aExtensionMask.Search( '.' )+1 );
+
+ // hat der Filter ueberhaupt eine Extension
+ if( aExtension.Len() )
+ {
+ // keine Wildcards enthalten?
+ if( ( aExtension.Search( '*' ) == STRING_NOTFOUND ) &&
+ ( aExtension.Search( '?' ) == STRING_NOTFOUND ) )
+ {
+ // OK, Filter hat Extension ohne Wildcards -> verwenden
+ aPostfix = aExtension;
+ }
+ else
+ {
+ // Filter hat Extension mit Wildcards (z.B. *.*) -> nicht verwenden
+ aPostfix.Erase();
+ }
+ }
+ else
+ {
+ // Filter hatte keine Extension (schwer vorstellbar) -> nichts anhaengen
+ aPostfix.Erase();
+ }
+ }
+ else
+ {
+ // kein Filter gefunden (merkw�rdig) -> Default-Extension anhaengen
+ aPostfix = GetFileDialog()->GetDefaultExt();
+ }
+
+ // jetzt kann es mit dem Anhaengen losgehen
+ const sal_Unicode* pExt = aPostfix.GetBuffer();
+ while( *pExt == '*' || *pExt == '?' )
+ pExt++;
+
+ if( *pExt )
+ {
+ UniString aName = aEntry.GetName();
+ if( *pExt != '.' )
+ aName += '.';
+ aName += pExt;
+ aEntry.SetName( aName );
+ }
+ }
+ return aEntry.GetFull();
+}
+
+
+void ImpSvFileDlg::CreateDialog( PathDialog* pSvDlg, WinBits nStyle, RESOURCE_TYPE nType, BOOL bCreate )
+{
+ delete pDlg;
+ if ( nType == WINDOW_PATHDIALOG )
+ pDlg = new ImpPathDialog( pSvDlg, nType, bCreate );
+ else
+ pDlg = new ImpFileDialog( pSvDlg, nStyle, nType );
+}
+
+
diff --git a/svtools/source/dialogs/filedlg2.hrc b/svtools/source/dialogs/filedlg2.hrc
new file mode 100644
index 000000000000..a75e9047eafb
--- /dev/null
+++ b/svtools/source/dialogs/filedlg2.hrc
@@ -0,0 +1,44 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: filedlg2.hrc,v $
+ * $Revision: 1.3 $
+ *
+ * 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.
+ *
+ ************************************************************************/
+#define STR_FILEDLG_SELECT 1000
+#define STR_FILEDLG_CANTCHDIR 1001
+#define STR_FILEDLG_OPEN 1002
+#define STR_FILEDLG_FILE 1003
+#define STR_FILEDLG_DIR 1004
+#define STR_FILEDLG_TYPE 1005
+#define STR_FILEDLG_CANTOPENFILE 1006
+#define STR_FILEDLG_CANTOPENDIR 1007
+#define STR_FILEDLG_OVERWRITE 1008
+#define STR_FILEDLG_GOUP 1009
+#define STR_FILEDLG_SAVE 1010
+#define STR_FILEDLG_DRIVES 1011
+#define STR_FILEDLG_HOME 1012
+#define STR_FILEDLG_NEWDIR 1013
+#define STR_FILEDLG_ASKNEWDIR 1014
diff --git a/svtools/source/dialogs/filedlg2.hxx b/svtools/source/dialogs/filedlg2.hxx
new file mode 100644
index 000000000000..fffa318e2529
--- /dev/null
+++ b/svtools/source/dialogs/filedlg2.hxx
@@ -0,0 +1,222 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: filedlg2.hxx,v $
+ * $Revision: 1.5 $
+ *
+ * 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 _FILEDLG2_HXX
+#define _FILEDLG2_HXX
+
+#include <tools/debug.hxx>
+#include <tools/fsys.hxx>
+#ifndef _SV_BUTTON_HXX //autogen wg. PushButton
+#include <vcl/button.hxx>
+#endif
+#include <vcl/unohelp.hxx>
+
+class FixedText;
+class Edit;
+class ListBox;
+class ListBox;
+class Button;
+
+class PathDialog;
+class FileDialog;
+class ImpPathDialog;
+
+struct ImpFilterItem
+{
+ String aName;
+ String aMask;
+
+ ImpFilterItem( const String & rFilter, const String & rMask )
+ {
+ aName = rFilter;
+ aMask = rMask;
+ }
+};
+
+DECLARE_LIST( ImpFilterList, ImpFilterItem* )
+#include <vcl/lstbox.hxx>
+
+class KbdListBox : public ListBox
+{
+public:
+
+ KbdListBox( Window* pParent, WinBits nStyle = WB_BORDER )
+ : ListBox ( pParent, nStyle )
+ {};
+
+virtual long PreNotify( NotifyEvent& rNEvt );
+
+};
+
+
+class ImpPathDialog
+{
+ friend class ImpFileDialog;
+
+private:
+ PathDialog* pSvPathDialog;
+ Edit* pEdit;
+ FixedText* pDirTitel;
+ KbdListBox* pDirList;
+ FixedText* pDirPath;
+ ListBox* pDriveList;
+ FixedText* pDriveTitle;
+ PushButton* pLoadBtn;
+ PushButton* pOkBtn;
+ PushButton* pCancelBtn;
+ PushButton* pHomeBtn;
+ PushButton* pNewDirBtn;
+
+ USHORT nOwnChilds;
+
+ DirEntry aPath; // aktuell angewaehlter Pfad
+ USHORT nDirCount; // Anzahl der Verzeichnis-
+ // Verschachtelungen
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::i18n::XCollator >
+ xCollator;
+
+protected:
+
+ virtual void UpdateEntries( const BOOL bWithDirs );
+ void UpdateDirs( const DirEntry& rTmpPath );
+
+ BOOL IsFileOk( const DirEntry& rDirEntry );
+ void InitControls();
+
+ DECL_LINK( SelectHdl, ListBox * );
+ DECL_LINK( DblClickHdl, ListBox * );
+ DECL_LINK( ClickHdl, Button * );
+
+public:
+ ImpPathDialog( PathDialog* pDlg, RESOURCE_TYPE nType, BOOL bCreateDir );
+ virtual ~ImpPathDialog();
+
+ virtual void SetPath( const String& rPath );
+ virtual void SetPath( const Edit& rEdit );
+ virtual String GetPath() const;
+
+ virtual void PreExecute();
+ virtual void PostExecute();
+
+ PathDialog* GetPathDialog() const { return pSvPathDialog; }
+
+ void SetOkButtonText( const String& rText ) { pOkBtn->SetText( rText ); }
+ void SetCancelButtonText( const String& rText ) { pCancelBtn->SetText( rText ); }
+
+};
+
+
+class ImpFileDialog : public ImpPathDialog
+{
+private:
+ FixedText* pFileTitel;
+ ListBox* pFileList;
+ FixedText* pTypeTitel;
+ ListBox* pTypeList;
+
+ WildCard aMask; // aktuelle Maske
+
+ ImpFilterList aFilterList; // Filterliste
+ USHORT nCurFilter; // aktueller Filter
+
+ BOOL bOpen; // TRUE = Open; FALSE = SAVEAS
+
+protected:
+ void InitControls();
+
+ String ExtendFileName( DirEntry aEntry ) const;
+
+ DECL_LINK( SelectHdl, ListBox * );
+ DECL_LINK( DblClickHdl, ListBox * );
+ DECL_LINK( ClickHdl, Button * );
+
+ virtual void UpdateEntries( const BOOL bWithDirs );
+ BOOL IsFileOk( const DirEntry& rDirEntry );
+
+public:
+ ImpFileDialog( PathDialog* pDlg, WinBits nStyle, RESOURCE_TYPE nType );
+ virtual ~ImpFileDialog();
+
+ void AddFilter( const String& rFilter, const String& rMask );
+ void RemoveFilter( const String& rFilter );
+ void RemoveAllFilter();
+ void SetCurFilter( const String& rFilter );
+ String GetCurFilter() const;
+
+ USHORT GetFilterCount() const { return (USHORT)aFilterList.Count(); }
+ inline String GetFilterName( USHORT nPos ) const;
+ inline String GetFilterType( USHORT nPos ) const;
+
+ virtual void SetPath( const String& rPath );
+ virtual void SetPath( const Edit& rEdit );
+ virtual String GetPath() const;
+
+ virtual void PreExecute();
+
+ FileDialog* GetFileDialog() const { return (FileDialog*)GetPathDialog(); }
+};
+
+inline String ImpFileDialog::GetFilterName( USHORT nPos ) const
+{
+ String aName;
+ ImpFilterItem* pItem = aFilterList.GetObject( nPos );
+ if ( pItem )
+ aName = pItem->aName;
+ return aName;
+}
+
+inline String ImpFileDialog::GetFilterType( USHORT nPos ) const
+{
+ String aFilterMask;
+ ImpFilterItem* pItem = aFilterList.GetObject( nPos );
+ if ( pItem )
+ aFilterMask = pItem->aMask;
+ return aFilterMask;
+}
+
+class ImpSvFileDlg
+{
+private:
+ ImpPathDialog* pDlg;
+
+public:
+ ImpSvFileDlg() { pDlg = 0; }
+ ~ImpSvFileDlg() { delete pDlg; }
+
+ ImpPathDialog* GetDialog() const { return pDlg; }
+ void CreateDialog( PathDialog* pCreateFrom, WinBits nStyle, RESOURCE_TYPE nType, BOOL bCreate );
+
+ void SetOkButtonText( const String& rText ) { pDlg->SetOkButtonText( rText ); } // ihr habts ja nicht anders gewollt
+ void SetCancelButtonText( const String& rText ) { pDlg->SetCancelButtonText( rText ); }
+
+};
+
+#endif // _FILEDLG2_HXX
diff --git a/svtools/source/dialogs/filedlg2.src b/svtools/source/dialogs/filedlg2.src
new file mode 100644
index 000000000000..ecbabc79941b
--- /dev/null
+++ b/svtools/source/dialogs/filedlg2.src
@@ -0,0 +1,129 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: filedlg2.src,v $
+ * $Revision: 1.29 $
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#include <filedlg2.hrc>
+String STR_FILEDLG_SELECT
+{
+ Text [ en-US ] = "Select Directory" ;
+};
+String STR_FILEDLG_CANTCHDIR
+{
+ Text [ en-US ] = "Cannot change to directory" ;
+};
+String STR_FILEDLG_OPEN
+{
+ Text [ en-US ] = "Open" ;
+};
+String STR_FILEDLG_FILE
+{
+ Text [ en-US ] = "~File" ;
+};
+String STR_FILEDLG_DIR
+{
+ Text [ en-US ] = "~Directory" ;
+};
+String STR_FILEDLG_TYPE
+{
+ Text [ en-US ] = "File ~type" ;
+};
+String STR_FILEDLG_CANTOPENFILE
+{
+ Text [ en-US ] = "Can't open file" ;
+};
+String STR_FILEDLG_CANTOPENDIR
+{
+ Text [ en-US ] = "Can't open directory" ;
+};
+String STR_FILEDLG_OVERWRITE
+{
+ Text [ en-US ] = "This file already exists. \nOverwrite ?" ;
+};
+String STR_FILEDLG_GOUP
+{
+ Text [ en-US ] = "Up One Level" ;
+};
+String STR_FILEDLG_SAVE
+{
+ Text [ en-US ] = "Save" ;
+};
+String STR_FILEDLG_DRIVES
+{
+ Text [ en-US ] = "D~rive" ;
+};
+String STR_FILEDLG_HOME
+{
+ Text [ en-US ] = "User Directory" ;
+};
+String STR_FILEDLG_NEWDIR
+{
+ Text [ en-US ] = "Create Directory" ;
+};
+String STR_FILEDLG_ASKNEWDIR
+{
+ Text [ en-US ] = "Do you want the directory %s to be created ?" ;
+};
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/svtools/source/dialogs/formats.src b/svtools/source/dialogs/formats.src
new file mode 100644
index 000000000000..a3a738a705fb
--- /dev/null
+++ b/svtools/source/dialogs/formats.src
@@ -0,0 +1,297 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: formats.src,v $
+ * $Revision: 1.7 $
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#include "sores.hxx"
+
+String STR_FORMAT_STRING
+{
+ Text [ en-US ] = "Unformatted text" ;
+};
+String STR_FORMAT_BITMAP
+{
+ Text [ en-US ] = "Bitmap";
+};
+String STR_FORMAT_GDIMETAFILE
+{
+ Text [ en-US ] = "GDI metafile";
+};
+String STR_FORMAT_RTF
+{
+ Text [ en-US ] = "Formatted text [RTF]" ;
+};
+String STR_FORMAT_ID_DRAWING
+{
+ Text [ en-US ] = "Drawing format";
+};
+String STR_FORMAT_ID_SVXB
+{
+ Text [ en-US ] = "SVXB (StarView bitmap/animation)";
+};
+String STR_FORMAT_ID_INTERNALLINK_STATE
+{
+ Text [ en-US ] = "Status Info from Svx Internal Link";
+};
+String STR_FORMAT_ID_SOLK
+{
+ Text [ en-US ] = "SOLK (%PRODUCTNAME Link)";
+};
+String STR_FORMAT_ID_NETSCAPE_BOOKMARK
+{
+ Text [ en-US ] = "Netscape Bookmark";
+};
+String STR_FORMAT_ID_STARSERVER
+{
+ Text [ en-US ] = "Star server format";
+};
+String STR_FORMAT_ID_STAROBJECT
+{
+ Text [ en-US ] = "Star object format";
+};
+String STR_FORMAT_ID_APPLETOBJECT
+{
+ Text [ en-US ] = "Applet object";
+};
+String STR_FORMAT_ID_PLUGIN_OBJECT
+{
+ Text [ en-US ] = "Plug-in object";
+};
+String STR_FORMAT_ID_STARWRITER_30
+{
+ Text [ en-US ] = "StarWriter 3.0 object";
+};
+String STR_FORMAT_ID_STARWRITER_40
+{
+ Text [ en-US ] = "StarWriter 4.0 object";
+};
+String STR_FORMAT_ID_STARWRITER_50
+{
+ Text [ en-US ] = "StarWriter 5.0 object";
+};
+String STR_FORMAT_ID_STARWRITERWEB_40
+{
+ Text [ en-US ] = "StarWriter/Web 4.0 object";
+};
+String STR_FORMAT_ID_STARWRITERWEB_50
+{
+ Text [ en-US ] = "StarWriter/Web 5.0 object";
+};
+String STR_FORMAT_ID_STARWRITERGLOB_40
+{
+ Text [ en-US ] = "StarWriter/Master 4.0 object";
+};
+String STR_FORMAT_ID_STARWRITERGLOB_50
+{
+ Text [ en-US ] = "StarWriter/Master 5.0 object";
+};
+String STR_FORMAT_ID_STARDRAW
+{
+ Text [ en-US ] = "StarDraw object";
+};
+String STR_FORMAT_ID_STARDRAW_40
+{
+ Text [ en-US ] = "StarDraw 4.0 object";
+};
+String STR_FORMAT_ID_STARIMPRESS_50
+{
+ Text [ en-US ] = "StarImpress 5.0 object";
+};
+String STR_FORMAT_ID_STARDRAW_50
+{
+ Text [ en-US ] = "StarDraw 5.0 object";
+};
+String STR_FORMAT_ID_STARCALC
+{
+ Text [ en-US ] = "StarCalc object";
+};
+String STR_FORMAT_ID_STARCALC_40
+{
+ Text [ en-US ] = "StarCalc 4.0 object";
+};
+String STR_FORMAT_ID_STARCALC_50
+{
+ Text [ en-US ] = "StarCalc 5.0 object";
+};
+String STR_FORMAT_ID_STARCHART
+{
+ Text [ en-US ] = "StarChart object";
+};
+String STR_FORMAT_ID_STARCHART_40
+{
+ Text [ en-US ] = "StarChart 4.0 object";
+};
+String STR_FORMAT_ID_STARCHART_50
+{
+ Text [ en-US ] = "StarChart 5.0 object";
+};
+String STR_FORMAT_ID_STARIMAGE
+{
+ Text [ en-US ] = "StarImage object";
+};
+String STR_FORMAT_ID_STARIMAGE_40
+{
+ Text [ en-US ] = "StarImage 4.0 object";
+};
+String STR_FORMAT_ID_STARIMAGE_50
+{
+ Text [ en-US ] = "StarImage 5.0 object";
+};
+String STR_FORMAT_ID_STARMATH
+{
+ Text [ en-US ] = "StarMath object";
+};
+String STR_FORMAT_ID_STARMATH_40
+{
+ Text [ en-US ] = "StarMath 4.0 object";
+};
+String STR_FORMAT_ID_STARMATH_50
+{
+ Text [ en-US ] = "StarMath 5.0 object";
+};
+String STR_FORMAT_ID_STAROBJECT_PAINTDOC
+{
+ Text [ en-US ] = "StarObject Paint object";
+};
+String STR_FORMAT_ID_HTML
+{
+ Text [ en-US ] = "HTML (HyperText Markup Language)";
+};
+String STR_FORMAT_ID_HTML_SIMPLE
+{
+ Text [ en-US ] = "HTML format";
+};
+String STR_FORMAT_ID_BIFF_5
+{
+ Text [ en-US ] = "Biff5 (Microsoft Excel 5.0/95)";
+};
+String STR_FORMAT_ID_BIFF_8
+{
+ Text [ en-US ] = "Biff8 (Microsoft Excel 97/2000/XP)";
+};
+String STR_FORMAT_ID_SYLK
+{
+ Text [ en-US ] = "Sylk";
+};
+String STR_FORMAT_ID_LINK
+{
+ Text [ en-US ] = "DDE link" ;
+};
+String STR_FORMAT_ID_DIF
+{
+ Text [ en-US ] = "DIF";
+};
+String STR_FORMAT_ID_MSWORD_DOC
+{
+ Text [ en-US ] = "Microsoft Word object";
+};
+String STR_FORMAT_ID_STAR_FRAMESET_DOC
+{
+ Text [ en-US ] = "StarFrameSet object";
+};
+String STR_FORMAT_ID_OFFICE_DOC
+{
+ Text [ en-US ] = "Office document object";
+};
+String STR_FORMAT_ID_NOTES_DOCINFO
+{
+ Text [ en-US ] = "Notes document info";
+};
+String STR_FORMAT_ID_SFX_DOC
+{
+ Text [ en-US ] = "Sfx document";
+};
+String STR_FORMAT_ID_STARCHARTDOCUMENT_50
+{
+ Text [ en-US ] = "StarChart 5.0 object";
+};
+String STR_FORMAT_ID_GRAPHOBJ
+{
+ Text [ en-US ] = "Graphic object";
+};
+String STR_FORMAT_ID_STARWRITER_60
+{
+ Text [ en-US ] = "%PRODUCTXMLFILEFORMATNAME %PRODUCTXMLFILEFORMATVERSION Writer object";
+};
+String STR_FORMAT_ID_STARWRITERWEB_60
+{
+ Text [ en-US ] = "%PRODUCTXMLFILEFORMATNAME %PRODUCTXMLFILEFORMATVERSION Writer/Web object";
+};
+String STR_FORMAT_ID_STARWRITERGLOB_60
+{
+ Text [ en-US ] = "%PRODUCTXMLFILEFORMATNAME %PRODUCTXMLFILEFORMATVERSION Writer/Master object";
+};
+String STR_FORMAT_ID_STARDRAW_60
+{
+ Text [ en-US ] = "%PRODUCTXMLFILEFORMATNAME %PRODUCTXMLFILEFORMATVERSION Draw object";
+};
+String STR_FORMAT_ID_STARIMPRESS_60
+{
+ Text [ en-US ] = "%PRODUCTXMLFILEFORMATNAME %PRODUCTXMLFILEFORMATVERSION Impress object";
+};
+String STR_FORMAT_ID_STARCALC_60
+{
+ Text [ en-US ] = "%PRODUCTXMLFILEFORMATNAME %PRODUCTXMLFILEFORMATVERSION Calc object";
+};
+String STR_FORMAT_ID_STARCHART_60
+{
+ Text [ en-US ] = "%PRODUCTXMLFILEFORMATNAME %PRODUCTXMLFILEFORMATVERSION Chart object";
+};
+String STR_FORMAT_ID_STARMATH_60
+{
+ Text [ en-US ] = "%PRODUCTXMLFILEFORMATNAME %PRODUCTXMLFILEFORMATVERSION Math object";
+};
+String STR_FORMAT_ID_WMF
+{
+ Text [ en-US ] = "Windows metafile";
+};
+String STR_FORMAT_ID_DBACCESS_QUERY
+{
+ Text [ en-US ] = "Data source object";
+};
+String STR_FORMAT_ID_DBACCESS_TABLE
+{
+ Text [ en-US ] = "Data source table";
+};
+String STR_FORMAT_ID_DBACCESS_COMMAND
+{
+ Text [ en-US ] = "SQL query";
+};
+String STR_FORMAT_ID_DIALOG_60
+{
+ Text [ en-US ] = "%PRODUCTXMLFILEFORMATNAME %PRODUCTXMLFILEFORMATVERSION dialog";
+};
+String STR_FORMAT_ID_FILEGRPDESCRIPTOR
+{
+ Text [ en-US ] = "Link";
+};
+String STR_FORMAT_ID_HTML_NO_COMMENT
+{
+ Text [ en-US ] = "HTML format without comments";
+};
+
diff --git a/svtools/source/dialogs/insdlg.cxx b/svtools/source/dialogs/insdlg.cxx
new file mode 100644
index 000000000000..a1bbbd9b9edb
--- /dev/null
+++ b/svtools/source/dialogs/insdlg.cxx
@@ -0,0 +1,392 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: insdlg.cxx,v $
+ * $Revision: 1.12 $
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_svtools.hxx"
+
+#define _INSDLG_CXX
+
+// include ---------------------------------------------------------------
+
+#include <svtools/insdlg.hxx>
+#include "sores.hxx"
+#include <svtools/svtdata.hxx>
+
+#include <tools/rc.hxx>
+#include <unotools/configmgr.hxx>
+#include <sot/clsids.hxx>
+#include <sot/stg.hxx>
+
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/beans/PropertyValue.hpp>
+#include <comphelper/processfactory.hxx>
+#include <com/sun/star/container/XNameAccess.hpp>
+
+using namespace ::com::sun::star;
+
+//---------------------------------------------
+// this struct conforms to the Microsoft
+// OBJECTDESCRIPTOR -> see oleidl.h
+// (MS platform sdk)
+//---------------------------------------------
+
+struct OleObjectDescriptor
+{
+ sal_uInt32 cbSize;
+ ClsId clsid;
+ sal_uInt32 dwDrawAspect;
+ Size sizel;
+ Point pointl;
+ sal_uInt32 dwStatus;
+ sal_uInt32 dwFullUserTypeName;
+ sal_uInt32 dwSrcOfCopy;
+};
+
+/********************** SvObjectServerList ********************************
+**************************************************************************/
+PRV_SV_IMPL_OWNER_LIST( SvObjectServerList, SvObjectServer )
+
+/*************************************************************************
+|* SvObjectServerList::SvObjectServerList()
+|*
+|* Beschreibung
+*************************************************************************/
+const SvObjectServer * SvObjectServerList::Get( const String & rHumanName ) const
+{
+ for( ULONG i = 0; i < Count(); i++ )
+ {
+ if( rHumanName == GetObject( i ).GetHumanName() )
+ return &GetObject( i );
+ }
+ return NULL;
+}
+
+/*************************************************************************
+|* SvObjectServerList::SvObjectServerList()
+|*
+|* Beschreibung
+*************************************************************************/
+const SvObjectServer * SvObjectServerList::Get( const SvGlobalName & rName ) const
+{
+ for( ULONG i = 0; i < Count(); i++ )
+ {
+ if( rName == GetObject( i ).GetClassName() )
+ return &GetObject( i );
+ }
+ return NULL;
+}
+
+void SvObjectServerList::Remove( const SvGlobalName & rName )
+{
+ SvObjectServer * pS = (SvObjectServer *)aTypes.First();
+ while( pS )
+ {
+ if( rName == pS->GetClassName() )
+ {
+ Remove();
+ pS = (SvObjectServer *)aTypes.GetCurObject();
+ }
+ else
+ pS = (SvObjectServer *)aTypes.Next();
+ }
+}
+
+//---------------------------------------------------------------------
+void SvObjectServerList::FillInsertObjects()
+/* [Beschreibung]
+
+ Die Liste wird mit allen Typen gef"ullt, die im Insert-Dialog
+ ausgew"ahlt werden k"onnen.
+*/
+{
+ try{
+ uno::Reference< lang::XMultiServiceFactory > _globalMSFactory= comphelper::getProcessServiceFactory();
+ if( _globalMSFactory.is())
+ {
+ ::rtl::OUString sProviderService =
+ ::rtl::OUString::createFromAscii( "com.sun.star.configuration.ConfigurationProvider" );
+ uno::Reference< lang::XMultiServiceFactory > sProviderMSFactory(
+ _globalMSFactory->createInstance( sProviderService ), uno::UNO_QUERY );
+
+ if( sProviderMSFactory.is())
+ {
+ ::rtl::OUString sReaderService =
+ ::rtl::OUString::createFromAscii( "com.sun.star.configuration.ConfigurationAccess" );
+ uno::Sequence< uno::Any > aArguments( 1 );
+ beans::PropertyValue aPathProp;
+ aPathProp.Name = ::rtl::OUString::createFromAscii( "nodepath" );
+ aPathProp.Value <<= ::rtl::OUString::createFromAscii( "/org.openoffice.Office.Embedding/ObjectNames");
+ aArguments[0] <<= aPathProp;
+
+ uno::Reference< container::XNameAccess > xNameAccess(
+ sProviderMSFactory->createInstanceWithArguments( sReaderService,aArguments ),
+ uno::UNO_QUERY );
+
+ if( xNameAccess.is())
+ {
+ uno::Sequence< ::rtl::OUString > seqNames= xNameAccess->getElementNames();
+ sal_Int32 nInd;
+
+ ::rtl::OUString aStringProductName( RTL_CONSTASCII_USTRINGPARAM( "%PRODUCTNAME" ) );
+ sal_Int32 nStringProductNameLength = aStringProductName.getLength();
+
+ ::rtl::OUString aStringProductVersion( RTL_CONSTASCII_USTRINGPARAM( "%PRODUCTVERSION" ) );
+ sal_Int32 nStringProductVersionLength = aStringProductVersion.getLength();
+
+ // TODO/LATER: Do the request only once ( needs incompatible change )
+ ::rtl::OUString aProductName;
+ ::rtl::OUString aProductVersion;
+ uno::Any aProperty =
+ ::utl::ConfigManager::GetDirectConfigProperty( ::utl::ConfigManager::PRODUCTNAME );
+ if ( !( aProperty >>= aProductName ) )
+ {
+ OSL_ENSURE( sal_False, "Coudn't get PRODUCTNAME variable!\n" );
+ aProductName = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "StarOffice" ) );
+ }
+ aProperty = ::utl::ConfigManager::GetDirectConfigProperty( ::utl::ConfigManager::PRODUCTVERSION );
+ if ( !( aProperty >>= aProductVersion ) )
+ {
+ OSL_ENSURE( sal_False, "Coudn't get PRODUCTVERSION variable!\n" );
+ }
+
+ for( nInd = 0; nInd < seqNames.getLength(); nInd++ )
+ {
+ uno::Reference< container::XNameAccess > xEntry ;
+ xNameAccess->getByName( seqNames[nInd] ) >>= xEntry;
+ if ( xEntry.is() )
+ {
+ ::rtl::OUString aUIName;
+ ::rtl::OUString aClassID;
+ xEntry->getByName( ::rtl::OUString::createFromAscii("ObjectUIName") ) >>= aUIName;
+ xEntry->getByName( ::rtl::OUString::createFromAscii("ClassID") ) >>= aClassID;
+
+ if ( aUIName.getLength() )
+ {
+ // replace %PRODUCTNAME
+ sal_Int32 nIndex = aUIName.indexOf( aStringProductName );
+ while( nIndex != -1 )
+ {
+ aUIName = aUIName.replaceAt( nIndex, nStringProductNameLength, aProductName );
+ nIndex = aUIName.indexOf( aStringProductName );
+ }
+
+ // replace %PRODUCTVERSION
+ nIndex = aUIName.indexOf( aStringProductVersion );
+ while( nIndex != -1 )
+ {
+ aUIName = aUIName.replaceAt( nIndex, nStringProductVersionLength, aProductVersion );
+ nIndex = aUIName.indexOf( aStringProductVersion );
+ }
+ }
+
+ SvGlobalName aClassName;
+ if( aClassName.MakeId( String( aClassID )))
+ {
+ if( !Get( aClassName ) )
+ // noch nicht eingetragen
+ Append( SvObjectServer( aClassName, String( aUIName.getStr() ) ) );
+ }
+ }
+ }
+ }
+ }
+ }
+
+
+#ifdef WNT
+ SvGlobalName aOleFact( SO3_OUT_CLASSID );
+ String aOleObj( SvtResId( STR_FURTHER_OBJECT ) );
+ Append( SvObjectServer( aOleFact, aOleObj ) );
+#endif
+
+ }catch( container::NoSuchElementException)
+ {
+ }catch( uno::Exception)
+ {
+ }
+ catch(...)
+ {
+ }
+}
+
+String SvPasteObjectHelper::GetSotFormatUIName( SotFormatStringId nId )
+{
+ struct SotResourcePair
+ {
+ SotFormatStringId mnSotId;
+ USHORT mnResId;
+ };
+
+ static const SotResourcePair aSotResourcePairs[] =
+ {
+ { SOT_FORMAT_STRING, STR_FORMAT_STRING },
+ { SOT_FORMAT_BITMAP, STR_FORMAT_BITMAP },
+ { SOT_FORMAT_GDIMETAFILE, STR_FORMAT_GDIMETAFILE },
+ { SOT_FORMAT_RTF, STR_FORMAT_RTF },
+ { SOT_FORMATSTR_ID_DRAWING, STR_FORMAT_ID_DRAWING },
+ { SOT_FORMATSTR_ID_SVXB, STR_FORMAT_ID_SVXB },
+ { SOT_FORMATSTR_ID_INTERNALLINK_STATE, STR_FORMAT_ID_INTERNALLINK_STATE },
+ { SOT_FORMATSTR_ID_SOLK, STR_FORMAT_ID_SOLK },
+ { SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK, STR_FORMAT_ID_NETSCAPE_BOOKMARK },
+ { SOT_FORMATSTR_ID_STARSERVER, STR_FORMAT_ID_STARSERVER },
+ { SOT_FORMATSTR_ID_STAROBJECT, STR_FORMAT_ID_STAROBJECT },
+ { SOT_FORMATSTR_ID_APPLETOBJECT, STR_FORMAT_ID_APPLETOBJECT },
+ { SOT_FORMATSTR_ID_PLUGIN_OBJECT, STR_FORMAT_ID_PLUGIN_OBJECT },
+ { SOT_FORMATSTR_ID_STARWRITER_30, STR_FORMAT_ID_STARWRITER_30 },
+ { SOT_FORMATSTR_ID_STARWRITER_40, STR_FORMAT_ID_STARWRITER_40 },
+ { SOT_FORMATSTR_ID_STARWRITER_50, STR_FORMAT_ID_STARWRITER_50 },
+ { SOT_FORMATSTR_ID_STARWRITERWEB_40, STR_FORMAT_ID_STARWRITERWEB_40 },
+ { SOT_FORMATSTR_ID_STARWRITERWEB_50, STR_FORMAT_ID_STARWRITERWEB_50 },
+ { SOT_FORMATSTR_ID_STARWRITERGLOB_40, STR_FORMAT_ID_STARWRITERGLOB_40 },
+ { SOT_FORMATSTR_ID_STARWRITERGLOB_50, STR_FORMAT_ID_STARWRITERGLOB_50 },
+ { SOT_FORMATSTR_ID_STARDRAW, STR_FORMAT_ID_STARDRAW },
+ { SOT_FORMATSTR_ID_STARDRAW_40, STR_FORMAT_ID_STARDRAW_40 },
+ { SOT_FORMATSTR_ID_STARIMPRESS_50, STR_FORMAT_ID_STARIMPRESS_50 },
+ { SOT_FORMATSTR_ID_STARDRAW_50, STR_FORMAT_ID_STARDRAW_50 },
+ { SOT_FORMATSTR_ID_STARCALC, STR_FORMAT_ID_STARCALC },
+ { SOT_FORMATSTR_ID_STARCALC_40, STR_FORMAT_ID_STARCALC_40 },
+ { SOT_FORMATSTR_ID_STARCALC_50, STR_FORMAT_ID_STARCALC_50 },
+ { SOT_FORMATSTR_ID_STARCHART, STR_FORMAT_ID_STARCHART },
+ { SOT_FORMATSTR_ID_STARCHART_40, STR_FORMAT_ID_STARCHART_40 },
+ { SOT_FORMATSTR_ID_STARCHART_50, STR_FORMAT_ID_STARCHART_50 },
+ { SOT_FORMATSTR_ID_STARIMAGE, STR_FORMAT_ID_STARIMAGE },
+ { SOT_FORMATSTR_ID_STARIMAGE_40, STR_FORMAT_ID_STARIMAGE_40 },
+ { SOT_FORMATSTR_ID_STARIMAGE_50, STR_FORMAT_ID_STARIMAGE_50 },
+ { SOT_FORMATSTR_ID_STARMATH, STR_FORMAT_ID_STARMATH },
+ { SOT_FORMATSTR_ID_STARMATH_40, STR_FORMAT_ID_STARMATH_40 },
+ { SOT_FORMATSTR_ID_STARMATH_50, STR_FORMAT_ID_STARMATH_50 },
+ { SOT_FORMATSTR_ID_STAROBJECT_PAINTDOC, STR_FORMAT_ID_STAROBJECT_PAINTDOC },
+ { SOT_FORMATSTR_ID_HTML, STR_FORMAT_ID_HTML },
+ { SOT_FORMATSTR_ID_HTML_SIMPLE, STR_FORMAT_ID_HTML_SIMPLE },
+ { SOT_FORMATSTR_ID_BIFF_5, STR_FORMAT_ID_BIFF_5 },
+ { SOT_FORMATSTR_ID_BIFF_8, STR_FORMAT_ID_BIFF_8 },
+ { SOT_FORMATSTR_ID_SYLK, STR_FORMAT_ID_SYLK },
+ { SOT_FORMATSTR_ID_LINK, STR_FORMAT_ID_LINK },
+ { SOT_FORMATSTR_ID_DIF, STR_FORMAT_ID_DIF },
+ { SOT_FORMATSTR_ID_MSWORD_DOC, STR_FORMAT_ID_MSWORD_DOC },
+ { SOT_FORMATSTR_ID_STAR_FRAMESET_DOC, STR_FORMAT_ID_STAR_FRAMESET_DOC },
+ { SOT_FORMATSTR_ID_OFFICE_DOC, STR_FORMAT_ID_OFFICE_DOC },
+ { SOT_FORMATSTR_ID_NOTES_DOCINFO, STR_FORMAT_ID_NOTES_DOCINFO },
+ { SOT_FORMATSTR_ID_SFX_DOC, STR_FORMAT_ID_SFX_DOC },
+ { SOT_FORMATSTR_ID_STARCHARTDOCUMENT_50,STR_FORMAT_ID_STARCHARTDOCUMENT_50 },
+ { SOT_FORMATSTR_ID_GRAPHOBJ, STR_FORMAT_ID_GRAPHOBJ },
+ { SOT_FORMATSTR_ID_STARWRITER_60, STR_FORMAT_ID_STARWRITER_60 },
+ { SOT_FORMATSTR_ID_STARWRITERWEB_60, STR_FORMAT_ID_STARWRITERWEB_60 },
+ { SOT_FORMATSTR_ID_STARWRITERGLOB_60, STR_FORMAT_ID_STARWRITERGLOB_60 },
+ { SOT_FORMATSTR_ID_STARDRAW_60, STR_FORMAT_ID_STARDRAW_60 },
+ { SOT_FORMATSTR_ID_STARIMPRESS_60, STR_FORMAT_ID_STARIMPRESS_60 },
+ { SOT_FORMATSTR_ID_STARCALC_60, STR_FORMAT_ID_STARCALC_60 },
+ { SOT_FORMATSTR_ID_STARCHART_60, STR_FORMAT_ID_STARCHART_60 },
+ { SOT_FORMATSTR_ID_STARMATH_60, STR_FORMAT_ID_STARMATH_60 },
+ { SOT_FORMATSTR_ID_WMF, STR_FORMAT_ID_WMF },
+ { SOT_FORMATSTR_ID_DBACCESS_QUERY, STR_FORMAT_ID_DBACCESS_QUERY },
+ { SOT_FORMATSTR_ID_DBACCESS_TABLE, STR_FORMAT_ID_DBACCESS_TABLE },
+ { SOT_FORMATSTR_ID_DBACCESS_COMMAND, STR_FORMAT_ID_DBACCESS_COMMAND },
+ { SOT_FORMATSTR_ID_DIALOG_60, STR_FORMAT_ID_DIALOG_60 },
+ { SOT_FORMATSTR_ID_FILEGRPDESCRIPTOR, STR_FORMAT_ID_FILEGRPDESCRIPTOR },
+ { SOT_FORMATSTR_ID_HTML_NO_COMMENT, STR_FORMAT_ID_HTML_NO_COMMENT }
+ };
+
+ String aUIName;
+ USHORT nResId = 0;
+
+ for( sal_uInt32 i = 0, nCount = sizeof( aSotResourcePairs ) / sizeof( aSotResourcePairs[ 0 ] ); ( i < nCount ) && !nResId; i++ )
+ {
+ if( aSotResourcePairs[ i ].mnSotId == nId )
+ nResId = aSotResourcePairs[ i ].mnResId;
+ }
+
+ if( nResId )
+ aUIName = String( SvtResId( nResId ) );
+ else
+ aUIName = SotExchange::GetFormatName( nId );
+
+ return aUIName;
+}
+// -----------------------------------------------------------------------------
+sal_Bool SvPasteObjectHelper::GetEmbeddedName(const TransferableDataHelper& rData,String& _rName,String& _rSource,SotFormatStringId& _nFormat)
+{
+ sal_Bool bRet = sal_False;
+ if( _nFormat == SOT_FORMATSTR_ID_EMBED_SOURCE_OLE || _nFormat == SOT_FORMATSTR_ID_EMBEDDED_OBJ_OLE )
+ {
+ datatransfer::DataFlavor aFlavor;
+ SotExchange::GetFormatDataFlavor( SOT_FORMATSTR_ID_OBJECTDESCRIPTOR_OLE, aFlavor );
+
+ uno::Any aAny;
+ if( rData.HasFormat( aFlavor ) &&
+ ( aAny = rData.GetAny( aFlavor ) ).hasValue() )
+ {
+ uno::Sequence< sal_Int8 > anySequence;
+ aAny >>= anySequence;
+
+ OleObjectDescriptor* pOleObjDescr =
+ reinterpret_cast< OleObjectDescriptor* >( anySequence.getArray( ) );
+
+ // determine the user friendly description of the embedded object
+ if ( pOleObjDescr->dwFullUserTypeName )
+ {
+ // we set the pointer to the start of user friendly description
+ // string. it starts at &OleObjectDescriptor + dwFullUserTypeName.
+ // dwFullUserTypeName is the offset in bytes.
+ // the user friendly description string is '\0' terminated.
+ const sal_Unicode* pUserTypeName =
+ reinterpret_cast< sal_Unicode* >(
+ reinterpret_cast< sal_Char* >( pOleObjDescr ) +
+ pOleObjDescr->dwFullUserTypeName );
+
+ _rName.Append( pUserTypeName );
+ // the following statement was here for historical reasons, it is commented out since it causes bug i49460
+ // _nFormat = SOT_FORMATSTR_ID_EMBED_SOURCE_OLE;
+ }
+
+ // determine the source of the embedded object
+ if ( pOleObjDescr->dwSrcOfCopy )
+ {
+ // we set the pointer to the start of source string
+ // it starts at &OleObjectDescriptor + dwSrcOfCopy.
+ // dwSrcOfCopy is the offset in bytes.
+ // the source string is '\0' terminated.
+ const sal_Unicode* pSrcOfCopy =
+ reinterpret_cast< sal_Unicode* >(
+ reinterpret_cast< sal_Char* >( pOleObjDescr ) +
+ pOleObjDescr->dwSrcOfCopy );
+
+ _rSource.Append( pSrcOfCopy );
+ }
+ else
+ _rSource =
+ String( SvtResId( STR_UNKNOWN_SOURCE ) );
+ }
+ bRet = sal_True;
+ }
+ return bRet;
+}
+// -----------------------------------------------------------------------------
+
diff --git a/svtools/source/dialogs/logindlg.cxx b/svtools/source/dialogs/logindlg.cxx
new file mode 100644
index 000000000000..7ac65a77947d
--- /dev/null
+++ b/svtools/source/dialogs/logindlg.cxx
@@ -0,0 +1,315 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: logindlg.cxx,v $
+ * $Revision: 1.10 $
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_svtools.hxx"
+#include <filedlg.hxx>
+#include <vcl/msgbox.hxx>
+#include <svtools/logindlg.hxx>
+
+#ifndef _SVTOOLS_LOGINDLG_HRC_
+#include "logindlg.hrc"
+#endif
+#ifndef _SVTOOLS_HRC
+#include <svtools/svtools.hrc>
+#endif
+#include <svtools/svtdata.hxx>
+
+#ifdef UNX
+#include <limits.h>
+#define _MAX_PATH PATH_MAX
+#endif
+
+// LoginDialog -------------------------------------------------------
+
+//............................................................................
+namespace svt
+{
+//............................................................................
+
+void LoginDialog::HideControls_Impl( USHORT nFlags )
+{
+ FASTBOOL bPathHide = FALSE;
+ FASTBOOL bErrorHide = FALSE;
+ FASTBOOL bAccountHide = FALSE;
+
+ if ( ( nFlags & LF_NO_PATH ) == LF_NO_PATH )
+ {
+ aPathFT.Hide();
+ aPathED.Hide();
+ aPathBtn.Hide();
+ bPathHide = TRUE;
+ }
+ else if ( ( nFlags & LF_PATH_READONLY ) == LF_PATH_READONLY )
+ {
+ aPathED.Hide();
+ aPathInfo.Show();
+ aPathBtn.Hide();
+ }
+
+ if ( ( nFlags & LF_NO_USERNAME ) == LF_NO_USERNAME )
+ {
+ aNameFT.Hide();
+ aNameED.Hide();
+ }
+ else if ( ( nFlags & LF_USERNAME_READONLY ) == LF_USERNAME_READONLY )
+ {
+ aNameED.Hide();
+ aNameInfo.Show();
+ }
+
+ if ( ( nFlags & LF_NO_PASSWORD ) == LF_NO_PASSWORD )
+ {
+ aPasswordFT.Hide();
+ aPasswordED.Hide();
+ }
+
+ if ( ( nFlags & LF_NO_SAVEPASSWORD ) == LF_NO_SAVEPASSWORD )
+ aSavePasswdBtn.Hide();
+
+ if ( ( nFlags & LF_NO_ERRORTEXT ) == LF_NO_ERRORTEXT )
+ {
+ aErrorInfo.Hide();
+ aErrorGB.Hide();
+ bErrorHide = TRUE;
+ }
+
+ if ( ( nFlags & LF_NO_ACCOUNT ) == LF_NO_ACCOUNT )
+ {
+ aAccountFT.Hide();
+ aAccountED.Hide();
+ bAccountHide = TRUE;
+ }
+
+ if ( bErrorHide )
+ {
+ long nOffset = aLoginGB.GetPosPixel().Y() -
+ aErrorGB.GetPosPixel().Y();
+ Point aNewPnt = aRequestInfo.GetPosPixel();
+ aNewPnt.Y() -= nOffset;
+ aRequestInfo.SetPosPixel( aNewPnt );
+ aNewPnt = aPathFT.GetPosPixel();
+ aNewPnt.Y() -= nOffset;
+ aPathFT.SetPosPixel( aNewPnt );
+ aNewPnt = aPathED.GetPosPixel();
+ aNewPnt.Y() -= nOffset;
+ aPathED.SetPosPixel( aNewPnt );
+ aNewPnt = aPathInfo.GetPosPixel();
+ aNewPnt.Y() -= nOffset;
+ aPathInfo.SetPosPixel( aNewPnt );
+ aNewPnt = aPathBtn.GetPosPixel();
+ aNewPnt.Y() -= nOffset;
+ aPathBtn.SetPosPixel( aNewPnt );
+ aNewPnt = aNameFT.GetPosPixel();
+ aNewPnt.Y() -= nOffset;
+ aNameFT.SetPosPixel( aNewPnt );
+ aNewPnt = aNameED.GetPosPixel();
+ aNewPnt.Y() -= nOffset;
+ aNameED.SetPosPixel( aNewPnt );
+ aNewPnt = aNameInfo.GetPosPixel();
+ aNewPnt.Y() -= nOffset;
+ aNameInfo.SetPosPixel( aNewPnt );
+ aNewPnt = aPasswordFT.GetPosPixel();
+ aNewPnt.Y() -= nOffset;
+ aPasswordFT.SetPosPixel( aNewPnt );
+ aNewPnt = aPasswordED.GetPosPixel();
+ aNewPnt.Y() -= nOffset;
+ aPasswordED.SetPosPixel( aNewPnt );
+ aNewPnt = aAccountFT.GetPosPixel();
+ aNewPnt.Y() -= nOffset;
+ aAccountFT.SetPosPixel( aNewPnt );
+ aNewPnt = aAccountED.GetPosPixel();
+ aNewPnt.Y() -= nOffset;
+ aAccountED.SetPosPixel( aNewPnt );
+ aNewPnt = aSavePasswdBtn.GetPosPixel();
+ aNewPnt.Y() -= nOffset;
+ aSavePasswdBtn.SetPosPixel( aNewPnt );
+ aNewPnt = aLoginGB.GetPosPixel();
+ aNewPnt.Y() -= nOffset;
+ aLoginGB.SetPosPixel( aNewPnt );
+ Size aNewSiz = GetSizePixel();
+ aNewSiz.Height() -= nOffset;
+ SetSizePixel( aNewSiz );
+ }
+
+ if ( bPathHide )
+ {
+ long nOffset = aNameED.GetPosPixel().Y() -
+ aPathED.GetPosPixel().Y();
+
+ Point aTmpPnt1 = aNameFT.GetPosPixel();
+ Point aTmpPnt2 = aPasswordFT.GetPosPixel();
+ aNameFT.SetPosPixel( aPathFT.GetPosPixel() );
+ aPasswordFT.SetPosPixel( aTmpPnt1 );
+ aAccountFT.SetPosPixel( aTmpPnt2 );
+ aTmpPnt1 = aNameED.GetPosPixel();
+ aTmpPnt2 = aPasswordED.GetPosPixel();
+ aNameED.SetPosPixel( aPathED.GetPosPixel() );
+ aPasswordED.SetPosPixel( aTmpPnt1 );
+ aAccountED.SetPosPixel( aTmpPnt2 );
+ aNameInfo.SetPosPixel( aPathInfo.GetPosPixel() );
+ aTmpPnt1 = aSavePasswdBtn.GetPosPixel();
+ aTmpPnt1.Y() -= nOffset;
+ aSavePasswdBtn.SetPosPixel( aTmpPnt1 );
+ Size aNewSz = GetSizePixel();
+ aNewSz.Height() -= nOffset;
+ SetSizePixel( aNewSz );
+ }
+
+ if ( bAccountHide )
+ {
+ long nOffset = aAccountED.GetPosPixel().Y() - aPasswordED.GetPosPixel().Y();
+
+ Point aTmpPnt = aSavePasswdBtn.GetPosPixel();
+ aTmpPnt.Y() -= nOffset;
+ aSavePasswdBtn.SetPosPixel( aTmpPnt );
+ Size aNewSz = GetSizePixel();
+ aNewSz.Height() -= nOffset;
+ SetSizePixel( aNewSz );
+ }
+};
+
+// -----------------------------------------------------------------------
+
+IMPL_LINK( LoginDialog, OKHdl_Impl, OKButton *, EMPTYARG )
+{
+ // trim the strings
+ aNameED.SetText( aNameED.GetText().EraseLeadingChars().
+ EraseTrailingChars() );
+ aPasswordED.SetText( aPasswordED.GetText().EraseLeadingChars().
+ EraseTrailingChars() );
+ EndDialog( RET_OK );
+ return 1;
+}
+
+// -----------------------------------------------------------------------
+
+IMPL_LINK( LoginDialog, PathHdl_Impl, PushButton *, EMPTYARG )
+{
+ PathDialog* pDlg = new PathDialog( this, WB_3DLOOK );
+// DirEntry aEntry;
+// aEntry.ToAbs();
+// pDlg->SetPath( aEntry.GetFull() );
+
+ if ( pDlg->Execute() == RET_OK )
+ aPathED.SetText( pDlg->GetPath() );
+
+ delete pDlg;
+ return 1;
+}
+
+// -----------------------------------------------------------------------
+
+LoginDialog::LoginDialog
+(
+ Window* pParent,
+ USHORT nFlags,
+ const String& rServer,
+ const String* pRealm
+) :
+
+ ModalDialog( pParent, SvtResId( DLG_LOGIN ) ),
+
+ aErrorInfo ( this, SvtResId( INFO_LOGIN_ERROR ) ),
+ aErrorGB ( this, SvtResId( GB_LOGIN_ERROR ) ),
+ aRequestInfo ( this, SvtResId( INFO_LOGIN_REQUEST ) ),
+ aPathFT ( this, SvtResId( FT_LOGIN_PATH ) ),
+ aPathED ( this, SvtResId( ED_LOGIN_PATH ) ),
+ aPathInfo ( this, SvtResId( INFO_LOGIN_PATH ) ),
+ aPathBtn ( this, SvtResId( BTN_LOGIN_PATH ) ),
+ aNameFT ( this, SvtResId( FT_LOGIN_USERNAME ) ),
+ aNameED ( this, SvtResId( ED_LOGIN_USERNAME ) ),
+ aNameInfo ( this, SvtResId( INFO_LOGIN_USERNAME ) ),
+ aPasswordFT ( this, SvtResId( FT_LOGIN_PASSWORD ) ),
+ aPasswordED ( this, SvtResId( ED_LOGIN_PASSWORD ) ),
+ aAccountFT ( this, SvtResId( FT_LOGIN_ACCOUNT ) ),
+ aAccountED ( this, SvtResId( ED_LOGIN_ACCOUNT ) ),
+ aSavePasswdBtn ( this, SvtResId( CB_LOGIN_SAVEPASSWORD ) ),
+ aLoginGB ( this, SvtResId( GB_LOGIN_LOGIN ) ),
+ aOKBtn ( this, SvtResId( BTN_LOGIN_OK ) ),
+ aCancelBtn ( this, SvtResId( BTN_LOGIN_CANCEL ) ),
+ aHelpBtn ( this, SvtResId( BTN_LOGIN_HELP ) )
+
+{
+ // Einlog-Ort eintragen
+ String aServer;
+
+ if ( ( ( nFlags & LF_NO_ACCOUNT ) == LF_NO_ACCOUNT ) && pRealm && pRealm->Len() )
+ {
+ aServer = *pRealm;
+ ( ( aServer += ' ' ) += String( SvtResId( STR_LOGIN_AT ) ) ) += ' ';
+ }
+ aServer += rServer;
+ String aTxt = aRequestInfo.GetText();
+ aTxt.SearchAndReplaceAscii( "%1", aServer );
+ aRequestInfo.SetText( aTxt );
+
+ FreeResource();
+
+ aPathED.SetMaxTextLen( _MAX_PATH );
+ aNameED.SetMaxTextLen( _MAX_PATH );
+
+ aOKBtn.SetClickHdl( LINK( this, LoginDialog, OKHdl_Impl ) );
+ aPathBtn.SetClickHdl( LINK( this, LoginDialog, PathHdl_Impl ) );
+
+ HideControls_Impl( nFlags );
+};
+
+// -----------------------------------------------------------------------
+
+void LoginDialog::SetName( const String& rNewName )
+{
+ aNameED.SetText( rNewName );
+ aNameInfo.SetText( rNewName );
+}
+
+// -----------------------------------------------------------------------
+
+void LoginDialog::ClearPassword()
+{
+ aPasswordED.SetText( String() );
+
+ if ( 0 == aNameED.GetText().Len() )
+ aNameED.GrabFocus();
+ else
+ aPasswordED.GrabFocus();
+};
+
+// -----------------------------------------------------------------------
+
+void LoginDialog::ClearAccount()
+{
+ aAccountED.SetText( String() );
+ aAccountED.GrabFocus();
+};
+
+//............................................................................
+} // namespace svt
+//............................................................................
diff --git a/svtools/source/dialogs/logindlg.hrc b/svtools/source/dialogs/logindlg.hrc
new file mode 100644
index 000000000000..1998c55ebce4
--- /dev/null
+++ b/svtools/source/dialogs/logindlg.hrc
@@ -0,0 +1,60 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: logindlg.hrc,v $
+ * $Revision: 1.4 $
+ *
+ * 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 _SVTOOLS_LOGINDLG_HRC_
+#define _SVTOOLS_LOGINDLG_HRC_
+
+//============================================================================
+#define INFO_LOGIN_ERROR 10
+#define GB_LOGIN_ERROR 11
+
+#define INFO_LOGIN_REQUEST 20
+#define FT_LOGIN_PATH 21
+#define ED_LOGIN_PATH 22
+#define INFO_LOGIN_PATH 23
+#define BTN_LOGIN_PATH 24
+#define FT_LOGIN_USERNAME 25
+#define ED_LOGIN_USERNAME 26
+#define INFO_LOGIN_USERNAME 27
+#define FT_LOGIN_PASSWORD 28
+#define ED_LOGIN_PASSWORD 29
+#define FT_LOGIN_ACCOUNT 30
+#define ED_LOGIN_ACCOUNT 31
+#define CB_LOGIN_SAVEPASSWORD 32
+#define GB_LOGIN_LOGIN 33
+
+#define BTN_LOGIN_OK 50
+#define BTN_LOGIN_CANCEL 51
+#define BTN_LOGIN_HELP 52
+
+#define STR_LOGIN_AT 60
+
+#endif // _SVTOOLS_LOGINDLG_HRC_
diff --git a/svtools/source/dialogs/logindlg.src b/svtools/source/dialogs/logindlg.src
new file mode 100644
index 000000000000..897597f383bf
--- /dev/null
+++ b/svtools/source/dialogs/logindlg.src
@@ -0,0 +1,203 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: logindlg.src,v $
+ * $Revision: 1.43 $
+ *
+ * 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 _SVTOOLS_HRC
+#include <svtools/svtools.hrc>
+#endif
+
+#ifndef _SVTOOLS_LOGINDLG_HRC_
+#include "logindlg.hrc"
+#endif
+
+ModalDialog DLG_LOGIN
+{
+// HelpId = HID_DLG_LOGIN ;
+ Border = TRUE ;
+ Moveable = TRUE ;
+ OutputSize = TRUE ;
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( 265 , 158 ) ;
+ FixedText INFO_LOGIN_ERROR
+ {
+ Pos = MAP_APPFONT ( 12 , 14 ) ;
+ Size = MAP_APPFONT ( 185 , 18 ) ;
+ WordBreak = TRUE ;
+ };
+ FixedLine GB_LOGIN_ERROR
+ {
+ Pos = MAP_APPFONT ( 6 , 3 ) ;
+ Size = MAP_APPFONT ( 197 , 8 ) ;
+ Text [ en-US ] = "Message from server" ;
+ };
+ FixedText INFO_LOGIN_REQUEST
+ {
+ Pos = MAP_APPFONT ( 12 , 55 ) ;
+ Size = MAP_APPFONT ( 185 , 18 ) ;
+ WordBreak = TRUE ;
+ Text [ en-US ] = "Please enter user name and password for %1." ;
+ };
+ FixedText FT_LOGIN_PATH
+ {
+ Pos = MAP_APPFONT ( 12 , 77 ) ;
+ Size = MAP_APPFONT ( 57 , 10 ) ;
+ Text [ en-US ] = "~Path" ;
+ };
+ Edit ED_LOGIN_PATH
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 72 , 76 ) ;
+ Size = MAP_APPFONT ( 108 , 12 ) ;
+ };
+ FixedText INFO_LOGIN_PATH
+ {
+ Hide = TRUE ;
+ Pos = MAP_APPFONT ( 72 , 77 ) ;
+ Size = MAP_APPFONT ( 125 , 10 ) ;
+ };
+ PushButton BTN_LOGIN_PATH
+ {
+ Pos = MAP_APPFONT ( 183 , 75 ) ;
+ Size = MAP_APPFONT ( 14 , 14 ) ;
+ Text = "~..." ;
+ };
+ FixedText FT_LOGIN_USERNAME
+ {
+ Pos = MAP_APPFONT ( 12 , 92 ) ;
+ Size = MAP_APPFONT ( 57 , 10 ) ;
+ Text [ en-US ] = "~User name" ;
+ };
+ Edit ED_LOGIN_USERNAME
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 72 , 91 ) ;
+ Size = MAP_APPFONT ( 125 , 12 ) ;
+ };
+ FixedText INFO_LOGIN_USERNAME
+ {
+ Hide = TRUE ;
+ Pos = MAP_APPFONT ( 72 , 92 ) ;
+ Size = MAP_APPFONT ( 125 , 10 ) ;
+ };
+ FixedText FT_LOGIN_PASSWORD
+ {
+ Pos = MAP_APPFONT ( 12 , 107 ) ;
+ Size = MAP_APPFONT ( 57 , 10 ) ;
+ Text [ en-US ] = "Pass~word" ;
+ };
+ Edit ED_LOGIN_PASSWORD
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 72 , 106 ) ;
+ Size = MAP_APPFONT ( 125 , 12 ) ;
+ PassWord = TRUE ;
+ };
+ FixedText FT_LOGIN_ACCOUNT
+ {
+ Pos = MAP_APPFONT ( 12 , 122 ) ;
+ Size = MAP_APPFONT ( 57 , 10 ) ;
+ Text [ en-US ] = "A~ccount";
+ };
+ Edit ED_LOGIN_ACCOUNT
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 72 , 121 ) ;
+ Size = MAP_APPFONT ( 125 , 12 ) ;
+ PassWord = TRUE ;
+ };
+ CheckBox CB_LOGIN_SAVEPASSWORD
+ {
+ Pos = MAP_APPFONT ( 12 , 136 ) ;
+ Size = MAP_APPFONT ( 185 , 10 ) ;
+ Text [ en-US ] = "~Save password" ;
+ };
+ FixedLine GB_LOGIN_LOGIN
+ {
+ Pos = MAP_APPFONT ( 7 , 44 ) ;
+ Size = MAP_APPFONT ( 197 , 8 ) ;
+ Text [ en-US ] = "Log in" ;
+ };
+ OKButton BTN_LOGIN_OK
+ {
+ Pos = MAP_APPFONT ( 209 , 6 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ DefButton = TRUE ;
+ };
+ CancelButton BTN_LOGIN_CANCEL
+ {
+ Pos = MAP_APPFONT ( 209 , 23 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ };
+ HelpButton BTN_LOGIN_HELP
+ {
+ Pos = MAP_APPFONT ( 209 , 43 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ };
+ String STR_LOGIN_AT
+ {
+ Text [ en-US ] = "to " ;
+ };
+ Text [ en-US ] = "User Name and Password Required" ;
+};
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/svtools/source/dialogs/makefile.mk b/svtools/source/dialogs/makefile.mk
new file mode 100644
index 000000000000..6abf15732b8e
--- /dev/null
+++ b/svtools/source/dialogs/makefile.mk
@@ -0,0 +1,81 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2008 by Sun Microsystems, Inc.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# $RCSfile: makefile.mk,v $
+#
+# $Revision: 1.16 $
+#
+# 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.
+#
+#*************************************************************************
+
+PRJ=..$/..
+
+PRJNAME=svtools
+TARGET=dialogs
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+.INCLUDE : $(PRJ)$/util$/svt.pmk
+
+# --- Files --------------------------------------------------------
+
+SRS1NAME=$(TARGET)
+SRC1FILES= filedlg2.src \
+ so3res.src \
+ formats.src \
+ prnsetup.src \
+ printdlg.src \
+ colrdlg.src \
+ logindlg.src \
+ addresstemplate.src \
+ wizardmachine.src
+
+
+EXCEPTIONSFILES= $(SLO)$/addresstemplate.obj \
+ $(SLO)$/insdlg.obj \
+ $(SLO)$/roadmapwizard.obj \
+ $(SLO)$/printdlg.obj \
+ $(SLO)$/wizardmachine.obj
+
+
+SLOFILES= \
+ $(SLO)$/insdlg.obj \
+ $(SLO)$/roadmapwizard.obj \
+ $(SLO)$/wizardmachine.obj \
+ $(SLO)$/addresstemplate.obj \
+ $(SLO)$/filedlg.obj \
+ $(SLO)$/filedlg2.obj \
+ $(SLO)$/prnsetup.obj \
+ $(SLO)$/printdlg.obj \
+ $(SLO)$/colctrl.obj \
+ $(SLO)$/colrdlg.obj \
+ $(SLO)$/property.obj \
+ $(SLO)$/wizdlg.obj \
+ $(SLO)$/mcvmath.obj \
+ $(SLO)$/logindlg.obj
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk
diff --git a/svtools/source/dialogs/mcvmath.cxx b/svtools/source/dialogs/mcvmath.cxx
new file mode 100644
index 000000000000..fef27c4c9a62
--- /dev/null
+++ b/svtools/source/dialogs/mcvmath.cxx
@@ -0,0 +1,308 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: mcvmath.cxx,v $
+ * $Revision: 1.5 $
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_svtools.hxx"
+
+#include <mcvmath.hxx>
+
+// ---------------------------------------------------------------------
+// die folgenden Tabellen enthalten sin(phi) * 2**14
+// fuer phi= 360Grad*2**-32 bis 360 Grad
+// def. fuer x: phi=360Grad * 2**(x-16)
+// d.h. x = 16 -> 360 Grad
+// x = -16 -> (2**-16) * 360 Grad
+// x: -16 ... 0 ... 15
+//x= 0, 1, 2, 3, 4, 5, 6, 7,
+// 8, 9, 10, 11, 12, 13, 14, 15
+
+static const short CosTab[16] =
+{
+ 16384, 16384, 16384, 16384, 16384, 16384, 16384, 16383,
+ 16379, 16364, 16305, 16069, 15137, 11585, 0, -16383
+};
+static const short SinTab[16]=
+{
+ 2, 3, 6, 13, 25, 50, 101, 201,
+ 402, 804, 1606, 3196, 6270, 11585, 16384, 0
+};
+
+/**************************************************************************
+|*
+|* ImpMultBig2()
+|*
+|* Beschreibung Multiplikation fuer FixPoint-Berechnungen
+|* Ersterstellung SH 01.07.93
+|* Letzte Aenderung SH 01.07.93
+|*
+**************************************************************************/
+
+// first parameter should be the bigger one
+
+Fix ImpMultBig2( const Fix& a, const Fix& b )
+{
+ Fix f;
+ f.x = (((b.x+FIX_A2)>>FIX_P2)*a.x+FIX_A3)>>FIX_P3;
+ return f;
+}
+
+/**************************************************************************
+|*
+|* ImpMultBig2()
+|*
+|* Beschreibung Multiplikation fuer FixPoint-Berechnungen
+|* Ersterstellung SH 01.07.93
+|* Letzte Aenderung SH 01.07.93
+|*
+**************************************************************************/
+
+// first parameter should be the bigger one
+
+FixCpx ImpMultBig2( const FixCpx& ra, const FixCpx& rb )
+{
+ Fix rr = ImpMultBig2(ra.r,rb.r)-ImpMultBig2(ra.i,rb.i);
+ Fix ii = ImpMultBig2(ra.r,rb.i)+ImpMultBig2(ra.i,rb.r);
+ return FixCpx( rr,ii );
+}
+
+/**************************************************************************
+|*
+|* ImpSqrt()
+|*
+|* Beschreibung Wurzelfunktion fuer FixPoint-Berechnungen
+|* Ersterstellung SH 01.07.93
+|* Letzte Aenderung SH 01.07.93
+|*
+**************************************************************************/
+
+USHORT ImpSqrt( ULONG nRadi )
+{
+ register ULONG inf = 1;
+ register ULONG sup = nRadi;
+ register ULONG sqr;
+
+ if ( !nRadi )
+ return 0;
+
+ while ( (inf<<1) <= sup )
+ {
+ sup >>= 1;
+ inf <<= 1;
+ }
+ sqr = (sup+inf) >> 1; // Anfangswert der Iteration
+
+ sqr = (nRadi/sqr + sqr) >> 1; // 2 Newton-Iterationen reichen fuer
+ sqr = (nRadi/sqr + sqr) >> 1; // +- 1 Digit
+
+ return sal::static_int_cast< USHORT >(sqr);
+}
+
+/**************************************************************************
+|*
+|* ImpExPI()
+|*
+|* Beschreibung EXPI-Funktion fuer FixPoint-Berechnungen
+|* Ersterstellung SH 01.07.93
+|* Letzte Aenderung SH 01.07.93
+|*
+**************************************************************************/
+
+// e**(i*nPhi), Einheit nPhi: 2**16 == 360 Grad
+
+FixCpx ImpExPI( USHORT nPhi )
+{
+ short i;
+ FixCpx aIter(1L); // e**(0*i)
+ FixCpx Mul;
+ const char Sft=14-FIX_POST;
+
+ for ( i = 15; i >= 0; i-- )
+ {
+ if ( (1L<<i) & nPhi )
+ {
+ Mul.r.x = CosTab[i]>>Sft; // e**(i(phi1+phi2)) =
+ Mul.i.x = SinTab[i]>>Sft; // e**(i*phi1)) * e**(i*phi2))
+ aIter *= Mul;
+ }
+ }
+
+ return aIter;
+}
+
+/**************************************************************************
+|*
+|* ImpATanx2()
+|*
+|* Beschreibung ATANX2-Funktion fuer FixPoint-Berechnungen
+|* Ersterstellung SH 01.07.93
+|* Letzte Aenderung SH 01.07.93
+|*
+**************************************************************************/
+
+// use for x*x+y*y==1 only
+
+static USHORT ImpATanx2( const Fix& rX, const Fix& rY )
+{
+ USHORT phi0 = 0; // result angel higher part
+ USHORT phi = 0; // dito lower part
+ long x = rX.x;
+ long y = rY.x;
+ long z;
+ const char Sft=14-FIX_POST;
+ short i;
+ FixCpx aTry;
+ FixCpx aInc;
+ FixCpx aIter(1L);
+ BOOL Small = FALSE;
+
+ if ( (x==0) && (y==0) )
+ return 0;
+
+ if ( y < 0)
+ {
+ // reduce 3. to 1. quadrant (0..90 Degree)
+ phi0 += 180L * 65536L / 360L;
+ // turn 180 degree
+ y *= -1;
+ x *= -1;
+ }
+
+ if ( x < 0)
+ {
+ // 2. to 1. q.
+ phi0 += 90L * 65536L / 360L;
+ // turn 90 degree clockwise
+ z = y;
+ y = -x;
+ x = z;
+ }
+
+ for ( i = 13; i >= 0; i-- )
+ {
+ aInc.r.x = CosTab[i]>>Sft; // e**(i(phi1+phi2)) =
+ aInc.i.x = SinTab[i]>>Sft; // e**(i*phi1)) * e**(i*phi2))
+ aTry = aIter*aInc;
+
+ if ( Small )
+ {
+ // is try ok
+ if ( aTry.r.x >= x )
+ {
+ aIter = aTry;
+ phi += (1<<i);
+ }
+ }
+ else
+ {
+ // is try ok
+ if ( aTry.i.x <= y )
+ {
+ aIter = aTry;
+ phi += (1<<i);
+
+ if ( i > 11 )
+ Small=TRUE;
+ }
+ }
+ }
+
+ return phi0+phi;
+}
+
+/**************************************************************************
+|*
+|* ImpATan2()
+|*
+|* Beschreibung ATAN-Funktion fuer FixPoint-Berechnungen
+|* Ersterstellung SH 01.07.93
+|* Letzte Aenderung SH 01.07.93
+|*
+**************************************************************************/
+
+USHORT ImpATan2( const short x, const short y )
+{
+ Fix rRad = ImpSqrt(ULONG(long(x)*x+long(y)*y));
+
+ if ( !rRad.x )
+ return 0;
+ Fix fx = x;
+ fx.DivBig( rRad ); // Normiere auf Einheitskreis
+ Fix fy = y;
+ fy.DivBig( rRad );
+
+ return ImpATanx2( fx, fy );
+}
+
+/**************************************************************************
+|*
+|* ImpCartToPolar()
+|*
+|* Beschreibung Koordinaaten-Wandlung
+|* Ersterstellung SH 01.07.93
+|* Letzte Aenderung SH 01.07.93
+|*
+**************************************************************************/
+
+void ImpCartToPolar( const short x, const short y, Fix& rRad, USHORT& rPhi )
+{
+ rRad = Fix( ImpSqrt( ULONG( long(x)*x+long(y)*y ) ) );
+
+ if ( !rRad.x )
+ rPhi=0;
+ else
+ {
+ // Normiere auf Einheitskreis
+ Fix fx = x;
+ fx.DivBig(rRad);
+ Fix fy = y;
+ fy.DivBig(rRad);
+ rPhi = ImpATanx2(fx, fy);
+ }
+}
+
+/**************************************************************************
+|*
+|* ImpPolarToCart()
+|*
+|* Beschreibung Koordinaaten-Wandlung
+|* Ersterstellung SH 01.07.93
+|* Letzte Aenderung SH 01.07.93
+|*
+**************************************************************************/
+
+void ImpPolarToCart( const Fix& rR, const USHORT Phi, short& rX, short& rY )
+{
+ FixCpx fc = ImpExPI( Phi ); // calculate sin() & cos()
+ fc.GetReal().MultBig( rR );
+ rX = sal::static_int_cast< short >(long( fc.GetReal() ));
+ fc.GetImag().MultBig( rR );
+ rY = sal::static_int_cast< short >(long( fc.GetImag() ));
+}
+
diff --git a/svtools/source/dialogs/mcvmath.hxx b/svtools/source/dialogs/mcvmath.hxx
new file mode 100644
index 000000000000..cd021559c780
--- /dev/null
+++ b/svtools/source/dialogs/mcvmath.hxx
@@ -0,0 +1,231 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: mcvmath.hxx,v $
+ * $Revision: 1.4 $
+ *
+ * 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 _MCVMATH_HXX
+#define _MCVMATH_HXX
+
+#include <tools/solar.h>
+
+class FixCpx;
+class ColWheel;
+
+// No of fractal bits
+// allowed range 0..14, must be even
+#define FIX_POST 14
+
+// scale for ...Big() -Functions
+#if (FIX_POST>=4)
+#define FIX_P2 4
+#define FIX_P3 (FIX_POST-FIX_P2)
+#else
+#define FIX_P2 0
+#define FIX_P3 FIX_POST
+#endif
+
+#if (FIX_POST>=1)
+#define FIX_ADD (1<<(FIX_POST-1))
+#else
+#define FIX_ADD 0
+#endif
+
+#if (FIX_P2>=1)
+#define FIX_A2 (1<<(FIX_P2-1))
+#else
+#define FIX_A2 0
+#endif
+
+#if (FIX_P3>=1)
+#define FIX_A3 (1<<(FIX_P3-1))
+#else
+#define FIX_A3 0
+#endif
+
+// -------
+// - Fix -
+// -------
+
+class Fix
+{
+private:
+ friend class FixCpx;
+ friend class ColWheel;
+
+// friend Fix ImpMultBig2( const Fix& a, const Fix& b );
+
+public:
+ long x;
+
+public:
+ Fix() { x=0; }
+ Fix( int i ) { x=(long(i)<<FIX_POST); }
+ Fix( short l ) { x=(long(l)<<FIX_POST); }
+ Fix( USHORT l ) { x=(long(l)<<FIX_POST); }
+ Fix( long l ) { x=(l<<FIX_POST); }
+ Fix( long Z, long N ) { x=(Z<<FIX_POST)/N; }
+
+ void SetInternVal( long nVal ) { x=nVal; }
+ long GetInternVal() const { return x; }
+
+ void operator+= ( const Fix& a ) { x+=a.x; }
+ void operator-= ( const Fix& a ) { x-=a.x; }
+ void operator*= ( const Fix& a ) { x=(x*a.x+FIX_ADD)>>FIX_POST; }
+ void operator/= ( const Fix& a ) { x=(x<<FIX_POST)/a.x; }
+ friend Fix operator- ( const Fix& a );
+
+ void MultBig( const Fix& a )
+ { x=((((a.x+FIX_A2)>>FIX_P2)*x+FIX_A3)>>FIX_P3); }
+ void DivBig( const Fix& a )
+ { x=((x<<FIX_P3)/a.x)<<FIX_P2; }
+
+ friend BOOL operator> ( const Fix& a, const Fix& b ) { return a.x > b.x; }
+ friend BOOL operator< ( const Fix& a, const Fix& b ) { return a.x < b.x; }
+
+ operator long() const { return (x+FIX_ADD) >> FIX_POST; }
+ operator double() const { return double(x)/(1<<FIX_POST); }
+
+ friend Fix operator+ ( const Fix& a, const Fix& b );
+ friend Fix operator- ( const Fix& a, const Fix& b );
+ friend Fix operator* ( const Fix& a, const Fix& b );
+ friend Fix operator/ ( const Fix& a, const Fix& b );
+
+ friend FixCpx operator-( const FixCpx& a );
+};
+
+// ----------
+// - FixCpx -
+// ----------
+
+class FixCpx
+{
+// friend FixCpx ImpMultBig2( const FixCpx& ra, const FixCpx& rb );
+
+public:
+ Fix r;
+ Fix i;
+
+public:
+ FixCpx() : r(), i() {}
+ FixCpx( Fix a ) : r( a ), i() {}
+ FixCpx( Fix a, Fix b ) : r( a ), i( b ) {}
+
+ Fix& GetReal() { return r; }
+ Fix& GetImag() { return i; }
+
+ void operator*= ( const FixCpx& ra );
+ void MultBig( const FixCpx& ra, const FixCpx& rb );
+
+ friend FixCpx operator+ ( const FixCpx& a, const FixCpx& b );
+ friend FixCpx operator- ( const FixCpx& a, const FixCpx& b );
+ friend FixCpx operator* ( const FixCpx& a, const FixCpx& b );
+ friend FixCpx operator/ ( const FixCpx& a, const FixCpx& b );
+ friend FixCpx operator- ( const FixCpx& a );
+};
+
+inline Fix operator- ( const Fix& a )
+{
+ Fix f;
+ f.x = -a.x;
+ return f;
+}
+
+inline Fix operator+ ( const Fix& a, const Fix& b )
+{
+ long l = a.x+b.x;
+ return *((Fix*)&l);
+}
+
+inline Fix operator- ( const Fix& a, const Fix& b )
+{
+ long l = a.x-b.x;
+ return *((Fix*)&l);
+}
+
+inline Fix operator* ( const Fix& a, const Fix& b )
+{
+ long l=(a.x*b.x+FIX_ADD)>>FIX_POST;
+ return *((Fix*)&l);
+}
+
+inline Fix operator/ ( const Fix& a, const Fix& b )
+{
+ long l=(a.x<<FIX_POST)/b.x;
+ return *((Fix*)&l);
+}
+
+inline FixCpx operator- ( const FixCpx& a )
+{
+ FixCpx fc;
+
+ fc.r.x = -a.r.x;
+ fc.i.x = -a.i.x;
+ return fc;
+}
+
+inline FixCpx operator+ ( const FixCpx& a, const FixCpx& b )
+{
+ return FixCpx( a.r+b.r, a.i+b.i );
+}
+
+inline FixCpx operator- ( const FixCpx& a, const FixCpx& b )
+{
+ return FixCpx( a.r-b.r, a.i-b.i );
+}
+
+inline void FixCpx::operator*= ( const FixCpx& ra )
+{
+ Fix rr = ra.r*r-ra.i*i;
+ i = ra.r*i+ra.i*r;
+ r = rr;
+}
+
+inline FixCpx operator* ( const FixCpx& a, const FixCpx& b )
+{
+ return FixCpx( a.r*b.r-a.i*b.i, a.r*b.i+a.i*b.r );
+}
+
+inline FixCpx operator/ ( const FixCpx& a, const FixCpx& b )
+{
+ return FixCpx( (a.r*b.r+a.i*b.i)/(b.r*b.r+b.i*b.i),
+ (b.r*a.r-a.r*b.i)/(b.r*b.r+b.i*b.i) );
+}
+
+// -----------------------------------------------------------------------
+
+Fix ImpMultBig2( const Fix& a, const Fix& b );
+FixCpx ImpMultBig2( const FixCpx& ra, const FixCpx& rb );
+
+void ImpCartToPolar( const short x, const short y, Fix& rRad, USHORT& rPhi );
+void ImpPolarToCart( const Fix& rR, const USHORT Phi, short& rX, short& rY );
+
+USHORT ImpSqrt( ULONG nRadi );
+USHORT ImpATan2( const short x, const short y );
+FixCpx ImpExPI( USHORT nPhi );
+
+#endif // _MCVMATH_HXX
diff --git a/svtools/source/dialogs/printdlg.cxx b/svtools/source/dialogs/printdlg.cxx
new file mode 100644
index 000000000000..68acffc62a74
--- /dev/null
+++ b/svtools/source/dialogs/printdlg.cxx
@@ -0,0 +1,801 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: printdlg.cxx,v $
+ * $Revision: 1.32 $
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_svtools.hxx"
+#include <tools/debug.hxx>
+#ifndef _SV_APP_HXX
+#include <vcl/svapp.hxx>
+#endif
+#ifndef _VCL_PRINT_HXX
+#include <vcl/print.hxx>
+#endif
+#include <vcl/msgbox.hxx>
+#include <vcl/jobset.hxx>
+#include <tools/urlobj.hxx>
+
+#include "printdlg.hrc"
+#include "controldims.hrc"
+#include <svtools/prnsetup.hxx>
+#include <svtools/printdlg.hxx>
+#include <svtools/svtdata.hxx>
+#include <filedlg.hxx>
+#include "pickerhelper.hxx"
+#ifndef _SVT_HELPID_HRC
+#include <svtools/helpid.hrc>
+#endif
+#include <com/sun/star/ui/dialogs/TemplateDescription.hpp>
+#include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp>
+#include <com/sun/star/ui/dialogs/XFilePicker.hpp>
+#include <com/sun/star/ui/dialogs/XFilterManager.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <comphelper/processfactory.hxx>
+
+using rtl::OUString;
+using namespace com::sun::star;
+
+struct SvtPrinterImpl
+{
+ Printer* m_pTempPrinter;
+ sal_Bool m_bHelpDisabled;
+ PrintSheetRange m_eSheetRange;
+
+ SvtPrinterImpl() :
+ m_pTempPrinter( NULL ), m_bHelpDisabled( sal_False ), m_eSheetRange( PRINTSHEETS_ALL ) {}
+ ~SvtPrinterImpl() { delete m_pTempPrinter; }
+};
+
+#define TEMPPRINTER() mpPrinterImpl->m_pTempPrinter
+
+// =======================================================================
+
+PrintDialog::PrintDialog( Window* pWindow, bool bWithSheetsAndCells ) :
+ ModalDialog ( pWindow, SvtResId( DLG_SVT_PRNDLG_PRINTDLG ) ),
+ maFlPrinter ( this, SvtResId( FL_PRINTER ) ),
+ maFtName ( this, SvtResId( FT_NAME ) ),
+ maLbName ( this, SvtResId( LB_NAMES ) ),
+ maBtnProperties ( this, SvtResId( BTN_PROPERTIES ) ),
+ maFtStatus ( this, SvtResId( FT_STATUS ) ),
+ maFiStatus ( this, SvtResId( FI_STATUS ) ),
+ maFtType ( this, SvtResId( FT_TYPE ) ),
+ maFiType ( this, SvtResId( FI_TYPE ) ),
+ maFtLocation ( this, SvtResId( FT_LOCATION ) ),
+ maFiLocation ( this, SvtResId( FI_LOCATION ) ),
+ maFtComment ( this, SvtResId( FT_COMMENT ) ),
+ maFiComment ( this, SvtResId( FI_COMMENT ) ),
+ maCbxFilePrint ( this, SvtResId( CBX_FILEPRINT ) ),
+ maFiPrintFile ( this, SvtResId( FI_PRINTFILE ) ),
+ maFiFaxNo ( this, SvtResId( FI_FAXNO ) ),
+ maEdtFaxNo ( this, SvtResId( EDT_FAXNO ) ),
+ maFlPrint ( this, SvtResId( FL_PRINT ) ),
+ maRbtAllSheets ( this, SvtResId( RBT_ALL_SHEETS ) ),
+ maRbtSelectedSheets ( this, SvtResId( RBT_SELECTED_SHEETS ) ),
+ maRbtSelectedCells ( this, SvtResId( RBT_SELECTED_CELLS ) ),
+ maFlPrintRange ( this, SvtResId( FL_PRINTRANGE ) ),
+ maRbtAll ( this, SvtResId( RBT_ALL ) ),
+ maRbtPages ( this, SvtResId( RBT_PAGES ) ),
+ maRbtSelection ( this, SvtResId( RBT_SELECTION ) ),
+ maEdtPages ( this, SvtResId( EDT_PAGES ) ),
+ maFlSepCopiesRange ( this, SvtResId( FL_SEPCOPIESRANGE ) ),
+ maFlCopies ( this, SvtResId( FL_COPIES ) ),
+ maFtCopies ( this, SvtResId( FT_COPIES ) ),
+ maNumCopies ( this, SvtResId( NUM_COPIES ) ),
+ maImgCollate ( this, SvtResId( IMG_COLLATE ) ),
+ maImgNotCollate ( this, SvtResId( IMG_NOT_COLLATE ) ),
+ maCbxCollate ( this, SvtResId( CBX_COLLATE ) ),
+ maFlSepButtonLine ( this, SvtResId( FL_SEPBUTTONLINE ) ),
+ maBtnOptions ( this, SvtResId( BTN_OPTIONS ) ),
+ maBtnOK ( this, SvtResId( BTN_OK ) ),
+ maBtnCancel ( this, SvtResId( BTN_CANCEL ) ),
+ maBtnHelp ( this, SvtResId( BTN_HELP ) ),
+ mbWithSheetsAndCells( bWithSheetsAndCells ),
+ maAllFilterStr ( SvtResId( STR_ALLFILTER ) )
+
+{
+ FreeResource();
+
+ mpPrinter = NULL;
+ mpPrinterImpl = new SvtPrinterImpl;
+ mnCopyCount = 1;
+ mnFirstPage = 0;
+ mnLastPage = 0;
+ mnMinPage = 1;
+ mnMaxPage = 65535;
+ meCheckRange = PRINTDIALOG_ALL;
+ mbAll = TRUE;
+ mbSelection = FALSE;
+ mbFromTo = FALSE;
+ mbRange = FALSE;
+ mbCollate = TRUE;
+ mbCollateCheck = TRUE;
+ mbOptions = FALSE;
+
+ maStatusTimer.SetTimeout( IMPL_PRINTDLG_STATUS_UPDATE );
+ maStatusTimer.SetTimeoutHdl( LINK( this, PrintDialog, ImplStatusHdl ) );
+ maBtnProperties.SetClickHdl( LINK( this, PrintDialog, ImplPropertiesHdl ) );
+ maLbName.SetSelectHdl( LINK( this, PrintDialog, ImplChangePrinterHdl ) );
+
+ maFiPrintFile.SetStyle( maFiPrintFile.GetStyle() | WB_PATHELLIPSIS );
+
+ Link aLink( LINK( this, PrintDialog, ImplModifyControlHdl ) );
+ maCbxFilePrint.SetClickHdl( aLink );
+ maRbtAll.SetClickHdl( aLink );
+ maRbtPages.SetClickHdl( aLink );
+ maRbtSelection.SetClickHdl( aLink );
+ maEdtPages.SetModifyHdl( aLink );
+ maNumCopies.SetModifyHdl( aLink );
+ maCbxCollate.SetClickHdl( aLink );
+ maBtnOptions.SetClickHdl( aLink );
+ maEdtFaxNo.SetModifyHdl( aLink );
+ maBtnOK.SetClickHdl( aLink );
+
+ maRbtAll.Check();
+ ImplSetImages();
+}
+
+// -----------------------------------------------------------------------
+
+PrintDialog::~PrintDialog()
+{
+ ImplFreePrnDlgListBox( &maLbName, FALSE );
+ delete mpPrinterImpl;
+}
+
+// -----------------------------------------------------------------------
+
+void PrintDialog::ImplSetImages()
+{
+ if( ! GetSettings().GetStyleSettings().GetDialogColor().IsDark() )
+ {
+ maImgCollate.SetModeImage( Image( SvtResId( RID_IMG_PRNDLG_COLLATE ) ), BMP_COLOR_NORMAL );
+ maImgNotCollate.SetModeImage( Image( SvtResId( RID_IMG_PRNDLG_NOCOLLATE ) ), BMP_COLOR_NORMAL );
+ }
+ else
+ {
+ maImgCollate.SetModeImage( Image( SvtResId( RID_IMG_PRNDLG_COLLATE_HC ) ), BMP_COLOR_HIGHCONTRAST );
+ maImgNotCollate.SetModeImage( Image( SvtResId( RID_IMG_PRNDLG_NOCOLLATE_HC ) ), BMP_COLOR_HIGHCONTRAST );
+ }
+}
+
+// -----------------------------------------------------------------------
+
+void PrintDialog::ImplSetInfo()
+{
+ const QueueInfo* pInfo = Printer::GetQueueInfo( maLbName.GetSelectEntry(), true );
+ if ( pInfo )
+ {
+ maFiType.SetText( pInfo->GetDriver() );
+ maFiLocation.SetText( pInfo->GetLocation() );
+ maFiComment.SetText( pInfo->GetComment() );
+ maFiStatus.SetText( ImplPrnDlgGetStatusText( *pInfo ) );
+ }
+ else
+ {
+ XubString aTempStr;
+ maFiType.SetText( aTempStr );
+ maFiLocation.SetText( aTempStr );
+ maFiComment.SetText( aTempStr );
+ maFiStatus.SetText( aTempStr );
+ }
+
+#ifdef UNX
+ if( pInfo && pInfo->GetLocation().EqualsAscii( "fax_queue" ) )
+ {
+ maFiPrintFile.Show( FALSE );
+ maCbxFilePrint.Show( FALSE );
+ maFiFaxNo.Show( TRUE );
+ maEdtFaxNo.Show( TRUE );
+ Printer* pPrinter = TEMPPRINTER() ? TEMPPRINTER() : mpPrinter;
+ maEdtFaxNo.SetText( pPrinter->GetJobValue( String::CreateFromAscii( "FAX#" ) ) );
+
+ Size aFTSize = maFiFaxNo.GetSizePixel();
+ long nTextWidth = maFiFaxNo.GetCtrlTextWidth( maFiFaxNo.GetText() ) + 10;
+ if ( aFTSize.Width() < nTextWidth )
+ {
+ long nDelta = nTextWidth - aFTSize.Width();
+ aFTSize.Width() = aFTSize.Width() + nDelta;
+ maFiFaxNo.SetSizePixel( aFTSize );
+ Size aEdtSize = maEdtFaxNo.GetSizePixel();
+ aEdtSize.Width() = aEdtSize.Width() - nDelta;
+ Point aEdtPos = maEdtFaxNo.GetPosPixel();
+ aEdtPos.X() = aEdtPos.X() + nDelta;
+ maEdtFaxNo.SetPosSizePixel( aEdtPos, aEdtSize );
+ }
+ }
+ else
+#endif
+ {
+ maFiPrintFile.Show( TRUE );
+ maCbxFilePrint.Show( TRUE );
+ maFiFaxNo.Show( FALSE );
+ maEdtFaxNo.Show( FALSE );
+ }
+
+}
+
+// -----------------------------------------------------------------------
+
+void PrintDialog::ImplCheckOK()
+{
+ // Ueberprueft, ob der OK-Button enabled ist
+ BOOL bEnable = TRUE;
+
+ if ( bEnable && maRbtPages.IsChecked() )
+ bEnable = maEdtPages.GetText().Len() > 0;
+
+ if ( bEnable )
+ {
+ if ( TEMPPRINTER() )
+ bEnable = TEMPPRINTER()->IsValid();
+ else
+ bEnable = mpPrinter->IsValid();
+ }
+
+ maBtnOK.Enable( bEnable );
+}
+
+// -----------------------------------------------------------------------
+
+void PrintDialog::ImplInitControls()
+{
+ // Alles
+ if ( mbAll )
+ {
+ maRbtAll.Enable();
+ if( meCheckRange == PRINTDIALOG_ALL )
+ maRbtAll.Check( TRUE );
+ }
+ else
+ maRbtAll.Enable( FALSE );
+
+ // Selektion
+ if ( mbSelection )
+ {
+ maRbtSelection.Enable();
+ if ( meCheckRange == PRINTDIALOG_SELECTION )
+ maRbtSelection.Check( TRUE );
+ }
+ else
+ maRbtSelection.Enable( FALSE );
+
+ // Seiten
+ if ( mbRange )
+ {
+ maRbtPages.Enable();
+ maEdtPages.Show();
+ maEdtPages.SetText( maRangeText );
+
+ if( ( meCheckRange == PRINTDIALOG_FROMTO ) ||
+ ( meCheckRange == PRINTDIALOG_RANGE ) )
+ {
+ maRbtPages.Check( TRUE );
+ maEdtPages.Enable();
+ }
+ else
+ maEdtPages.Enable( FALSE );
+ }
+ else
+ {
+ maRbtPages.Enable( FALSE );
+ maEdtPages.Hide();
+ }
+
+ // Anzahl Kopien
+ maNumCopies.SetValue( mnCopyCount );
+
+ // Sortierung
+ maCbxCollate.Enable( mbCollate );
+ maCbxCollate.Check( mbCollateCheck );
+
+ // Zusaetze-Button
+ if ( mbOptions )
+ maBtnOptions.Show();
+
+ if ( !mbWithSheetsAndCells )
+ {
+ Size aMarginSize =
+ LogicToPixel( Size( RSC_SP_CTRL_GROUP_X, RSC_SP_CTRL_GROUP_Y ), MAP_APPFONT );
+ long nTempPos = maImgCollate.GetPosPixel().Y() +
+ maImgCollate.GetSizePixel().Height() + aMarginSize.Height();
+ long nDelta1 = maFlPrintRange.GetPosPixel().Y() - maFlPrint.GetPosPixel().Y();
+ long nDelta2 = maFlSepButtonLine.GetPosPixel().Y() - nTempPos;
+
+ maFlPrint.Hide();
+ maRbtAllSheets.Hide();
+ maRbtSelectedSheets.Hide();
+ maRbtSelectedCells.Hide();
+ maRbtSelection.Show();
+
+ Size aNewSize = GetSizePixel();
+ aNewSize.Height() -= nDelta2;
+ SetSizePixel( aNewSize );
+ aNewSize = maFlSepCopiesRange.GetSizePixel();
+ aNewSize.Height() -= nDelta2;
+ maFlSepCopiesRange.SetSizePixel( aNewSize );
+
+ long nDelta = nDelta1;
+ Window* pControls[] = { &maFlPrintRange, &maRbtAll,
+ &maRbtPages, &maEdtPages, &maRbtSelection, NULL,
+ &maFlSepButtonLine, &maBtnOptions, &maBtnOK,
+ &maBtnCancel, &maBtnHelp };
+ Window** pCtrl = pControls;
+ const sal_Int32 nCount = sizeof( pControls ) / sizeof( pControls[0] );
+ for ( sal_Int32 i = 0; i < nCount; ++i, ++pCtrl )
+ {
+ if ( NULL == *pCtrl )
+ {
+ nDelta = nDelta2;
+ continue;
+ }
+ Point aNewPos = (*pCtrl)->GetPosPixel();
+ aNewPos.Y() -= nDelta;
+ (*pCtrl)->SetPosPixel( aNewPos );
+ }
+ }
+}
+
+// -----------------------------------------------------------------------
+
+void PrintDialog::ImplFillDialogData()
+{
+ if ( maRbtAll.IsChecked() )
+ meCheckRange = PRINTDIALOG_ALL;
+ else if( maRbtSelection.IsChecked() )
+ meCheckRange = PRINTDIALOG_SELECTION;
+ else
+ {
+ meCheckRange = PRINTDIALOG_RANGE;
+ maRangeText = maEdtPages.GetText();
+ }
+
+ mnCopyCount = (USHORT) maNumCopies.GetValue();
+ mbCollateCheck = maCbxCollate.IsChecked();
+
+ // In Datei drucken
+ if ( maCbxFilePrint.IsChecked() )
+ mpPrinter->SetPrintFile( maFiPrintFile.GetText() );
+ mpPrinter->EnablePrintFile( maCbxFilePrint.IsChecked() );
+}
+
+// -----------------------------------------------------------------------
+
+IMPL_LINK( PrintDialog, ImplStatusHdl, Timer*, EMPTYARG )
+{
+ QueueInfo aInfo;
+ ImplPrnDlgUpdateQueueInfo( &maLbName, aInfo );
+ maFiStatus.SetText( ImplPrnDlgGetStatusText( aInfo ) );
+
+ return 0;
+}
+
+// -----------------------------------------------------------------------
+
+IMPL_LINK( PrintDialog, ImplPropertiesHdl, void*, EMPTYARG )
+{
+ if ( !TEMPPRINTER() )
+ TEMPPRINTER() = new Printer( mpPrinter->GetJobSetup() );
+ TEMPPRINTER()->Setup( this );
+
+ return 0;
+}
+
+// -----------------------------------------------------------------------
+
+IMPL_LINK( PrintDialog, ImplChangePrinterHdl, void*, EMPTYARG )
+{
+ TEMPPRINTER() = ImplPrnDlgListBoxSelect( &maLbName, &maBtnProperties,
+ mpPrinter, TEMPPRINTER() );
+ ImplSetInfo();
+ ImplCheckOK(); // Check if "OK" button can be enabled now!
+
+ return 0;
+}
+
+// -----------------------------------------------------------------------
+
+bool PrintDialog::ImplGetFilename()
+{
+ uno::Reference< lang::XMultiServiceFactory > xFactory( ::comphelper::getProcessServiceFactory() );
+ static ::rtl::OUString aOldFile;
+ if( xFactory.is() )
+ {
+ uno::Sequence< uno::Any > aTempl( 1 );
+ aTempl.getArray()[0] <<= ui::dialogs::TemplateDescription::FILESAVE_AUTOEXTENSION;
+ uno::Reference< ui::dialogs::XFilePicker > xFilePicker(
+ xFactory->createInstanceWithArguments(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.ui.dialogs.FilePicker" ) ),
+ aTempl ), uno::UNO_QUERY );
+ DBG_ASSERT( xFilePicker.is(), "could not get FilePicker service" );
+
+ uno::Reference< ui::dialogs::XFilterManager > xFilterMgr( xFilePicker, uno::UNO_QUERY );
+ if( xFilePicker.is() && xFilterMgr.is() )
+ {
+ try
+ {
+#ifdef UNX
+ // add PostScript and PDF
+ Printer* pPrinter = TEMPPRINTER() ? TEMPPRINTER() : mpPrinter;
+ bool bPS = true, bPDF = true;
+ if( pPrinter )
+ {
+ if( pPrinter->GetCapabilities( PRINTER_CAPABILITIES_PDF ) )
+ bPS = false;
+ else
+ bPDF = false;
+ }
+ if( bPS )
+ xFilterMgr->appendFilter( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PostScript" ) ), ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "*.ps" ) ) );
+ if( bPDF )
+ xFilterMgr->appendFilter( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Portable Document Format" ) ), ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "*.pdf" ) ) );
+#elif defined WNT
+ xFilterMgr->appendFilter( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "*.PRN" ) ), ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "*.prn" ) ) );
+#endif
+ // add arbitrary files
+ xFilterMgr->appendFilter( maAllFilterStr, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "*.*" ) ) );
+ }
+ catch( lang::IllegalArgumentException rExc )
+ {
+ DBG_ERRORFILE( "caught IllegalArgumentException when registering filter\n" );
+ }
+
+ if( aOldFile.getLength() )
+ {
+ INetURLObject aUrl( aOldFile, INET_PROT_FILE );
+ xFilePicker->setDefaultName( aUrl.GetLastName() );
+ aUrl.CutLastName();
+ xFilePicker->setDisplayDirectory( aUrl.GetMainURL( INetURLObject::DECODE_TO_IURI ) );
+ }
+
+ if( xFilePicker->execute() == ui::dialogs::ExecutableDialogResults::OK )
+ {
+ uno::Sequence< ::rtl::OUString > aPathSeq( xFilePicker->getFiles() );
+ INetURLObject aObj( aPathSeq[0] );
+ maFiPrintFile.SetText( aOldFile = aObj.PathToFileName() );
+ return true;
+ }
+ return false;
+ }
+ }
+
+ // something went awry, lets try the old fashioned dialogue
+ Window* pDlgParent = IsReallyVisible() ? this : GetParent();
+ FileDialog aDlg( pDlgParent, WB_STDDIALOG | WB_SAVEAS );
+#ifdef WNT
+ aDlg.AddFilter( String( RTL_CONSTASCII_USTRINGPARAM( "*.prn" ) ), String( RTL_CONSTASCII_USTRINGPARAM( "*.prn" ) ) );
+ aDlg.SetDefaultExt( String( RTL_CONSTASCII_USTRINGPARAM( "prn" ) ) );
+#elif defined UNX
+ aDlg.AddFilter( String( RTL_CONSTASCII_USTRINGPARAM( "PostScript" ) ), String( RTL_CONSTASCII_USTRINGPARAM( "*.ps" ) ) );
+ aDlg.SetDefaultExt( String( RTL_CONSTASCII_USTRINGPARAM( "ps" ) ) );
+#endif
+
+ if( aOldFile.getLength() )
+ aDlg.SetPath( aOldFile );
+
+ if( aDlg.Execute() )
+ {
+ String aTargetFile = aDlg.GetPath();
+ maFiPrintFile.SetText( aOldFile = aTargetFile );
+ return true;
+ }
+
+ return false;
+}
+
+// -----------------------------------------------------------------------
+
+IMPL_LINK( PrintDialog, ImplModifyControlHdl, void*, p )
+{
+ // Radiobuttons (Umfang)
+ if ( !p || (p == &maRbtAll) || (p == &maRbtPages) || (p == &maRbtSelection) )
+ {
+ BOOL bCheck = maRbtPages.IsChecked();
+ maEdtPages.Enable( bCheck );
+ if ( p == &maRbtPages )
+ maEdtPages.GrabFocus();
+ ImplCheckOK();
+ }
+
+ // Edit-Felder (Seiten)
+ if ( p == &maEdtPages )
+ ImplCheckOK();
+
+ if( p == &maEdtFaxNo )
+ {
+ Printer* pPrinter = TEMPPRINTER() ? TEMPPRINTER() : mpPrinter;
+ pPrinter->SetJobValue( String::CreateFromAscii( "FAX#" ), maEdtFaxNo.GetText() );
+ }
+
+ // Anzahl Kopien
+ BOOL bNumCopies = FALSE;
+
+ if ( !p || p == &maNumCopies )
+ {
+ if ( p )
+ bNumCopies = TRUE;
+ //BOOL bCopies = maNumCopies.GetValue() > 1;
+ maCbxCollate.Enable( mbCollate );
+
+ /*if ( !bCopies )
+ maCbxCollate.Check( FALSE );
+ else*/
+ if ( mbCollateCheck )
+ maCbxCollate.Check( TRUE );
+ }
+
+ // Sortieren
+ if ( !p || p == &maCbxCollate || bNumCopies )
+ {
+ BOOL bCheck = maCbxCollate.IsChecked();
+
+ if ( !bNumCopies )
+ mbCollateCheck = maCbxCollate.IsChecked();
+
+ if( bCheck )
+ {
+ maImgCollate.Show();
+ maImgNotCollate.Hide();
+ }
+ else
+ {
+ maImgCollate.Hide();
+ maImgNotCollate.Show();
+ }
+ }
+
+ // Zus"atze
+ if ( p == &maBtnOptions )
+ ClickOptionsHdl();
+
+ if( p == &maBtnOK )
+ {
+ EndDialog( maCbxFilePrint.IsChecked() ? ImplGetFilename() : TRUE );
+ }
+
+ return 0;
+}
+
+// -----------------------------------------------------------------------
+
+long PrintDialog::ClickOptionsHdl()
+{
+ if ( maOptionsHdlLink.IsSet() )
+ return maOptionsHdlLink.Call( this );
+ else
+ return TRUE;
+}
+
+// -----------------------------------------------------------------------
+
+long PrintDialog::OK()
+{
+ if ( maOKHdlLink.IsSet() )
+ return maOKHdlLink.Call( this );
+ else
+ return TRUE;
+}
+
+// -----------------------------------------------------------------------
+
+void PrintDialog::EnableSheetRange( bool bEnable, PrintSheetRange eRange )
+{
+ if ( mbWithSheetsAndCells )
+ {
+ switch ( eRange )
+ {
+ case PRINTSHEETS_ALL :
+ maRbtAllSheets.Enable( bEnable != false );
+ break;
+ case PRINTSHEETS_SELECTED_SHEETS :
+ maRbtSelectedSheets.Enable( bEnable != false );
+ break;
+ case PRINTSHEETS_SELECTED_CELLS :
+ maRbtSelectedCells.Enable( bEnable != false );
+ break;
+ default:
+ DBG_ERRORFILE( "PrintDialog::EnableSheetRange(): invalid range" );
+ }
+ }
+}
+
+// -----------------------------------------------------------------------
+
+bool PrintDialog::IsSheetRangeEnabled( PrintSheetRange eRange ) const
+{
+ if ( !mbWithSheetsAndCells )
+ return false;
+
+ bool bRet = false;
+ switch ( eRange )
+ {
+ case PRINTSHEETS_ALL :
+ bRet = maRbtAllSheets.IsEnabled() != FALSE;
+ break;
+ case PRINTSHEETS_SELECTED_SHEETS :
+ bRet = maRbtSelectedSheets.IsEnabled() != FALSE;
+ break;
+ case PRINTSHEETS_SELECTED_CELLS :
+ bRet = maRbtSelectedCells.IsEnabled() != FALSE;
+ break;
+ default:
+ DBG_ERRORFILE( "PrintDialog::IsSheetRangeEnabled(): invalid range" );
+ }
+ return bRet;
+}
+
+// -----------------------------------------------------------------------
+
+void PrintDialog::CheckSheetRange( PrintSheetRange eRange )
+{
+ if ( mbWithSheetsAndCells )
+ {
+ switch ( eRange )
+ {
+ case PRINTSHEETS_ALL :
+ maRbtAllSheets.Check();
+ break;
+ case PRINTSHEETS_SELECTED_SHEETS :
+ maRbtSelectedSheets.Check();
+ break;
+ case PRINTSHEETS_SELECTED_CELLS :
+ maRbtSelectedCells.Check();
+ break;
+ default:
+ DBG_ERRORFILE( "PrintDialog::CheckSheetRange(): invalid range" );
+ }
+ }
+}
+
+// -----------------------------------------------------------------------
+
+PrintSheetRange PrintDialog::GetCheckedSheetRange() const
+{
+ PrintSheetRange eRange = PRINTSHEETS_ALL;
+ if ( mbWithSheetsAndCells )
+ {
+ if ( maRbtSelectedSheets.IsChecked() )
+ eRange = PRINTSHEETS_SELECTED_SHEETS;
+ else if ( maRbtSelectedCells.IsChecked() )
+ eRange = PRINTSHEETS_SELECTED_CELLS;
+ }
+ return eRange;
+}
+
+// -----------------------------------------------------------------------
+
+bool PrintDialog::IsSheetRangeChecked( PrintSheetRange eRange ) const
+{
+ if ( !mbWithSheetsAndCells )
+ return false;
+
+ bool bRet = false;
+ switch ( eRange )
+ {
+ case PRINTSHEETS_ALL :
+ bRet = maRbtAllSheets.IsChecked() != FALSE;
+ break;
+ case PRINTSHEETS_SELECTED_SHEETS :
+ bRet = maRbtSelectedSheets.IsChecked() != FALSE;
+ break;
+ case PRINTSHEETS_SELECTED_CELLS :
+ bRet = maRbtSelectedCells.IsChecked() != FALSE;
+ break;
+ default:
+ DBG_ERRORFILE( "PrintDialog::IsSheetRangeChecked(): invalid range" );
+ }
+ return bRet;
+}
+
+// -----------------------------------------------------------------------
+
+long PrintDialog::Notify( NotifyEvent& rNEvt )
+{
+ if ( (rNEvt.GetType() == EVENT_GETFOCUS) && IsReallyVisible() )
+ ImplStatusHdl( &maStatusTimer );
+ else if ( rNEvt.GetType() == EVENT_KEYINPUT )
+ {
+ if ( rNEvt.GetKeyEvent()->GetKeyCode().GetCode() == KEY_F1 && mpPrinterImpl->m_bHelpDisabled )
+ return 1; // do nothing
+ }
+
+ return ModalDialog::Notify( rNEvt );
+}
+
+// -----------------------------------------------------------------------
+
+void PrintDialog::DataChanged( const DataChangedEvent& rDCEvt )
+{
+ if ( rDCEvt.GetType() == DATACHANGED_PRINTER )
+ {
+ TEMPPRINTER() = ImplPrnDlgUpdatePrinter( mpPrinter, TEMPPRINTER() );
+ Printer* pPrn;
+ if ( TEMPPRINTER() )
+ pPrn = TEMPPRINTER();
+ else
+ pPrn = mpPrinter;
+ ImplFillPrnDlgListBox( pPrn, &maLbName, &maBtnProperties );
+ ImplSetInfo();
+ ImplCheckOK();
+ }
+ else if ( rDCEvt.GetType() == DATACHANGED_SETTINGS )
+ ImplSetImages();
+
+ ModalDialog::DataChanged( rDCEvt );
+}
+
+// -----------------------------------------------------------------------
+
+short PrintDialog::Execute()
+{
+ if ( !mpPrinter || mpPrinter->IsPrinting() || mpPrinter->IsJobActive() )
+ {
+ DBG_ERRORFILE( "PrinterSetupDialog::Execute() - No Printer or printer is printing" );
+ return FALSE;
+ }
+
+ // check if the printer brings up its own dialog
+ // in that case leave the work to that dialog
+ if( mpPrinter->GetCapabilities( PRINTER_CAPABILITIES_EXTERNALDIALOG ) )
+ return TRUE;
+
+ Printer::updatePrinters();
+
+ // Controls initialisieren
+ ImplFillPrnDlgListBox( mpPrinter, &maLbName, &maBtnProperties );
+ ImplSetInfo();
+ maStatusTimer.Start();
+ ImplInitControls();
+ maNumCopies.GrabFocus();
+ maNumCopies.SetSelection( Selection( 0, maNumCopies.GetText().Len() ) );
+ ImplModifyControlHdl( NULL );
+
+ // Dialog starten
+ short nRet = ModalDialog::Execute();
+
+ // Wenn Dialog mit OK beendet wurde, dann die Daten updaten
+ if( nRet == TRUE )
+ {
+ if ( TEMPPRINTER() )
+ mpPrinter->SetPrinterProps( TEMPPRINTER() );
+ ImplFillDialogData();
+ }
+
+ maStatusTimer.Stop();
+
+ return nRet;
+}
+
+// -----------------------------------------------------------------------
+
+void PrintDialog::DisableHelp()
+{
+ mpPrinterImpl->m_bHelpDisabled = sal_True;
+ maBtnHelp.Disable();
+}
+
diff --git a/svtools/source/dialogs/printdlg.hrc b/svtools/source/dialogs/printdlg.hrc
new file mode 100644
index 000000000000..cae57cefdb0e
--- /dev/null
+++ b/svtools/source/dialogs/printdlg.hrc
@@ -0,0 +1,77 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: printdlg.hrc,v $
+ * $Revision: 1.8 $
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#include <svtools/svtools.hrc>
+
+#define FL_PRINTER 1
+#define LB_NAMES 2
+#define BTN_PROPERTIES 3
+#define FT_NAME 4
+#define FT_STATUS 5
+#define FI_STATUS 6
+#define FT_TYPE 7
+#define FI_TYPE 8
+#define FT_LOCATION 9
+#define FI_LOCATION 10
+#define FT_COMMENT 11
+#define FI_COMMENT 12
+#define CBX_FILEPRINT 13
+#define FI_PRINTFILE 14
+#define FI_FAXNO 15
+#define EDT_FAXNO 16
+
+#define FL_PRINT 20
+#define RBT_ALL_SHEETS 21
+#define RBT_SELECTED_SHEETS 22
+#define RBT_SELECTED_CELLS 23
+
+#define FL_PRINTRANGE 30
+#define RBT_ALL 31
+#define RBT_PAGES 32
+#define EDT_PAGES 33
+#define RBT_SELECTION 34
+
+#define FL_SEPCOPIESRANGE 35
+
+#define FL_COPIES 40
+#define FT_COPIES 41
+#define NUM_COPIES 42
+#define CBX_COLLATE 43
+#define IMG_COLLATE 44
+#define IMG_NOT_COLLATE 45
+
+#define FL_SEPBUTTONLINE 50
+#define BTN_OK 51
+#define BTN_CANCEL 52
+#define BTN_HELP 53
+#define BTN_OPTIONS 54
+
+#define STR_ALLFILTER 10
+
diff --git a/svtools/source/dialogs/printdlg.src b/svtools/source/dialogs/printdlg.src
new file mode 100644
index 000000000000..c3ab39564d75
--- /dev/null
+++ b/svtools/source/dialogs/printdlg.src
@@ -0,0 +1,336 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: printdlg.src,v $
+ * $Revision: 1.49 $
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#include "printdlg.hrc"
+
+#define IMAGE_MAGENTA_MASK Color { Red = 0xFFFF; Green = 0x0000; Blue = 0xFFFF; }
+
+ModalDialog DLG_SVT_PRNDLG_PRINTDLG
+{
+ SVLook = TRUE ;
+ OutputSize = TRUE ;
+ Moveable = TRUE ;
+ Size = MAP_APPFONT ( 265 , 210 ) ;
+ Text [ en-US ] = "Print" ;
+ FixedLine FL_PRINTER
+ {
+ Pos = MAP_APPFONT ( 6 , 3 ) ;
+ Size = MAP_APPFONT ( 253 , 8 ) ;
+ Text [ en-US ] = "Printer" ;
+ };
+ FixedText FT_NAME
+ {
+ Pos = MAP_APPFONT ( 12 , 14 ) ;
+ Size = MAP_APPFONT ( 45 , 10 ) ;
+ Text [ en-US ] = "~Name" ;
+ };
+ ListBox LB_NAMES
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 60 , 13 ) ;
+ Size = MAP_APPFONT ( 130 , 80 ) ;
+ DropDown = TRUE ;
+ Sort = TRUE ;
+ };
+ PushButton BTN_PROPERTIES
+ {
+ Pos = MAP_APPFONT ( 193 , 12 ) ;
+ Size = MAP_APPFONT ( 60 , 14 ) ;
+ Text [ en-US ] = "Propert~ies..." ;
+ };
+ FixedText FT_STATUS
+ {
+ Pos = MAP_APPFONT ( 12 , 29 ) ;
+ Size = MAP_APPFONT ( 45 , 8 ) ;
+ Text [ en-US ] = "Status" ;
+ };
+ FixedText FI_STATUS
+ {
+ Pos = MAP_APPFONT ( 60 , 29 ) ;
+ Size = MAP_APPFONT ( 193 , 8 ) ;
+ };
+ FixedText FT_TYPE
+ {
+ Pos = MAP_APPFONT ( 12 , 40 ) ;
+ Size = MAP_APPFONT ( 45 , 8 ) ;
+ Text [ en-US ] = "Type" ;
+ };
+ FixedText FI_TYPE
+ {
+ Pos = MAP_APPFONT ( 60 , 40 ) ;
+ Size = MAP_APPFONT ( 193 , 8 ) ;
+ };
+ FixedText FT_LOCATION
+ {
+ Pos = MAP_APPFONT ( 12 , 51 ) ;
+ Size = MAP_APPFONT ( 45 , 8 ) ;
+ Text [ en-US ] = "Location" ;
+ };
+ FixedText FI_LOCATION
+ {
+ Pos = MAP_APPFONT ( 60 , 51 ) ;
+ Size = MAP_APPFONT ( 193 , 8 ) ;
+ };
+ FixedText FT_COMMENT
+ {
+ Pos = MAP_APPFONT ( 12 , 62 ) ;
+ Size = MAP_APPFONT ( 45 , 8 ) ;
+ Text [ en-US ] = "Comment" ;
+ };
+ FixedText FI_COMMENT
+ {
+ Pos = MAP_APPFONT ( 60 , 62 ) ;
+ Size = MAP_APPFONT ( 193 , 8 ) ;
+ };
+ FixedText FI_FAXNO
+ {
+ Pos = MAP_APPFONT ( 12 , 75 ) ;
+ Size = MAP_APPFONT ( 45 , 8 ) ;
+ Text [ en-US ] = "Fax number";
+ };
+ Edit EDT_FAXNO
+ {
+ Border = TRUE;
+ Pos = MAP_APPFONT ( 60 , 73 );
+ Size = MAP_APPFONT ( 188 , 12 );
+ };
+ CheckBox CBX_FILEPRINT
+ {
+ Pos = MAP_APPFONT ( 12 , 73 ) ;
+ Size = MAP_APPFONT ( 75 , 10 ) ;
+ Text [ en-US ] = "Print to file" ;
+ };
+ FixedText FI_PRINTFILE
+ {
+ Pos = MAP_APPFONT ( 90 , 74 ) ;
+ Size = MAP_APPFONT ( 163 , 8 ) ;
+ };
+ /*!!!
+ PushButton BTN_BROWSE
+ {
+ Pos = MAP_APPFONT ( 234 , 75 ) ;
+ Size = MAP_APPFONT ( 14 , 14 ) ;
+ Text = "~..." ;
+ Hide = TRUE ;
+ };
+ */
+ FixedLine FL_PRINT
+ {
+ Pos = MAP_APPFONT ( 6 , 91 ) ;
+ Size = MAP_APPFONT ( 117 , 8 ) ;
+ Text [ en-US ] = "Print" ;
+ };
+ RadioButton RBT_ALL_SHEETS
+ {
+ Pos = MAP_APPFONT ( 12 , 102 ) ;
+ Size = MAP_APPFONT ( 105 , 10 ) ;
+ Text [ en-US ] = "All sheets" ;
+ };
+ RadioButton RBT_SELECTED_SHEETS
+ {
+ Pos = MAP_APPFONT ( 12 , 115 ) ;
+ Size = MAP_APPFONT ( 105 , 10 ) ;
+ Text [ en-US ] = "Selected sheets" ;
+ };
+ RadioButton RBT_SELECTED_CELLS
+ {
+ Pos = MAP_APPFONT ( 12 , 128 ) ;
+ Size = MAP_APPFONT ( 105 , 10 ) ;
+ Text [ en-US ] = "Selected cells" ;
+ };
+ FixedLine FL_PRINTRANGE
+ {
+ Pos = MAP_APPFONT ( 6 , 141 ) ;
+ Size = MAP_APPFONT ( 117 , 8 ) ;
+ Text [ en-US ] = "Print range" ;
+ };
+ RadioButton RBT_ALL
+ {
+ Pos = MAP_APPFONT ( 12 , 152 ) ;
+ Size = MAP_APPFONT ( 105 , 10 ) ;
+ Text [ en-US ] = "All pages" ;
+ };
+ RadioButton RBT_PAGES
+ {
+ Pos = MAP_APPFONT ( 12 , 165 ) ;
+ Size = MAP_APPFONT ( 50 , 10 ) ;
+ Text [ en-US ] = "Pages" ;
+ };
+ Edit EDT_PAGES
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 65 , 164 ) ;
+ Size = MAP_APPFONT ( 52 , 12 ) ;
+ };
+ RadioButton RBT_SELECTION
+ {
+ Hide = TRUE ;
+ Pos = MAP_APPFONT ( 12 , 179 ) ;
+ Size = MAP_APPFONT ( 105 , 10 ) ;
+ Text [ en-US ] = "Selection" ;
+ };
+ FixedLine FL_SEPCOPIESRANGE
+ {
+ Pos = MAP_APPFONT( 126, 102 );
+ Size = MAP_APPFONT( 1, 74 );
+ Vert = TRUE;
+ };
+ FixedLine FL_COPIES
+ {
+ Pos = MAP_APPFONT ( 129 , 91 ) ;
+ Size = MAP_APPFONT ( 130 , 8 ) ;
+ Text [ en-US ] = "Copies" ;
+ };
+ FixedText FT_COPIES
+ {
+ Pos = MAP_APPFONT ( 135 , 104 ) ;
+ Size = MAP_APPFONT ( 63 , 8 ) ;
+ Text [ en-US ] = "Number of copies" ;
+ };
+ NumericField NUM_COPIES
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 201 , 102 ) ;
+ Size = MAP_APPFONT ( 33 , 12 ) ;
+ Repeat = TRUE ;
+ Spin = TRUE ;
+ Minimum = 1 ;
+ Maximum = 9999 ;
+ StrictFormat = TRUE ;
+ First = 1 ;
+ Last = 9999 ;
+ };
+ CheckBox CBX_COLLATE
+ {
+ Pos = MAP_APPFONT ( 201 , 123 ) ;
+ Size = MAP_APPFONT ( 60 , 10 ) ;
+ Text [ en-US ] = "Co~llate" ;
+ };
+ FixedImage IMG_COLLATE
+ {
+ Pos = MAP_APPFONT ( 132 , 117 ) ;
+ Size = MAP_APPFONT ( 67 , 22 ) ;
+ Hide = TRUE ;
+ };
+ FixedImage IMG_NOT_COLLATE
+ {
+ Pos = MAP_APPFONT ( 132 , 117 ) ;
+ Size = MAP_APPFONT ( 67 , 22 ) ;
+ Hide = TRUE ;
+ };
+ FixedLine FL_SEPBUTTONLINE
+ {
+ Pos = MAP_APPFONT( 0, 179 );
+ Size = MAP_APPFONT( 265, 8 );
+ };
+ PushButton BTN_OPTIONS
+ {
+ Hide = TRUE ;
+ Pos = MAP_APPFONT ( 6 , 190 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ Text [ en-US ] = "~Options..." ;
+ };
+ OKButton BTN_OK
+ {
+ Pos = MAP_APPFONT ( 100 , 190 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ DefButton = TRUE ;
+ };
+ CancelButton BTN_CANCEL
+ {
+ Pos = MAP_APPFONT ( 153 , 190 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ };
+ HelpButton BTN_HELP
+ {
+ Pos = MAP_APPFONT ( 209 , 190 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ };
+ String STR_ALLFILTER
+ {
+ Text [ en-US ] = "<All>";
+ };
+};
+
+Image RID_IMG_PRNDLG_COLLATE
+{
+ ImageBitmap = Bitmap { File = "collate.bmp" ; };
+ MaskColor = IMAGE_MAGENTA_MASK ;
+};
+
+Image RID_IMG_PRNDLG_NOCOLLATE
+{
+ ImageBitmap = Bitmap { File = "ncollate.bmp" ; };
+ MaskColor = IMAGE_MAGENTA_MASK ;
+};
+
+Image RID_IMG_PRNDLG_COLLATE_HC
+{
+ ImageBitmap = Bitmap { File = "collate_h.bmp" ; };
+ MaskColor = IMAGE_MAGENTA_MASK ;
+};
+
+Image RID_IMG_PRNDLG_NOCOLLATE_HC
+{
+ ImageBitmap = Bitmap { File = "ncollate_h.bmp" ; };
+ MaskColor = IMAGE_MAGENTA_MASK ;
+};
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/svtools/source/dialogs/prnsetup.cxx b/svtools/source/dialogs/prnsetup.cxx
new file mode 100644
index 000000000000..dedb5b2d7143
--- /dev/null
+++ b/svtools/source/dialogs/prnsetup.cxx
@@ -0,0 +1,406 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: prnsetup.cxx,v $
+ * $Revision: 1.10 $
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_svtools.hxx"
+#include <tools/debug.hxx>
+#ifndef _VCL_PRINT_HXX
+#include <vcl/print.hxx>
+#endif
+
+#ifndef GCC
+#endif
+
+#include <svtools/svtdata.hxx>
+#include "prnsetup.hrc"
+#include <svtools/prnsetup.hxx>
+
+// =======================================================================
+
+void ImplFillPrnDlgListBox( const Printer* pPrinter,
+ ListBox* pBox, PushButton* pPropBtn )
+{
+ ImplFreePrnDlgListBox( pBox );
+
+ const std::vector<rtl::OUString>& rPrinters = Printer::GetPrinterQueues();
+ unsigned int nCount = rPrinters.size();
+ if ( nCount )
+ {
+ for( unsigned int i = 0; i < nCount; i++ )
+ pBox->InsertEntry( rPrinters[i] );
+ pBox->SelectEntry( pPrinter->GetName() );
+ }
+
+ pBox->Enable( nCount != 0 );
+ pPropBtn->Enable( pPrinter->HasSupport( SUPPORT_SETUPDIALOG ) );
+}
+
+// -----------------------------------------------------------------------
+
+void ImplFreePrnDlgListBox( ListBox* pBox, BOOL bClear )
+{
+ if ( bClear )
+ pBox->Clear();
+}
+
+// -----------------------------------------------------------------------
+
+Printer* ImplPrnDlgListBoxSelect( ListBox* pBox, PushButton* pPropBtn,
+ Printer* pPrinter, Printer* pTempPrinter )
+{
+ if ( pBox->GetSelectEntryPos() != LISTBOX_ENTRY_NOTFOUND )
+ {
+ const QueueInfo* pInfo = Printer::GetQueueInfo( pBox->GetSelectEntry(), true );
+ if( pInfo)
+ {
+ if ( !pTempPrinter )
+ {
+ if ( (pPrinter->GetName() == pInfo->GetPrinterName()) &&
+ (pPrinter->GetDriverName() == pInfo->GetDriver()) )
+ pTempPrinter = new Printer( pPrinter->GetJobSetup() );
+ else
+ pTempPrinter = new Printer( *pInfo );
+ }
+ else
+ {
+ if ( (pTempPrinter->GetName() != pInfo->GetPrinterName()) ||
+ (pTempPrinter->GetDriverName() != pInfo->GetDriver()) )
+ {
+ delete pTempPrinter;
+ pTempPrinter = new Printer( *pInfo );
+ }
+ }
+
+ pPropBtn->Enable( pTempPrinter->HasSupport( SUPPORT_SETUPDIALOG ) );
+ }
+ else
+ pPropBtn->Disable();
+ }
+ else
+ pPropBtn->Disable();
+
+ return pTempPrinter;
+}
+
+// -----------------------------------------------------------------------
+
+Printer* ImplPrnDlgUpdatePrinter( Printer* pPrinter, Printer* pTempPrinter )
+{
+ XubString aPrnName;
+ if ( pTempPrinter )
+ aPrnName = pTempPrinter->GetName();
+ else
+ aPrnName = pPrinter->GetName();
+
+ if ( ! Printer::GetQueueInfo( aPrnName, false ) )
+ {
+ if ( pTempPrinter )
+ delete pTempPrinter;
+ pTempPrinter = new Printer;
+ }
+
+ return pTempPrinter;
+}
+
+// -----------------------------------------------------------------------
+
+void ImplPrnDlgUpdateQueueInfo( ListBox* pBox, QueueInfo& rInfo )
+{
+ if ( pBox->GetSelectEntryPos() != LISTBOX_ENTRY_NOTFOUND )
+ {
+ const QueueInfo* pInfo = Printer::GetQueueInfo( pBox->GetSelectEntry(), true );
+ if( pInfo )
+ rInfo = *pInfo;
+ }
+}
+
+// -----------------------------------------------------------------------
+
+static void ImplPrnDlgAddString( XubString& rStr, const XubString& rAddStr )
+{
+ if ( rStr.Len() )
+ rStr.AppendAscii( "; " );
+ rStr += rAddStr;
+}
+
+// -----------------------------------------------------------------------
+
+static void ImplPrnDlgAddResString( XubString& rStr, USHORT nResId )
+{
+ SvtResId aResId( nResId );
+ XubString aAddStr( aResId );
+ ImplPrnDlgAddString( rStr, aAddStr );
+}
+
+// -----------------------------------------------------------------------
+
+XubString ImplPrnDlgGetStatusText( const QueueInfo& rInfo )
+{
+ XubString aStr;
+ ULONG nStatus = rInfo.GetStatus();
+
+ // Default-Printer
+ if ( rInfo.GetPrinterName().Len() &&
+ (rInfo.GetPrinterName() == Printer::GetDefaultPrinterName()) )
+ ImplPrnDlgAddResString( aStr, STR_SVT_PRNDLG_DEFPRINTER );
+
+ // Status
+ if ( nStatus & QUEUE_STATUS_READY )
+ ImplPrnDlgAddResString( aStr, STR_SVT_PRNDLG_READY );
+ if ( nStatus & QUEUE_STATUS_PAUSED )
+ ImplPrnDlgAddResString( aStr, STR_SVT_PRNDLG_PAUSED );
+ if ( nStatus & QUEUE_STATUS_PENDING_DELETION )
+ ImplPrnDlgAddResString( aStr, STR_SVT_PRNDLG_PENDING );
+ if ( nStatus & QUEUE_STATUS_BUSY )
+ ImplPrnDlgAddResString( aStr, STR_SVT_PRNDLG_BUSY );
+ if ( nStatus & QUEUE_STATUS_INITIALIZING )
+ ImplPrnDlgAddResString( aStr, STR_SVT_PRNDLG_INITIALIZING );
+ if ( nStatus & QUEUE_STATUS_WAITING )
+ ImplPrnDlgAddResString( aStr, STR_SVT_PRNDLG_WAITING );
+ if ( nStatus & QUEUE_STATUS_WARMING_UP )
+ ImplPrnDlgAddResString( aStr, STR_SVT_PRNDLG_WARMING_UP );
+ if ( nStatus & QUEUE_STATUS_PROCESSING )
+ ImplPrnDlgAddResString( aStr, STR_SVT_PRNDLG_PROCESSING );
+ if ( nStatus & QUEUE_STATUS_PRINTING )
+ ImplPrnDlgAddResString( aStr, STR_SVT_PRNDLG_PRINTING );
+ if ( nStatus & QUEUE_STATUS_OFFLINE )
+ ImplPrnDlgAddResString( aStr, STR_SVT_PRNDLG_OFFLINE );
+ if ( nStatus & QUEUE_STATUS_ERROR )
+ ImplPrnDlgAddResString( aStr, STR_SVT_PRNDLG_ERROR );
+ if ( nStatus & QUEUE_STATUS_SERVER_UNKNOWN )
+ ImplPrnDlgAddResString( aStr, STR_SVT_PRNDLG_SERVER_UNKNOWN );
+ if ( nStatus & QUEUE_STATUS_PAPER_JAM )
+ ImplPrnDlgAddResString( aStr, STR_SVT_PRNDLG_PAPER_JAM );
+ if ( nStatus & QUEUE_STATUS_PAPER_OUT )
+ ImplPrnDlgAddResString( aStr, STR_SVT_PRNDLG_PAPER_OUT );
+ if ( nStatus & QUEUE_STATUS_MANUAL_FEED )
+ ImplPrnDlgAddResString( aStr, STR_SVT_PRNDLG_MANUAL_FEED );
+ if ( nStatus & QUEUE_STATUS_PAPER_PROBLEM )
+ ImplPrnDlgAddResString( aStr, STR_SVT_PRNDLG_PAPER_PROBLEM );
+ if ( nStatus & QUEUE_STATUS_IO_ACTIVE )
+ ImplPrnDlgAddResString( aStr, STR_SVT_PRNDLG_IO_ACTIVE );
+ if ( nStatus & QUEUE_STATUS_OUTPUT_BIN_FULL )
+ ImplPrnDlgAddResString( aStr, STR_SVT_PRNDLG_OUTPUT_BIN_FULL );
+ if ( nStatus & QUEUE_STATUS_TONER_LOW )
+ ImplPrnDlgAddResString( aStr, STR_SVT_PRNDLG_TONER_LOW );
+ if ( nStatus & QUEUE_STATUS_NO_TONER )
+ ImplPrnDlgAddResString( aStr, STR_SVT_PRNDLG_NO_TONER );
+ if ( nStatus & QUEUE_STATUS_PAGE_PUNT )
+ ImplPrnDlgAddResString( aStr, STR_SVT_PRNDLG_PAGE_PUNT );
+ if ( nStatus & QUEUE_STATUS_USER_INTERVENTION )
+ ImplPrnDlgAddResString( aStr, STR_SVT_PRNDLG_USER_INTERVENTION );
+ if ( nStatus & QUEUE_STATUS_OUT_OF_MEMORY )
+ ImplPrnDlgAddResString( aStr, STR_SVT_PRNDLG_OUT_OF_MEMORY );
+ if ( nStatus & QUEUE_STATUS_DOOR_OPEN )
+ ImplPrnDlgAddResString( aStr, STR_SVT_PRNDLG_DOOR_OPEN );
+ if ( nStatus & QUEUE_STATUS_POWER_SAVE )
+ ImplPrnDlgAddResString( aStr, STR_SVT_PRNDLG_POWER_SAVE );
+
+ // Anzahl Jobs
+ ULONG nJobs = rInfo.GetJobs();
+ if ( nJobs && (nJobs != QUEUE_JOBS_DONTKNOW) )
+ {
+ XubString aJobStr( SvtResId( STR_SVT_PRNDLG_JOBCOUNT ) );
+ XubString aJobs( XubString::CreateFromInt32( nJobs ) );
+ aJobStr.SearchAndReplaceAscii( "%d", aJobs );
+ ImplPrnDlgAddString( aStr, aJobStr );
+ }
+
+ return aStr;
+}
+
+// =======================================================================
+
+PrinterSetupDialog::PrinterSetupDialog( Window* pWindow ) :
+ ModalDialog ( pWindow, SvtResId( DLG_SVT_PRNDLG_PRNSETUPDLG ) ),
+ maFlPrinter ( this, SvtResId( FL_PRINTER ) ),
+ maFtName ( this, SvtResId( FT_NAME ) ),
+ maLbName ( this, SvtResId( LB_NAMES ) ),
+ maBtnProperties ( this, SvtResId( BTN_PROPERTIES ) ),
+ maBtnOptions ( this, SvtResId( BTN_OPTIONS ) ),
+ maFtStatus ( this, SvtResId( FT_STATUS ) ),
+ maFiStatus ( this, SvtResId( FI_STATUS ) ),
+ maFtType ( this, SvtResId( FT_TYPE ) ),
+ maFiType ( this, SvtResId( FI_TYPE ) ),
+ maFtLocation ( this, SvtResId( FT_LOCATION ) ),
+ maFiLocation ( this, SvtResId( FI_LOCATION ) ),
+ maFtComment ( this, SvtResId( FT_COMMENT ) ),
+ maFiComment ( this, SvtResId( FI_COMMENT ) ),
+ maFlSepButton ( this, SvtResId( FL_SEPBUTTON ) ),
+ maBtnOK ( this, SvtResId( BTN_OK ) ),
+ maBtnCancel ( this, SvtResId( BTN_CANCEL ) ),
+ maBtnHelp ( this, SvtResId( BTN_HELP ) )
+{
+ FreeResource();
+
+ // show options button only if link is set
+ maBtnOptions.Hide();
+
+ mpPrinter = NULL;
+ mpTempPrinter = NULL;
+
+ maStatusTimer.SetTimeout( IMPL_PRINTDLG_STATUS_UPDATE );
+ maStatusTimer.SetTimeoutHdl( LINK( this, PrinterSetupDialog, ImplStatusHdl ) );
+ maBtnProperties.SetClickHdl( LINK( this, PrinterSetupDialog, ImplPropertiesHdl ) );
+ maLbName.SetSelectHdl( LINK( this, PrinterSetupDialog, ImplChangePrinterHdl ) );
+}
+
+// -----------------------------------------------------------------------
+
+PrinterSetupDialog::~PrinterSetupDialog()
+{
+ ImplFreePrnDlgListBox( &maLbName, FALSE );
+ delete mpTempPrinter;
+}
+
+// -----------------------------------------------------------------------
+
+void PrinterSetupDialog::SetOptionsHdl( const Link& rLink )
+{
+ maBtnOptions.SetClickHdl( rLink );
+ maBtnOptions.Show( rLink.IsSet() );
+}
+
+const Link& PrinterSetupDialog::GetOptionsHdl() const
+{
+ return maBtnOptions.GetClickHdl();
+}
+
+void PrinterSetupDialog::ImplSetInfo()
+{
+ const QueueInfo* pInfo = Printer::GetQueueInfo(maLbName.GetSelectEntry(), true);
+ if ( pInfo )
+ {
+ maFiType.SetText( pInfo->GetDriver() );
+ maFiLocation.SetText( pInfo->GetLocation() );
+ maFiComment.SetText( pInfo->GetComment() );
+ maFiStatus.SetText( ImplPrnDlgGetStatusText( *pInfo ) );
+ }
+ else
+ {
+ XubString aTempStr;
+ maFiType.SetText( aTempStr );
+ maFiLocation.SetText( aTempStr );
+ maFiComment.SetText( aTempStr );
+ maFiStatus.SetText( aTempStr );
+ }
+}
+
+// -----------------------------------------------------------------------
+
+IMPL_LINK( PrinterSetupDialog, ImplStatusHdl, Timer*, EMPTYARG )
+{
+ QueueInfo aInfo;
+ ImplPrnDlgUpdateQueueInfo( &maLbName, aInfo );
+ maFiStatus.SetText( ImplPrnDlgGetStatusText( aInfo ) );
+
+ return 0;
+}
+
+// -----------------------------------------------------------------------
+
+IMPL_LINK( PrinterSetupDialog, ImplPropertiesHdl, void*, EMPTYARG )
+{
+ if ( !mpTempPrinter )
+ mpTempPrinter = new Printer( mpPrinter->GetJobSetup() );
+ mpTempPrinter->Setup( this );
+
+ return 0;
+}
+
+// -----------------------------------------------------------------------
+
+IMPL_LINK( PrinterSetupDialog, ImplChangePrinterHdl, void*, EMPTYARG )
+{
+ mpTempPrinter = ImplPrnDlgListBoxSelect( &maLbName, &maBtnProperties,
+ mpPrinter, mpTempPrinter );
+ ImplSetInfo();
+ return 0;
+}
+
+// -----------------------------------------------------------------------
+
+long PrinterSetupDialog::Notify( NotifyEvent& rNEvt )
+{
+ if ( (rNEvt.GetType() == EVENT_GETFOCUS) && IsReallyVisible() )
+ ImplStatusHdl( &maStatusTimer );
+
+ return ModalDialog::Notify( rNEvt );
+}
+
+// -----------------------------------------------------------------------
+
+void PrinterSetupDialog::DataChanged( const DataChangedEvent& rDCEvt )
+{
+ if ( rDCEvt.GetType() == DATACHANGED_PRINTER )
+ {
+ mpTempPrinter = ImplPrnDlgUpdatePrinter( mpPrinter, mpTempPrinter );
+ Printer* pPrn;
+ if ( mpTempPrinter )
+ pPrn = mpTempPrinter;
+ else
+ pPrn = mpPrinter;
+ ImplFillPrnDlgListBox( pPrn, &maLbName, &maBtnProperties );
+ ImplSetInfo();
+ }
+
+ ModalDialog::DataChanged( rDCEvt );
+}
+
+// -----------------------------------------------------------------------
+
+short PrinterSetupDialog::Execute()
+{
+ if ( !mpPrinter || mpPrinter->IsPrinting() || mpPrinter->IsJobActive() )
+ {
+ DBG_ERRORFILE( "PrinterSetupDialog::Execute() - No Printer or printer is printing" );
+ return FALSE;
+ }
+
+ Printer::updatePrinters();
+
+ ImplFillPrnDlgListBox( mpPrinter, &maLbName, &maBtnProperties );
+ ImplSetInfo();
+ maStatusTimer.Start();
+
+ // Dialog starten
+ short nRet = ModalDialog::Execute();
+
+ // Wenn Dialog mit OK beendet wurde, dann die Daten updaten
+ if ( nRet == TRUE )
+ {
+ if ( mpTempPrinter )
+ mpPrinter->SetPrinterProps( mpTempPrinter );
+ }
+
+ maStatusTimer.Stop();
+
+ return nRet;
+}
diff --git a/svtools/source/dialogs/prnsetup.hrc b/svtools/source/dialogs/prnsetup.hrc
new file mode 100644
index 000000000000..33f98f7ed5e0
--- /dev/null
+++ b/svtools/source/dialogs/prnsetup.hrc
@@ -0,0 +1,51 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: prnsetup.hrc,v $
+ * $Revision: 1.6 $
+ *
+ * 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.
+ *
+ ************************************************************************/
+#include <svtools/svtools.hrc>
+
+#define FL_PRINTER 1
+#define LB_NAMES 2
+#define BTN_PROPERTIES 3
+#define FT_NAME 4
+#define FT_STATUS 5
+#define FI_STATUS 6
+#define FT_TYPE 7
+#define FI_TYPE 8
+#define FT_LOCATION 9
+#define FI_LOCATION 10
+#define FT_COMMENT 11
+#define FI_COMMENT 12
+
+#define BTN_OK 13
+#define BTN_CANCEL 14
+#define BTN_HELP 15
+
+#define FL_SEPBUTTON 16
+
+#define BTN_OPTIONS 17
diff --git a/svtools/source/dialogs/prnsetup.src b/svtools/source/dialogs/prnsetup.src
new file mode 100644
index 000000000000..9f8731742c84
--- /dev/null
+++ b/svtools/source/dialogs/prnsetup.src
@@ -0,0 +1,281 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: prnsetup.src,v $
+ * $Revision: 1.40 $
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#include "prnsetup.hrc"
+
+String STR_SVT_PRNDLG_READY
+{
+ Text [ en-US ] = "Ready" ;
+};
+String STR_SVT_PRNDLG_PAUSED
+{
+ Text [ en-US ] = "Paused" ;
+};
+String STR_SVT_PRNDLG_PENDING
+{
+ Text [ en-US ] = "Pending deletion" ;
+};
+String STR_SVT_PRNDLG_BUSY
+{
+ Text [ en-US ] = "Busy" ;
+};
+String STR_SVT_PRNDLG_INITIALIZING
+{
+ Text [ en-US ] = "Initializing" ;
+};
+String STR_SVT_PRNDLG_WAITING
+{
+ Text [ en-US ] = "Waiting" ;
+};
+String STR_SVT_PRNDLG_WARMING_UP
+{
+ Text [ en-US ] = "Warming up" ;
+};
+String STR_SVT_PRNDLG_PROCESSING
+{
+ Text [ en-US ] = "Processing" ;
+};
+String STR_SVT_PRNDLG_PRINTING
+{
+ Text [ en-US ] = "Printing" ;
+};
+String STR_SVT_PRNDLG_OFFLINE
+{
+ Text [ en-US ] = "Offline" ;
+};
+String STR_SVT_PRNDLG_ERROR
+{
+ Text [ en-US ] = "Error" ;
+};
+String STR_SVT_PRNDLG_SERVER_UNKNOWN
+{
+ Text [ en-US ] = "Unknown Server" ;
+};
+String STR_SVT_PRNDLG_PAPER_JAM
+{
+ Text [ en-US ] = "Paper jam" ;
+};
+String STR_SVT_PRNDLG_PAPER_OUT
+{
+ Text [ en-US ] = "Not enough paper" ;
+};
+String STR_SVT_PRNDLG_MANUAL_FEED
+{
+ Text [ en-US ] = "Manual feed" ;
+};
+String STR_SVT_PRNDLG_PAPER_PROBLEM
+{
+ Text [ en-US ] = "Paper problem" ;
+};
+String STR_SVT_PRNDLG_IO_ACTIVE
+{
+ Text [ en-US ] = "I/O active" ;
+};
+String STR_SVT_PRNDLG_OUTPUT_BIN_FULL
+{
+ Text [ en-US ] = "Output bin full" ;
+};
+String STR_SVT_PRNDLG_TONER_LOW
+{
+ Text [ en-US ] = "Toner low" ;
+};
+String STR_SVT_PRNDLG_NO_TONER
+{
+ Text [ en-US ] = "No toner" ;
+};
+String STR_SVT_PRNDLG_PAGE_PUNT
+{
+ Text [ en-US ] = "Delete Page" ;
+};
+String STR_SVT_PRNDLG_USER_INTERVENTION
+{
+ Text [ en-US ] = "User intervention necessary" ;
+};
+String STR_SVT_PRNDLG_OUT_OF_MEMORY
+{
+ Text [ en-US ] = "Insufficient memory" ;
+};
+String STR_SVT_PRNDLG_DOOR_OPEN
+{
+ Text [ en-US ] = "Cover open" ;
+};
+String STR_SVT_PRNDLG_POWER_SAVE
+{
+ Text [ en-US ] = "Power save mode" ;
+};
+String STR_SVT_PRNDLG_DEFPRINTER
+{
+ Text [ en-US ] = "Default printer" ;
+};
+String STR_SVT_PRNDLG_JOBCOUNT
+{
+ Text [ en-US ] = "%d documents" ;
+};
+
+ModalDialog DLG_SVT_PRNDLG_PRNSETUPDLG
+{
+ OutputSize = TRUE ;
+ SVLook = TRUE ;
+ Moveable = TRUE ;
+ Size = MAP_APPFONT ( 260 , 104 ) ;
+ Text [ en-US ] = "Printer Setup" ;
+ FixedLine FL_PRINTER
+ {
+ Pos = MAP_APPFONT ( 6 , 3 ) ;
+ Size = MAP_APPFONT ( 248 , 8 ) ;
+ Text [ en-US ] = "Printer" ;
+ };
+ FixedText FT_NAME
+ {
+ Pos = MAP_APPFONT ( 12 , 14 ) ;
+ Size = MAP_APPFONT ( 45 , 10 ) ;
+ Text [ en-US ] = "~Name" ;
+ };
+ ListBox LB_NAMES
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 60 , 12 ) ;
+ Size = MAP_APPFONT ( 125 , 80 ) ;
+ DropDown = TRUE ;
+ Sort = TRUE ;
+ };
+ PushButton BTN_PROPERTIES
+ {
+ Pos = MAP_APPFONT ( 188 , 12 ) ;
+ Size = MAP_APPFONT ( 60 , 14 ) ;
+ Text [ en-US ] = "Propert~ies..." ;
+ };
+ FixedText FT_STATUS
+ {
+ Pos = MAP_APPFONT ( 12 , 29 ) ;
+ Size = MAP_APPFONT ( 45 , 10 ) ;
+ Text [ en-US ] = "Status" ;
+ };
+ FixedText FI_STATUS
+ {
+ Pos = MAP_APPFONT ( 60 , 29 ) ;
+ Size = MAP_APPFONT ( 188 , 10 ) ;
+ };
+ FixedText FT_TYPE
+ {
+ Pos = MAP_APPFONT ( 12 , 40 ) ;
+ Size = MAP_APPFONT ( 45 , 10 ) ;
+ Text [ en-US ] = "Type" ;
+ };
+ FixedText FI_TYPE
+ {
+ Pos = MAP_APPFONT ( 60 , 40 ) ;
+ Size = MAP_APPFONT ( 188 , 10 ) ;
+ };
+ FixedText FT_LOCATION
+ {
+ Pos = MAP_APPFONT ( 12 , 51 ) ;
+ Size = MAP_APPFONT ( 45 , 10 ) ;
+ Text [ en-US ] = "Location" ;
+ };
+ FixedText FI_LOCATION
+ {
+ Pos = MAP_APPFONT ( 60 , 51 ) ;
+ Size = MAP_APPFONT ( 188 , 10 ) ;
+ };
+ FixedText FT_COMMENT
+ {
+ Pos = MAP_APPFONT ( 12 , 62 ) ;
+ Size = MAP_APPFONT ( 45 , 10 ) ;
+ Text [ en-US ] = "Comment" ;
+ };
+ FixedText FI_COMMENT
+ {
+ Pos = MAP_APPFONT ( 60 , 62 ) ;
+ Size = MAP_APPFONT ( 188 , 10 ) ;
+ };
+ FixedLine FL_SEPBUTTON
+ {
+ Pos = MAP_APPFONT ( 0, 78 );
+ Size = MAP_APPFONT ( 260, 2 );
+ };
+ PushButton BTN_OPTIONS
+ {
+ Pos = MAP_APPFONT ( 5 , 84 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ Text [ en-US ] = "~Options..." ;
+ };
+ OKButton BTN_OK
+ {
+ Pos = MAP_APPFONT ( 95 , 84 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ DefButton = TRUE ;
+ };
+ CancelButton BTN_CANCEL
+ {
+ Pos = MAP_APPFONT ( 148 , 84 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ };
+ HelpButton BTN_HELP
+ {
+ Pos = MAP_APPFONT ( 204 , 84 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ };
+};
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/svtools/source/dialogs/propctrl.cxx b/svtools/source/dialogs/propctrl.cxx
new file mode 100644
index 000000000000..40fd55fb1586
--- /dev/null
+++ b/svtools/source/dialogs/propctrl.cxx
@@ -0,0 +1,506 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: propctrl.cxx,v $
+ * $Revision: 1.4 $
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_svtools.hxx"
+
+
+#ifndef _USR_INTROSP_HXX
+#include <usr/inspect.hxx>
+#endif
+#ifndef _USR_SERINFO_HXX
+#include <usr/serinfo.hxx>
+#endif
+#ifndef _USR_INTROSP_HXX
+#include <usr/introsp.hxx>
+#endif
+
+#include <propctrl.hxx>
+#include <property.hxx>
+
+
+// Controller-Implementation
+class PropertyEditorControler_Impl : public SvPropertyDataControl
+{
+ XIntrospectionAccessRef mxUnoAccess;
+ PropertySequence mPropSeq;
+ XPropertyEditorRef mxEditor;
+ SvPropertyBox* mpPropBox;
+ UsrAny maUnoObj;
+
+public:
+ // Provisorisch direkt Window mitgeben
+ PropertyEditorControler_Impl( SvPropertyBox* pPropBox_ );
+ //SimplePropertyEditor_Impl( void );
+
+ // Objekt zum Editieren setzen, dies loest das Eintragen
+ // der Properties in die PropertyBox aus
+ void setObject( XPropertyEditorRef xEditor_, const UsrAny& aToEditObj,
+ /* HACK fuer History-Interface*/String aPath, BOOL bBack=FALSE, BOOL bForward=FALSE );
+
+ /* SPAETER
+ SMART_UNO_DECLARATION(ImplIntrospection,UsrObject);
+
+ // Methoden von XInterface
+ XInterface * queryInterface( Uik aUik );
+ XIdlClassRef getIdlClass();
+ */
+
+ // Methoden von SvPropertyDataControl
+ virtual void Modified( const String& aName,
+ const String& aVal,
+ void* pData);
+
+ virtual void Clicked( const String& aName,
+ const String& aVal,
+ void* pData);
+
+ virtual void Commit( const String& aName,
+ const String& aVal,
+ void* pData);
+
+ virtual void Select( const String& aName,
+ void* pData);
+
+ virtual void LinkClicked(const String& aName,
+ void* pData);
+
+ // TODO: Das muss raus, sehr unglueckliche Schnittstelle
+ // PropertyBox erzwingt Zustand des Controllers
+ virtual String GetTheCorrectProperty() const;
+};
+
+// Methoden von XPropertyEditor
+PropertyEditorControler_Impl::PropertyEditorControler_Impl( SvPropertyBox* pPropBox_ )
+{
+ mpPropBox = pPropBox_;
+}
+
+void PropertyEditorControler_Impl::setObject( XPropertyEditorRef xEditor_, const UsrAny& aToEditObj,
+ /* HACK fuer History-Interface*/ String aPath, BOOL bBack, BOOL bForward )
+{
+ static XIntrospectionRef xIntrospection;
+
+ // Ohne Fenster laeuft gar nix
+ if( !mpPropBox )
+ return;
+
+ // Fenster aufraeumen
+ mpPropBox->ClearAll();
+
+ // Editor und Objekt übernehmen
+ mxEditor = xEditor_;
+ maUnoObj = aToEditObj;
+
+ if( !xIntrospection.is() )
+ {
+ // Introspection-Service holen
+ XServiceManagerRef xServiceManager = getGlobalServiceManager();
+ XServiceProviderRef xProv = xServiceManager->getServiceProvider
+ ( "com.sun.star.beans.Introspection", UikSequence(), UikSequence() );
+ xIntrospection = (XIntrospection *)xProv->newInstance()
+ ->queryInterface( XIntrospection::getSmartUik() );
+ }
+ if( !xIntrospection.is() )
+ return;
+
+ // und unspecten
+ mxUnoAccess = xIntrospection->inspect( maUnoObj );
+ if( !mxUnoAccess.Is() )
+ return;
+
+ // Uns als Controler anmelden
+ mpPropBox->SetController( this );
+
+ // Properties anlegen
+ mPropSeq = mxUnoAccess->getProperties();
+ UINT32 nPropCount = mPropSeq.getLen();
+ const Property* pProps = mPropSeq.getConstArray();
+
+ // 1. Seite anlegen
+ USHORT nPropPageId = mpPropBox->AppendPage("Properties");
+
+ // Beim Eintragen solls nicht flimmern
+ mpPropBox->DisableUpdate();
+
+ // Dummy-Properties fuer Path und Navigation
+ SvPropertyData aProperty;
+ if( aPath.Len() )
+ {
+ // Interface und Structs werden Hyperlinks
+ aProperty.bIsHyperLink = FALSE;
+ aProperty.bIsLocked = TRUE;
+ aProperty.bHasVisibleXButton = FALSE;
+ aProperty.eKind = KOC_EDIT;
+ aProperty.pControl = NULL;
+ aProperty.pDataPtr = NULL;
+ aProperty.aName = "Path";
+ aProperty.aValue = aPath;
+ mpPropBox->InsertEntry( aProperty );
+ }
+ if( bBack || bForward )
+ {
+ // Interface und Structs werden Hyperlinks
+ aProperty.bIsHyperLink = TRUE;
+ aProperty.bIsLocked = TRUE;
+ // HACK, solange Hyperlink nicht funktioniert
+ aProperty.bHasVisibleXButton = aProperty.bIsHyperLink;
+ aProperty.eKind = KOC_EDIT;
+ UINT32 iHandle;
+ aProperty.pControl = NULL;
+ if( bBack )
+ {
+ iHandle = 1000001;
+ aProperty.pDataPtr = (void*)iHandle;
+ aProperty.aName = "<-";
+ aProperty.aValue = "Back";
+ mpPropBox->InsertEntry( aProperty );
+ }
+ if( bForward )
+ {
+ iHandle = 1000000;
+ aProperty.pDataPtr = (void*)iHandle;
+ aProperty.aName = "->";
+ aProperty.aValue = "Forward";
+ mpPropBox->InsertEntry( aProperty );
+ }
+ }
+
+ // Properties eintragen
+ // TODO: Wo kommen die Strings her
+ UINT32 i;
+ for( i = 0 ; i < nPropCount ; i++ )
+ {
+ const Property& rProp = pProps[ i ];
+
+ // TypeClass des Property ermitteln
+ XIdlClassRef xPropClass = rProp.Type;
+ if( !xPropClass.is() )
+ {
+ DBG_ERROR( "PropertyEditorControler_Impl::Commit(), Property without type" )
+ return;
+ }
+ TypeClass eType = xPropClass->getTypeClass();
+
+ // Interface und Structs werden Hyperlinks
+ aProperty.bIsHyperLink = ( eType == TYPECLASS_INTERFACE || eType == TYPECLASS_STRUCT );
+ aProperty.bIsLocked = ((rProp.Attributes & PROPERTY_READONLY) != 0 );
+
+ // HACK, solange Hyperlink nicht funktioniert
+ aProperty.bHasVisibleXButton = aProperty.bIsHyperLink;
+
+ // Wert holen und in String wandeln
+ UsrAny aVal = mxUnoAccess->getPropertyValueByIndex( maUnoObj, i );
+ String aStrVal = AnyToString( aVal );
+
+ // Properties reinbraten
+ aProperty.eKind = KOC_EDIT;
+ aProperty.aName = rProp.Name;
+ aProperty.aValue = aStrVal;
+ aProperty.pDataPtr = (void*)i;
+ aProperty.pControl = NULL;
+ //aProperty.theValues.Insert(new String("1"),aProperty.theValues.Count());
+ //aProperty.theValues.Insert(new String("2"),aProperty.theValues.Count());
+ //aProperty.theValues.Insert(new String("3"),aProperty.theValues.Count());
+ //aProperty.theValues.Insert(new String("4"),aProperty.theValues.Count());
+ mpPropBox->InsertEntry( aProperty );
+ }
+
+ // 2. Seite fuer Listener
+ // TODO: Wo kommen die Eintraege her
+ USHORT nListenerPageId = mpPropBox->AppendPage("Listener");
+
+ XIdlClassSequence aSupportedListenerSeq = mxUnoAccess->getSupportedListeners();
+ const XIdlClassRef* pListenerArray = aSupportedListenerSeq.getConstArray();
+ UINT32 nIfaceCount = aSupportedListenerSeq.getLen();
+
+ // Property-Data vorfuellen
+ aProperty.eKind = KOC_EDIT;
+ //aProperty.eKind = KOC_UNDEFINED;
+ aProperty.aValue = "Listener-Value";
+ aProperty.bHasVisibleXButton = TRUE;
+ // TEST
+ //aProperty.bIsHyperLink = TRUE;
+ aProperty.bIsHyperLink = FALSE;
+ aProperty.bIsLocked = TRUE;
+ //aProperty.bIsLocked = FALSE;
+ aProperty.pDataPtr = NULL;
+ aProperty.pControl = NULL;
+
+ for( UINT32 j = 0 ; j < nIfaceCount ; j++ )
+ {
+ const XIdlClassRef& rxIfaceClass = pListenerArray[j];
+ aProperty.aName = rxIfaceClass->getName();
+ mpPropBox->InsertEntry( aProperty );
+ }
+ mpPropBox->EnableUpdate();
+ mpPropBox->SetPage( nPropPageId );
+}
+
+void PropertyEditorControler_Impl::Modified
+( const String& aName, const String& aVal, void* pData)
+{
+}
+
+void PropertyEditorControler_Impl::Clicked
+( const String& aName, const String& aVal, void* pData)
+{
+ // HACK, solange LinkClicked nicht funktioniert
+ UINT32 iPos = (UINT32)pData;
+ UINT32 nPropCount = mPropSeq.getLen();
+ if( iPos >= nPropCount )
+ {
+ // Spezial-IDs fuer forward/back?
+ BOOL bForward = (iPos == 1000000);
+ BOOL bBack = (iPos == 1000001);
+ if( bForward || bBack )
+ {
+ // Unterstuetzt der PropertyEditor das?
+ XPropertyEditorNavigationRef xPropEdNav = (XPropertyEditorNavigation*)
+ mxEditor->queryInterface( XPropertyEditorNavigation::getSmartUik() );
+ if( xPropEdNav.is() )
+ {
+ if( bForward )
+ xPropEdNav->forward();
+ else
+ xPropEdNav->back();
+ }
+ }
+ return;
+ }
+
+ const Property* pProps = mPropSeq.getConstArray();
+ const Property& rProp = pProps[ iPos ];
+ XIdlClassRef xPropClass = rProp.Type;
+ if( !xPropClass.is() )
+ {
+ DBG_ERROR( "PropertyEditorControler_Impl::Commit(), Property without type" )
+ return;
+ }
+ TypeClass eType = xPropClass->getTypeClass();
+ if( eType == TYPECLASS_INTERFACE || eType == TYPECLASS_STRUCT )
+ LinkClicked( aName, pData );
+}
+
+void PropertyEditorControler_Impl::Commit
+( const String& aName, const String& aVal, void* pData)
+{
+ UINT32 iPos = (UINT32)pData;
+ UINT32 nPropCount = mPropSeq.getLen();
+ if( iPos >= nPropCount )
+ return;
+
+ // String in Property-Typ wandeln
+ const Property* pProps = mPropSeq.getConstArray();
+ const Property& rProp = pProps[ iPos ];
+ XIdlClassRef xPropClass = rProp.Type;
+ if( !xPropClass.is() )
+ {
+ DBG_ERROR( "PropertyEditorControler_Impl::Commit(), Property without type" )
+ return;
+ }
+ TypeClass eType = xPropClass->getTypeClass();
+ UsrAny aValue = StringToAny( aVal, eType );
+
+ // Wert setzen
+ mxUnoAccess->setPropertyValueByIndex( maUnoObj, iPos, aValue );
+
+ // Wert neu holen und ggf. neu setzen
+ UsrAny aNewVal = mxUnoAccess->getPropertyValueByIndex( maUnoObj, iPos );
+ String aNewStrVal = AnyToString( aNewVal );
+ if( aNewStrVal != aVal )
+ mpPropBox->SetPropertyValue( aName, aNewStrVal );
+}
+
+void PropertyEditorControler_Impl::Select
+( const String& aName, void* pData)
+{
+}
+
+void PropertyEditorControler_Impl::LinkClicked(const String& aName, void* pData)
+{
+ UINT32 iPos = (UINT32)pData;
+ UINT32 nPropCount = mPropSeq.getLen();
+ if( iPos >= nPropCount )
+ return;
+
+ // Wert holen und an Master-Controller zurueckgeben
+ UsrAny aNewObj = mxUnoAccess->getPropertyValueByIndex( maUnoObj, iPos );
+ mxEditor->setObject( aNewObj, aName );
+}
+
+
+// TODO: Das muss raus, sehr unglueckliche Schnittstelle
+// PropertyBox erzwingt Zustand des Controllers
+String PropertyEditorControler_Impl::GetTheCorrectProperty() const
+{
+ return String();
+}
+
+
+SMART_UNO_IMPLEMENTATION(SimplePropertyEditor_Impl,UsrObject);
+
+// Methoden von XInterface
+XInterface * SimplePropertyEditor_Impl::queryInterface( Uik aUik )
+{
+ if( aUik == XPropertyEditor::getSmartUik() )
+ return (XPropertyEditor *)this;
+ if( aUik == XPropertyEditorNavigation::getSmartUik() )
+ return (XPropertyEditorNavigation *)this;
+ return UsrObject::queryInterface( aUik );
+}
+
+XIdlClassRef SimplePropertyEditor_Impl::getIdlClass()
+{
+ // TODO: Unterstuetzen
+ return NULL;
+}
+
+
+// Methoden von SimplePropertyEditor_Impl
+SimplePropertyEditor_Impl::SimplePropertyEditor_Impl( Window *pParent )
+ : maHistorySeq( 10 ), maHistoryNames( 10 ), bSimpleHistory( FALSE )
+{
+ //XVCLComponent xC = pParent->getVCLComponent
+ //xC->addVCLComponentListener( MyListener )
+
+ pActiveControler = NULL;
+ mpPropBox = new SvPropertyBox( pParent );
+ mpPropBox->Show();
+
+ long cxOut = pParent->GetOutputSizePixel().Width();
+ long cyOut = pParent->GetOutputSizePixel().Height();
+ Size aSize( cxOut, cyOut );
+ mpPropBox->SetPosSizePixel( Point( 0, 0 ), aSize );
+
+ mnHistoryCount = 0;
+ mnActualHistoryLevel = -1;
+}
+
+SimplePropertyEditor_Impl::~SimplePropertyEditor_Impl()
+{
+ delete mpPropBox;
+ if( pActiveControler )
+ delete pActiveControler;
+}
+
+// Private Methode zum Anlegen/Aktivieren der Controller
+void SimplePropertyEditor_Impl::showObject( const UsrAny& aToShowObj )
+{
+ if( pActiveControler )
+ delete pActiveControler;
+
+ // Neuen Controller auf der Wiese anlegen (TODO: Controller cachen?)
+ pActiveControler = new PropertyEditorControler_Impl( mpPropBox );
+
+ XPropertyEditorRef xThis = (XPropertyEditor *)this;
+ pActiveControler->setObject( xThis, aToShowObj,
+ /*aPath*/bSimpleHistory ? getPath() : String(),
+ /*bBack*/bSimpleHistory && mnActualHistoryLevel > 0,
+ /*bForward*/bSimpleHistory && (INT32)mnHistoryCount > mnActualHistoryLevel );
+}
+
+String SimplePropertyEditor_Impl::getPath( void )
+{
+ String aRetStr;
+ const String* pStr = maHistoryNames.getConstArray();
+ for( INT32 i = 0 ; i <= mnActualHistoryLevel ; i++ )
+ {
+ String aName = pStr[i];
+
+ // Root speziell behandeln
+ if( i == 0 )
+ {
+ aRetStr += aName;
+ }
+ else
+ {
+ // Ist es ein Index?
+ long l = (long)aName;
+ String aNumStr( l );
+ if( aNumStr == aName )
+ {
+ aRetStr += '[';
+ aRetStr += aName;
+ aRetStr += ']';
+ }
+ else
+ {
+ aRetStr += '.';
+ aRetStr += aName;
+ }
+ }
+ }
+ return aRetStr;
+}
+
+// Methoden von XPropertyEditor
+void SimplePropertyEditor_Impl::setObject( const UsrAny& aToEditObj, const XubString& aObjName )
+{
+ // History pflegen
+ mnActualHistoryLevel++;
+ mnHistoryCount = (UINT32)mnActualHistoryLevel;
+ UINT32 iHistorySize = maHistorySeq.getLen();
+ if( mnHistoryCount > iHistorySize )
+ {
+ maHistorySeq.realloc( iHistorySize + 10 );
+ maHistoryNames.realloc( iHistorySize + 10 );
+ }
+
+ // Neues Object eintragen
+ maHistorySeq.getArray()[ mnHistoryCount ] = aToEditObj;
+ maHistoryNames.getArray()[ mnHistoryCount ] = aObjName;
+
+ // Object anzeigen
+ showObject( aToEditObj );
+}
+
+// Methoden von PropertyEditorNavigation
+void SimplePropertyEditor_Impl::forward(void)
+{
+ if( (INT32)mnHistoryCount > mnActualHistoryLevel )
+ {
+ // Naechstes Object darstellen
+ mnActualHistoryLevel++;
+ showObject( maHistorySeq.getConstArray()[mnActualHistoryLevel] );
+ }
+}
+
+void SimplePropertyEditor_Impl::back(void)
+{
+ if( mnActualHistoryLevel > 0 )
+ {
+ // Voriges Object darstellen
+ mnActualHistoryLevel--;
+ showObject( maHistorySeq.getConstArray()[mnActualHistoryLevel] );
+ }
+}
+
+
diff --git a/svtools/source/dialogs/property.cxx b/svtools/source/dialogs/property.cxx
new file mode 100644
index 000000000000..a0d2c557a3f6
--- /dev/null
+++ b/svtools/source/dialogs/property.cxx
@@ -0,0 +1,1563 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: property.cxx,v $
+ * $Revision: 1.8 $
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_svtools.hxx"
+
+
+#ifndef GCC
+#endif
+
+//------------------------------------------------------------------
+
+//#include "Svitems.hxx"
+
+#include "property.hxx"
+/*
+#include "property.hrc"
+#include "Scresid.hxx"
+*/
+#define FRAME_OFFSET 4
+
+
+SvXPropertyControl::SvXPropertyControl( Window* pParent, WinBits nWinStyle)
+ : Control(pParent,nWinStyle)
+{
+}
+
+SvXPropertyControl::SvXPropertyControl( Window* pParent, const ResId& rResId )
+ : Control(pParent,rResId )
+{
+}
+
+//------------------------------------------------------------------
+
+SvXPropertyEdit::SvXPropertyEdit( Window* pParent, WinBits nWinStyle)
+ : SvXPropertyControl(pParent,nWinStyle),
+ aEdit(this,WB_BORDER | WB_TABSTOP)
+{
+ pListener=NULL;
+ aEdit.SetModifyHdl(
+ LINK( this, SvXPropertyEdit, ModifiedHdl ));
+ aEdit.SetGetFocusHdl(
+ LINK( this, SvXPropertyEdit, GetFocusHdl));
+ aEdit.SetLoseFocusHdl(
+ LINK( this, SvXPropertyEdit, LoseFocusHdl));
+
+ aEdit.Show();
+}
+
+SvXPropertyEdit::SvXPropertyEdit( Window* pParent, const ResId& rResId)
+ : SvXPropertyControl(pParent,rResId),
+ aEdit(this,WB_BORDER | WB_TABSTOP)
+{
+ pListener=NULL;
+ aEdit.SetModifyHdl(
+ LINK( this, SvXPropertyEdit, ModifiedHdl ));
+ aEdit.SetGetFocusHdl(
+ LINK( this, SvXPropertyEdit, GetFocusHdl));
+ aEdit.SetLoseFocusHdl(
+ LINK( this, SvXPropertyEdit, LoseFocusHdl));
+
+ Size aSize=GetSizePixel();
+ SetCtrSize(aSize);
+ aEdit.Show();
+}
+
+void SvXPropertyEdit::SetSvXPropertyCtrListener(SvXPropertyCtrListener* pCtrListener)
+{
+ pListener=pCtrListener;
+}
+
+SvXPropertyCtrListener* SvXPropertyEdit::GetSvXPropertyCtrListener()
+{
+ return pListener;
+}
+
+
+void SvXPropertyEdit::SetCtrSize(const Size& rSize)
+{
+ SetSizePixel(rSize);
+ Size aSize=GetOutputSizePixel();
+ Point aPos(0,0);
+ aEdit.SetPosPixel(aPos);
+ aEdit.SetSizePixel(aSize);
+}
+
+void SvXPropertyEdit::SetLocked(BOOL bLocked)
+{
+ if(bLocked)
+ Disable();
+ else
+ Enable();
+}
+
+void SvXPropertyEdit::SetProperty(const String &rString)
+{
+ aEdit.SetText(rString);
+}
+
+String SvXPropertyEdit::GetProperty() const
+{
+ return aEdit.GetText();
+}
+
+BOOL SvXPropertyEdit::HasList()
+{
+ return FALSE;
+};
+
+
+void SvXPropertyEdit::ClearList()
+{
+ return;
+}
+void SvXPropertyEdit::InsertEntry( const String&,USHORT )
+{
+ return;
+}
+
+void SvXPropertyEdit::SetMyName(const String &rString)
+{
+ aName=rString;
+}
+
+String SvXPropertyEdit::GetMyName()const
+{
+ return aName;
+}
+
+void SvXPropertyEdit::SetMyData(void* pDat)
+{
+ pData=pDat;
+}
+
+void* SvXPropertyEdit::GetMyData()
+{
+ return pData;
+}
+
+
+IMPL_LINK( SvXPropertyEdit, ModifiedHdl, Edit*, EMPTYARG )
+{
+ if(pListener!=NULL)
+ pListener->Modified(this);
+ return 0;
+}
+
+IMPL_LINK( SvXPropertyEdit, GetFocusHdl, Edit*, EMPTYARG )
+{
+ if(pListener!=NULL)
+ pListener->GetFocus(this);
+ return 0;
+}
+
+IMPL_LINK( SvXPropertyEdit, LoseFocusHdl, Edit*, EMPTYARG )
+{
+ if(pListener!=NULL)
+ pListener->LoseFocus(this);
+ return 0;
+}
+
+//------------------------------------------------------------------
+
+SvXPropertyListBox::SvXPropertyListBox( Window* pParent, WinBits nWinStyle)
+ : SvXPropertyControl(pParent,nWinStyle),
+ aListBox(this,WB_BORDER | WB_DROPDOWN | WB_TABSTOP)
+{
+ pListener=NULL;
+ aListBox.SetSelectHdl(
+ LINK( this, SvXPropertyListBox, ModifiedHdl ));
+ aListBox.SetGetFocusHdl(
+ LINK( this, SvXPropertyListBox, GetFocusHdl));
+ aListBox.SetLoseFocusHdl(
+ LINK( this, SvXPropertyListBox, LoseFocusHdl));
+ aListBox.Show();
+}
+
+SvXPropertyListBox::SvXPropertyListBox( Window* pParent, const ResId& rResId)
+ : SvXPropertyControl(pParent,rResId),
+ aListBox(this,WB_BORDER | WB_DROPDOWN | WB_TABSTOP)
+{
+ pListener=NULL;
+ aListBox.SetSelectHdl(
+ LINK( this, SvXPropertyListBox, ModifiedHdl ));
+ aListBox.SetGetFocusHdl(
+ LINK( this, SvXPropertyListBox, GetFocusHdl));
+ aListBox.SetLoseFocusHdl(
+ LINK( this, SvXPropertyListBox, LoseFocusHdl));
+
+ Size aSize=GetSizePixel();
+ SetCtrSize(aSize);
+ aListBox.Show();
+}
+
+void SvXPropertyListBox::SetSvXPropertyCtrListener(SvXPropertyCtrListener* pCtrListener)
+{
+ pListener=pCtrListener;
+}
+
+SvXPropertyCtrListener* SvXPropertyListBox::GetSvXPropertyCtrListener()
+{
+ return pListener;
+}
+
+
+void SvXPropertyListBox::SetCtrSize(const Size& rSize)
+{
+ SetSizePixel(rSize);
+ Size aSize=GetOutputSizePixel();
+ Point aPos(0,0);
+ aListBox.SetPosPixel(aPos);
+ aListBox.SetSizePixel(aSize);
+}
+
+void SvXPropertyListBox::SetLocked(BOOL bLocked)
+{
+ if(bLocked)
+ Disable();
+ else
+ Enable();
+}
+
+void SvXPropertyListBox::SetProperty(const String &rString)
+{
+ aListBox.SelectEntry(rString);
+}
+
+String SvXPropertyListBox::GetProperty()const
+{
+ return aListBox.GetSelectEntry();
+}
+
+BOOL SvXPropertyListBox::HasList()
+{
+ return TRUE;
+}
+
+
+void SvXPropertyListBox::ClearList()
+{
+ aListBox.Clear();
+}
+
+void SvXPropertyListBox::InsertEntry( const String& rString,USHORT nPos)
+{
+ aListBox.InsertEntry(rString,nPos);
+}
+
+void SvXPropertyListBox::SetMyName(const String &rString)
+{
+ aName=rString;
+}
+
+String SvXPropertyListBox::GetMyName()const
+{
+ return aName;
+}
+
+void SvXPropertyListBox::SetMyData(void* pDat)
+{
+ pData=pDat;
+}
+
+void* SvXPropertyListBox::GetMyData()
+{
+ return pData;
+}
+
+IMPL_LINK( SvXPropertyListBox, ModifiedHdl, ListBox*, EMPTYARG )
+{
+ if(pListener!=NULL)
+ pListener->Modified(this);
+ return 0;
+}
+
+IMPL_LINK( SvXPropertyListBox, GetFocusHdl, ListBox*, EMPTYARG )
+{
+ if(pListener!=NULL)
+ pListener->GetFocus(this);
+ return 0;
+}
+
+IMPL_LINK( SvXPropertyListBox, LoseFocusHdl, ListBox*, EMPTYARG )
+{
+ if(pListener!=NULL)
+ pListener->LoseFocus(this);
+ return 0;
+}
+
+//------------------------------------------------------------------
+
+
+SvXPropertyComboBox::SvXPropertyComboBox( Window* pParent, WinBits nWinStyle)
+ : SvXPropertyControl(pParent,nWinStyle),
+ aComboBox(this,WB_BORDER | WB_DROPDOWN | WB_TABSTOP)
+{
+ pListener=NULL;
+ aComboBox.SetModifyHdl(
+ LINK( this, SvXPropertyComboBox, ModifiedHdl ));
+ aComboBox.SetGetFocusHdl(
+ LINK( this, SvXPropertyComboBox, GetFocusHdl));
+ aComboBox.SetLoseFocusHdl(
+ LINK( this, SvXPropertyComboBox, LoseFocusHdl));
+ aComboBox.Show();
+}
+
+SvXPropertyComboBox::SvXPropertyComboBox( Window* pParent, const ResId& rResId)
+ : SvXPropertyControl(pParent,rResId),
+ aComboBox(this,WB_BORDER | WB_DROPDOWN | WB_TABSTOP)
+{
+ pListener=NULL;
+ aComboBox.SetModifyHdl(
+ LINK( this, SvXPropertyComboBox, ModifiedHdl ));
+ aComboBox.SetGetFocusHdl(
+ LINK( this, SvXPropertyComboBox, GetFocusHdl));
+ aComboBox.SetLoseFocusHdl(
+ LINK( this, SvXPropertyComboBox, LoseFocusHdl));
+
+ Size aSize=GetSizePixel();
+ SetCtrSize(aSize);
+ aComboBox.Show();
+}
+
+void SvXPropertyComboBox::SetLocked(BOOL bLocked)
+{
+ if(bLocked)
+ Disable();
+ else
+ Enable();
+}
+
+void SvXPropertyComboBox::SetSvXPropertyCtrListener(SvXPropertyCtrListener* pCtrListener)
+{
+ pListener=pCtrListener;
+}
+
+SvXPropertyCtrListener* SvXPropertyComboBox::GetSvXPropertyCtrListener()
+{
+ return pListener;
+}
+
+
+void SvXPropertyComboBox::SetCtrSize(const Size& rSize)
+{
+ SetSizePixel(rSize);
+ Size aSize=GetOutputSizePixel();
+ Point aPos(0,0);
+ aComboBox.SetPosPixel(aPos);
+ aComboBox.SetSizePixel(aSize);
+}
+
+
+void SvXPropertyComboBox::SetProperty(const String &rString)
+{
+ aComboBox.SetText(rString);
+}
+
+String SvXPropertyComboBox::GetProperty() const
+{
+ return aComboBox.GetText();
+}
+
+BOOL SvXPropertyComboBox::HasList()
+{
+ return TRUE;
+}
+
+void SvXPropertyComboBox::ClearList()
+{
+ aComboBox.Clear();
+}
+
+void SvXPropertyComboBox::InsertEntry( const String& rString,USHORT nPos)
+{
+ aComboBox.InsertEntry(rString,nPos);
+}
+
+void SvXPropertyComboBox::SetMyName(const String &rString)
+{
+ aName=rString;
+}
+
+String SvXPropertyComboBox::GetMyName()const
+{
+ return aName;
+}
+
+void SvXPropertyComboBox::SetMyData(void* pDat)
+{
+ pData=pDat;
+}
+
+void* SvXPropertyComboBox::GetMyData()
+{
+ return pData;
+}
+
+IMPL_LINK( SvXPropertyComboBox, ModifiedHdl, ComboBox*, EMPTYARG )
+{
+ if(pListener!=NULL)
+ pListener->Modified(this);
+ return 0;
+}
+
+IMPL_LINK( SvXPropertyComboBox, GetFocusHdl, ComboBox*, EMPTYARG )
+{
+ if(pListener!=NULL)
+ pListener->GetFocus(this);
+ return 0;
+}
+
+IMPL_LINK( SvXPropertyComboBox, LoseFocusHdl, ComboBox*, EMPTYARG )
+{
+ if(pListener!=NULL)
+ pListener->LoseFocus(this);
+ return 0;
+}
+//------------------------------------------------------------------
+
+SvPropertyLine::SvPropertyLine( Window* pParent,WinBits nWinStyle)
+ : Control(pParent,nWinStyle),
+ aName(this,WB_BORDER),
+ pSvXPropertyControl(NULL),
+ aXButton(this,WB_BORDER),
+ bIsLocked(FALSE),
+ bIsHyperlink(FALSE)
+{
+ bNeedsRepaint = TRUE;
+ bHasXButton = FALSE;
+ aXButton.SetText( XubString( RTL_CONSTASCII_USTRINGPARAM( "..." ) ) );
+ aName.Show();
+ aXButton.Show();
+ eKindOfCtr = KOC_UNDEFINED;
+ Wallpaper aWall = GetBackground();
+ aWall.SetColor( Color( COL_TRANSPARENT ) );
+ SetBackground( aWall );
+}
+
+SvPropertyLine::SvPropertyLine( Window* pParent,const ResId& rResId )
+ : Control(pParent,rResId),
+ aName (this,WB_BORDER),
+ pSvXPropertyControl(NULL),
+ aXButton (this,WB_BORDER),
+ bIsLocked(FALSE),
+ bIsHyperlink(FALSE)
+{
+ bNeedsRepaint = TRUE;
+ bHasXButton = FALSE;
+ eKindOfCtr = KOC_UNDEFINED;
+ aXButton.SetText( XubString( RTL_CONSTASCII_USTRINGPARAM( "..." ) ) );
+ aName.Show();
+ aXButton.Show();
+ Wallpaper aWall = GetBackground();
+ aWall.SetColor( Color( COL_TRANSPARENT ) );
+ SetBackground( aWall );
+ Resize();
+}
+
+void SvPropertyLine::SetSvXPropertyControl(SvXPropertyControl* pXControl)
+{
+ pSvXPropertyControl=pXControl;
+ pSvXPropertyControl->Show();
+ Resize();
+}
+
+SvXPropertyControl* SvPropertyLine::GetSvXPropertyControl()
+{
+ return pSvXPropertyControl;
+}
+
+void SvPropertyLine::Resize()
+{
+ Size aSize=GetOutputSizePixel();
+ Size a2Size=aSize;
+
+ aSize.Width()=nNameWidth;
+ a2Size.Width()-=nNameWidth;
+
+ Point aPos(0,0);
+ aName.SetPosPixel(aPos);
+ aName.SetSizePixel(aSize);
+
+ USHORT nXButtonWidth=0;
+
+ if(bHasXButton)
+ {
+ nXButtonWidth=(USHORT)aSize.Height();
+ }
+ a2Size.Width()=a2Size.Width()-nXButtonWidth;
+
+ aPos.X()+=aSize.Width();
+
+ if(pSvXPropertyControl!=NULL)
+ {
+ pSvXPropertyControl->SetPosPixel(aPos);
+ pSvXPropertyControl->SetCtrSize(a2Size);
+ }
+
+ if(bHasXButton)
+ {
+ aPos.X()=GetOutputSizePixel().Width()
+ -nXButtonWidth;
+ aSize.Width()=nXButtonWidth;
+ aXButton .SetSizePixel(aSize);
+ aXButton .SetPosPixel(aPos);
+ }
+}
+
+void SvPropertyLine::SetNeedsRepaint(BOOL bFlag)
+{
+ bNeedsRepaint=bFlag;
+}
+
+BOOL SvPropertyLine::NeedsRepaint()
+{
+ return bNeedsRepaint;
+}
+
+void SvPropertyLine::SetName(const String& rString )
+{
+ aName.SetText(rString);
+ aName.Invalidate();
+}
+
+String SvPropertyLine::GetName() const
+{
+ return aName.GetText();
+}
+
+void SvPropertyLine::SetKindOfControl(eKindOfControl eKOC)
+{
+ eKindOfCtr=eKOC;
+}
+
+eKindOfControl SvPropertyLine::GetKindOfControl()
+{
+ return eKindOfCtr;
+}
+
+void SvPropertyLine::ShowXButton()
+{
+ bHasXButton=TRUE;
+ aXButton.Show();
+ Resize();
+}
+void SvPropertyLine::HideXButton()
+{
+ bHasXButton=FALSE;
+ aXButton.Hide();
+ Resize();
+}
+BOOL SvPropertyLine::IsVisibleXButton()
+{
+ return bHasXButton;
+}
+
+void SvPropertyLine::ShowAsHyperLink(BOOL nFlag)
+{
+ bIsHyperlink=nFlag;
+ if(nFlag)
+ {
+ Font aFont=GetFont();
+ aFont.SetUnderline(UNDERLINE_SINGLE);
+ aFont.SetColor(Color(COL_BLUE));
+ aName.SetFont(aFont);
+ }
+ else
+ {
+ Font aFont=GetFont();
+ aName.SetFont(aFont);
+ }
+}
+
+BOOL SvPropertyLine::IsShownAsHyperlink()
+{
+ return bIsHyperlink;
+}
+
+void SvPropertyLine::Locked(BOOL nFlag)
+{
+ bIsLocked=nFlag;
+ if(pSvXPropertyControl!=NULL)
+ pSvXPropertyControl->SetLocked(nFlag);
+}
+
+BOOL SvPropertyLine::IsLineLocked()
+{
+ return bIsLocked;
+}
+
+void SvPropertyLine::SetNameWidth(USHORT nWidth)
+{
+ nNameWidth=nWidth;
+ Resize();
+}
+
+void SvPropertyLine::SetClickHdl(const Link& rLink)
+{
+ aXButton.SetClickHdl(rLink );
+}
+
+//----------------------------------------------------------
+
+SvXPropEvListener::SvXPropEvListener()
+{
+ pTheActiveControl=NULL;
+}
+
+SvXPropEvListener::~SvXPropEvListener()
+{
+}
+
+void SvXPropEvListener::Modified (SvXPropertyControl *pSvXPCtr)
+{
+ pTheActiveControl=pSvXPCtr;
+ aModifyLink.Call(this);
+}
+
+void SvXPropEvListener::GetFocus (SvXPropertyControl *pSvXPCtr)
+{
+ pTheActiveControl=pSvXPCtr;
+ aGetFocusLink.Call(this);
+}
+
+void SvXPropEvListener::LoseFocus (SvXPropertyControl *pSvXPCtr)
+{
+ pTheActiveControl=pSvXPCtr;
+ aLoseFocusLink.Call(this);
+}
+
+void SvXPropEvListener::KeyInput (SvXPropertyControl *pSvXPCtr,const KeyCode& theKeyCode)
+{
+ pTheActiveControl=pSvXPCtr;
+ aKeyCode=theKeyCode;
+ aKeyInputLink.Call(this);
+}
+
+SvXPropertyControl * SvXPropEvListener::GetPropertyControl()
+{
+ return pTheActiveControl;
+}
+
+KeyCode SvXPropEvListener::GetKeyCode() const
+{
+ return aKeyCode;
+}
+
+//------------------------------------------------------------------
+
+SvListBoxForProperties::SvListBoxForProperties( Window* pParent, WinBits nWinStyle)
+ : Control(pParent,nWinStyle),
+ aPlayGround(this,WB_DIALOGCONTROL),
+ aVScroll(this,WB_VSCROLL|WB_REPEAT|WB_DRAG),
+ pPropDataControl(NULL)
+{
+
+ aListener.SetModifyHdl (LINK( this, SvListBoxForProperties, ModifyHdl));
+ aListener.SetGetFocusHdl (LINK( this, SvListBoxForProperties, GetFocusHdl));
+ aListener.SetLoseFocusHdl(LINK( this, SvListBoxForProperties,LoseFocusHdl));
+ aListener.SetKeyInputHdl (LINK( this, SvListBoxForProperties, KeyInputHdl));
+
+ nYOffset=0;
+ nTheNameSize=0;
+ ListBox aListBox(this,WB_DROPDOWN);
+ aListBox.SetPosSizePixel(Point(0,0),Size(100,100));
+ nRowHeight=(USHORT)aListBox.GetSizePixel().Height();
+ Wallpaper aWall = aPlayGround.GetBackground();
+ aWall.SetColor( Color( COL_TRANSPARENT ) );
+ aPlayGround.SetBackground( aWall );
+ aPlayGround.Show();
+ aVScroll.Hide();
+ aVScroll.SetScrollHdl(
+ LINK( this, SvListBoxForProperties, ScrollHdl ));
+
+}
+
+
+SvListBoxForProperties::SvListBoxForProperties( Window* pParent, const ResId& rResId )
+ : Control(pParent,rResId),
+ aPlayGround(this,0),
+ aVScroll(this,WB_VSCROLL|WB_REPEAT|WB_DRAG),
+ pPropDataControl(NULL)
+{
+ nTheNameSize=0;
+ nYOffset=0;
+ ListBox aListBox(this,WB_DROPDOWN);
+ aListBox.SetPosSizePixel(Point(0,0),Size(100,100));
+ nRowHeight=(USHORT)aListBox.GetSizePixel().Height();
+ Wallpaper aWall = aPlayGround.GetBackground();
+ aWall.SetColor( Color( COL_TRANSPARENT ) );
+ aPlayGround.SetBackground( aWall );
+ aPlayGround.Show();
+ aVScroll.Hide();
+ aVScroll.SetScrollHdl( LINK( this, SvListBoxForProperties, ScrollHdl ) );
+ UpdateVScroll();
+ Resize();
+}
+
+SvListBoxForProperties::~SvListBoxForProperties()
+{
+ Clear();
+}
+
+void SvListBoxForProperties::Clear()
+{
+ for(USHORT i=0;i<PLineArray.Count();i++)
+ {
+ SvPropertyLine* pPropLine=PLineArray[i];
+
+ switch(pPropLine->GetKindOfControl())
+ {
+ case KOC_LISTBOX:
+ case KOC_COMBOBOX:
+ case KOC_EDIT: delete pPropLine->GetSvXPropertyControl();
+ break;
+ default:
+ break;
+ }
+ delete pPropLine;
+ }
+ PLineArray.Remove(0,PLineArray.Count());
+}
+
+
+void SvListBoxForProperties::Resize()
+{
+ Size aSize=GetOutputSizePixel();
+ Size a2Size=aSize;
+ Size aVScrollSize;
+
+ if(aVScroll.IsVisible())
+ {
+ Point aPos(0,0);
+ aVScrollSize=aVScroll.GetSizePixel();
+ aVScrollSize.Height()=aSize.Height();
+ a2Size.Width()-=aVScrollSize.Width();
+ aPos.X()=a2Size.Width();
+ aVScroll.SetPosPixel(aPos);
+ aVScroll.SetSizePixel(aVScrollSize);
+ }
+
+ aPlayGround.SetPosPixel(Point(0,0));
+ aPlayGround.SetSizePixel(a2Size);
+ UpdatePosNSize();
+}
+
+void SvListBoxForProperties::SetController( SvPropertyDataControl *pPDC)
+{
+ pPropDataControl=pPDC;
+}
+
+USHORT SvListBoxForProperties::CalcVisibleLines()
+{
+ Size aSize=aPlayGround.GetOutputSizePixel();
+ USHORT nResult=0;
+ if(nRowHeight!=0)
+ nResult=(USHORT) aSize.Height()/nRowHeight;
+
+ return nResult;
+}
+
+void SvListBoxForProperties::UpdateVScroll()
+{
+ USHORT nLines=CalcVisibleLines();
+ aVScroll.SetPageSize(nLines-1);
+ aVScroll.SetVisibleSize(nLines-1);
+ aVScroll.SetRange(Range(0,PLineArray.Count()-1));
+ if(PLineArray.Count()<=nLines)
+ {
+ aVScroll.Hide();
+ }
+ else
+ {
+ BOOL bFlag=aVScroll.IsVisible();
+ aVScroll.Show();
+ if(!bFlag)Resize();
+ }
+
+
+}
+
+void SvListBoxForProperties::UpdatePosNSize()
+{
+ Point aPos(0,nYOffset);
+
+ for(USHORT i=0; i<PLineArray.Count();i++)
+ {
+ if((PLineArray[i])->NeedsRepaint())
+ {
+ (PLineArray[i])->SetPosPixel(aPos);
+ Size aSize=aPlayGround.GetOutputSizePixel();
+ aSize.Height()=nRowHeight;
+ (PLineArray[i])->SetSizePixel(aSize);
+ (PLineArray[i])->SetNameWidth(nTheNameSize+2*FRAME_OFFSET);
+ (PLineArray[i])->Invalidate();
+ (PLineArray[i])->Update();
+ (PLineArray[i])->Show();
+ (PLineArray[i])->SetNeedsRepaint(FALSE);
+ }
+ else
+ {
+ if((PLineArray[i])->IsVisible())
+ {
+ Size aSize=aPlayGround.GetOutputSizePixel();
+ aSize.Height()=nRowHeight;
+ (PLineArray[i])->SetSizePixel(aSize);
+ (PLineArray[i])->SetNameWidth(nTheNameSize+2*FRAME_OFFSET);
+ (PLineArray[i])->Invalidate();
+ }
+ }
+
+ aPos.Y()+=nRowHeight;
+ }
+ aPlayGround.Invalidate();
+ aPlayGround.Update();
+}
+
+void SvListBoxForProperties::UpdatePlayGround()
+{
+ Point aPos(0,0);
+ long nThumbPos=aVScroll.GetThumbPos();
+ long nLines=aVScroll.GetPageSize();
+ long nDelta=aVScroll.GetDelta();
+
+ USHORT nStart,nEnd;
+ Size aSize=aPlayGround.GetOutputSizePixel();
+ Point aPEnd;
+ aPEnd.X()=aSize.Width();
+
+ if(nDelta>0)
+ {
+ nStart=(USHORT)(nThumbPos+nLines+1-nDelta);
+ nEnd=(USHORT)(nThumbPos+nLines);
+ aPos.Y()=(nLines+1-nDelta)*nRowHeight;
+ }
+ else
+ {
+ nStart=(USHORT)nThumbPos;
+ nEnd=(USHORT)(nThumbPos-nDelta);
+ aPEnd.Y()=(nThumbPos-nDelta)*nRowHeight;;
+ }
+
+ aSize.Height()=nRowHeight;
+
+ nDelta=-nDelta*nRowHeight;
+
+ aPlayGround.Scroll(0,nDelta,SCROLL_CHILDREN);
+
+ for(USHORT i=nStart; i<=nEnd;i++)
+ {
+ (PLineArray[i])->SetPosSizePixel(aPos,aSize);
+ (PLineArray[i])->SetNameWidth(nTheNameSize+2*FRAME_OFFSET);
+ (PLineArray[i])->Show();
+ aPos.Y()+=nRowHeight;
+ }
+ aPlayGround.Update();
+}
+
+void SvListBoxForProperties::UpdateAll()
+{
+ UpdatePosNSize();
+ UpdatePlayGround();
+ //UpdateVScroll();
+}
+
+void SvListBoxForProperties::DisableUpdate()
+{
+ bUpdate=FALSE;
+}
+
+void SvListBoxForProperties::EnableUpdate()
+{
+ bUpdate=TRUE;
+ UpdateAll();
+}
+
+void SvListBoxForProperties::SetPropertyValue( const String & rEntryName, const String & rValue )
+{
+ USHORT i, iEnd = PLineArray.Count();
+ for( i = 0 ; i < iEnd ; i++ )
+ {
+ SvPropertyLine* pPropLine = PLineArray[ i ];
+ SvXPropertyControl* pSvXPCtr=pPropLine->GetSvXPropertyControl();
+ if( pSvXPCtr && pSvXPCtr->GetMyName() == rEntryName )
+ {
+ pSvXPCtr->SetProperty( rValue );
+ }
+ }
+}
+
+USHORT SvListBoxForProperties::AppendEntry( const SvPropertyData& aPropData)
+{
+ return InsertEntry(aPropData);
+}
+
+USHORT SvListBoxForProperties::InsertEntry( const SvPropertyData& aPropData, USHORT nPos)
+{
+ USHORT nInsPos=nPos;
+ SvPropertyLine* pPropLine=new SvPropertyLine(&aPlayGround,WB_TABSTOP | WB_DIALOGCONTROL);
+
+ if(nPos==LISTBOX_APPEND)
+ {
+ nInsPos=PLineArray.Count();
+ PLineArray.Insert(pPropLine,nInsPos);
+ }
+ else
+ {
+ PLineArray.Insert(pPropLine,nPos);
+ }
+ pPropLine->SetNameWidth(nTheNameSize);
+ UpdateVScroll();
+ UpdatePosNSize();
+ ChangeEntry(aPropData,nInsPos);
+ return nInsPos;
+}
+
+void SvListBoxForProperties::ChangeEntry( const SvPropertyData& aPropData, USHORT nPos)
+{
+ if(nPos<PLineArray.Count())
+ {
+ SvPropertyLine* pPropLine=PLineArray[nPos];
+
+ switch(pPropLine->GetKindOfControl())
+ {
+ case KOC_LISTBOX:
+ case KOC_COMBOBOX:
+ case KOC_EDIT: delete pPropLine->GetSvXPropertyControl();
+ break;
+ default:
+ break;
+ }
+
+ switch(aPropData.eKind)
+ {
+ case KOC_LISTBOX:
+ pPropLine->SetSvXPropertyControl(
+ new SvXPropertyComboBox(pPropLine,WB_TABSTOP));
+ pPropLine->SetKindOfControl(aPropData.eKind);
+ break;
+ case KOC_COMBOBOX:
+ pPropLine->SetSvXPropertyControl(
+ new SvXPropertyComboBox(pPropLine,WB_TABSTOP));
+ pPropLine->SetKindOfControl(aPropData.eKind);
+ break;
+ case KOC_EDIT:
+ pPropLine->SetSvXPropertyControl(
+ new SvXPropertyEdit(pPropLine,WB_TABSTOP));
+ pPropLine->SetKindOfControl(aPropData.eKind);
+ break;
+ case KOC_USERDEFINED:
+ pPropLine->SetSvXPropertyControl(aPropData.pControl);
+ aPropData.pControl->SetParent(pPropLine);
+ pPropLine->SetKindOfControl(aPropData.eKind);
+ break;
+ default:
+ pPropLine->SetSvXPropertyControl(NULL);
+ pPropLine->SetKindOfControl(KOC_UNDEFINED);
+ break;
+ }
+
+ SvXPropertyControl* pSvXPCtr=pPropLine->GetSvXPropertyControl();
+
+ if(pSvXPCtr!=NULL)
+ {
+ pSvXPCtr->SetSvXPropertyCtrListener(&aListener);
+ pSvXPCtr->SetProperty(aPropData.aValue);
+ pSvXPCtr->SetMyData(aPropData.pDataPtr);
+ pSvXPCtr->SetMyName(aPropData.aName);
+
+ if(pSvXPCtr->HasList())
+ {
+ for(USHORT i=0;i<aPropData.theValues.Count();i++)
+ {
+ pSvXPCtr->InsertEntry(*(aPropData.theValues[i]));
+ }
+ }
+ }
+
+ pPropLine->SetName(aPropData.aName);
+
+ USHORT nTextWidth=(USHORT)aPlayGround.GetTextWidth(aPropData.aName);
+
+ if ( nTheNameSize < nTextWidth )
+ nTheNameSize = nTextWidth;
+
+ if ( aPropData.bHasVisibleXButton )
+ {
+ pPropLine->SetClickHdl(LINK( this, SvListBoxForProperties, ClickHdl ) );
+ pPropLine->ShowXButton();
+ }
+ else
+ pPropLine->HideXButton();
+
+ pPropLine->Locked(aPropData.bIsLocked);
+
+ pPropLine->ShowAsHyperLink(aPropData.bIsHyperLink);
+ pPropLine->SetData(aPropData.pDataPtr);
+ }
+}
+
+USHORT SvListBoxForProperties::GetFirstVisibleEntry()
+{
+ return 0;
+}
+void SvListBoxForProperties::SetFirstVisibleEntry(USHORT)
+{
+ return;
+}
+
+void SvListBoxForProperties::SetSelectedEntry(USHORT)
+{
+ return;
+}
+
+USHORT SvListBoxForProperties::GetSelectedEntry()
+{
+ return 0;
+}
+
+IMPL_LINK( SvListBoxForProperties, ScrollHdl, ScrollBar*, pSB )
+{
+ if(pSB!=NULL)
+ {
+ long nDelta=aVScroll.GetDelta();
+ nYOffset=-aVScroll.GetThumbPos()*nRowHeight;
+ //aPlayGround.SetUpdateMode(FALSE);
+
+ long nThumbPos=aVScroll.GetThumbPos();
+ long nLines=aVScroll.GetPageSize();
+
+ UpdatePlayGround();
+
+ for(long i=nThumbPos-nDelta; i<nThumbPos+nLines-nDelta;i++)
+ {
+ if(i>=nThumbPos && i<=nThumbPos+nLines)
+ {
+ (PLineArray[sal::static_int_cast< USHORT >(i)])->
+ SetNeedsRepaint(TRUE);
+ }
+ else
+ {
+ (PLineArray[sal::static_int_cast< USHORT >(i)])->Hide();
+ (PLineArray[sal::static_int_cast< USHORT >(i)])->
+ SetNeedsRepaint(FALSE);
+ }
+ }
+ }
+ return 0;
+}
+
+IMPL_LINK( SvListBoxForProperties, ClickHdl, PushButton*,pPB)
+{
+ if(pPB!=NULL)
+ {
+ SvPropertyLine *pPropLine=(SvPropertyLine *)pPB->GetParent();
+ SvXPropertyControl* pSvXPCtr=pPropLine->GetSvXPropertyControl();
+ pPropDataControl->Clicked(pSvXPCtr->GetMyName(),
+ pSvXPCtr->GetProperty(),pSvXPCtr->GetMyData());
+ }
+ return 0;
+}
+
+IMPL_LINK( SvListBoxForProperties, ModifyHdl,SvXPropEvListener*, pSvXPEvL)
+{
+ if(pSvXPEvL!=NULL && pPropDataControl!=NULL)
+ {
+
+ SvXPropertyControl* pSvXPCtr=aListener.GetPropertyControl();
+
+ pPropDataControl->Modified(pSvXPCtr->GetMyName(),
+ pSvXPCtr->GetProperty(),pSvXPCtr->GetMyData());
+
+ }
+ return 0;
+}
+
+IMPL_LINK( SvListBoxForProperties, GetFocusHdl,SvXPropEvListener*, pSvXPEvL)
+{
+ if(pSvXPEvL!=NULL && pPropDataControl!=NULL)
+ {
+ SvXPropertyControl* pSvXPCtr=aListener.GetPropertyControl();
+
+ pPropDataControl->Select(pSvXPCtr->GetMyName(),pSvXPCtr->GetMyData());
+ }
+ return 0;
+}
+
+IMPL_LINK( SvListBoxForProperties, LoseFocusHdl,SvXPropEvListener*, pSvXPEvL)
+{
+ if(pSvXPEvL!=NULL && pPropDataControl!=NULL)
+ {
+ SvXPropertyControl* pSvXPCtr=aListener.GetPropertyControl();
+
+ pPropDataControl->Commit(pSvXPCtr->GetMyName(),
+ pSvXPCtr->GetProperty(),pSvXPCtr->GetMyData());
+ /*
+ {
+ pSvXPCtr->SetProperty(
+ pPropDataControl->GetTheCorrectProperty());
+ }
+ */
+ }
+ return 0;
+}
+
+IMPL_LINK( SvListBoxForProperties, KeyInputHdl,SvXPropEvListener*, pSvXPEvL)
+{
+ // FIXME - This code does not make a lot of sense.
+ if(pSvXPEvL!=NULL && pPropDataControl!=NULL)
+ {
+ /*SvXPropertyControl* pSvXPCtr=*/aListener.GetPropertyControl();
+ }
+ return 0;
+}
+
+
+
+
+SvTabPageForProperties::SvTabPageForProperties(Window* pParent,WinBits nWinStyle)
+ : TabPage(pParent,nWinStyle),
+ aLbProp(this)
+{
+ aLbProp.Show();
+}
+
+void SvTabPageForProperties::Resize()
+{
+ Point aPos(3,3);
+ Size aSize=GetOutputSizePixel();
+ aSize.Width()-=6;
+ aSize.Height()-=6;
+
+ aLbProp.SetPosSizePixel(aPos,aSize);
+}
+
+SvListBoxForProperties* SvTabPageForProperties::GetTheListBox()
+{
+ return &aLbProp;
+}
+
+
+SvPropertyBox::SvPropertyBox( Window* pParent, WinBits nWinStyle)
+ : Control(pParent,nWinStyle),
+ aTabControl(this)
+{
+ aTabControl.Show();
+}
+
+SvPropertyBox::SvPropertyBox( Window* pParent, const ResId& rResId )
+ : Control(pParent,rResId),
+ aTabControl(this)
+{
+ aTabControl.Show();
+ Resize();
+}
+
+SvPropertyBox::~SvPropertyBox()
+{
+ ClearAll();
+}
+
+
+void SvPropertyBox::ClearAll()
+{
+ USHORT nCount=aTabControl.GetPageCount();
+
+ for(USHORT i=nCount;i>=1;i--)
+ {
+ SvTabPageForProperties* pPage=(SvTabPageForProperties*)
+ aTabControl.GetTabPage(i);
+ aTabControl.RemovePage(i);
+ delete pPage;
+ }
+}
+
+
+void SvPropertyBox::Resize()
+{
+ Point aPos(3,3);
+ Size aSize=GetOutputSizePixel();
+ aSize.Width()-=6;
+ aSize.Height()-=6;
+
+ aTabControl.SetPosSizePixel(aPos,aSize);
+
+ USHORT nCount=aTabControl.GetPageCount();
+
+ aSize=aTabControl.GetTabPageSizePixel();
+ for(USHORT i=1;i<=nCount;i++)
+ {
+ SvTabPageForProperties* pPage=(SvTabPageForProperties*)
+ aTabControl.GetTabPage(i);
+ pPage->SetSizePixel(aSize);
+ }
+
+}
+
+
+USHORT SvPropertyBox::AppendPage( const String & rText )
+{
+ USHORT nId=aTabControl.GetPageCount()+1;
+ aTabControl.InsertPage( nId,rText);
+ SvTabPageForProperties* pPage=new SvTabPageForProperties(&aTabControl);
+ pPage->SetSizePixel(aTabControl.GetTabPageSizePixel());
+ pPage->GetTheListBox()->SetController(pThePropDataCtr);
+ aTabControl.SetTabPage( nId, pPage);
+ aTabControl.SetCurPageId(nId);
+ return nId;
+}
+
+void SvPropertyBox::SetPage( USHORT nId)
+{
+ aTabControl.SetCurPageId(nId);
+}
+
+USHORT SvPropertyBox::GetCurPage()
+{
+ return aTabControl.GetCurPageId();
+}
+
+USHORT SvPropertyBox::CalcVisibleLines()
+{
+ SvTabPageForProperties* pPage=(SvTabPageForProperties*)
+ aTabControl.GetTabPage(aTabControl.GetCurPageId());
+ return pPage->GetTheListBox()->CalcVisibleLines();
+}
+void SvPropertyBox::EnableUpdate()
+{
+ SvTabPageForProperties* pPage=(SvTabPageForProperties*)
+ aTabControl.GetTabPage(aTabControl.GetCurPageId());
+ pPage->GetTheListBox()->EnableUpdate();
+}
+
+void SvPropertyBox::DisableUpdate()
+{
+ SvTabPageForProperties* pPage=(SvTabPageForProperties*)
+ aTabControl.GetTabPage(aTabControl.GetCurPageId());
+ pPage->GetTheListBox()->DisableUpdate();
+}
+
+void SvPropertyBox::SetController(SvPropertyDataControl *pDataCtr)
+{
+ pThePropDataCtr=pDataCtr;
+ USHORT nCount=aTabControl.GetPageCount();
+
+ for(USHORT i=1;i<=nCount;i++)
+ {
+ SvTabPageForProperties* pPage=(SvTabPageForProperties*)
+ aTabControl.GetTabPage(i);
+
+ pPage->GetTheListBox()->SetController(pThePropDataCtr);
+ }
+
+}
+
+USHORT SvPropertyBox::InsertEntry( const SvPropertyData& rData, USHORT nPos)
+{
+ SvTabPageForProperties* pPage=(SvTabPageForProperties*)
+ aTabControl.GetTabPage(aTabControl.GetCurPageId());
+ return pPage->GetTheListBox()->InsertEntry(rData,nPos);
+}
+
+void SvPropertyBox::ChangeEntry( const SvPropertyData& rData, USHORT nPos)
+{
+ SvTabPageForProperties* pPage=(SvTabPageForProperties*)
+ aTabControl.GetTabPage(aTabControl.GetCurPageId());
+ pPage->GetTheListBox()->ChangeEntry(rData,nPos);
+}
+
+USHORT SvPropertyBox::AppendEntry( const SvPropertyData& rData)
+{
+ SvTabPageForProperties* pPage=(SvTabPageForProperties*)
+ aTabControl.GetTabPage(aTabControl.GetCurPageId());
+ return pPage->GetTheListBox()->AppendEntry(rData);
+}
+
+void SvPropertyBox::SetPropertyValue( const String & rEntryName, const String & rValue )
+{
+ SvTabPageForProperties* pPage=(SvTabPageForProperties*)
+ aTabControl.GetTabPage(aTabControl.GetCurPageId());
+ pPage->GetTheListBox()->SetPropertyValue( rEntryName, rValue );
+}
+
+void SvPropertyBox::SetFirstVisibleEntry(USHORT nPos)
+{
+ SvTabPageForProperties* pPage=(SvTabPageForProperties*)
+ aTabControl.GetTabPage(aTabControl.GetCurPageId());
+ pPage->GetTheListBox()->SetFirstVisibleEntry(nPos);
+}
+USHORT SvPropertyBox::GetFirstVisibleEntry()
+{
+ SvTabPageForProperties* pPage=(SvTabPageForProperties*)
+ aTabControl.GetTabPage(aTabControl.GetCurPageId());
+ return pPage->GetTheListBox()->GetFirstVisibleEntry();
+}
+
+void SvPropertyBox::SetSelectedEntry(USHORT nPos)
+{
+ SvTabPageForProperties* pPage=(SvTabPageForProperties*)
+ aTabControl.GetTabPage(aTabControl.GetCurPageId());
+ pPage->GetTheListBox()->SetSelectedEntry(nPos);
+}
+USHORT SvPropertyBox::GetSelectedEntry()
+{
+ SvTabPageForProperties* pPage=(SvTabPageForProperties*)
+ aTabControl.GetTabPage(aTabControl.GetCurPageId());
+ return pPage->GetTheListBox()->GetSelectedEntry();
+}
+
+void SvPropertyBox::ClearTable()
+{
+ SvTabPageForProperties* pPage=(SvTabPageForProperties*)
+ aTabControl.GetTabPage(aTabControl.GetCurPageId());
+ pPage->GetTheListBox()->Clear();
+}
+
+SvBasicPropertyDataControl::~SvBasicPropertyDataControl()
+{
+}
+
+void SvBasicPropertyDataControl::Modified(const String& aName,
+ const String& aVal,void* pData)
+{
+ aEntryName=aName;
+ aEntryProperty=aVal;
+ pTheData=pData;
+ aModifyLink.Call(this);
+}
+
+void SvBasicPropertyDataControl::Clicked( const String& aName,
+ const String& aVal,
+ void* pData) //Xtension-Button pressed
+{
+ aEntryName=aName;
+ aEntryProperty=aVal;
+ pTheData=pData;
+ aClickedLink.Call(this);
+}
+
+void SvBasicPropertyDataControl::Commit( const String& aName,
+ const String& aVal,
+ void* pData) //User accept changes
+{
+ aEntryName=aName;
+ aEntryProperty=aVal;
+ pTheData=pData;
+ aCommitLink.Call(this);
+}
+
+void SvBasicPropertyDataControl::Select( const String& aName,
+ void* pData) //User select new Row
+{
+ aEntryName=aName;
+ pTheData=pData;
+ aSelectLink.Call(this);
+}
+
+void SvBasicPropertyDataControl::LinkClicked(const String&, void*)
+{
+}
+
+
+String SvBasicPropertyDataControl::GetName() const //Tell's the name of the Property
+{
+ return aEntryName;
+}
+
+String SvBasicPropertyDataControl::GetProperty() const //Tell's the content of the Property
+{
+ return aEntryProperty;
+}
+
+void* SvBasicPropertyDataControl::GetData() //Tell's the storage
+{
+ return pTheData;
+}
+
+/*
+String SvBasicPropertyDataControl::GetTheCorrectProperty() const
+{
+ return aCorrectProperty;
+}
+*/
+
+void SvBasicPropertyDataControl::SetTheCorrectProperty(const String& aString)
+{
+ aCorrectProperty=aString;
+}
+
+void SvBasicPropertyDataControl::SetIsCorrect(BOOL nFlag)
+{
+ bCorrectness=nFlag;
+}
+
+
+
+//========================================================================
+// Property-Dialog:
+/* zum TESTEN im CALC*/
+//========================================================================
+/*
+ScPropertyDlg::ScPropertyDlg( Window* pParent) :
+ ModalDialog ( pParent, ScResId( RID_SCDLG_PROPERTIES) ),
+ aPropListBox ( this, ResId( CTR_PROPLINE) ),
+ aKindOfListBox (this,ResId( LB_KIND_OF_PROP)),
+ aModAnswer (this,ResId(FT_ANSMOD )),
+ aClickAnswer (this,ResId(FT_ANSCLICK )),
+ aCommitAnswer (this,ResId(FT_ANSCOMMIT)),
+ aSelectAnswer (this,ResId(FT_ANSSELECT)),
+ anOk(this,ResId( BTN_OK)),
+ aCancel(this,ResId( BTN_CANCEL))
+{
+ FreeResource();
+
+ aKindOfListBox.SelectEntryPos(0);
+ aKindOfListBox.SetSelectHdl(
+ LINK( this, ScPropertyDlg, ModifiedHdl ));
+ nCount=0;
+ nClickCount=0;
+
+ String aString("Don't know ");
+
+ aBaProDatCtr.SetModifyHdl (LINK( this, ScPropertyDlg, RowModifiedHdl ));
+ aBaProDatCtr.SetClickedHdl(LINK( this, ScPropertyDlg, ClickHdl ));
+ aBaProDatCtr.SetCommitHdl (LINK( this, ScPropertyDlg, SelectHdl ));
+ aBaProDatCtr.SetSelectHdl (LINK( this, ScPropertyDlg, CommitHdl ));
+
+ aPropListBox.SetController(&aBaProDatCtr);
+
+ USHORT nPageId=aPropListBox.AppendPage("YabbaDabbaDo");
+ aPropListBox.SetPage(nPageId);
+ aProperty.eKind=KOC_EDIT;
+ aProperty.aName=aString;
+ aProperty.aName+=String((USHORT)++nCount);
+ aProperty.aValue=sizeof ComboBox;
+ aProperty.bHasVisibleXButton=FALSE;
+ aProperty.bIsHyperLink=FALSE;
+ aProperty.bIsLocked=FALSE;
+ aProperty.pDataPtr=NULL;
+ aProperty.pControl=NULL;
+ aProperty.theValues.Insert(new String("1"),aProperty.theValues.Count());
+ aProperty.theValues.Insert(new String("2"),aProperty.theValues.Count());
+ aProperty.theValues.Insert(new String("3"),aProperty.theValues.Count());
+ aProperty.theValues.Insert(new String("4"),aProperty.theValues.Count());
+ aPropListBox.InsertEntry(aProperty);
+ aProperty.bHasVisibleXButton=TRUE;
+ aProperty.aName=aString;
+ aProperty.aName+=String((USHORT)++nCount);
+ aProperty.aValue="42";
+ aProperty.eKind=KOC_LISTBOX;
+ aPropListBox.InsertEntry(aProperty);
+ aProperty.aName=aString;
+ aProperty.aName+=String((USHORT)++nCount);
+ aProperty.eKind=KOC_COMBOBOX;
+ aProperty.bHasVisibleXButton=FALSE;
+ aPropListBox.InsertEntry(aProperty);
+}
+
+ScPropertyDlg::~ScPropertyDlg()
+{
+ delete aProperty.theValues[0];
+ delete aProperty.theValues[1];
+ delete aProperty.theValues[2];
+ delete aProperty.theValues[3];
+}
+
+IMPL_LINK( ScPropertyDlg, ModifiedHdl, ListBox*, pLB )
+{
+ if(pLB!=NULL)
+ {
+ String aString("Don't know ");
+ aProperty.aName=aString;
+ aProperty.aName+=String((USHORT)++nCount);
+ if(nCount>20)
+ {
+ String aStr("Yabba ");
+ aStr+=aPropListBox.GetCurPage();
+ USHORT nPageId=aPropListBox.AppendPage(aStr);
+ aPropListBox.SetPage(nPageId);
+ nCount=0;
+ }
+
+ aProperty.eKind=(eKindOfControl)(aKindOfListBox.GetSelectEntryPos()+1);
+ aProperty.bHasVisibleXButton=FALSE;
+ if((nCount % 5)==0) aProperty.bHasVisibleXButton=TRUE;
+ aPropListBox.InsertEntry(aProperty);
+ }
+ return 0;
+}
+
+IMPL_LINK( ScPropertyDlg, RowModifiedHdl, SvBasicPropertyDataControl* ,pProCtr)
+{
+ if(pProCtr!=NULL)
+ {
+ aModAnswer.SetText(aBaProDatCtr.GetProperty());
+ aModAnswer.Invalidate();
+ aBaProDatCtr.SetIsCorrect(TRUE);
+ }
+ return 0;
+}
+
+IMPL_LINK( ScPropertyDlg, CommitHdl, SvBasicPropertyDataControl*,pProCtr)
+{
+ if(pProCtr!=NULL)
+ {
+ aCommitAnswer.SetText(aBaProDatCtr.GetProperty());
+ aCommitAnswer.Invalidate();
+ aBaProDatCtr.SetIsCorrect(TRUE);
+ }
+ return 0;
+}
+
+IMPL_LINK( ScPropertyDlg, ClickHdl, SvBasicPropertyDataControl*,pProCtr)
+{
+ if(pProCtr!=NULL)
+ {
+ aClickAnswer.SetText(aBaProDatCtr.GetName());
+ aClickAnswer.Invalidate();
+ aBaProDatCtr.SetIsCorrect(TRUE);
+ }
+ return 0;
+}
+
+IMPL_LINK( ScPropertyDlg, SelectHdl, SvBasicPropertyDataControl*,pProCtr)
+{
+ if(pProCtr!=NULL)
+ {
+ aSelectAnswer.SetText(aBaProDatCtr.GetName());
+ aSelectAnswer.Invalidate();
+ aBaProDatCtr.SetIsCorrect(TRUE);
+ }
+ return 0;
+}
+*/
+
+
diff --git a/svtools/source/dialogs/roadmapwizard.cxx b/svtools/source/dialogs/roadmapwizard.cxx
new file mode 100644
index 000000000000..b0fff49e5e8d
--- /dev/null
+++ b/svtools/source/dialogs/roadmapwizard.cxx
@@ -0,0 +1,708 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: roadmapwizard.cxx,v $
+ * $Revision: 1.19.10.2 $
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_svtools.hxx"
+
+#include <svtools/roadmapwizard.hxx>
+#include <svtools/svtools.hrc>
+#include <svtools/svtdata.hxx>
+#include "roadmap.hxx"
+#include <tools/debug.hxx>
+
+#include <stdarg.h>
+
+#include <vector>
+#include <map>
+#include <set>
+
+//........................................................................
+namespace svt
+{
+//........................................................................
+
+ namespace
+ {
+ typedef ::std::set< WizardTypes::WizardState > StateSet;
+
+ typedef ::std::map<
+ RoadmapWizardTypes::PathId,
+ RoadmapWizardTypes::WizardPath
+ > Paths;
+
+ typedef ::std::map<
+ WizardTypes::WizardState,
+ ::std::pair<
+ String,
+ RoadmapWizardTypes::RoadmapPageFactory
+ >
+ > StateDescriptions;
+ }
+
+ struct RoadmapWizardImpl : public RoadmapWizardTypes
+ {
+ ORoadmap* pRoadmap;
+ Paths aPaths;
+ PathId nActivePath;
+ StateDescriptions aStateDescriptors;
+ StateSet aDisabledStates;
+ bool bActivePathIsDefinite;
+ FixedLine* pFixedLine;
+
+ RoadmapWizardImpl()
+ :pRoadmap( NULL )
+ ,nActivePath( -1 )
+ ,bActivePathIsDefinite( false )
+ ,pFixedLine(NULL)
+ {
+ }
+
+ ~RoadmapWizardImpl()
+ {
+ delete pRoadmap;
+ delete pFixedLine;
+ }
+
+ /// returns the index of the current state in given path, or -1
+ sal_Int32 getStateIndexInPath( WizardTypes::WizardState _nState, const WizardPath& _rPath );
+ /// returns the index of the current state in the path with the given id, or -1
+ sal_Int32 getStateIndexInPath( WizardTypes::WizardState _nState, PathId _nPathId );
+ /// returns the index of the first state in which the two given paths differ
+ sal_Int32 getFirstDifferentIndex( const WizardPath& _rLHS, const WizardPath& _rRHS );
+ };
+
+ //--------------------------------------------------------------------
+ sal_Int32 RoadmapWizardImpl::getStateIndexInPath( WizardTypes::WizardState _nState, const WizardPath& _rPath )
+ {
+ sal_Int32 nStateIndexInPath = 0;
+ WizardPath::const_iterator aPathLoop = _rPath.begin();
+ for ( ; aPathLoop != _rPath.end(); ++aPathLoop, ++nStateIndexInPath )
+ if ( *aPathLoop == _nState )
+ break;
+ if ( aPathLoop == _rPath.end() )
+ nStateIndexInPath = -1;
+ return nStateIndexInPath;
+ }
+
+ //--------------------------------------------------------------------
+ sal_Int32 RoadmapWizardImpl::getStateIndexInPath( WizardTypes::WizardState _nState, PathId _nPathId )
+ {
+ sal_Int32 nStateIndexInPath = -1;
+ Paths::const_iterator aPathPos = aPaths.find( _nPathId );
+ if ( aPathPos != aPaths.end( ) )
+ nStateIndexInPath = getStateIndexInPath( _nState, aPathPos->second );
+ return nStateIndexInPath;
+ }
+
+ //--------------------------------------------------------------------
+ sal_Int32 RoadmapWizardImpl::getFirstDifferentIndex( const WizardPath& _rLHS, const WizardPath& _rRHS )
+ {
+ sal_Int32 nMinLength = ::std::min( _rLHS.size(), _rRHS.size() );
+ for ( sal_Int32 nCheck = 0; nCheck < nMinLength; ++nCheck )
+ {
+ if ( _rLHS[ nCheck ] != _rRHS[ nCheck ] )
+ return nCheck;
+ }
+ return nMinLength;
+ }
+
+ //====================================================================
+ //= RoadmapWizard
+ //====================================================================
+ DBG_NAME( RoadmapWizard )
+ //--------------------------------------------------------------------
+#if OSL_DEBUG_LEVEL > 0
+ const char* CheckInvariants( const void* pVoid )
+ {
+ return static_cast< const RoadmapWizard* >( pVoid )->checkInvariants();
+ }
+
+ //--------------------------------------------------------------------
+ const sal_Char* RoadmapWizard::checkInvariants() const
+ {
+ // all paths have to start with the same state
+ WizardState nSharedFirstState = WZS_INVALID_STATE;
+ for ( Paths::const_iterator aPath = m_pImpl->aPaths.begin();
+ aPath != m_pImpl->aPaths.end();
+ ++aPath
+ )
+ {
+ if ( aPath->second.empty() )
+ return "RoadmapWizard::checkInvariants: paths should not be empty!";
+
+ if ( nSharedFirstState == WZS_INVALID_STATE )
+ // first path
+ nSharedFirstState = aPath->second[ 0 ];
+ else
+ if ( nSharedFirstState != aPath->second[ 0 ] )
+ return "RoadmapWizard::checkInvariants: alls paths must start with the same state!";
+ }
+
+ if ( !m_pImpl->aPaths.empty() )
+ {
+ Paths::const_iterator aCurrentPathPos = m_pImpl->aPaths.find( m_pImpl->nActivePath );
+ if ( aCurrentPathPos == m_pImpl->aPaths.end() )
+ return "RoadmapWizard::checkInvariants: invalid active path!";
+
+ if ( -1 == m_pImpl->getStateIndexInPath( getCurrentState(), m_pImpl->nActivePath ) )
+ return "RoadmapWizard::checkInvariants: the current state is not part of the current path!";
+ }
+
+ return NULL;
+ }
+#endif
+
+ //--------------------------------------------------------------------
+ RoadmapWizard::RoadmapWizard( Window* _pParent, const ResId& _rRes, sal_uInt32 _nButtonFlags )
+ :OWizardMachine( _pParent, _rRes, _nButtonFlags )
+ ,m_pImpl( new RoadmapWizardImpl )
+ {
+ DBG_CTOR( RoadmapWizard, CheckInvariants );
+
+ SetLeftAlignedButtonCount( 1 );
+ SetEmptyViewMargin();
+
+ m_pImpl->pRoadmap = new ORoadmap( this, WB_TABSTOP );
+ m_pImpl->pRoadmap->SetText( SvtResId( STR_WIZDLG_ROADMAP_TITLE ) );
+ m_pImpl->pRoadmap->SetPosPixel( Point( 0, 0 ) );
+ m_pImpl->pRoadmap->SetItemSelectHdl( LINK( this, RoadmapWizard, OnRoadmapItemSelected ) );
+
+ Size aRoadmapSize =( LogicToPixel( Size( 85, 0 ), MAP_APPFONT ) );
+ aRoadmapSize.Height() = GetSizePixel().Height();
+ m_pImpl->pRoadmap->SetSizePixel( aRoadmapSize );
+
+ m_pImpl->pFixedLine = new FixedLine( this, WB_VERT );
+ m_pImpl->pFixedLine->Show();
+ m_pImpl->pFixedLine->SetPosPixel( Point( aRoadmapSize.Width() + 1, 0 ) );
+ m_pImpl->pFixedLine->SetSizePixel( Size( LogicToPixel( Size( 2, 0 ) ).Width(), aRoadmapSize.Height() ) );
+
+ SetViewWindow( m_pImpl->pRoadmap );
+ SetViewAlign( WINDOWALIGN_LEFT );
+ m_pImpl->pRoadmap->Show();
+ }
+
+ //--------------------------------------------------------------------
+ RoadmapWizard::~RoadmapWizard()
+ {
+ delete m_pImpl;
+ DBG_DTOR( RoadmapWizard, CheckInvariants );
+ }
+
+ //--------------------------------------------------------------------
+ void RoadmapWizard::SetRoadmapBitmap( const BitmapEx& _rBitmap )
+ {
+ m_pImpl->pRoadmap->SetRoadmapBitmap( _rBitmap );
+ }
+
+ //--------------------------------------------------------------------
+ const BitmapEx& RoadmapWizard::GetRoadmapBitmap( ) const
+ {
+ return m_pImpl->pRoadmap->GetRoadmapBitmap();
+ }
+
+ //--------------------------------------------------------------------
+ void RoadmapWizard::SetRoadmapSmartHelpId( const SmartId& _rId, SmartIdUpdateMode _aMode )
+ {
+ m_pImpl->pRoadmap->SetSmartHelpId( _rId, _aMode );
+ }
+
+ //--------------------------------------------------------------------
+ SmartId RoadmapWizard::GetRoadmapSmartHelpId() const
+ {
+ return m_pImpl->pRoadmap->GetSmartHelpId();
+ }
+
+ //--------------------------------------------------------------------
+ void RoadmapWizard::SetRoadmapInteractive( sal_Bool _bInteractive )
+ {
+ m_pImpl->pRoadmap->SetRoadmapInteractive( _bInteractive );
+ }
+
+ //--------------------------------------------------------------------
+ sal_Bool RoadmapWizard::IsRoadmapInteractive()
+ {
+ return m_pImpl->pRoadmap->IsRoadmapInteractive();
+ }
+
+ //--------------------------------------------------------------------
+ void RoadmapWizard::declarePath( PathId _nPathId, const WizardPath& _lWizardStates)
+ {
+ DBG_CHKTHIS( RoadmapWizard, CheckInvariants );
+
+ m_pImpl->aPaths.insert( Paths::value_type( _nPathId, _lWizardStates ) );
+
+ if ( m_pImpl->aPaths.size() == 1 )
+ // the very first path -> activate it
+ activatePath( _nPathId, false );
+ else
+ implUpdateRoadmap( );
+ }
+
+ //--------------------------------------------------------------------
+ void RoadmapWizard::declarePath( PathId _nPathId, WizardState _nFirstState, ... )
+ {
+ DBG_CHKTHIS( RoadmapWizard, CheckInvariants );
+
+ DBG_ASSERT( _nFirstState != WZS_INVALID_STATE, "RoadmapWizard::declarePath: there should be at least one state in the path!" );
+ if ( _nFirstState == WZS_INVALID_STATE )
+ return;
+
+ WizardPath aNewPath;
+
+ // collect the elements of the path
+ va_list aStateList;
+ va_start( aStateList, _nFirstState );
+
+ WizardState nState = _nFirstState;
+ while ( nState != WZS_INVALID_STATE )
+ {
+ aNewPath.push_back( nState );
+ nState = sal::static_int_cast< WizardState >(
+ va_arg( aStateList, int ));
+ }
+ va_end( aStateList );
+
+ DBG_ASSERT( _nFirstState == 0, "RoadmapWizard::declarePath: first state must be NULL." );
+ // The WizardDialog (our very base class) always starts with a mnCurLevel == 0
+
+ declarePath( _nPathId, aNewPath );
+ }
+
+ //--------------------------------------------------------------------
+ void RoadmapWizard::describeState( WizardState _nState, const String& _rStateDisplayName, RoadmapPageFactory _pPageFactory )
+ {
+ OSL_ENSURE( m_pImpl->aStateDescriptors.find( _nState ) == m_pImpl->aStateDescriptors.end(),
+ "RoadmapWizard::describeState: there already is a descriptor for this state!" );
+ m_pImpl->aStateDescriptors[ _nState ] = StateDescriptions::mapped_type( _rStateDisplayName, _pPageFactory );
+ }
+
+ //--------------------------------------------------------------------
+ void RoadmapWizard::activatePath( PathId _nPathId, bool _bDecideForIt )
+ {
+ DBG_CHKTHIS( RoadmapWizard, CheckInvariants );
+
+ if ( ( _nPathId == m_pImpl->nActivePath ) && ( _bDecideForIt == m_pImpl->bActivePathIsDefinite ) )
+ // nothing to do
+ return;
+
+ // does the given path exist?
+ Paths::const_iterator aNewPathPos = m_pImpl->aPaths.find( _nPathId );
+ DBG_ASSERT( aNewPathPos != m_pImpl->aPaths.end(), "RoadmapWizard::activate: there is no such path!" );
+ if ( aNewPathPos == m_pImpl->aPaths.end() )
+ return;
+
+ // determine the index of the current state in the current path
+ sal_Int32 nCurrentStatePathIndex = -1;
+ if ( m_pImpl->nActivePath != -1 )
+ nCurrentStatePathIndex = m_pImpl->getStateIndexInPath( getCurrentState(), m_pImpl->nActivePath );
+
+ DBG_ASSERT( (sal_Int32)aNewPathPos->second.size() > nCurrentStatePathIndex,
+ "RoadmapWizard::activate: you cannot activate a path which has less states than we've already advanced!" );
+ // If this asserts, this for instance means that we are already in state number, say, 5
+ // of our current path, and the caller tries to activate a path which has less than 5
+ // states
+ if ( (sal_Int32)aNewPathPos->second.size() <= nCurrentStatePathIndex )
+ return;
+
+#if OSL_DEBUG_LEVEL > 0
+ // assert that the current and the new path are equal, up to nCurrentStatePathIndex
+ Paths::const_iterator aActivePathPos = m_pImpl->aPaths.find( m_pImpl->nActivePath );
+ if ( aActivePathPos != m_pImpl->aPaths.end() )
+ {
+ DBG_ASSERT( m_pImpl->getFirstDifferentIndex( aActivePathPos->second, aNewPathPos->second ) > nCurrentStatePathIndex,
+ "RoadmapWizard::activate: you cannot activate a path which conflicts with the current one *before* the current state!" );
+ }
+#endif
+
+ m_pImpl->nActivePath = _nPathId;
+ m_pImpl->bActivePathIsDefinite = _bDecideForIt;
+
+ implUpdateRoadmap( );
+ }
+
+ //--------------------------------------------------------------------
+ void RoadmapWizard::implUpdateRoadmap( )
+ {
+ DBG_CHKTHIS( RoadmapWizard, CheckInvariants );
+
+ DBG_ASSERT( m_pImpl->aPaths.find( m_pImpl->nActivePath ) != m_pImpl->aPaths.end(),
+ "RoadmapWizard::implUpdateRoadmap: there is no such path!" );
+ const WizardPath& rActivePath( m_pImpl->aPaths[ m_pImpl->nActivePath ] );
+
+ sal_Int32 nCurrentStatePathIndex = m_pImpl->getStateIndexInPath( getCurrentState(), rActivePath );
+
+ // determine up to which index (in the new path) we have to display the items
+ RoadmapTypes::ItemIndex nUpperStepBoundary = (RoadmapTypes::ItemIndex)rActivePath.size();
+ sal_Bool bIncompletePath = sal_False;
+ if ( !m_pImpl->bActivePathIsDefinite )
+ {
+ for ( Paths::const_iterator aPathPos = m_pImpl->aPaths.begin();
+ aPathPos != m_pImpl->aPaths.end();
+ ++aPathPos
+ )
+ {
+ if ( aPathPos->first == m_pImpl->nActivePath )
+ // it's the path we are just activating -> no need to check anything
+ continue;
+ // the index from which on both paths differ
+ sal_Int32 nDivergenceIndex = m_pImpl->getFirstDifferentIndex( rActivePath, aPathPos->second );
+ if ( nDivergenceIndex <= nCurrentStatePathIndex )
+ // they differ in an index which we have already left behind us
+ // -> this is no conflict anymore
+ continue;
+
+ // the path conflicts with our new path -> don't activate the
+ // *complete* new path, but only up to the step which is unambiguous
+ nUpperStepBoundary = nDivergenceIndex;
+ bIncompletePath = sal_True;
+ }
+ }
+
+ // can we advance from the current page?
+ const OWizardPage* pCurrentPage = dynamic_cast< const OWizardPage* >( GetPage( getCurrentState() ) );
+ const bool bCurrentPageCanAdvance = !pCurrentPage || pCurrentPage->canAdvance();
+
+ // now, we have to remove all items after nCurrentStatePathIndex, and insert the items from the active
+ // path, up to (excluding) nUpperStepBoundary
+ RoadmapTypes::ItemIndex nLoopUntil = ::std::max( (RoadmapTypes::ItemIndex)nUpperStepBoundary, m_pImpl->pRoadmap->GetItemCount() );
+ for ( RoadmapTypes::ItemIndex nItemIndex = nCurrentStatePathIndex; nItemIndex < nLoopUntil; ++nItemIndex )
+ {
+ bool bExistentItem = ( nItemIndex < m_pImpl->pRoadmap->GetItemCount() );
+ bool bNeedItem = ( nItemIndex < nUpperStepBoundary );
+
+ bool bInsertItem = false;
+ if ( bExistentItem )
+ {
+ if ( !bNeedItem )
+ {
+ while ( nItemIndex < m_pImpl->pRoadmap->GetItemCount() )
+ m_pImpl->pRoadmap->DeleteRoadmapItem( nItemIndex );
+ break;
+ }
+ else
+ {
+ // there is an item with this index in the roadmap - does it match what is requested by
+ // the respective state in the active path?
+ RoadmapTypes::ItemId nPresentItemId = m_pImpl->pRoadmap->GetItemID( nItemIndex );
+ WizardState nRequiredState = rActivePath[ nItemIndex ];
+ if ( nPresentItemId != nRequiredState )
+ {
+ m_pImpl->pRoadmap->DeleteRoadmapItem( nItemIndex );
+ bInsertItem = true;
+ }
+ }
+ }
+ else
+ {
+ DBG_ASSERT( bNeedItem, "RoadmapWizard::implUpdateRoadmap: ehm - none needed, none present - why did the loop not terminate?" );
+ bInsertItem = bNeedItem;
+ }
+
+ WizardState nState( rActivePath[ nItemIndex ] );
+ if ( bInsertItem )
+ {
+ m_pImpl->pRoadmap->InsertRoadmapItem(
+ nItemIndex,
+ getStateDisplayName( nState ),
+ nState
+ );
+ }
+
+ // if the item is *after* the current state, but the current page does not
+ // allow advancing, the disable the state. This relieves derived classes
+ // from disabling all future states just because the current state does not
+ // (yet) allow advancing.
+ const bool nUnconditionedDisable = !bCurrentPageCanAdvance && ( nItemIndex > nCurrentStatePathIndex );
+ const bool bEnable = !nUnconditionedDisable && ( m_pImpl->aDisabledStates.find( nState ) == m_pImpl->aDisabledStates.end() );
+
+ m_pImpl->pRoadmap->EnableRoadmapItem( m_pImpl->pRoadmap->GetItemID( nItemIndex ), bEnable );
+ }
+
+ m_pImpl->pRoadmap->SetRoadmapComplete( !bIncompletePath );
+ }
+
+ //--------------------------------------------------------------------
+ WizardTypes::WizardState RoadmapWizard::determineNextState( WizardState _nCurrentState ) const
+ {
+ DBG_CHKTHIS( RoadmapWizard, CheckInvariants );
+
+ sal_Int32 nCurrentStatePathIndex = -1;
+
+ Paths::const_iterator aActivePathPos = m_pImpl->aPaths.find( m_pImpl->nActivePath );
+ if ( aActivePathPos != m_pImpl->aPaths.end() )
+ nCurrentStatePathIndex = m_pImpl->getStateIndexInPath( _nCurrentState, aActivePathPos->second );
+
+ DBG_ASSERT( nCurrentStatePathIndex != -1, "RoadmapWizard::determineNextState: ehm - how can we travel if there is no (valid) active path?" );
+ if ( nCurrentStatePathIndex == -1 )
+ return WZS_INVALID_STATE;
+
+ sal_Int32 nNextStateIndex = nCurrentStatePathIndex + 1;
+
+ while ( ( nNextStateIndex < (sal_Int32)aActivePathPos->second.size() )
+ && ( m_pImpl->aDisabledStates.find( aActivePathPos->second[ nNextStateIndex ] ) != m_pImpl->aDisabledStates.end() )
+ )
+ {
+ ++nNextStateIndex;
+ }
+
+ if ( nNextStateIndex >= (sal_Int32)aActivePathPos->second.size() )
+ // there is no next state in the current path (at least none which is enabled)
+ return WZS_INVALID_STATE;
+
+ return aActivePathPos->second[ nNextStateIndex ];
+ }
+
+ //---------------------------------------------------------------------
+ bool RoadmapWizard::canAdvance() const
+ {
+ if ( !m_pImpl->bActivePathIsDefinite )
+ {
+ // check how many paths are still allowed
+ const WizardPath& rActivePath( m_pImpl->aPaths[ m_pImpl->nActivePath ] );
+ sal_Int32 nCurrentStatePathIndex = m_pImpl->getStateIndexInPath( getCurrentState(), rActivePath );
+
+ size_t nPossiblePaths(0);
+ for ( Paths::const_iterator aPathPos = m_pImpl->aPaths.begin();
+ aPathPos != m_pImpl->aPaths.end();
+ ++aPathPos
+ )
+ {
+ // the index from which on both paths differ
+ sal_Int32 nDivergenceIndex = m_pImpl->getFirstDifferentIndex( rActivePath, aPathPos->second );
+
+ if ( nDivergenceIndex > nCurrentStatePathIndex )
+ // this path is still a possible path
+ nPossiblePaths += 1;
+ }
+
+ // if we have more than one path which is still possible, then we assume
+ // to always have a next state. Though there might be scenarios where this
+ // is not true, but this is too sophisticated (means not really needed) right now.
+ if ( nPossiblePaths > 1 )
+ return true;
+ }
+
+ const WizardPath& rPath = m_pImpl->aPaths[ m_pImpl->nActivePath ];
+ if ( *rPath.rbegin() == getCurrentState() )
+ return false;
+
+ return true;
+ }
+
+ //---------------------------------------------------------------------
+ void RoadmapWizard::updateTravelUI()
+ {
+ OWizardMachine::updateTravelUI();
+
+ // disable the "Previous" button if all states in our history are disabled
+ ::std::vector< WizardState > aHistory;
+ getStateHistory( aHistory );
+ bool bHaveEnabledState = false;
+ for ( ::std::vector< WizardState >::const_iterator state = aHistory.begin();
+ state != aHistory.end() && !bHaveEnabledState;
+ ++state
+ )
+ {
+ if ( isStateEnabled( *state ) )
+ bHaveEnabledState = true;
+ }
+
+ enableButtons( WZB_PREVIOUS, bHaveEnabledState );
+
+ implUpdateRoadmap();
+ }
+
+ //--------------------------------------------------------------------
+ IMPL_LINK( RoadmapWizard, OnRoadmapItemSelected, void*, EMPTYARG )
+ {
+ DBG_CHKTHIS( RoadmapWizard, CheckInvariants );
+
+ RoadmapTypes::ItemId nCurItemId = m_pImpl->pRoadmap->GetCurrentRoadmapItemID();
+ if ( nCurItemId == getCurrentState() )
+ // nothing to do
+ return 1L;
+
+ if ( isTravelingSuspended() )
+ return 0;
+
+ WizardTravelSuspension aTravelGuard( *this );
+
+ sal_Int32 nCurrentIndex = m_pImpl->getStateIndexInPath( getCurrentState(), m_pImpl->nActivePath );
+ sal_Int32 nNewIndex = m_pImpl->getStateIndexInPath( nCurItemId, m_pImpl->nActivePath );
+
+ DBG_ASSERT( ( nCurrentIndex != -1 ) && ( nNewIndex != -1 ),
+ "RoadmapWizard::OnRoadmapItemSelected: something's wrong here!" );
+ if ( ( nCurrentIndex == -1 ) || ( nNewIndex == -1 ) )
+ {
+ return 0L;
+ }
+
+ sal_Bool bResult = sal_True;
+ if ( nNewIndex > nCurrentIndex )
+ {
+ bResult = skipUntil( (WizardState)nCurItemId );
+ WizardState nTemp = (WizardState)nCurItemId;
+ while( nTemp )
+ {
+ if( m_pImpl->aDisabledStates.find( --nTemp ) != m_pImpl->aDisabledStates.end() )
+ removePageFromHistory( nTemp );
+ }
+ }
+ else
+ bResult = skipBackwardUntil( (WizardState)nCurItemId );
+
+ if ( !bResult )
+ m_pImpl->pRoadmap->SelectRoadmapItemByID( getCurrentState() );
+
+ return 1L;
+ }
+
+ //--------------------------------------------------------------------
+ void RoadmapWizard::enterState( WizardState _nState )
+ {
+ DBG_CHKTHIS( RoadmapWizard, CheckInvariants );
+
+ OWizardMachine::enterState( _nState );
+
+ // synchronize the roadmap
+ implUpdateRoadmap( );
+ m_pImpl->pRoadmap->SelectRoadmapItemByID( getCurrentState() );
+ }
+
+ //--------------------------------------------------------------------
+ String RoadmapWizard::getStateDisplayName( WizardState _nState ) const
+ {
+ String sDisplayName;
+
+ StateDescriptions::const_iterator pos = m_pImpl->aStateDescriptors.find( _nState );
+ OSL_ENSURE( pos != m_pImpl->aStateDescriptors.end(),
+ "RoadmapWizard::getStateDisplayName: no default implementation available for this state!" );
+ if ( pos != m_pImpl->aStateDescriptors.end() )
+ sDisplayName = pos->second.first;
+
+ return sDisplayName;
+ }
+
+ //--------------------------------------------------------------------
+ TabPage* RoadmapWizard::createPage( WizardState _nState )
+ {
+ TabPage* pPage( NULL );
+
+ StateDescriptions::const_iterator pos = m_pImpl->aStateDescriptors.find( _nState );
+ OSL_ENSURE( pos != m_pImpl->aStateDescriptors.end(),
+ "RoadmapWizard::createPage: no default implementation available for this state!" );
+ if ( pos != m_pImpl->aStateDescriptors.end() )
+ {
+ RoadmapPageFactory pFactory = pos->second.second;
+ pPage = (*pFactory)( *this );
+ }
+
+ return pPage;
+ }
+
+ //--------------------------------------------------------------------
+ void RoadmapWizard::enableState( WizardState _nState, bool _bEnable )
+ {
+ DBG_CHKTHIS( RoadmapWizard, CheckInvariants );
+
+ // remember this (in case the state appears in the roadmap later on)
+ if ( _bEnable )
+ m_pImpl->aDisabledStates.erase( _nState );
+ else
+ {
+ m_pImpl->aDisabledStates.insert( _nState );
+ removePageFromHistory( _nState );
+ }
+
+ // if the state is currently in the roadmap, reflect it's new status
+ m_pImpl->pRoadmap->EnableRoadmapItem( (RoadmapTypes::ItemId)_nState, _bEnable );
+ }
+ //--------------------------------------------------------------------
+ bool RoadmapWizard::isStateEnabled( WizardState _nState ) const
+ {
+ return m_pImpl->aDisabledStates.find( _nState ) == m_pImpl->aDisabledStates.end();
+ }
+ //--------------------------------------------------------------------
+ void RoadmapWizard::Resize()
+ {
+ OWizardMachine::Resize();
+
+ if ( IsReallyShown() && !IsInInitShow() )
+ ResizeFixedLine();
+ }
+
+
+ //--------------------------------------------------------------------
+ void RoadmapWizard::StateChanged( StateChangedType nType )
+ {
+ WizardDialog::StateChanged( nType );
+
+ if ( nType == STATE_CHANGE_INITSHOW )
+ ResizeFixedLine();
+ }
+
+ //--------------------------------------------------------------------
+ void RoadmapWizard::ResizeFixedLine()
+ {
+ Size aSize( m_pImpl->pRoadmap->GetSizePixel() );
+ aSize.Width() = m_pImpl->pFixedLine->GetSizePixel().Width();
+ m_pImpl->pFixedLine->SetSizePixel( aSize );
+ }
+
+ //--------------------------------------------------------------------
+ void RoadmapWizard::updateRoadmapItemLabel( WizardState _nState )
+ {
+ const WizardPath& rActivePath( m_pImpl->aPaths[ m_pImpl->nActivePath ] );
+ RoadmapTypes::ItemIndex nUpperStepBoundary = (RoadmapTypes::ItemIndex)rActivePath.size();
+ RoadmapTypes::ItemIndex nLoopUntil = ::std::max( (RoadmapTypes::ItemIndex)nUpperStepBoundary, m_pImpl->pRoadmap->GetItemCount() );
+ sal_Int32 nCurrentStatePathIndex = -1;
+ if ( m_pImpl->nActivePath != -1 )
+ nCurrentStatePathIndex = m_pImpl->getStateIndexInPath( getCurrentState(), m_pImpl->nActivePath );
+ for ( RoadmapTypes::ItemIndex nItemIndex = nCurrentStatePathIndex; nItemIndex < nLoopUntil; ++nItemIndex )
+ {
+ bool bExistentItem = ( nItemIndex < m_pImpl->pRoadmap->GetItemCount() );
+ if ( bExistentItem )
+ {
+ // there is an item with this index in the roadmap - does it match what is requested by
+ // the respective state in the active path?
+ RoadmapTypes::ItemId nPresentItemId = m_pImpl->pRoadmap->GetItemID( nItemIndex );
+ WizardState nRequiredState = rActivePath[ nItemIndex ];
+ if ( _nState == nRequiredState )
+ {
+ m_pImpl->pRoadmap->ChangeRoadmapItemLabel( nPresentItemId, getStateDisplayName( nRequiredState ) );
+ break;
+ }
+ }
+ }
+ }
+
+//........................................................................
+} // namespace svt
+//........................................................................
diff --git a/svtools/source/dialogs/so3res.src b/svtools/source/dialogs/so3res.src
new file mode 100644
index 000000000000..c99b917d891e
--- /dev/null
+++ b/svtools/source/dialogs/so3res.src
@@ -0,0 +1,318 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: so3res.src,v $
+ * $Revision: 1.8 $
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#include "sores.hxx"
+#define __RSC
+#include "soerr.hxx"
+#define S_MAX 0x7fff
+Resource RID_SO_ERROR_HANDLER
+{
+ String ERRCODE_SO_GENERALERROR&S_MAX
+ {
+ Text [ en-US ] = "General OLE error." ;
+ };
+ String ERRCODE_SO_CANT_BINDTOSOURCE&S_MAX
+ {
+ // ### ACHTUNG: Neuer Text in Resource? Die Verbindung zum Objekt kann nicht hergestellt werden : Die Verbindung zum Objekt kann nicht hergestellt werden.
+ Text [ en-US ] = "The connection to the object cannot be established." ;
+ };
+ String ERRCODE_SO_NOCACHE_UPDATED&S_MAX
+ {
+ Text [ en-US ] = "No cache files were updated." ;
+ };
+ String ERRCODE_SO_SOMECACHES_NOTUPDATED&S_MAX
+ {
+ Text [ en-US ] = "Some cache files were not updated." ;
+ };
+ String ERRCODE_SO_MK_UNAVAILABLE&S_MAX
+ {
+ Text [ en-US ] = "Status of object cannot be determined in a timely manner." ;
+ };
+ String ERRCODE_SO_E_CLASSDIFF&S_MAX
+ {
+ Text [ en-US ] = "Source of the OLE link has been converted." ;
+ };
+ String ERRCODE_SO_MK_NO_OBJECT&S_MAX
+ {
+ Text [ en-US ] = "The object could not be found." ;
+ };
+ String ERRCODE_SO_MK_EXCEEDED_DEADLINE&S_MAX
+ {
+ Text [ en-US ] = "The process could not be completed within the specified time period." ;
+ };
+ String ERRCODE_SO_MK_CONNECT_MANUALLY&S_MAX
+ {
+ Text [ en-US ] = "OLE could not connect to a network device (server)." ;
+ };
+ String ERRCODE_SO_MK_INTERMEDIATE_INTERFACE_NOT_SUPPORTED&S_MAX
+ {
+ Text [ en-US ] = "The object found does not support the interface required for the desired operation." ;
+ };
+ String ERRCODE_SO_NO_INTERFACE&S_MAX
+ {
+ Text [ en-US ] = "Interface not supported." ;
+ };
+ String ERRCODE_SO_OUT_OF_MEMORY&S_MAX
+ {
+ Text [ en-US ] = "Insufficient memory." ;
+ };
+ String ERRCODE_SO_MK_SYNTAX&S_MAX
+ {
+ Text [ en-US ] = "The connection name could not be processed." ;
+ };
+ String ERRCODE_SO_MK_REDUCED_TO_SELF&S_MAX
+ {
+ Text [ en-US ] = "The connection name could not be reduced further." ;
+ };
+ String ERRCODE_SO_MK_NO_INVERSE&S_MAX
+ {
+ Text [ en-US ] = "The connection name has no inverse." ;
+ };
+ String ERRCODE_SO_MK_NO_PREFIX&S_MAX
+ {
+ Text [ en-US ] = "No common prefix exists." ;
+ };
+ String ERRCODE_SO_MK_HIM&S_MAX
+ {
+ Text [ en-US ] = "The connection name is contained in the other one." ;
+ };
+ String ERRCODE_SO_MK_US&S_MAX
+ {
+ Text [ en-US ] = "The connection names (the receiver and the other moniker) are identical." ;
+ };
+ String ERRCODE_SO_MK_ME&S_MAX
+ {
+ Text [ en-US ] = "The connection name is contained in the other one." ;
+ };
+ String ERRCODE_SO_MK_NOT_BINDABLE&S_MAX
+ {
+ // ### ACHTUNG: Neuer Text in Resource? Der Verbindungsname kann nicht verbunden werden Es handelt sich um einen relativen Namen : Der Verbindungsname kann nicht verbunden werden. Es handelt sich um einen relativen Namen
+ Text [ en-US ] = "The connection name cannot be connected. This is a relative name." ;
+ };
+ String ERRCODE_SO_NOT_IMPLEMENTED&S_MAX
+ {
+ Text [ en-US ] = "Operation not implemented." ;
+ };
+ String ERRCODE_SO_MK_NO_STORAGE&S_MAX
+ {
+ Text [ en-US ] = "No storage." ;
+ };
+ String ERRCODE_SO_FALSE&S_MAX
+ {
+ Text [ en-US ] = "False." ;
+ };
+ String ERRCODE_SO_MK_NEED_GENERIC&S_MAX
+ {
+ Text [ en-US ] = "Monikers must be composed generically." ;
+ };
+ String ERRCODE_SO_PENDING&S_MAX
+ {
+ Text [ en-US ] = "Data not available at this time." ;
+ };
+ String ERRCODE_SO_NOT_INPLACEACTIVE & S_MAX
+ {
+ /* ### ACHTUNG: Neuer Text in Resource? Objekt wurde nicht InPlace aktiviert : Objetkt wurde nicht InPlace aktiviert */
+ Text [ en-US ] = "Object could not be activated InPlace." ;
+ };
+ String ERRCODE_SO_LINDEX & S_MAX
+ {
+ /* ### ACHTUNG: Neuer Text in Resource? Ungültiger Index : Ung³ltiger Index */
+ Text [ en-US ] = "Invalid index." ;
+ };
+ String ERRCODE_SO_CANNOT_DOVERB_NOW & S_MAX
+ {
+ /* ### ACHTUNG: Neuer Text in Resource? Das Objekt kann die Aktion im momentanen Zustand nicht ausführen : Das Objekt kann die Aktion im momentanen Zustand nicht ausf³hren */
+ Text [ en-US ] = "The action cannot be executed in the object's current state." ;
+ };
+ String ERRCODE_SO_OLEOBJ_INVALIDHWND & S_MAX
+ {
+ /* ### ACHTUNG: Neuer Text in Resource? Bei der Aktivierung wurde ein ungültiges Fenster ist übergeben : Bei der Aktivierung wurde ein ung³ltiges Fenster ist ³bergeben */
+ Text [ en-US ] = "An invalid window was passed when activated." ;
+ };
+ String ERRCODE_SO_NOVERBS & S_MAX
+ {
+ /* ### ACHTUNG: Neuer Text in Resource? Das Objekt unterstützt keine Aktionen : Das Objekt unterst³tzt keine Aktionen */
+ Text [ en-US ] = "The object does not support any actions." ;
+ };
+ String ERRCODE_SO_INVALIDVERB & S_MAX
+ {
+ /* ### ACHTUNG: Neuer Text in Resource? Die Aktion ist nicht definiert. Es wird die Default Aktion ausgelöst : Die Aktion ist nicht definiert. Es wird die Default Aktion ausgel÷st */
+ Text [ en-US ] = "The action is not defined. The default action will be executed." ;
+ };
+ String ERRCODE_SO_MK_CONNECT & S_MAX
+ {
+ /* ### ACHTUNG: Neuer Text in Resource? Eine Verknüpfung auf das Netzwerk konnte nicht wieder hergestellt werden : Eine Verkn³pfung auf das Netzwerk, die nicht wieder hergestellt werden konnte */
+ Text [ en-US ] = "A link to the network could not be re-established." ;
+ };
+ String ERRCODE_SO_NOTIMPL & S_MAX
+ {
+ /* ### ACHTUNG: Neuer Text in Resource? Das Objekt unterstützt diese Aktion nicht : Das Objekt unterst³tzt diese Aktion nicht */
+ Text [ en-US ] = "Object does not support this action." ;
+ };
+ String ERRCODE_SO_MK_CANTOPENFILE & S_MAX
+ {
+ Text [ en-US ] = "The specified file could not be opened." ;
+ };
+ /*
+ String & S_MAX
+ {
+ Text = "";
+ };
+*/
+};
+Resource RID_SO_ERRCTX
+{
+ String ERRCTX_SO_DOVERB
+ {
+ Text [ en-US ] = "$(ERR) activating object" ;
+ };
+};
+String STR_INS_OBJECT
+{
+ Text [ en-US ] = "Inserts a new %1-Object into your document." ;
+};
+String STR_INS_OBJECT_ICON
+{
+ Text [ en-US ] = "Inserts a new %1-Object into your document as a symbol." ;
+};
+String STR_INS_FILE
+{
+ Text [ en-US ] = "Inserts the contents of the file into your document to enable later editing in the original application." ;
+};
+String STR_INS_PLUGIN
+{
+ Text [ en-US ] = "Inserts a plug-in object into your document with a reference to the plug-in data. When the object is activated, the plug-in is automatically executed." ;
+};
+String STR_INS_APPLET
+{
+ Text [ en-US ] = "Inserts an applet object into your document. When the object is activated, the applet is automatically executed." ;
+};
+String STR_INS_FILE_ICON
+{
+ Text [ en-US ] = "Inserts the contents of the file as an icon into your document." ;
+};
+String STR_INS_FILE_LINK
+{
+ Text [ en-US ] = "Inserts the contents of the file into your document and creates a link to the source file. Changes made to the source file will be reflected in your document." ;
+};
+String STR_INS_FILE_ICON_LINK
+{
+ Text [ en-US ] = "Inserts an icon into your document representing the file. Changes made to the source file will be reflected in your document." ;
+};
+String STR_PASTE
+{
+ Text [ en-US ] = "Pastes the contents of the clipboard as %1 in your document." ;
+};
+String STR_CONVERT_TO
+{
+ Text [ en-US ] = "Converts the selected %1object to the object type %2." ;
+};
+String STR_ACTIVATE_AS
+{
+ Text [ en-US ] = "All objects of type %1 are activated as %2, but not converted" ;
+};
+String STR_VERB_OPEN
+{
+ Text [ en-US ] = "~Open" ;
+};
+String STR_VERB_PROPS
+{
+ Text [ en-US ] = "~Properties" ;
+};
+String STR_PLUGIN_CANT_SHOW
+{
+ Text [ en-US ] = "Plug-in % cannot be displayed." ;
+};
+String STR_ERROR_DDE
+{
+ Text [ en-US ] = "DDE link to % for % area % are not available." ;
+};
+String STR_ERROR_OBJNOCREATE
+{
+ Text [ en-US ] = "Object % could not be inserted." ;
+};
+String STR_ERROR_OBJNOCREATE_FROM_FILE
+{
+ Text [ en-US ] = "Object from file % could not be inserted." ;
+};
+String STR_ERROR_OBJNOCREATE_PLUGIN
+{
+ Text [ en-US ] = "Plug-in from document % could not be inserted." ;
+};
+String STR_QUERYUPDATELINKS
+{
+ Text [ en-US ] = "Update all links?" ;
+};
+String STR_FURTHER_OBJECT
+{
+ Text [ en-US ] = "Further objects" ;
+};
+String STR_EDIT_APPLET
+{
+ Text [ en-US ] = "Edit Applet" ;
+};
+
+Bitmap BMP_PLUGIN
+{
+ File = "plugin.png" ;
+};
+Bitmap BMP_OLEOBJ
+{
+ File = "oleobj.png" ;
+};
+Menu MB_PLUGIN
+{
+ ItemList =
+ {
+ MenuItem MI_PLUGIN ;
+ };
+ ExtraData = { 1 ; 0 ; 0 ; }; //Um InPlace Menu zu bentzen
+};
+MenuItem MI_PLUGIN
+{
+ Identifier = MI_PLUGIN ;
+ SubMenu = Menu
+ {
+ ItemList =
+ {
+ MenuItem
+ {
+ Identifier = MI_PLUGIN_DEACTIVATE ;
+ Text [ en-US ] = "Deactivate" ;
+ };
+ };
+ };
+};
+String STR_UNKNOWN_SOURCE
+{
+ Text [ en-US ] = "Unknown source" ;
+};
+
+
diff --git a/svtools/source/dialogs/wizardmachine.cxx b/svtools/source/dialogs/wizardmachine.cxx
new file mode 100644
index 000000000000..c436256a31c4
--- /dev/null
+++ b/svtools/source/dialogs/wizardmachine.cxx
@@ -0,0 +1,727 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: wizardmachine.cxx,v $
+ * $Revision: 1.21.10.2 $
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_svtools.hxx"
+#include <svtools/wizardmachine.hxx>
+#include <svtools/helpid.hrc>
+#include <tools/debug.hxx>
+#include <vcl/msgbox.hxx>
+#include <svtools/svtdata.hxx>
+#ifndef _SVTOOLS_HRC
+#include <svtools/svtools.hrc>
+#endif
+
+//.........................................................................
+namespace svt
+{
+//.........................................................................
+
+ //=====================================================================
+ //= WizardPageImplData
+ //=====================================================================
+ struct WizardPageImplData
+ {
+ WizardPageImplData()
+ {
+ }
+ };
+
+ //=====================================================================
+ //= OWizardPage
+ //=====================================================================
+ //---------------------------------------------------------------------
+ OWizardPage::OWizardPage( Window* _pParent, WinBits _nStyle )
+ :TabPage( _pParent, _nStyle )
+ ,m_pImpl( new WizardPageImplData )
+ {
+ }
+
+ //---------------------------------------------------------------------
+ OWizardPage::OWizardPage( Window* _pParent, const ResId& _rResId )
+ :TabPage( _pParent, _rResId )
+ ,m_pImpl( new WizardPageImplData )
+ {
+ }
+
+ //---------------------------------------------------------------------
+ OWizardPage::~OWizardPage()
+ {
+ delete m_pImpl;
+ }
+
+ //---------------------------------------------------------------------
+ void OWizardPage::initializePage()
+ {
+ }
+
+ //---------------------------------------------------------------------
+ void OWizardPage::ActivatePage()
+ {
+ TabPage::ActivatePage();
+ updateDialogTravelUI();
+ }
+
+ //---------------------------------------------------------------------
+ void OWizardPage::updateDialogTravelUI()
+ {
+ OWizardMachine* pWizardMachine = dynamic_cast< OWizardMachine* >( GetParent() );
+ OSL_ENSURE( pWizardMachine, "OWizardPage::updateDialogTravelUI: where am I?" );
+ if ( pWizardMachine )
+ pWizardMachine->updateTravelUI();
+ }
+
+ //---------------------------------------------------------------------
+ bool OWizardPage::canAdvance() const
+ {
+ return true;
+ }
+
+ //---------------------------------------------------------------------
+ sal_Bool OWizardPage::commitPage( CommitPageReason )
+ {
+ return sal_True;
+ }
+
+ //=====================================================================
+ //= WizardMachineImplData
+ //=====================================================================
+ struct WizardMachineImplData : public WizardTypes
+ {
+ String sTitleBase; // the base for the title
+ ::std::stack< WizardState > aStateHistory; // the history of all states (used for implementing "Back")
+
+ WizardState nFirstUnknownPage;
+ // the WizardDialog does not allow non-linear transitions (e.g. it's
+ // not possible to add pages in a non-linear order), so we need some own maintainance data
+
+ sal_Bool m_bAutoNextButtonState;
+
+ bool m_bTravelingSuspended;
+
+ WizardMachineImplData()
+ :nFirstUnknownPage( 0 )
+ ,m_bAutoNextButtonState( sal_False )
+ ,m_bTravelingSuspended( false )
+ {
+ }
+ };
+
+ long OWizardMachine::calcRightHelpOffset(sal_uInt32 _nButtonFlags)
+ {
+ sal_Int32 nMask = 1;
+ sal_Int32 nRightAlignedButtonCount = -1;
+ for (unsigned int i = 0; i < 8*sizeof(_nButtonFlags); i++ )
+ {
+ if( ( _nButtonFlags & nMask ) != 0 )
+ nRightAlignedButtonCount++;
+ nMask <<= 1;
+ }
+ Size aSize = GetPageSizePixel();
+ sal_Int32 nTotButtonWidth = nRightAlignedButtonCount * LogicalCoordinateToPixel(50);
+ sal_Int32 nTotRightButtonSpaceOffset = (nRightAlignedButtonCount) * WIZARDDIALOG_BUTTON_STDOFFSET_X;
+ if ((_nButtonFlags & WZB_NEXT) && (_nButtonFlags & WZB_NEXT))
+ nTotRightButtonSpaceOffset = (nTotRightButtonSpaceOffset - WIZARDDIALOG_BUTTON_STDOFFSET_X) + WIZARDDIALOG_BUTTON_SMALLSTDOFFSET_X;
+ return aSize.Width() - nTotButtonWidth - nTotRightButtonSpaceOffset;
+ }
+
+ //=====================================================================
+ //= OWizardMachine
+ //=====================================================================
+ //---------------------------------------------------------------------
+ OWizardMachine::OWizardMachine(Window* _pParent, const ResId& _rRes, sal_uInt32 _nButtonFlags )
+ :WizardDialog( _pParent, _rRes )
+ ,m_pFinish(NULL)
+ ,m_pCancel(NULL)
+ ,m_pNextPage(NULL)
+ ,m_pPrevPage(NULL)
+ ,m_pHelp(NULL)
+ ,m_pImpl( new WizardMachineImplData )
+ {
+ m_pImpl->sTitleBase = GetText();
+
+ // create the buttons according to the wizard button flags
+ // the help button
+ if (_nButtonFlags & WZB_HELP)
+ {
+ m_pHelp= new HelpButton(this, WB_TABSTOP);
+ m_pHelp->SetSizePixel( LogicToPixel( Size( 50, 14 ), MAP_APPFONT ) );
+ m_pHelp->Show();
+ AddButton( m_pHelp, WIZARDDIALOG_BUTTON_STDOFFSET_X);
+ }
+
+ // the previous button
+ if (_nButtonFlags & WZB_PREVIOUS)
+ {
+ m_pPrevPage = new PushButton(this, WB_TABSTOP);
+ m_pPrevPage->SetSmartHelpId( SmartId(HID_WIZARD_PREVIOUS) );
+ m_pPrevPage->SetSizePixel( LogicToPixel( Size( 50, 14 ), MAP_APPFONT ) );
+ m_pPrevPage->SetText(String(SvtResId(STR_WIZDLG_PREVIOUS)));
+ m_pPrevPage->Show();
+
+ if (_nButtonFlags & WZB_NEXT)
+ AddButton( m_pPrevPage, ( WIZARDDIALOG_BUTTON_SMALLSTDOFFSET_X) ); // half x-offset to the next button
+ else
+ AddButton( m_pPrevPage, WIZARDDIALOG_BUTTON_STDOFFSET_X );
+ SetPrevButton( m_pPrevPage );
+ m_pPrevPage->SetClickHdl( LINK( this, OWizardMachine, OnPrevPage ) );
+ }
+
+ // the next button
+ if (_nButtonFlags & WZB_NEXT)
+ {
+ m_pNextPage = new PushButton(this, WB_TABSTOP);
+ m_pNextPage->SetSmartHelpId( SmartId(HID_WIZARD_NEXT) );
+ m_pNextPage->SetSizePixel( LogicToPixel( Size( 50, 14 ), MAP_APPFONT ) );
+ m_pNextPage->SetText(String(SvtResId(STR_WIZDLG_NEXT)));
+ m_pNextPage->Show();
+
+ AddButton( m_pNextPage, WIZARDDIALOG_BUTTON_STDOFFSET_X );
+ SetNextButton( m_pNextPage );
+ m_pNextPage->SetClickHdl( LINK( this, OWizardMachine, OnNextPage ) );
+ }
+
+ // the finish button
+ if (_nButtonFlags & WZB_FINISH)
+ {
+ m_pFinish = new OKButton(this, WB_TABSTOP);
+ m_pFinish->SetSizePixel( LogicToPixel( Size( 50, 14 ), MAP_APPFONT ) );
+ m_pFinish->SetText(String(SvtResId(STR_WIZDLG_FINISH)));
+ m_pFinish->Show();
+
+ AddButton( m_pFinish, WIZARDDIALOG_BUTTON_STDOFFSET_X );
+ m_pFinish->SetClickHdl( LINK( this, OWizardMachine, OnFinish ) );
+ }
+
+ // the cancel button
+ if (_nButtonFlags & WZB_CANCEL)
+ {
+ m_pCancel = new CancelButton(this, WB_TABSTOP);
+ m_pCancel->SetSizePixel( LogicToPixel( Size( 50, 14 ), MAP_APPFONT ) );
+ m_pCancel->Show();
+
+ AddButton( m_pCancel, WIZARDDIALOG_BUTTON_STDOFFSET_X );
+ }
+
+
+ }
+
+ //---------------------------------------------------------------------
+ OWizardMachine::~OWizardMachine()
+ {
+ delete m_pFinish;
+ delete m_pCancel;
+ delete m_pNextPage;
+ delete m_pPrevPage;
+ delete m_pHelp;
+
+ for (WizardState i=0; i<m_pImpl->nFirstUnknownPage; ++i)
+ delete GetPage(i);
+
+ delete m_pImpl;
+ }
+
+ //---------------------------------------------------------------------
+ void OWizardMachine::implUpdateTitle()
+ {
+ String sCompleteTitle(m_pImpl->sTitleBase);
+
+ // append the page title
+ TabPage* pCurrentPage = GetPage(getCurrentState());
+ if ( pCurrentPage && pCurrentPage->GetText().Len() )
+ {
+ sCompleteTitle += String::CreateFromAscii(" - ");
+ sCompleteTitle += pCurrentPage->GetText();
+ }
+
+ SetText(sCompleteTitle);
+ }
+
+ //---------------------------------------------------------------------
+ const String& OWizardMachine::getTitleBase() const
+ {
+ return m_pImpl->sTitleBase;
+ }
+
+ //---------------------------------------------------------------------
+ void OWizardMachine::setTitleBase(const String& _rTitleBase)
+ {
+ m_pImpl->sTitleBase = _rTitleBase;
+ implUpdateTitle();
+ }
+
+ //---------------------------------------------------------------------
+ void OWizardMachine::ActivatePage()
+ {
+ WizardDialog::ActivatePage();
+
+ WizardState nCurrentLevel = GetCurLevel();
+ if (NULL == GetPage(nCurrentLevel))
+ {
+ TabPage* pNewPage = createPage(nCurrentLevel);
+ DBG_ASSERT(pNewPage, "OWizardMachine::ActivatePage: invalid new page (NULL)!");
+
+ // fill up the page sequence of our base class (with dummies)
+ while (m_pImpl->nFirstUnknownPage < nCurrentLevel)
+ {
+ AddPage(NULL);
+ ++m_pImpl->nFirstUnknownPage;
+ }
+
+ if (m_pImpl->nFirstUnknownPage == nCurrentLevel)
+ {
+ // encountered this page number the first time
+ AddPage(pNewPage);
+ ++m_pImpl->nFirstUnknownPage;
+ }
+ else
+ // already had this page - just change it
+ SetPage(nCurrentLevel, pNewPage);
+ }
+
+ enterState(nCurrentLevel);
+ }
+
+ //---------------------------------------------------------------------
+ long OWizardMachine::DeactivatePage()
+ {
+ WizardState nCurrentState = getCurrentState();
+ if (!leaveState(nCurrentState) || !WizardDialog::DeactivatePage())
+ return sal_False;
+ return sal_True;
+ }
+
+ //---------------------------------------------------------------------
+ void OWizardMachine::defaultButton(sal_uInt32 _nWizardButtonFlags)
+ {
+ // the new default button
+ PushButton* pNewDefButton = NULL;
+ if (m_pFinish && (_nWizardButtonFlags & WZB_FINISH))
+ pNewDefButton = m_pFinish;
+ if (m_pNextPage && (_nWizardButtonFlags & WZB_NEXT))
+ pNewDefButton = m_pNextPage;
+ if (m_pPrevPage && (_nWizardButtonFlags & WZB_PREVIOUS))
+ pNewDefButton = m_pPrevPage;
+ if (m_pHelp && (_nWizardButtonFlags & WZB_HELP))
+ pNewDefButton = m_pHelp;
+ if (m_pCancel && (_nWizardButtonFlags & WZB_CANCEL))
+ pNewDefButton = m_pCancel;
+
+ if (pNewDefButton)
+ defaultButton(pNewDefButton);
+ }
+
+ //---------------------------------------------------------------------
+ void OWizardMachine::implResetDefault(Window* _pWindow)
+ {
+ Window* pChildLoop = _pWindow->GetWindow(WINDOW_FIRSTCHILD);
+ while (pChildLoop)
+ {
+ // does the window participate in the tabbing order?
+ if (pChildLoop->GetStyle() & WB_DIALOGCONTROL)
+ implResetDefault(pChildLoop);
+
+ // is it a button?
+ WindowType eType = pChildLoop->GetType();
+ if ( (WINDOW_BUTTON == eType)
+ || (WINDOW_PUSHBUTTON == eType)
+ || (WINDOW_OKBUTTON == eType)
+ || (WINDOW_CANCELBUTTON == eType)
+ || (WINDOW_HELPBUTTON == eType)
+ || (WINDOW_IMAGEBUTTON == eType)
+ || (WINDOW_MENUBUTTON == eType)
+ || (WINDOW_MOREBUTTON == eType)
+ )
+ {
+ pChildLoop->SetStyle(pChildLoop->GetStyle() & ~WB_DEFBUTTON);
+ }
+
+ // the next one ...
+ pChildLoop = pChildLoop->GetWindow(WINDOW_NEXT);
+ }
+ }
+
+ //---------------------------------------------------------------------
+ void OWizardMachine::defaultButton(PushButton* _pNewDefButton)
+ {
+ // loop through all (direct and indirect) descendants which participate in our tabbing order, and
+ // reset the WB_DEFBUTTON for every window which is a button
+ implResetDefault(this);
+
+ // set it's new style
+ if (_pNewDefButton)
+ _pNewDefButton->SetStyle(_pNewDefButton->GetStyle() | WB_DEFBUTTON);
+ }
+
+ //---------------------------------------------------------------------
+ void OWizardMachine::enableButtons(sal_uInt32 _nWizardButtonFlags, sal_Bool _bEnable)
+ {
+ if (m_pFinish && (_nWizardButtonFlags & WZB_FINISH))
+ m_pFinish->Enable(_bEnable);
+ if (m_pNextPage && (_nWizardButtonFlags & WZB_NEXT))
+ m_pNextPage->Enable(_bEnable);
+ if (m_pPrevPage && (_nWizardButtonFlags & WZB_PREVIOUS))
+ m_pPrevPage->Enable(_bEnable);
+ if (m_pHelp && (_nWizardButtonFlags & WZB_HELP))
+ m_pHelp->Enable(_bEnable);
+ if (m_pCancel && (_nWizardButtonFlags & WZB_CANCEL))
+ m_pCancel->Enable(_bEnable);
+ }
+
+ //---------------------------------------------------------------------
+ void OWizardMachine::enterState(WizardState _nState)
+ {
+ // tell the page
+ IWizardPage* pCurrentPage = getWizardPage(GetPage(_nState));
+ if ( pCurrentPage )
+ pCurrentPage->initializePage();
+
+ if ( isAutomaticNextButtonStateEnabled() )
+ enableButtons( WZB_NEXT, canAdvance() );
+
+ enableButtons( WZB_PREVIOUS, !m_pImpl->aStateHistory.empty() );
+
+ // set the new title - it depends on the current page (i.e. state)
+ implUpdateTitle();
+ }
+
+ //---------------------------------------------------------------------
+ sal_Bool OWizardMachine::leaveState(WizardState)
+ {
+ // no need to ask the page here.
+ // If we reach this point, we already gave the current page the chance to commit it's data,
+ // and it was allowed to commit it's data
+
+ return sal_True;
+ }
+
+ //---------------------------------------------------------------------
+ sal_Bool OWizardMachine::onFinish(sal_Int32 _nResult)
+ {
+ return Finnish(_nResult);
+ }
+
+ //---------------------------------------------------------------------
+ IMPL_LINK(OWizardMachine, OnFinish, PushButton*, EMPTYARG)
+ {
+ if ( isTravelingSuspended() )
+ return 0;
+ WizardTravelSuspension aTravelGuard( *this );
+ if ( !prepareLeaveCurrentState( eFinish ) )
+ {
+ return 0L;
+ }
+ long nRet = onFinish( RET_OK );
+ return nRet;
+ }
+
+ //---------------------------------------------------------------------
+ OWizardMachine::WizardState OWizardMachine::determineNextState( WizardState _nCurrentState ) const
+ {
+ return _nCurrentState + 1;
+ }
+
+ //---------------------------------------------------------------------
+ sal_Bool OWizardMachine::prepareLeaveCurrentState( CommitPageReason _eReason )
+ {
+ IWizardPage* pCurrentPage = getWizardPage(GetPage(getCurrentState()));
+ if ( pCurrentPage )
+ return pCurrentPage->commitPage( _eReason );
+ return sal_True;
+ }
+
+ //---------------------------------------------------------------------
+ sal_Bool OWizardMachine::skipBackwardUntil( WizardState _nTargetState )
+ {
+ // alowed to leave the current page?
+ if ( !prepareLeaveCurrentState( eTravelBackward ) )
+ return sal_False;
+
+ // don't travel directly on m_pImpl->aStateHistory, in case something goes wrong
+ ::std::stack< WizardState > aTravelVirtually = m_pImpl->aStateHistory;
+ ::std::stack< WizardState > aOldStateHistory = m_pImpl->aStateHistory;
+
+ WizardState nCurrentRollbackState = getCurrentState();
+ while ( nCurrentRollbackState != _nTargetState )
+ {
+ DBG_ASSERT( !aTravelVirtually.empty(), "OWizardMachine::skipBackwardUntil: this target state does not exist in the history!" );
+ nCurrentRollbackState = aTravelVirtually.top();
+ aTravelVirtually.pop();
+ }
+ m_pImpl->aStateHistory = aTravelVirtually;
+ if ( !ShowPage( _nTargetState ) )
+ {
+ m_pImpl->aStateHistory = aOldStateHistory;
+ return sal_False;
+ }
+ return sal_True;
+ }
+
+ //---------------------------------------------------------------------
+ sal_Bool OWizardMachine::skipUntil( WizardState _nTargetState )
+ {
+ WizardState nCurrentState = getCurrentState();
+
+ // alowed to leave the current page?
+ if ( !prepareLeaveCurrentState( nCurrentState < _nTargetState ? eTravelForward : eTravelBackward ) )
+ return sal_False;
+
+ // don't travel directly on m_pImpl->aStateHistory, in case something goes wrong
+ ::std::stack< WizardState > aTravelVirtually = m_pImpl->aStateHistory;
+ ::std::stack< WizardState > aOldStateHistory = m_pImpl->aStateHistory;
+ while ( nCurrentState != _nTargetState )
+ {
+ WizardState nNextState = determineNextState( nCurrentState );
+ if ( WZS_INVALID_STATE == nNextState )
+ {
+ DBG_ERROR( "OWizardMachine::skipUntil: the given target state does not exist!" );
+ return sal_False;
+ }
+
+ // remember the skipped state in the history
+ aTravelVirtually.push( nCurrentState );
+
+ // get the next state
+ nCurrentState = nNextState;
+ }
+ m_pImpl->aStateHistory = aTravelVirtually;
+ // show the target page
+ if ( !ShowPage( nCurrentState ) )
+ {
+ // argh! prepareLeaveCurrentPage succeeded, determineNextState succeeded,
+ // but ShowPage doesn't? Somebody behaves very strange here ....
+ DBG_ERROR( "OWizardMachine::skipUntil: very unpolite ...." );
+ m_pImpl->aStateHistory = aOldStateHistory;
+ return sal_False;
+ }
+ return sal_True;
+ }
+
+ //---------------------------------------------------------------------
+ sal_Bool OWizardMachine::skip(sal_Int32 _nSteps)
+ {
+ DBG_ASSERT(_nSteps > 0, "OWizardMachine::skip: invalid number of steps!");
+ // alowed to leave the current page?
+ if ( !prepareLeaveCurrentState( eTravelForward ) )
+ return sal_False;
+
+ WizardState nCurrentState = getCurrentState();
+ WizardState nNextState = determineNextState(nCurrentState);
+ // loop _nSteps steps
+ while (_nSteps-- > 0)
+ {
+ if (WZS_INVALID_STATE == nNextState)
+ return sal_False;
+
+ // remember the skipped state in the history
+ m_pImpl->aStateHistory.push(nCurrentState);
+
+ // get the next state
+ nCurrentState = nNextState;
+ nNextState = determineNextState(nCurrentState);
+ }
+
+ // show the (n+1)th page
+ if (!ShowPage(nCurrentState))
+ {
+ // TODO: this leaves us in a state where we have no current page and an inconsistent state history.
+ // Perhaps we should rollback the skipping here ....
+ DBG_ERROR("OWizardMachine::skip: very unpolite ....");
+ // if somebody does a skip and then does not allow to leave ...
+ // (can't be a commit error, as we've already committed the current page. So if ShowPage fails here,
+ // somebody behaves really strange ...)
+ return sal_False;
+ }
+
+ // all fine
+ return sal_True;
+ }
+
+ //---------------------------------------------------------------------
+ sal_Bool OWizardMachine::travelNext()
+ {
+ // allowed to leave the current page?
+ if ( !prepareLeaveCurrentState( eTravelForward ) )
+ return sal_False;
+
+ // determine the next state to travel to
+ WizardState nCurrentState = getCurrentState();
+ WizardState nNextState = determineNextState(nCurrentState);
+ if (WZS_INVALID_STATE == nNextState)
+ return sal_False;
+
+ // the state history is used by the enterState method
+ // all fine
+ m_pImpl->aStateHistory.push(nCurrentState);
+ if (!ShowPage(nNextState))
+ {
+ m_pImpl->aStateHistory.pop();
+ return sal_False;
+ }
+
+ return sal_True;
+ }
+
+ //---------------------------------------------------------------------
+ sal_Bool OWizardMachine::travelPrevious()
+ {
+ DBG_ASSERT(m_pImpl->aStateHistory.size() > 0, "OWizardMachine::travelPrevious: have no previous page!");
+
+ // alowed to leave the current page?
+ if ( !prepareLeaveCurrentState( eTravelBackward ) )
+ return sal_False;
+
+ // the next state to switch to
+ WizardState nPreviousState = m_pImpl->aStateHistory.top();
+
+ // the state history is used by the enterState method
+ m_pImpl->aStateHistory.pop();
+ // show this page
+ if (!ShowPage(nPreviousState))
+ {
+ m_pImpl->aStateHistory.push(nPreviousState);
+ return sal_False;
+ }
+
+ // all fine
+ return sal_True;
+ }
+
+ //---------------------------------------------------------------------
+ void OWizardMachine::removePageFromHistory( WizardState nToRemove )
+ {
+
+ ::std::stack< WizardState > aTemp;
+ while(!m_pImpl->aStateHistory.empty())
+ {
+ WizardState nPreviousState = m_pImpl->aStateHistory.top();
+ m_pImpl->aStateHistory.pop();
+ if(nPreviousState != nToRemove)
+ aTemp.push( nPreviousState );
+ else
+ break;
+ }
+ while(!aTemp.empty())
+ {
+ m_pImpl->aStateHistory.push( aTemp.top() );
+ aTemp.pop();
+ }
+ }
+
+ //---------------------------------------------------------------------
+ void OWizardMachine::enableAutomaticNextButtonState( bool _bEnable )
+ {
+ m_pImpl->m_bAutoNextButtonState = _bEnable;
+ }
+
+ //---------------------------------------------------------------------
+ bool OWizardMachine::isAutomaticNextButtonStateEnabled() const
+ {
+ return m_pImpl->m_bAutoNextButtonState;
+ }
+
+ //---------------------------------------------------------------------
+ IMPL_LINK(OWizardMachine, OnPrevPage, PushButton*, EMPTYARG)
+ {
+ if ( isTravelingSuspended() )
+ return 0;
+ WizardTravelSuspension aTravelGuard( *this );
+ sal_Int32 nRet = travelPrevious();
+ return nRet;
+ }
+
+ //---------------------------------------------------------------------
+ IMPL_LINK(OWizardMachine, OnNextPage, PushButton*, EMPTYARG)
+ {
+ if ( isTravelingSuspended() )
+ return 0;
+ WizardTravelSuspension aTravelGuard( *this );
+ sal_Int32 nRet = travelNext();
+ return nRet;
+ }
+
+ //---------------------------------------------------------------------
+ IWizardPage* OWizardMachine::getWizardPage(TabPage* _pCurrentPage) const
+ {
+ OWizardPage* pPage = dynamic_cast< OWizardPage* >( _pCurrentPage );
+ return pPage;
+ }
+
+ //---------------------------------------------------------------------
+ void OWizardMachine::getStateHistory( ::std::vector< WizardState >& _out_rHistory )
+ {
+ ::std::stack< WizardState > aHistoryCopy( m_pImpl->aStateHistory );
+ while ( !aHistoryCopy.empty() )
+ {
+ _out_rHistory.push_back( aHistoryCopy.top() );
+ aHistoryCopy.pop();
+ }
+ }
+
+ //---------------------------------------------------------------------
+ bool OWizardMachine::canAdvance() const
+ {
+ return WZS_INVALID_STATE != determineNextState( getCurrentState() );
+ }
+
+ //---------------------------------------------------------------------
+ void OWizardMachine::updateTravelUI()
+ {
+ OWizardPage* pPage = dynamic_cast< OWizardPage* >( GetPage( getCurrentState() ) );
+
+ bool bCanAdvance =
+ ( !pPage || pPage->canAdvance() ) // the current page allows to advance
+ && canAdvance(); // the dialog as a whole allows to advance
+ enableButtons( WZB_NEXT, bCanAdvance );
+ }
+
+ //---------------------------------------------------------------------
+ bool OWizardMachine::isTravelingSuspended() const
+ {
+ return m_pImpl->m_bTravelingSuspended;
+ }
+
+ //---------------------------------------------------------------------
+ void OWizardMachine::suspendTraveling( AccessGuard )
+ {
+ DBG_ASSERT( !m_pImpl->m_bTravelingSuspended, "OWizardMachine::suspendTraveling: already suspended!" );
+ m_pImpl->m_bTravelingSuspended = true;
+ }
+
+ //---------------------------------------------------------------------
+ void OWizardMachine::resumeTraveling( AccessGuard )
+ {
+ DBG_ASSERT( m_pImpl->m_bTravelingSuspended, "OWizardMachine::resumeTraveling: nothing to resume!" );
+ m_pImpl->m_bTravelingSuspended = false;
+ }
+
+//.........................................................................
+} // namespace svt
+//.........................................................................
diff --git a/svtools/source/dialogs/wizardmachine.src b/svtools/source/dialogs/wizardmachine.src
new file mode 100644
index 000000000000..d83fdd98824b
--- /dev/null
+++ b/svtools/source/dialogs/wizardmachine.src
@@ -0,0 +1,53 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: wizardmachine.src,v $
+ * $Revision: 1.37 $
+ *
+ * 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 _SVTOOLS_HRC
+#include <svtools/svtools.hrc>
+#endif
+
+String STR_WIZDLG_FINISH
+{
+ Text [ en-US ] = "~Finish" ;
+};
+
+String STR_WIZDLG_NEXT
+{
+ Text [ en-US ] = "~Next >>";
+};
+
+String STR_WIZDLG_PREVIOUS
+{
+ Text [ en-US ] = "<< Bac~k";
+};
+
+String STR_WIZDLG_ROADMAP_TITLE
+{
+ Text [ en-US ] = "Steps";
+};
diff --git a/svtools/source/dialogs/wizdlg.cxx b/svtools/source/dialogs/wizdlg.cxx
new file mode 100644
index 000000000000..f0c69a24e4e4
--- /dev/null
+++ b/svtools/source/dialogs/wizdlg.cxx
@@ -0,0 +1,709 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: wizdlg.cxx,v $
+ * $Revision: 1.12 $
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_svtools.hxx"
+
+#define _SVT_WIZDLG_CXX
+#include <tools/debug.hxx>
+#ifndef _VCL_FIXED_HXX
+#include <vcl/fixed.hxx>
+#endif
+#ifndef _VCL_BUTTON_HXX
+#include <vcl/button.hxx>
+#endif
+#ifndef _VCL_TABPAGE_HXX
+#include <vcl/tabpage.hxx>
+#endif
+#include <svtools/wizdlg.hxx>
+
+// =======================================================================
+
+#define WIZARDDIALOG_BUTTON_OFFSET_Y 6
+#define WIZARDDIALOG_BUTTON_DLGOFFSET_X 6
+#define WIZARDDIALOG_VIEW_DLGOFFSET_X 6
+#define WIZARDDIALOG_VIEW_DLGOFFSET_Y 6
+
+// =======================================================================
+
+struct ImplWizPageData
+{
+ ImplWizPageData* mpNext;
+ TabPage* mpPage;
+};
+
+// -----------------------------------------------------------------------
+
+struct ImplWizButtonData
+{
+ ImplWizButtonData* mpNext;
+ Button* mpButton;
+ long mnOffset;
+};
+
+// =======================================================================
+
+void WizardDialog::ImplInitData()
+{
+ mpFirstPage = NULL;
+ mpFirstBtn = NULL;
+ mpFixedLine = NULL;
+ mpCurTabPage = NULL;
+ mpPrevBtn = NULL;
+ mpNextBtn = NULL;
+ mpViewWindow = NULL;
+ mnCurLevel = 0;
+ meViewAlign = WINDOWALIGN_LEFT;
+ mbEmptyViewMargin = false;
+ mnLeftAlignCount = 0;
+}
+
+// -----------------------------------------------------------------------
+void WizardDialog::SetLeftAlignedButtonCount( sal_Int16 _nCount )
+{
+ mnLeftAlignCount = _nCount;
+}
+
+// -----------------------------------------------------------------------
+
+void WizardDialog::SetEmptyViewMargin()
+{
+ mbEmptyViewMargin = true;
+}
+
+// -----------------------------------------------------------------------
+
+void WizardDialog::ImplCalcSize( Size& rSize )
+{
+ // ButtonBar-Hoehe berechnen
+ long nMaxHeight = 0;
+ ImplWizButtonData* pBtnData = mpFirstBtn;
+ while ( pBtnData )
+ {
+ long nBtnHeight = pBtnData->mpButton->GetSizePixel().Height();
+ if ( nBtnHeight > nMaxHeight )
+ nMaxHeight = nBtnHeight;
+ pBtnData = pBtnData->mpNext;
+ }
+ if ( nMaxHeight )
+ nMaxHeight += WIZARDDIALOG_BUTTON_OFFSET_Y*2;
+ if ( mpFixedLine && mpFixedLine->IsVisible() )
+ nMaxHeight += mpFixedLine->GetSizePixel().Height();
+ rSize.Height() += nMaxHeight;
+
+ // View-Window-Groesse dazurechnen
+ if ( mpViewWindow && mpViewWindow->IsVisible() )
+ {
+ Size aViewSize = mpViewWindow->GetSizePixel();
+ if ( meViewAlign == WINDOWALIGN_TOP )
+ rSize.Height() += aViewSize.Height();
+ else if ( meViewAlign == WINDOWALIGN_LEFT )
+ rSize.Width() += aViewSize.Width();
+ else if ( meViewAlign == WINDOWALIGN_BOTTOM )
+ rSize.Height() += aViewSize.Height();
+ else if ( meViewAlign == WINDOWALIGN_RIGHT )
+ rSize.Width() += aViewSize.Width();
+ }
+}
+
+// -----------------------------------------------------------------------
+
+void WizardDialog::ImplPosCtrls()
+{
+ Size aDlgSize = GetOutputSizePixel();
+ long nBtnWidth = 0;
+ long nMaxHeight = 0;
+ long nOffY = aDlgSize.Height();
+
+ ImplWizButtonData* pBtnData = mpFirstBtn;
+ int j = 0;
+ while ( pBtnData )
+ {
+ if (j >= mnLeftAlignCount)
+ {
+ Size aBtnSize = pBtnData->mpButton->GetSizePixel();
+ long nBtnHeight = aBtnSize.Height();
+ if ( nBtnHeight > nMaxHeight )
+ nMaxHeight = nBtnHeight;
+ nBtnWidth += aBtnSize.Width();
+ nBtnWidth += pBtnData->mnOffset;
+ }
+ pBtnData = pBtnData->mpNext;
+ j++;
+ }
+
+ if ( nMaxHeight )
+ {
+ long nOffX = aDlgSize.Width()-nBtnWidth-WIZARDDIALOG_BUTTON_DLGOFFSET_X;
+ long nOffLeftAlignX = LogicalCoordinateToPixel(6);
+ nOffY -= WIZARDDIALOG_BUTTON_OFFSET_Y+nMaxHeight;
+
+ pBtnData = mpFirstBtn;
+ int i = 0;
+ while ( pBtnData )
+ {
+ Size aBtnSize = pBtnData->mpButton->GetSizePixel();
+ if (i >= mnLeftAlignCount)
+ {
+ Point aPos( nOffX, nOffY+((nMaxHeight-aBtnSize.Height())/2) );
+ pBtnData->mpButton->SetPosPixel( aPos );
+ nOffX += aBtnSize.Width();
+ nOffX += pBtnData->mnOffset;
+ }
+ else
+ {
+ Point aPos( nOffLeftAlignX, nOffY+((nMaxHeight-aBtnSize.Height())/2) );
+ pBtnData->mpButton->SetPosPixel( aPos );
+ nOffLeftAlignX += aBtnSize.Width();
+ nOffLeftAlignX += pBtnData->mnOffset;
+ }
+
+ pBtnData = pBtnData->mpNext;
+ i++;
+ }
+
+ nOffY -= WIZARDDIALOG_BUTTON_OFFSET_Y;
+ }
+
+ if ( mpFixedLine && mpFixedLine->IsVisible() )
+ {
+ nOffY -= mpFixedLine->GetSizePixel().Height();
+ mpFixedLine->SetPosSizePixel( 0, nOffY, aDlgSize.Width(), 0,
+ WINDOW_POSSIZE_POS | WINDOW_POSSIZE_WIDTH );
+ }
+
+ if ( mpViewWindow && mpViewWindow->IsVisible() )
+ {
+ long nViewOffX = 0;
+ long nViewOffY = 0;
+ long nViewWidth = 0;
+ long nViewHeight = 0;
+ long nDlgHeight = nOffY;
+ USHORT nViewPosFlags = WINDOW_POSSIZE_POS;
+ if ( meViewAlign == WINDOWALIGN_TOP )
+ {
+ nViewOffX = WIZARDDIALOG_VIEW_DLGOFFSET_X;
+ nViewOffY = WIZARDDIALOG_VIEW_DLGOFFSET_Y;
+ nViewWidth = aDlgSize.Width()-(WIZARDDIALOG_VIEW_DLGOFFSET_X*2);
+ nViewPosFlags |= WINDOW_POSSIZE_WIDTH;
+ }
+ else if ( meViewAlign == WINDOWALIGN_LEFT )
+ {
+ if ( mbEmptyViewMargin )
+ {
+ nViewOffX = 0;
+ nViewOffY = 0;
+ nViewHeight = nDlgHeight;
+ }
+ else
+ {
+ nViewOffX = WIZARDDIALOG_VIEW_DLGOFFSET_X;
+ nViewOffY = WIZARDDIALOG_VIEW_DLGOFFSET_Y;
+ nViewHeight = nDlgHeight-(WIZARDDIALOG_VIEW_DLGOFFSET_Y*2);
+ }
+ nViewPosFlags |= WINDOW_POSSIZE_HEIGHT;
+ }
+ else if ( meViewAlign == WINDOWALIGN_BOTTOM )
+ {
+ nViewOffX = WIZARDDIALOG_VIEW_DLGOFFSET_X;
+ nViewOffY = nDlgHeight-mpViewWindow->GetSizePixel().Height()-WIZARDDIALOG_VIEW_DLGOFFSET_Y;
+ nViewWidth = aDlgSize.Width()-(WIZARDDIALOG_VIEW_DLGOFFSET_X*2);
+ nViewPosFlags |= WINDOW_POSSIZE_WIDTH;
+ }
+ else if ( meViewAlign == WINDOWALIGN_RIGHT )
+ {
+ nViewOffX = aDlgSize.Width()-mpViewWindow->GetSizePixel().Width()-WIZARDDIALOG_VIEW_DLGOFFSET_X;
+ nViewOffY = WIZARDDIALOG_VIEW_DLGOFFSET_Y;
+ nViewHeight = nDlgHeight-(WIZARDDIALOG_VIEW_DLGOFFSET_Y*2);
+ nViewPosFlags |= WINDOW_POSSIZE_HEIGHT;
+ }
+ mpViewWindow->SetPosSizePixel( nViewOffX, nViewOffY,
+ nViewWidth, nViewHeight,
+ nViewPosFlags );
+ }
+}
+
+
+long WizardDialog::LogicalCoordinateToPixel(int iCoordinate){
+ Size aLocSize = LogicToPixel(Size( iCoordinate, 0 ), MAP_APPFONT );
+ int iPixelCoordinate = aLocSize.Width();
+ return iPixelCoordinate;
+}
+
+
+// -----------------------------------------------------------------------
+
+void WizardDialog::ImplPosTabPage()
+{
+ if ( !mpCurTabPage )
+ return;
+
+ if ( !IsInInitShow() )
+ {
+ // #100199# - On Unix initial size is equal to screen size, on Windows
+ // it's 0,0. One cannot calculate the size unless dialog is visible.
+ if ( !IsReallyVisible() )
+ return;
+ }
+
+ // ButtonBar-Hoehe berechnen
+ long nMaxHeight = 0;
+ ImplWizButtonData* pBtnData = mpFirstBtn;
+ while ( pBtnData )
+ {
+ long nBtnHeight = pBtnData->mpButton->GetSizePixel().Height();
+ if ( nBtnHeight > nMaxHeight )
+ nMaxHeight = nBtnHeight;
+ pBtnData = pBtnData->mpNext;
+ }
+ if ( nMaxHeight )
+ nMaxHeight += WIZARDDIALOG_BUTTON_OFFSET_Y*2;
+ if ( mpFixedLine && mpFixedLine->IsVisible() )
+ nMaxHeight += mpFixedLine->GetSizePixel().Height();
+
+ // TabPage positionieren
+ Size aDlgSize = GetOutputSizePixel();
+ aDlgSize.Height() -= nMaxHeight;
+ long nOffX = 0;
+ long nOffY = 0;
+ if ( mpViewWindow && mpViewWindow->IsVisible() )
+ {
+ Size aViewSize = mpViewWindow->GetSizePixel();
+ if ( meViewAlign == WINDOWALIGN_TOP )
+ {
+ nOffY += aViewSize.Height()+WIZARDDIALOG_VIEW_DLGOFFSET_Y;
+ aDlgSize.Height() -= aViewSize.Height()+WIZARDDIALOG_VIEW_DLGOFFSET_Y;
+ }
+ else if ( meViewAlign == WINDOWALIGN_LEFT )
+ {
+ nOffX += aViewSize.Width()+WIZARDDIALOG_VIEW_DLGOFFSET_X;
+ aDlgSize.Width() -= aViewSize.Width()+WIZARDDIALOG_VIEW_DLGOFFSET_X;
+ }
+ else if ( meViewAlign == WINDOWALIGN_BOTTOM )
+ aDlgSize.Height() -= aViewSize.Height()+WIZARDDIALOG_VIEW_DLGOFFSET_Y;
+ else if ( meViewAlign == WINDOWALIGN_RIGHT )
+ aDlgSize.Width() -= aViewSize.Width()+WIZARDDIALOG_VIEW_DLGOFFSET_X;
+ }
+ Point aPos( nOffX, nOffY );
+ mpCurTabPage->SetPosSizePixel( aPos, aDlgSize );
+}
+
+// -----------------------------------------------------------------------
+
+void WizardDialog::ImplShowTabPage( TabPage* pTabPage )
+{
+ if ( mpCurTabPage == pTabPage )
+ return;
+
+ TabPage* pOldTabPage = mpCurTabPage;
+ if ( pOldTabPage )
+ pOldTabPage->DeactivatePage();
+
+ mpCurTabPage = pTabPage;
+ if ( pTabPage )
+ {
+ ImplPosTabPage();
+ pTabPage->ActivatePage();
+ pTabPage->Show();
+ }
+
+ if ( pOldTabPage )
+ pOldTabPage->Hide();
+}
+
+// -----------------------------------------------------------------------
+
+TabPage* WizardDialog::ImplGetPage( USHORT nLevel ) const
+{
+ USHORT nTempLevel = 0;
+ ImplWizPageData* pPageData = mpFirstPage;
+ while ( pPageData )
+ {
+ if ( (nTempLevel == nLevel) || !pPageData->mpNext )
+ break;
+
+ nTempLevel++;
+ pPageData = pPageData->mpNext;
+ }
+
+ if ( pPageData )
+ return pPageData->mpPage;
+ return NULL;
+}
+
+// =======================================================================
+
+WizardDialog::WizardDialog( Window* pParent, WinBits nStyle ) :
+ ModalDialog( pParent, nStyle )
+{
+ ImplInitData();
+}
+
+// -----------------------------------------------------------------------
+
+WizardDialog::WizardDialog( Window* pParent, const ResId& rResId ) :
+ ModalDialog( pParent, rResId )
+{
+ ImplInitData();
+}
+
+// -----------------------------------------------------------------------
+
+WizardDialog::~WizardDialog()
+{
+ if ( mpFixedLine )
+ delete mpFixedLine;
+
+ // Remove all buttons
+ while ( mpFirstBtn )
+ RemoveButton( mpFirstBtn->mpButton );
+
+ // Remove all pages
+ while ( mpFirstPage )
+ RemovePage( mpFirstPage->mpPage );
+}
+
+// -----------------------------------------------------------------------
+
+void WizardDialog::Resize()
+{
+ if ( IsReallyShown() && !IsInInitShow() )
+ {
+ ImplPosCtrls();
+ ImplPosTabPage();
+ }
+
+ Dialog::Resize();
+}
+
+// -----------------------------------------------------------------------
+
+void WizardDialog::StateChanged( StateChangedType nType )
+{
+ if ( nType == STATE_CHANGE_INITSHOW )
+ {
+ if ( IsDefaultSize() )
+ {
+ Size aDlgSize = GetPageSizePixel();
+ if ( !aDlgSize.Width() || !aDlgSize.Height() )
+ {
+ ImplWizPageData* pPageData = mpFirstPage;
+ while ( pPageData )
+ {
+ if ( pPageData->mpPage )
+ {
+ Size aPageSize = pPageData->mpPage->GetSizePixel();
+ if ( aPageSize.Width() > aDlgSize.Width() )
+ aDlgSize.Width() = aPageSize.Width();
+ if ( aPageSize.Height() > aDlgSize.Height() )
+ aDlgSize.Height() = aPageSize.Height();
+ }
+
+ pPageData = pPageData->mpNext;
+ }
+ }
+ ImplCalcSize( aDlgSize );
+ SetOutputSizePixel( aDlgSize );
+ }
+
+ ImplPosCtrls();
+ ImplPosTabPage();
+ ImplShowTabPage( ImplGetPage( mnCurLevel ) );
+ }
+
+ Dialog::StateChanged( nType );
+}
+
+// -----------------------------------------------------------------------
+
+long WizardDialog::Notify( NotifyEvent& rNEvt )
+{
+ if ( (rNEvt.GetType() == EVENT_KEYINPUT) && mpPrevBtn && mpNextBtn )
+ {
+ const KeyEvent* pKEvt = rNEvt.GetKeyEvent();
+ KeyCode aKeyCode = pKEvt->GetKeyCode();
+ USHORT nKeyCode = aKeyCode.GetCode();
+
+ if ( aKeyCode.IsMod1() )
+ {
+ if ( aKeyCode.IsShift() || (nKeyCode == KEY_PAGEUP) )
+ {
+ if ( (nKeyCode == KEY_TAB) || (nKeyCode == KEY_PAGEUP) )
+ {
+ if ( mpPrevBtn->IsVisible() &&
+ mpPrevBtn->IsEnabled() && mpPrevBtn->IsInputEnabled() )
+ {
+ mpPrevBtn->SetPressed( TRUE );
+ mpPrevBtn->SetPressed( FALSE );
+ mpPrevBtn->Click();
+ }
+ return TRUE;
+ }
+ }
+ else
+ {
+ if ( (nKeyCode == KEY_TAB) || (nKeyCode == KEY_PAGEDOWN) )
+ {
+ if ( mpNextBtn->IsVisible() &&
+ mpNextBtn->IsEnabled() && mpNextBtn->IsInputEnabled() )
+ {
+ mpNextBtn->SetPressed( TRUE );
+ mpNextBtn->SetPressed( FALSE );
+ mpNextBtn->Click();
+ }
+ return TRUE;
+ }
+ }
+ }
+ }
+
+ return Dialog::Notify( rNEvt );
+}
+
+// -----------------------------------------------------------------------
+
+void WizardDialog::ActivatePage()
+{
+ maActivateHdl.Call( this );
+}
+
+// -----------------------------------------------------------------------
+
+long WizardDialog::DeactivatePage()
+{
+ if ( maDeactivateHdl.IsSet() )
+ return maDeactivateHdl.Call( this );
+ else
+ return TRUE;
+}
+
+// -----------------------------------------------------------------------
+
+BOOL WizardDialog::ShowNextPage()
+{
+ return ShowPage( mnCurLevel+1 );
+}
+
+// -----------------------------------------------------------------------
+
+BOOL WizardDialog::ShowPrevPage()
+{
+ if ( !mnCurLevel )
+ return FALSE;
+ return ShowPage( mnCurLevel-1 );
+}
+
+// -----------------------------------------------------------------------
+
+BOOL WizardDialog::ShowPage( USHORT nLevel )
+{
+ if ( DeactivatePage() )
+ {
+ mnCurLevel = nLevel;
+ ActivatePage();
+ ImplShowTabPage( ImplGetPage( mnCurLevel ) );
+ return TRUE;
+ }
+ else
+ return FALSE;
+}
+
+// -----------------------------------------------------------------------
+
+BOOL WizardDialog::Finnish( long nResult )
+{
+ if ( DeactivatePage() )
+ {
+ if ( mpCurTabPage )
+ mpCurTabPage->DeactivatePage();
+
+ if ( IsInExecute() )
+ EndDialog( nResult );
+ else if ( GetStyle() & WB_CLOSEABLE )
+ Close();
+ return TRUE;
+ }
+ else
+ return FALSE;
+}
+
+// -----------------------------------------------------------------------
+
+void WizardDialog::AddPage( TabPage* pPage )
+{
+ ImplWizPageData* pNewPageData = new ImplWizPageData;
+ pNewPageData->mpNext = NULL;
+ pNewPageData->mpPage = pPage;
+
+ if ( !mpFirstPage )
+ mpFirstPage = pNewPageData;
+ else
+ {
+ ImplWizPageData* pPageData = mpFirstPage;
+ while ( pPageData->mpNext )
+ pPageData = pPageData->mpNext;
+ pPageData->mpNext = pNewPageData;
+ }
+}
+
+// -----------------------------------------------------------------------
+
+void WizardDialog::RemovePage( TabPage* pPage )
+{
+ ImplWizPageData* pPrevPageData = NULL;
+ ImplWizPageData* pPageData = mpFirstPage;
+ while ( pPageData )
+ {
+ if ( pPageData->mpPage == pPage )
+ {
+ if ( pPrevPageData )
+ pPrevPageData->mpNext = pPageData->mpNext;
+ else
+ mpFirstPage = pPageData->mpNext;
+ if ( pPage == mpCurTabPage )
+ mpCurTabPage = NULL;
+ delete pPageData;
+ return;
+ }
+
+ pPrevPageData = pPageData;
+ pPageData = pPageData->mpNext;
+ }
+
+ DBG_ERROR( "WizardDialog::RemovePage() - Page not in list" );
+}
+
+// -----------------------------------------------------------------------
+
+void WizardDialog::SetPage( USHORT nLevel, TabPage* pPage )
+{
+ USHORT nTempLevel = 0;
+ ImplWizPageData* pPageData = mpFirstPage;
+ while ( pPageData )
+ {
+ if ( (nTempLevel == nLevel) || !pPageData->mpNext )
+ break;
+
+ nTempLevel++;
+ pPageData = pPageData->mpNext;
+ }
+
+ if ( pPageData )
+ {
+ if ( pPageData->mpPage == mpCurTabPage )
+ mpCurTabPage = NULL;
+ pPageData->mpPage = pPage;
+ }
+}
+
+// -----------------------------------------------------------------------
+
+TabPage* WizardDialog::GetPage( USHORT nLevel ) const
+{
+ USHORT nTempLevel = 0;
+ ImplWizPageData* pPageData = mpFirstPage;
+ while ( pPageData )
+ {
+ if ( nTempLevel == nLevel )
+ return pPageData->mpPage;
+
+ nTempLevel++;
+ pPageData = pPageData->mpNext;
+ }
+
+ return NULL;
+}
+
+// -----------------------------------------------------------------------
+
+void WizardDialog::AddButton( Button* pButton, long nOffset )
+{
+ ImplWizButtonData* pNewBtnData = new ImplWizButtonData;
+ pNewBtnData->mpNext = NULL;
+ pNewBtnData->mpButton = pButton;
+ pNewBtnData->mnOffset = nOffset;
+
+ if ( !mpFirstBtn )
+ mpFirstBtn = pNewBtnData;
+ else
+ {
+ ImplWizButtonData* pBtnData = mpFirstBtn;
+ while ( pBtnData->mpNext )
+ pBtnData = pBtnData->mpNext;
+ pBtnData->mpNext = pNewBtnData;
+ }
+}
+
+// -----------------------------------------------------------------------
+
+void WizardDialog::RemoveButton( Button* pButton )
+{
+ ImplWizButtonData* pPrevBtnData = NULL;
+ ImplWizButtonData* pBtnData = mpFirstBtn;
+ while ( pBtnData )
+ {
+ if ( pBtnData->mpButton == pButton )
+ {
+ if ( pPrevBtnData )
+ pPrevBtnData->mpNext = pBtnData->mpNext;
+ else
+ mpFirstBtn = pBtnData->mpNext;
+ delete pBtnData;
+ return;
+ }
+
+ pPrevBtnData = pBtnData;
+ pBtnData = pBtnData->mpNext;
+ }
+
+ DBG_ERROR( "WizardDialog::RemoveButton() - Button not in list" );
+}
+
+// -----------------------------------------------------------------------
+
+void WizardDialog::ShowButtonFixedLine( BOOL bVisible )
+{
+ if ( !mpFixedLine )
+ {
+ if ( !bVisible )
+ return;
+
+ mpFixedLine = new FixedLine( this );
+ }
+
+ mpFixedLine->Show( bVisible );
+}
+
+// -----------------------------------------------------------------------
+
+BOOL WizardDialog::IsButtonFixedLineVisible()
+{
+ return (mpFixedLine && mpFixedLine->IsVisible());
+}