summaryrefslogtreecommitdiff
path: root/basctl/source/dlged
diff options
context:
space:
mode:
Diffstat (limited to 'basctl/source/dlged')
-rw-r--r--basctl/source/dlged/dlged.cxx1370
-rw-r--r--basctl/source/dlged/dlgedclip.cxx151
-rw-r--r--basctl/source/dlged/dlgedfac.cxx198
-rw-r--r--basctl/source/dlged/dlgedfunc.cxx621
-rw-r--r--basctl/source/dlged/dlgedlist.cxx116
-rw-r--r--basctl/source/dlged/dlgedmod.cxx81
-rw-r--r--basctl/source/dlged/dlgedobj.cxx1887
-rw-r--r--basctl/source/dlged/dlgedpage.cxx89
-rw-r--r--basctl/source/dlged/dlgedview.cxx217
-rw-r--r--basctl/source/dlged/dlgresid.src175
-rw-r--r--basctl/source/dlged/makefile.mk63
-rw-r--r--basctl/source/dlged/managelang.cxx427
-rw-r--r--basctl/source/dlged/managelang.hrc106
-rw-r--r--basctl/source/dlged/managelang.src237
-rw-r--r--basctl/source/dlged/propbrw.cxx596
15 files changed, 6334 insertions, 0 deletions
diff --git a/basctl/source/dlged/dlged.cxx b/basctl/source/dlged/dlged.cxx
new file mode 100644
index 000000000000..be5fdc556c59
--- /dev/null
+++ b/basctl/source/dlged/dlged.cxx
@@ -0,0 +1,1370 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_basctl.hxx"
+#include "dlged.hxx"
+#include "dlgedfunc.hxx"
+#include "dlgedfac.hxx"
+#include <dlgedmod.hxx>
+#include "dlgedpage.hxx"
+#include "dlgedview.hxx"
+#include "dlgedobj.hxx"
+#include "dlgedclip.hxx"
+#include <dlgeddef.hxx>
+#include "propbrw.hxx"
+#include <localizationmgr.hxx>
+
+#include <basidesh.hxx>
+#include <iderdll.hxx>
+#include <vcl/scrbar.hxx>
+#include <tools/shl.hxx>
+#include <svl/itempool.hxx>
+#include <sfx2/viewfrm.hxx>
+
+#include <svx/svxids.hrc>
+#include <svx/svdpagv.hxx>
+#include <xmlscript/xml_helper.hxx>
+#include <xmlscript/xmldlg_imexp.hxx>
+#include <com/sun/star/beans/PropertyValue.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/beans/Property.hpp>
+#include <com/sun/star/awt/XDialog.hpp>
+#include <com/sun/star/util/XCloneable.hpp>
+#include <com/sun/star/resource/XStringResourcePersistence.hpp>
+#include <comphelper/processfactory.hxx>
+#include <comphelper/types.hxx>
+#include <vcl/svapp.hxx>
+#include <toolkit/helper/vclunohelper.hxx>
+
+// #i74769#
+#include <svx/sdrpaintwindow.hxx>
+
+using namespace comphelper;
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::io;
+using ::rtl::OUString;
+
+static ::rtl::OUString aResourceResolverPropName( RTL_CONSTASCII_USTRINGPARAM( "ResourceResolver" ));
+static ::rtl::OUString aDecorationPropName( RTL_CONSTASCII_USTRINGPARAM( "Decoration" ));
+static ::rtl::OUString aTitlePropName( RTL_CONSTASCII_USTRINGPARAM( "Title" ));
+
+
+//============================================================================
+// DlgEdHint
+//============================================================================
+
+TYPEINIT1( DlgEdHint, SfxHint );
+
+DlgEdHint::DlgEdHint( DlgEdHintKind eHint )
+ :eHintKind( eHint )
+{
+}
+
+
+DlgEdHint::DlgEdHint( DlgEdHintKind eHint, DlgEdObj* pObj )
+ :eHintKind( eHint )
+ ,pDlgEdObj( pObj )
+{
+}
+
+
+DlgEdHint::~DlgEdHint()
+{
+}
+
+
+//============================================================================
+// DlgEditor
+//============================================================================
+
+void DlgEditor::ShowDialog()
+{
+ uno::Reference< lang::XMultiServiceFactory > xMSF = getProcessServiceFactory();
+
+ // create a dialog
+ uno::Reference< awt::XControl > xDlg( xMSF->createInstance( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlDialog" ) ) ), uno::UNO_QUERY );
+
+ // clone the dialog model
+ uno::Reference< util::XCloneable > xC( m_xUnoControlDialogModel, uno::UNO_QUERY );
+ uno::Reference< util::XCloneable > xNew = xC->createClone();
+ uno::Reference< awt::XControlModel > xDlgMod( xNew, uno::UNO_QUERY );
+
+ uno::Reference< beans::XPropertySet > xSrcDlgModPropSet( m_xUnoControlDialogModel, uno::UNO_QUERY );
+ uno::Reference< beans::XPropertySet > xNewDlgModPropSet( xDlgMod, uno::UNO_QUERY );
+ if( xNewDlgModPropSet.is() )
+ {
+ if( xSrcDlgModPropSet.is() )
+ {
+ try
+ {
+ Any aResourceResolver = xSrcDlgModPropSet->getPropertyValue( aResourceResolverPropName );
+ xNewDlgModPropSet->setPropertyValue( aResourceResolverPropName, aResourceResolver );
+ }
+ catch( UnknownPropertyException& )
+ {
+ OSL_FAIL( "DlgEditor::ShowDialog(): No ResourceResolver property" );
+ }
+ }
+
+ // Disable decoration
+ bool bDecoration = true;
+ try
+ {
+ Any aDecorationAny = xSrcDlgModPropSet->getPropertyValue( aDecorationPropName );
+ aDecorationAny >>= bDecoration;
+ if( !bDecoration )
+ {
+ xNewDlgModPropSet->setPropertyValue( aDecorationPropName, makeAny( true ) );
+ xNewDlgModPropSet->setPropertyValue( aTitlePropName, makeAny( ::rtl::OUString() ) );
+ }
+ }
+ catch( UnknownPropertyException& )
+ {}
+ }
+
+ // set the model
+ xDlg->setModel( xDlgMod );
+
+ // create a peer
+ uno::Reference< awt::XToolkit> xToolkit( xMSF->createInstance( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.ExtToolkit" ) ) ), uno::UNO_QUERY );
+ xDlg->createPeer( xToolkit, pWindow->GetComponentInterface() );
+
+ uno::Reference< awt::XDialog > xD( xDlg, uno::UNO_QUERY );
+ xD->execute();
+
+ uno::Reference< lang::XComponent > xComponent(xDlg, uno::UNO_QUERY);
+ if (xComponent.is())
+ xComponent->dispose();
+}
+
+
+sal_Bool DlgEditor::UnmarkDialog()
+{
+ SdrObject* pDlgObj = pDlgEdModel->GetPage(0)->GetObj(0);
+ SdrPageView* pPgView = pDlgEdView->GetSdrPageView();
+
+ sal_Bool bWasMarked = pDlgEdView->IsObjMarked( pDlgObj );
+
+ if( bWasMarked )
+ pDlgEdView->MarkObj( pDlgObj, pPgView, sal_True );
+
+ return bWasMarked;
+}
+
+
+sal_Bool DlgEditor::RemarkDialog()
+{
+ SdrObject* pDlgObj = pDlgEdModel->GetPage(0)->GetObj(0);
+ SdrPageView* pPgView = pDlgEdView->GetSdrPageView();
+
+ sal_Bool bWasMarked = pDlgEdView->IsObjMarked( pDlgObj );
+
+ if( !bWasMarked )
+ pDlgEdView->MarkObj( pDlgObj, pPgView, sal_False );
+
+ return bWasMarked;
+}
+
+
+DlgEditor::DlgEditor( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& xModel )
+ :pHScroll(NULL)
+ ,pVScroll(NULL)
+ ,pDlgEdModel(NULL)
+ ,pDlgEdPage(NULL)
+ ,pDlgEdView(NULL)
+ ,pDlgEdForm(NULL)
+ ,m_xUnoControlDialogModel(NULL)
+ ,m_ClipboardDataFlavors(1)
+ ,m_ClipboardDataFlavorsResource(2)
+ ,pObjFac(NULL)
+ ,pWindow(NULL)
+ ,pFunc(NULL)
+ ,eMode( DLGED_SELECT )
+ ,eActObj( OBJ_DLG_PUSHBUTTON )
+ ,bFirstDraw(sal_False)
+ ,aGridSize( 100, 100 ) // 100TH_MM
+ ,bGridVisible(sal_False)
+ ,bGridSnap(sal_True)
+ ,bCreateOK(sal_True)
+ ,bDialogModelChanged(sal_False)
+ ,mnPaintGuard(0)
+ ,m_xDocument( xModel )
+{
+ pDlgEdModel = new DlgEdModel();
+ pDlgEdModel->GetItemPool().FreezeIdRanges();
+ pDlgEdModel->SetScaleUnit( MAP_100TH_MM );
+
+ SdrLayerAdmin& rAdmin = pDlgEdModel->GetLayerAdmin();
+ rAdmin.NewLayer( rAdmin.GetControlLayerName() );
+ rAdmin.NewLayer( UniString::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM( "HiddenLayer" ) ) );
+
+ pDlgEdPage = new DlgEdPage( *pDlgEdModel );
+ pDlgEdModel->InsertPage( pDlgEdPage );
+
+ pObjFac = new DlgEdFactory();
+
+ pFunc = new DlgEdFuncSelect( this );
+
+ // set clipboard data flavors
+ m_ClipboardDataFlavors[0].MimeType = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "application/vnd.sun.xml.dialog" ));
+ m_ClipboardDataFlavors[0].HumanPresentableName = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Dialog 6.0" ));
+ m_ClipboardDataFlavors[0].DataType = ::getCppuType( (const Sequence< sal_Int8 >*) 0 );
+
+ m_ClipboardDataFlavorsResource[0] = m_ClipboardDataFlavors[0];
+ m_ClipboardDataFlavorsResource[1].MimeType = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "application/vnd.sun.xml.dialogwithresource" ));
+ m_ClipboardDataFlavorsResource[1].HumanPresentableName = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Dialog 8.0" ));
+ m_ClipboardDataFlavorsResource[1].DataType = ::getCppuType( (const Sequence< sal_Int8 >*) 0 );
+
+ aPaintTimer.SetTimeout( 1 );
+ aPaintTimer.SetTimeoutHdl( LINK( this, DlgEditor, PaintTimeout ) );
+
+ aMarkTimer.SetTimeout( 100 );
+ aMarkTimer.SetTimeoutHdl( LINK( this, DlgEditor, MarkTimeout ) );
+}
+
+
+DlgEditor::~DlgEditor()
+{
+ aPaintTimer.Stop();
+ aMarkTimer.Stop();
+
+ ::comphelper::disposeComponent( m_xControlContainer );
+
+ delete pObjFac;
+ delete pFunc;
+ delete pDlgEdView;
+ delete pDlgEdModel;
+}
+
+
+Reference< awt::XControlContainer > DlgEditor::GetWindowControlContainer()
+{
+ if ( !m_xControlContainer.is() && pWindow )
+ m_xControlContainer = VCLUnoHelper::CreateControlContainer( pWindow );
+ return m_xControlContainer;
+}
+
+
+void DlgEditor::SetWindow( Window* pWindow_ )
+{
+ DlgEditor::pWindow = pWindow_;
+ pWindow_->SetMapMode( MapMode( MAP_100TH_MM ) );
+ pDlgEdPage->SetSize( pWindow_->PixelToLogic( Size( DLGED_PAGE_WIDTH_MIN, DLGED_PAGE_HEIGHT_MIN ) ) );
+
+ pDlgEdView = new DlgEdView( pDlgEdModel, pWindow_, this );
+ pDlgEdView->ShowSdrPage(pDlgEdView->GetModel()->GetPage(0));
+ pDlgEdView->SetLayerVisible( UniString::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM( "HiddenLayer" ) ), sal_False );
+ pDlgEdView->SetMoveSnapOnlyTopLeft( sal_True );
+ pDlgEdView->SetWorkArea( Rectangle( Point( 0, 0 ), pDlgEdPage->GetSize() ) );
+
+ pDlgEdView->SetGridCoarse( aGridSize );
+ pDlgEdView->SetSnapGridWidth(Fraction(aGridSize.Width(), 1), Fraction(aGridSize.Height(), 1));
+ pDlgEdView->SetGridSnap( bGridSnap );
+ pDlgEdView->SetGridVisible( bGridVisible );
+ pDlgEdView->SetDragStripes( sal_False );
+
+ pDlgEdView->SetDesignMode( sal_True );
+
+ ::comphelper::disposeComponent( m_xControlContainer );
+}
+
+
+void DlgEditor::SetScrollBars( ScrollBar* pHS, ScrollBar* pVS )
+{
+ pHScroll = pHS;
+ pVScroll = pVS;
+
+ InitScrollBars();
+}
+
+
+void DlgEditor::InitScrollBars()
+{
+ DBG_ASSERT( pHScroll, "DlgEditor::InitScrollBars: no horizontal scroll bar!" );
+ DBG_ASSERT( pVScroll, "DlgEditor::InitScrollBars: no vertical scroll bar!" );
+ if ( !pHScroll || !pVScroll )
+ return;
+
+ Size aOutSize = pWindow->GetOutputSize();
+ Size aPgSize = pDlgEdPage->GetSize();
+
+ pHScroll->SetRange( Range( 0, aPgSize.Width() ));
+ pVScroll->SetRange( Range( 0, aPgSize.Height() ));
+ pHScroll->SetVisibleSize( (sal_uLong)aOutSize.Width() );
+ pVScroll->SetVisibleSize( (sal_uLong)aOutSize.Height() );
+
+ pHScroll->SetLineSize( aOutSize.Width() / 10 );
+ pVScroll->SetLineSize( aOutSize.Height() / 10 );
+ pHScroll->SetPageSize( aOutSize.Width() / 2 );
+ pVScroll->SetPageSize( aOutSize.Height() / 2 );
+
+ DoScroll( pHScroll );
+ DoScroll( pVScroll );
+}
+
+
+void DlgEditor::DoScroll( ScrollBar* )
+{
+ if( !pHScroll || !pVScroll )
+ return;
+
+ MapMode aMap = pWindow->GetMapMode();
+ Point aOrg = aMap.GetOrigin();
+
+ Size aScrollPos( pHScroll->GetThumbPos(), pVScroll->GetThumbPos() );
+ aScrollPos = pWindow->LogicToPixel( aScrollPos );
+ aScrollPos = pWindow->PixelToLogic( aScrollPos );
+
+ long nX = aScrollPos.Width() + aOrg.X();
+ long nY = aScrollPos.Height() + aOrg.Y();
+
+ if( !nX && !nY )
+ return;
+
+ pWindow->Update();
+
+ // #i31562#
+ // When scrolling, someone was rescuing the Wallpaper and forced the window scroll to
+ // be done without background refresh. I do not know why, but that causes the repaint
+ // problems. Taking that out.
+ // Wallpaper aOldBackground = pWindow->GetBackground();
+ // pWindow->SetBackground();
+
+ // #i74769# children should be scrolled
+ pWindow->Scroll( -nX, -nY, SCROLL_CHILDREN);
+ aMap.SetOrigin( Point( -aScrollPos.Width(), -aScrollPos.Height() ) );
+ pWindow->SetMapMode( aMap );
+ pWindow->Update();
+
+ DlgEdHint aHint( DLGED_HINT_WINDOWSCROLLED );
+ Broadcast( aHint );
+}
+
+
+void DlgEditor::UpdateScrollBars()
+{
+ MapMode aMap = pWindow->GetMapMode();
+ Point aOrg = aMap.GetOrigin();
+
+ if ( pHScroll )
+ pHScroll->SetThumbPos( -aOrg.X() );
+
+ if ( pVScroll )
+ pVScroll->SetThumbPos( -aOrg.Y() );
+}
+
+
+void DlgEditor::SetDialog( uno::Reference< container::XNameContainer > xUnoControlDialogModel )
+{
+ // set dialog model
+ m_xUnoControlDialogModel = xUnoControlDialogModel;
+
+ // create dialog form
+ pDlgEdForm = new DlgEdForm();
+ uno::Reference< awt::XControlModel > xDlgMod( m_xUnoControlDialogModel , uno::UNO_QUERY );
+ pDlgEdForm->SetUnoControlModel(xDlgMod);
+ pDlgEdForm->SetDlgEditor( this );
+ ((DlgEdPage*)pDlgEdModel->GetPage(0))->SetDlgEdForm( pDlgEdForm );
+ pDlgEdModel->GetPage(0)->InsertObject( pDlgEdForm );
+ AdjustPageSize();
+ pDlgEdForm->SetRectFromProps();
+ pDlgEdForm->UpdateTabIndices(); // for backward compatibility
+ pDlgEdForm->StartListening();
+
+ // create controls
+ Reference< ::com::sun::star::container::XNameAccess > xNameAcc( m_xUnoControlDialogModel, UNO_QUERY );
+ if ( xNameAcc.is() )
+ {
+ // get sequence of control names
+ Sequence< ::rtl::OUString > aNames = xNameAcc->getElementNames();
+ const ::rtl::OUString* pNames = aNames.getConstArray();
+ sal_Int32 nCtrls = aNames.getLength();
+
+ // create a map of tab indices and control names, sorted by tab index
+ IndexToNameMap aIndexToNameMap;
+ for ( sal_Int32 i = 0; i < nCtrls; ++i )
+ {
+ // get name
+ ::rtl::OUString aName( pNames[i] );
+
+ // get tab index
+ sal_Int16 nTabIndex = -1;
+ Any aCtrl = xNameAcc->getByName( aName );
+ Reference< ::com::sun::star::beans::XPropertySet > xPSet;
+ aCtrl >>= xPSet;
+ if ( xPSet.is() )
+ xPSet->getPropertyValue( DLGED_PROP_TABINDEX ) >>= nTabIndex;
+
+ // insert into map
+ aIndexToNameMap.insert( IndexToNameMap::value_type( nTabIndex, aName ) );
+ }
+
+ // create controls and insert them into drawing page
+ for ( IndexToNameMap::iterator aIt = aIndexToNameMap.begin(); aIt != aIndexToNameMap.end(); ++aIt )
+ {
+ Any aCtrl = xNameAcc->getByName( aIt->second );
+ Reference< ::com::sun::star::awt::XControlModel > xCtrlModel;
+ aCtrl >>= xCtrlModel;
+ DlgEdObj* pCtrlObj = new DlgEdObj();
+ pCtrlObj->SetUnoControlModel( xCtrlModel );
+ pCtrlObj->SetDlgEdForm( pDlgEdForm );
+ pDlgEdForm->AddChild( pCtrlObj );
+ pDlgEdModel->GetPage(0)->InsertObject( pCtrlObj );
+ pCtrlObj->SetRectFromProps();
+ pCtrlObj->UpdateStep();
+ pCtrlObj->StartListening();
+ }
+ }
+
+ bFirstDraw = sal_True;
+
+ pDlgEdModel->SetChanged( sal_False );
+}
+
+void DlgEditor::ResetDialog( void )
+{
+ DlgEdForm* pOldDlgEdForm = pDlgEdForm;
+ DlgEdPage* pPage = (DlgEdPage*)pDlgEdModel->GetPage(0);
+ SdrPageView* pPgView = pDlgEdView->GetSdrPageView();
+ sal_Bool bWasMarked = pDlgEdView->IsObjMarked( pOldDlgEdForm );
+ pDlgEdView->UnmarkAll();
+ pPage->Clear();
+ pPage->SetDlgEdForm( NULL );
+ SetDialog( m_xUnoControlDialogModel );
+ if( bWasMarked )
+ pDlgEdView->MarkObj( pDlgEdForm, pPgView, sal_False );
+}
+
+
+Reference< util::XNumberFormatsSupplier > const & DlgEditor::GetNumberFormatsSupplier()
+{
+ if ( !m_xSupplier.is() )
+ {
+ Reference< lang::XMultiServiceFactory > xMSF = ::comphelper::getProcessServiceFactory();
+ Reference< util::XNumberFormatsSupplier > xSupplier( xMSF->createInstance(
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.util.NumberFormatsSupplier") ) ), UNO_QUERY );
+
+ ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
+ if ( !m_xSupplier.is() )
+ {
+ m_xSupplier = xSupplier;
+ }
+ }
+ return m_xSupplier;
+}
+
+
+void DlgEditor::MouseButtonDown( const MouseEvent& rMEvt )
+{
+ if( pWindow )
+ pWindow->GrabFocus();
+ pFunc->MouseButtonDown( rMEvt );
+}
+
+
+void DlgEditor::MouseButtonUp( const MouseEvent& rMEvt )
+{
+ sal_Bool bRet = pFunc->MouseButtonUp( rMEvt );
+
+ if( (eMode == DLGED_INSERT) )
+ bCreateOK = bRet;
+}
+
+
+void DlgEditor::MouseMove( const MouseEvent& rMEvt )
+{
+ pFunc->MouseMove( rMEvt );
+}
+
+
+sal_Bool DlgEditor::KeyInput( const KeyEvent& rKEvt )
+{
+ return pFunc->KeyInput( rKEvt );
+}
+
+
+void DlgEditor::Paint( const Rectangle& rRect )
+{
+ aPaintRect = rRect;
+ PaintTimeout( &aPaintTimer );
+}
+
+
+IMPL_LINK( DlgEditor, PaintTimeout, Timer *, EMPTYARG )
+{
+ if( !pDlgEdView )
+ return 0;
+
+ mnPaintGuard++;
+
+ Size aMacSize;
+ if( bFirstDraw &&
+ pWindow->IsVisible() &&
+ (pWindow->GetOutputSize() != aMacSize) )
+ {
+ bFirstDraw = sal_False;
+
+ // get property set
+ ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > xPSet(pDlgEdForm->GetUnoControlModel(), ::com::sun::star::uno::UNO_QUERY);
+
+ if ( xPSet.is() )
+ {
+ // get dialog size from properties
+ sal_Int32 nWidth = 0, nHeight = 0;
+ xPSet->getPropertyValue( DLGED_PROP_WIDTH ) >>= nWidth;
+ xPSet->getPropertyValue( DLGED_PROP_HEIGHT ) >>= nHeight;
+
+ if ( nWidth == 0 && nHeight == 0 )
+ {
+ Size aSize = pWindow->PixelToLogic( Size( 400, 300 ) );
+
+ // align with grid
+ Size aGridSize_(long(pDlgEdView->GetSnapGridWidthX()), long(pDlgEdView->GetSnapGridWidthY()));
+ aSize.Width() -= aSize.Width() % aGridSize_.Width();
+ aSize.Height() -= aSize.Height() % aGridSize_.Height();
+
+ Point aPos;
+ Size aOutSize = pWindow->GetOutputSize();
+ aPos.X() = (aOutSize.Width()>>1) - (aSize.Width()>>1);
+ aPos.Y() = (aOutSize.Height()>>1) - (aSize.Height()>>1);
+
+ // align with grid
+ aPos.X() -= aPos.X() % aGridSize_.Width();
+ aPos.Y() -= aPos.Y() % aGridSize_.Height();
+
+ // don't put in the corner
+ Point aMinPos = pWindow->PixelToLogic( Point( 30, 20 ) );
+ if( (aPos.X() < aMinPos.X()) || (aPos.Y() < aMinPos.Y()) )
+ {
+ aPos = aMinPos;
+ aPos.X() -= aPos.X() % aGridSize_.Width();
+ aPos.Y() -= aPos.Y() % aGridSize_.Height();
+ }
+
+ // set dialog position and size
+ pDlgEdForm->SetSnapRect( Rectangle( aPos, aSize ) );
+ pDlgEdForm->EndListening(sal_False);
+ pDlgEdForm->SetPropsFromRect();
+ pDlgEdForm->GetDlgEditor()->SetDialogModelChanged(sal_True);
+ pDlgEdForm->StartListening();
+
+ // set position and size of controls
+ sal_uLong nObjCount;
+ if ( pDlgEdPage && ( ( nObjCount = pDlgEdPage->GetObjCount() ) > 0 ) )
+ {
+ for ( sal_uLong i = 0 ; i < nObjCount ; i++ )
+ {
+ SdrObject* pObj = pDlgEdPage->GetObj(i);
+ DlgEdObj* pDlgEdObj = PTR_CAST(DlgEdObj, pObj);
+ if ( pDlgEdObj && !pDlgEdObj->ISA(DlgEdForm) )
+ pDlgEdObj->SetRectFromProps();
+ }
+ }
+ }
+ }
+ }
+
+ // repaint, get PageView and prepare Region
+ SdrPageView* pPgView = pDlgEdView->GetSdrPageView();
+ const Region aPaintRectRegion(aPaintRect);
+
+
+ // #i74769#
+ SdrPaintWindow* pTargetPaintWindow = 0;
+
+ // mark repaint start
+ if(pPgView)
+ {
+ pTargetPaintWindow = pPgView->GetView().BeginDrawLayers(pWindow, aPaintRectRegion);
+ OSL_ENSURE(pTargetPaintWindow, "BeginDrawLayers: Got no SdrPaintWindow (!)");
+ }
+
+ // draw background self using wallpaper
+ // #i79128# ...and use correct OutDev for that
+ if(pTargetPaintWindow)
+ {
+ OutputDevice& rTargetOutDev = pTargetPaintWindow->GetTargetOutputDevice();
+ rTargetOutDev.DrawWallpaper(aPaintRect, Wallpaper(Color(COL_WHITE)));
+ }
+
+ // do paint (unbuffered) and mark repaint end
+ if(pPgView)
+ {
+ // paint of control layer is done in EndDrawLayers anyway...
+ pPgView->GetView().EndDrawLayers(*pTargetPaintWindow, true);
+ }
+
+ mnPaintGuard--;
+
+ DBG_ASSERT(pWindow,"Window not set");
+ return 0;
+}
+
+
+IMPL_LINK( DlgEditor, MarkTimeout, Timer *, EMPTYARG )
+{
+ BasicIDEShell* pIDEShell = IDE_DLL()->GetShell();
+
+ SfxViewFrame* pViewFrame = pIDEShell ? pIDEShell->GetViewFrame() : NULL;
+ SfxChildWindow* pChildWin = pViewFrame ? pViewFrame->GetChildWindow( SID_SHOW_PROPERTYBROWSER ) : NULL;
+ if ( !pChildWin )
+ return 0L;
+
+ ((PropBrw*)(pChildWin->GetWindow()))->Update( pIDEShell );
+
+ return 1;
+}
+
+
+void DlgEditor::SetMode( DlgEdMode eNewMode )
+{
+ if ( eNewMode != eMode )
+ {
+ delete pFunc;
+
+ if ( eNewMode == DLGED_INSERT )
+ pFunc = new DlgEdFuncInsert( this );
+ else
+ pFunc = new DlgEdFuncSelect( this );
+
+ if ( eNewMode == DLGED_READONLY )
+ pDlgEdModel->SetReadOnly( sal_True );
+ else
+ pDlgEdModel->SetReadOnly( sal_False );
+ }
+
+ if ( eNewMode == DLGED_TEST )
+ ShowDialog();
+
+ eMode = eNewMode;
+}
+
+
+void DlgEditor::SetInsertObj( sal_uInt16 eObj )
+{
+ eActObj = eObj;
+
+ if( pDlgEdView )
+ pDlgEdView->SetCurrentObj( eActObj, DlgInventor );
+}
+
+
+sal_uInt16 DlgEditor::GetInsertObj() const
+{
+ return eActObj;
+}
+
+
+void DlgEditor::CreateDefaultObject()
+{
+ // create object by factory
+ SdrObject* pObj = SdrObjFactory::MakeNewObject( pDlgEdView->GetCurrentObjInventor(), pDlgEdView->GetCurrentObjIdentifier(), pDlgEdPage );
+
+ DlgEdObj* pDlgEdObj = PTR_CAST( DlgEdObj, pObj );
+ if ( pDlgEdObj )
+ {
+ // set position and size
+ Size aSize = pWindow->PixelToLogic( Size( 96, 24 ) );
+ Point aPoint = (pDlgEdForm->GetSnapRect()).Center();
+ aPoint.X() -= aSize.Width() / 2;
+ aPoint.Y() -= aSize.Height() / 2;
+ pDlgEdObj->SetSnapRect( Rectangle( aPoint, aSize ) );
+
+ // set default property values
+ pDlgEdObj->SetDefaults();
+
+ // insert object into drawing page
+ SdrPageView* pPageView = pDlgEdView->GetSdrPageView();
+ pDlgEdView->InsertObjectAtView( pDlgEdObj, *pPageView);
+
+ // start listening
+ pDlgEdObj->StartListening();
+ }
+}
+
+
+void DlgEditor::Cut()
+{
+ Copy();
+ Delete();
+}
+
+
+void implCopyStreamToByteSequence( Reference< XInputStream > xStream,
+ Sequence< sal_Int8 >& bytes )
+{
+ sal_Int32 nRead = xStream->readBytes( bytes, xStream->available() );
+ for (;;)
+ {
+ Sequence< sal_Int8 > readBytes;
+ nRead = xStream->readBytes( readBytes, 1024 );
+ if (! nRead)
+ break;
+
+ sal_Int32 nPos = bytes.getLength();
+ bytes.realloc( nPos + nRead );
+ ::rtl_copyMemory( bytes.getArray() + nPos, readBytes.getConstArray(), (sal_uInt32)nRead );
+ }
+}
+
+void DlgEditor::Copy()
+{
+ if( !pDlgEdView->AreObjectsMarked() )
+ return;
+
+ // stop all drawing actions
+ pDlgEdView->BrkAction();
+
+ // create an empty clipboard dialog model
+ Reference< util::XCloneable > xClone( m_xUnoControlDialogModel, UNO_QUERY );
+ Reference< util::XCloneable > xNewClone = xClone->createClone();
+ Reference< container::XNameContainer > xClipDialogModel( xNewClone, UNO_QUERY );
+
+ Reference< container::XNameAccess > xNAcc( xClipDialogModel, UNO_QUERY );
+ if ( xNAcc.is() )
+ {
+ Sequence< OUString > aNames = xNAcc->getElementNames();
+ const OUString* pNames = aNames.getConstArray();
+ sal_uInt32 nCtrls = aNames.getLength();
+
+ for ( sal_uInt32 n = 0; n < nCtrls; n++ )
+ {
+ xClipDialogModel->removeByName( pNames[n] );
+ }
+ }
+
+ // insert control models of marked objects into clipboard dialog model
+ sal_uLong nMark = pDlgEdView->GetMarkedObjectList().GetMarkCount();
+ for( sal_uLong i = 0; i < nMark; i++ )
+ {
+ SdrObject* pObj = pDlgEdView->GetMarkedObjectList().GetMark(i)->GetMarkedSdrObj();
+ DlgEdObj* pDlgEdObj = PTR_CAST(DlgEdObj, pObj);
+
+ if (pDlgEdObj && !pDlgEdObj->ISA(DlgEdForm) )
+ {
+ ::rtl::OUString aName;
+ Reference< beans::XPropertySet > xMarkPSet(pDlgEdObj->GetUnoControlModel(), uno::UNO_QUERY);
+ if (xMarkPSet.is())
+ {
+ xMarkPSet->getPropertyValue( DLGED_PROP_NAME ) >>= aName;
+ }
+
+ Reference< container::XNameAccess > xNameAcc(m_xUnoControlDialogModel, UNO_QUERY );
+ if ( xNameAcc.is() && xNameAcc->hasByName(aName) )
+ {
+ Any aCtrl = xNameAcc->getByName( aName );
+
+ // clone control model
+ Reference< util::XCloneable > xCtrl;
+ aCtrl >>= xCtrl;
+ Reference< util::XCloneable > xNewCtrl = xCtrl->createClone();
+ Any aNewCtrl;
+ aNewCtrl <<= xNewCtrl;
+
+ if (xClipDialogModel.is())
+ xClipDialogModel->insertByName( aName , aNewCtrl );
+ }
+ }
+ }
+
+ // export clipboard dialog model to xml
+ Reference< XComponentContext > xContext;
+ Reference< beans::XPropertySet > xProps( ::comphelper::getProcessServiceFactory(), UNO_QUERY );
+ OSL_ASSERT( xProps.is() );
+ OSL_VERIFY( xProps->getPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("DefaultContext")) ) >>= xContext );
+ Reference< XInputStreamProvider > xISP = ::xmlscript::exportDialogModel( xClipDialogModel, xContext, m_xDocument );
+ Reference< XInputStream > xStream( xISP->createInputStream() );
+ Sequence< sal_Int8 > DialogModelBytes;
+ implCopyStreamToByteSequence( xStream, DialogModelBytes );
+ xStream->closeInput();
+
+ // set clipboard content
+ Reference< datatransfer::clipboard::XClipboard > xClipboard = GetWindow()->GetClipboard();
+ if ( xClipboard.is() )
+ {
+ // With resource?
+ uno::Reference< beans::XPropertySet > xDialogModelPropSet( m_xUnoControlDialogModel, uno::UNO_QUERY );
+ uno::Reference< resource::XStringResourcePersistence > xStringResourcePersistence;
+ if( xDialogModelPropSet.is() )
+ {
+ try
+ {
+ Any aResourceResolver = xDialogModelPropSet->getPropertyValue( aResourceResolverPropName );
+ aResourceResolver >>= xStringResourcePersistence;
+ }
+ catch( UnknownPropertyException& )
+ {}
+ }
+
+ DlgEdTransferableImpl* pTrans = NULL;
+ if( xStringResourcePersistence.is() )
+ {
+ // With resource, support old and new format
+
+ // Export xClipDialogModel another time with ids replaced by current language string
+ uno::Reference< resource::XStringResourceManager >
+ xStringResourceManager( xStringResourcePersistence, uno::UNO_QUERY );
+ LocalizationMgr::resetResourceForDialog( xClipDialogModel, xStringResourceManager );
+ Reference< XInputStreamProvider > xISP2 = ::xmlscript::exportDialogModel( xClipDialogModel, xContext, m_xDocument );
+ Reference< XInputStream > xStream2( xISP2->createInputStream() );
+ Sequence< sal_Int8 > NoResourceDialogModelBytes;
+ implCopyStreamToByteSequence( xStream2, NoResourceDialogModelBytes );
+ xStream2->closeInput();
+
+ // Old format contains dialog with replaced ids
+ Sequence< Any > aSeqData(2);
+ Any aNoResourceDialogModelBytesAny;
+ aNoResourceDialogModelBytesAny <<= NoResourceDialogModelBytes;
+ aSeqData[0] = aNoResourceDialogModelBytesAny;
+
+ // New format contains dialog and resource
+ Sequence< sal_Int8 > aResData = xStringResourcePersistence->exportBinary();
+
+ // Create sequence for combined dialog and resource
+ sal_Int32 nDialogDataLen = DialogModelBytes.getLength();
+ sal_Int32 nResDataLen = aResData.getLength();
+
+ // Combined data = 4 Bytes 32Bit Offset to begin of resource data, lowest byte first
+ // + nDialogDataLen bytes dialog data + nResDataLen resource data
+ sal_Int32 nTotalLen = 4 + nDialogDataLen + nResDataLen;
+ sal_Int32 nResOffset = 4 + nDialogDataLen;
+ Sequence< sal_Int8 > aCombinedData( nTotalLen );
+ sal_Int8* pCombinedData = aCombinedData.getArray();
+
+ // Write offset
+ sal_Int32 n = nResOffset;
+ for( sal_Int16 i = 0 ; i < 4 ; i++ )
+ {
+ pCombinedData[i] = sal_Int8( n & 0xff );
+ n >>= 8;
+ }
+ ::rtl_copyMemory( pCombinedData + 4, DialogModelBytes.getConstArray(), nDialogDataLen );
+ ::rtl_copyMemory( pCombinedData + nResOffset, aResData.getConstArray(), nResDataLen );
+
+ Any aCombinedDataAny;
+ aCombinedDataAny <<= aCombinedData;
+ aSeqData[1] = aCombinedDataAny;
+
+ pTrans = new DlgEdTransferableImpl( m_ClipboardDataFlavorsResource, aSeqData );
+ }
+ else
+ {
+ // No resource, support only old format
+ Sequence< Any > aSeqData(1);
+ Any aDialogModelBytesAny;
+ aDialogModelBytesAny <<= DialogModelBytes;
+ aSeqData[0] = aDialogModelBytesAny;
+ pTrans = new DlgEdTransferableImpl( m_ClipboardDataFlavors , aSeqData );
+ }
+ const sal_uInt32 nRef = Application::ReleaseSolarMutex();
+ xClipboard->setContents( pTrans , pTrans );
+ Application::AcquireSolarMutex( nRef );
+ }
+}
+
+
+void DlgEditor::Paste()
+{
+ // stop all drawing actions
+ pDlgEdView->BrkAction();
+
+ // unmark all objects
+ pDlgEdView->UnmarkAll();
+
+ // get clipboard
+ Reference< datatransfer::clipboard::XClipboard > xClipboard = GetWindow()->GetClipboard();
+ if ( xClipboard.is() )
+ {
+ // get clipboard content
+ const sal_uInt32 nRef = Application::ReleaseSolarMutex();
+ Reference< datatransfer::XTransferable > xTransf = xClipboard->getContents();
+ Application::AcquireSolarMutex( nRef );
+ if ( xTransf.is() )
+ {
+ // Is target dialog (library) localized?
+ uno::Reference< beans::XPropertySet > xDialogModelPropSet( m_xUnoControlDialogModel, uno::UNO_QUERY );
+ uno::Reference< resource::XStringResourceManager > xStringResourceManager;
+ if( xDialogModelPropSet.is() )
+ {
+ try
+ {
+ Any aResourceResolver = xDialogModelPropSet->getPropertyValue( aResourceResolverPropName );
+ aResourceResolver >>= xStringResourceManager;
+ }
+ catch( UnknownPropertyException& )
+ {}
+ }
+ bool bLocalized = false;
+ if( xStringResourceManager.is() )
+ bLocalized = ( xStringResourceManager->getLocales().getLength() > 0 );
+
+ if ( xTransf->isDataFlavorSupported( m_ClipboardDataFlavors[0] ) )
+ {
+ // create clipboard dialog model from xml
+ Reference< lang::XMultiServiceFactory > xMSF = getProcessServiceFactory();
+ Reference< container::XNameContainer > xClipDialogModel( xMSF->createInstance
+ ( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlDialogModel" ) ) ),
+ uno::UNO_QUERY );
+
+ bool bSourceIsLocalized = false;
+ Sequence< sal_Int8 > DialogModelBytes;
+ Sequence< sal_Int8 > aResData;
+ if( bLocalized && xTransf->isDataFlavorSupported( m_ClipboardDataFlavorsResource[1] ) )
+ {
+ bSourceIsLocalized = true;
+
+ Any aCombinedDataAny = xTransf->getTransferData( m_ClipboardDataFlavorsResource[1] );
+ Sequence< sal_Int8 > aCombinedData;
+ aCombinedDataAny >>= aCombinedData;
+ const sal_Int8* pCombinedData = aCombinedData.getConstArray();
+
+ sal_Int32 nTotalLen = aCombinedData.getLength();
+
+ // Reading offset
+ sal_Int32 nResOffset = 0;
+ sal_Int32 nFactor = 1;
+ for( sal_Int16 i = 0; i < 4; i++ )
+ {
+ nResOffset += nFactor * sal_uInt8( pCombinedData[i] );
+ nFactor *= 256;
+ }
+
+ sal_Int32 nResDataLen = nTotalLen - nResOffset;
+ sal_Int32 nDialogDataLen = nTotalLen - nResDataLen - 4;
+
+ DialogModelBytes.realloc( nDialogDataLen );
+ ::rtl_copyMemory( DialogModelBytes.getArray(), pCombinedData + 4, nDialogDataLen );
+
+ aResData.realloc( nResDataLen );
+ ::rtl_copyMemory( aResData.getArray(), pCombinedData + nResOffset, nResDataLen );
+ }
+ else
+ {
+ Any aAny = xTransf->getTransferData( m_ClipboardDataFlavors[0] );
+ aAny >>= DialogModelBytes;
+ }
+
+ if ( xClipDialogModel.is() )
+ {
+ Reference< XComponentContext > xContext;
+ Reference< beans::XPropertySet > xProps( xMSF, UNO_QUERY );
+ OSL_ASSERT( xProps.is() );
+ OSL_VERIFY( xProps->getPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("DefaultContext")) ) >>= xContext );
+ ::xmlscript::importDialogModel( ::xmlscript::createInputStream( rtl::ByteSequence(DialogModelBytes.getArray(), DialogModelBytes.getLength()) ) , xClipDialogModel, xContext, m_xDocument );
+ }
+
+ // get control models from clipboard dialog model
+ Reference< ::com::sun::star::container::XNameAccess > xNameAcc( xClipDialogModel, UNO_QUERY );
+ if ( xNameAcc.is() )
+ {
+ Sequence< OUString > aNames = xNameAcc->getElementNames();
+ const OUString* pNames = aNames.getConstArray();
+ sal_uInt32 nCtrls = aNames.getLength();
+
+ Reference< resource::XStringResourcePersistence > xStringResourcePersistence;
+ if( nCtrls > 0 && bSourceIsLocalized )
+ {
+ Reference< lang::XMultiServiceFactory > xSMgr = getProcessServiceFactory();
+ xStringResourcePersistence = Reference< resource::XStringResourcePersistence >( xSMgr->createInstance
+ ( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.resource.StringResource" )) ), UNO_QUERY );
+ if( xStringResourcePersistence.is() )
+ xStringResourcePersistence->importBinary( aResData );
+ }
+ for( sal_uInt32 n = 0; n < nCtrls; n++ )
+ {
+ Any aA = xNameAcc->getByName( pNames[n] );
+ Reference< ::com::sun::star::awt::XControlModel > xCM;
+ aA >>= xCM;
+
+ // clone the control model
+ Reference< util::XCloneable > xClone( xCM, uno::UNO_QUERY );
+ Reference< awt::XControlModel > xCtrlModel( xClone->createClone(), uno::UNO_QUERY );
+
+ DlgEdObj* pCtrlObj = new DlgEdObj();
+ pCtrlObj->SetDlgEdForm(pDlgEdForm); // set parent form
+ pDlgEdForm->AddChild(pCtrlObj); // add child to parent form
+ pCtrlObj->SetUnoControlModel( xCtrlModel ); // set control model
+
+ // set new name
+ ::rtl::OUString aOUniqueName( pCtrlObj->GetUniqueName() );
+ Reference< beans::XPropertySet > xPSet( xCtrlModel , UNO_QUERY );
+ Any aUniqueName;
+ aUniqueName <<= aOUniqueName;
+ xPSet->setPropertyValue( DLGED_PROP_NAME, aUniqueName );
+
+ // set tabindex
+ Reference< container::XNameAccess > xNA( m_xUnoControlDialogModel , UNO_QUERY );
+ Sequence< OUString > aNames_ = xNA->getElementNames();
+ Any aTabIndex;
+ aTabIndex <<= (sal_Int16) aNames_.getLength();
+ xPSet->setPropertyValue( DLGED_PROP_TABINDEX, aTabIndex );
+
+ if( bLocalized )
+ {
+ Any aControlAny;
+ aControlAny <<= xCtrlModel;
+ if( bSourceIsLocalized && xStringResourcePersistence.is() )
+ {
+ Reference< resource::XStringResourceResolver >
+ xSourceStringResolver( xStringResourcePersistence, UNO_QUERY );
+ LocalizationMgr::copyResourcesForPastedEditorObject( this,
+ aControlAny, aOUniqueName, xSourceStringResolver );
+ }
+ else
+ {
+ LocalizationMgr::setControlResourceIDsForNewEditorObject
+ ( this, aControlAny, aOUniqueName );
+ }
+ }
+
+ // insert control model in editor dialog model
+ Any aCtrlModel;
+ aCtrlModel <<= xCtrlModel;
+ m_xUnoControlDialogModel->insertByName( aOUniqueName , aCtrlModel );
+
+ // insert object into drawing page
+ pDlgEdModel->GetPage(0)->InsertObject( pCtrlObj );
+ pCtrlObj->SetRectFromProps();
+ pCtrlObj->UpdateStep();
+ pDlgEdForm->UpdateTabOrderAndGroups();
+ pCtrlObj->StartListening(); // start listening
+
+ // mark object
+ SdrPageView* pPgView = pDlgEdView->GetSdrPageView();
+ pDlgEdView->MarkObj( pCtrlObj, pPgView, sal_False, sal_True);
+ }
+
+ // center marked objects in dialog editor form
+ Point aMarkCenter = (pDlgEdView->GetMarkedObjRect()).Center();
+ Point aFormCenter = (pDlgEdForm->GetSnapRect()).Center();
+ Point aPoint = aFormCenter - aMarkCenter;
+ Size aSize( aPoint.X() , aPoint.Y() );
+ pDlgEdView->MoveMarkedObj( aSize ); // update of control model properties (position + size) in NbcMove
+ pDlgEdView->MarkListHasChanged();
+
+ // dialog model changed
+ SetDialogModelChanged(sal_True);
+ }
+ }
+ }
+ }
+}
+
+
+void DlgEditor::Delete()
+{
+ if( !pDlgEdView->AreObjectsMarked() )
+ return;
+
+ // remove control models of marked objects from dialog model
+ sal_uLong nMark = pDlgEdView->GetMarkedObjectList().GetMarkCount();
+
+ for( sal_uLong i = 0; i < nMark; i++ )
+ {
+ SdrObject* pObj = pDlgEdView->GetMarkedObjectList().GetMark(i)->GetMarkedSdrObj();
+ DlgEdObj* pDlgEdObj = PTR_CAST(DlgEdObj, pObj);
+
+ if ( pDlgEdObj && !pDlgEdObj->ISA(DlgEdForm) )
+ {
+ // get name from property
+ ::rtl::OUString aName;
+ uno::Reference< beans::XPropertySet > xPSet(pDlgEdObj->GetUnoControlModel(), uno::UNO_QUERY);
+ if (xPSet.is())
+ {
+ xPSet->getPropertyValue( DLGED_PROP_NAME ) >>= aName;
+ }
+
+ // remove control from dialog model
+ Reference< ::com::sun::star::container::XNameAccess > xNameAcc(pDlgEdObj->GetDlgEdForm()->GetUnoControlModel(), UNO_QUERY );
+ if ( xNameAcc.is() && xNameAcc->hasByName(aName) )
+ {
+ Reference< ::com::sun::star::container::XNameContainer > xCont(xNameAcc, UNO_QUERY );
+ if ( xCont.is() )
+ {
+ if( xCont->hasByName( aName ) )
+ {
+ Any aAny = xCont->getByName( aName );
+ LocalizationMgr::deleteControlResourceIDsForDeletedEditorObject( this, aAny, aName );
+ }
+ xCont->removeByName( aName );
+ }
+ }
+
+ // remove child from parent form
+ pDlgEdForm->RemoveChild( pDlgEdObj );
+ }
+ }
+
+ // update tab indices
+ pDlgEdForm->UpdateTabIndices();
+
+ pDlgEdView->BrkAction();
+
+ sal_Bool bDlgMarked = UnmarkDialog();
+ pDlgEdView->DeleteMarked();
+ if( bDlgMarked )
+ RemarkDialog();
+}
+
+
+sal_Bool DlgEditor::IsPasteAllowed()
+{
+ sal_Bool bPaste = sal_False;
+
+ // get clipboard
+ Reference< datatransfer::clipboard::XClipboard > xClipboard = GetWindow()->GetClipboard();
+ if ( xClipboard.is() )
+ {
+ // get clipboard content
+ const sal_uInt32 nRef = Application::ReleaseSolarMutex();
+ Reference< datatransfer::XTransferable > xTransf = xClipboard->getContents();
+ Application::AcquireSolarMutex( nRef );
+ if ( xTransf.is() )
+ {
+ if ( xTransf->isDataFlavorSupported( m_ClipboardDataFlavors[0] ) )
+ {
+ bPaste = sal_True;
+ }
+ }
+ }
+
+ return bPaste;
+}
+
+
+void DlgEditor::ShowProperties()
+{
+ BasicIDEShell* pIDEShell = IDE_DLL()->GetShell();
+ SfxViewFrame* pViewFrame = pIDEShell ? pIDEShell->GetViewFrame() : NULL;
+ if ( pViewFrame && !pViewFrame->HasChildWindow( SID_SHOW_PROPERTYBROWSER ) )
+ pViewFrame->ToggleChildWindow( SID_SHOW_PROPERTYBROWSER );
+}
+
+
+void DlgEditor::UpdatePropertyBrowserDelayed()
+{
+ aMarkTimer.Start();
+}
+
+
+sal_Bool DlgEditor::IsModified() const
+{
+ return pDlgEdModel->IsChanged() || bDialogModelChanged;
+}
+
+
+void DlgEditor::ClearModifyFlag()
+{
+ pDlgEdModel->SetChanged( sal_False );
+ bDialogModelChanged = sal_False;
+}
+
+
+#define LMARGPRN 1700
+#define RMARGPRN 900
+#define TMARGPRN 2000
+#define BMARGPRN 1000
+#define BORDERPRN 300
+
+
+void lcl_PrintHeader( Printer* pPrinter, const String& rTitle ) // not working yet
+{
+ pPrinter->Push();
+
+ short nLeftMargin = LMARGPRN;
+ Size aSz = pPrinter->GetOutputSize();
+ short nBorder = BORDERPRN;
+
+ pPrinter->SetLineColor( COL_BLACK );
+ pPrinter->SetFillColor();
+
+ Font aFont( pPrinter->GetFont() );
+ aFont.SetWeight( WEIGHT_BOLD );
+ aFont.SetAlign( ALIGN_BOTTOM );
+ pPrinter->SetFont( aFont );
+
+ long nFontHeight = pPrinter->GetTextHeight();
+
+ // 1.Border => Strich, 2+3 Border = Freiraum.
+ long nYTop = TMARGPRN-3*nBorder-nFontHeight;
+
+ long nXLeft = nLeftMargin-nBorder;
+ long nXRight = aSz.Width()-RMARGPRN+nBorder;
+
+ pPrinter->DrawRect( Rectangle(
+ Point( nXLeft, nYTop ),
+ Size( nXRight-nXLeft, aSz.Height() - nYTop - BMARGPRN + nBorder ) ) );
+
+ long nY = TMARGPRN-2*nBorder;
+ Point aPos( nLeftMargin, nY );
+ pPrinter->DrawText( aPos, rTitle );
+
+ nY = TMARGPRN-nBorder;
+
+ pPrinter->DrawLine( Point( nXLeft, nY ), Point( nXRight, nY ) );
+
+ pPrinter->Pop();
+}
+
+
+sal_Int32 DlgEditor::countPages( Printer* )
+{
+ return 1;
+}
+
+void DlgEditor::printPage( sal_Int32 nPage, Printer* pPrinter, const String& rTitle )
+{
+ if( nPage == 0 )
+ Print( pPrinter, rTitle );
+}
+
+
+void DlgEditor::Print( Printer* pPrinter, const String& rTitle ) // not working yet
+{
+ if( pDlgEdView )
+ {
+ MapMode aOldMap( pPrinter->GetMapMode());
+ Font aOldFont( pPrinter->GetFont() );
+
+ MapMode aMap( MAP_100TH_MM );
+ pPrinter->SetMapMode( aMap );
+ Font aFont;
+ aFont.SetAlign( ALIGN_BOTTOM );
+ aFont.SetSize( Size( 0, 360 ));
+ pPrinter->SetFont( aFont );
+
+ Size aPaperSz = pPrinter->GetOutputSize();
+ aPaperSz.Width() -= (LMARGPRN+RMARGPRN);
+ aPaperSz.Height() -= (TMARGPRN+BMARGPRN);
+
+ lcl_PrintHeader( pPrinter, rTitle );
+
+ Bitmap aDlg;
+#ifdef OS2
+ Bitmap* pDlg = new Bitmap;
+ SvMemoryStream* pStrm = new SvMemoryStream;
+ *pStrm << *pDlg;
+ delete pDlg;
+ pStrm->Seek(0);
+ *pStrm >> aDlg;
+ delete pStrm;
+#endif
+ Size aBmpSz( pPrinter->PixelToLogic( aDlg.GetSizePixel() ) );
+ double nPaperSzWidth = aPaperSz.Width();
+ double nPaperSzHeight = aPaperSz.Height();
+ double nBmpSzWidth = aBmpSz.Width();
+ double nBmpSzHeight = aBmpSz.Height();
+ double nScaleX = (nPaperSzWidth / nBmpSzWidth );
+ double nScaleY = (nPaperSzHeight / nBmpSzHeight );
+
+ Size aOutputSz;
+ if( nBmpSzHeight * nScaleX <= nPaperSzHeight )
+ {
+ aOutputSz.Width() = (long)(((double)nBmpSzWidth) * nScaleX);
+ aOutputSz.Height() = (long)(((double)nBmpSzHeight) * nScaleX);
+ }
+ else
+ {
+ aOutputSz.Width() = (long)(((double)nBmpSzWidth) * nScaleY);
+ aOutputSz.Height() = (long)(((double)nBmpSzHeight) * nScaleY);
+ }
+
+ Point aPosOffs(
+ (aPaperSz.Width() / 2) - (aOutputSz.Width() / 2),
+ (aPaperSz.Height()/ 2) - (aOutputSz.Height() / 2));
+
+ aPosOffs.X() += LMARGPRN;
+ aPosOffs.Y() += TMARGPRN;
+
+ pPrinter->DrawBitmap( aPosOffs, aOutputSz, aDlg );
+
+ pPrinter->SetMapMode( aOldMap );
+ pPrinter->SetFont( aOldFont );
+ }
+}
+
+
+bool DlgEditor::AdjustPageSize()
+{
+ bool bAdjustedPageSize = false;
+ Reference< beans::XPropertySet > xPSet( m_xUnoControlDialogModel, UNO_QUERY );
+ if ( xPSet.is() )
+ {
+ sal_Int32 nFormXIn = 0, nFormYIn = 0, nFormWidthIn = 0, nFormHeightIn = 0;
+ xPSet->getPropertyValue( DLGED_PROP_POSITIONX ) >>= nFormXIn;
+ xPSet->getPropertyValue( DLGED_PROP_POSITIONY ) >>= nFormYIn;
+ xPSet->getPropertyValue( DLGED_PROP_WIDTH ) >>= nFormWidthIn;
+ xPSet->getPropertyValue( DLGED_PROP_HEIGHT ) >>= nFormHeightIn;
+
+ sal_Int32 nFormX, nFormY, nFormWidth, nFormHeight;
+ if ( pDlgEdForm && pDlgEdForm->TransformFormToSdrCoordinates( nFormXIn, nFormYIn, nFormWidthIn, nFormHeightIn, nFormX, nFormY, nFormWidth, nFormHeight ) )
+ {
+ Size aPageSizeDelta( 400, 300 );
+ DBG_ASSERT( pWindow, "DlgEditor::AdjustPageSize: no window!" );
+ if ( pWindow )
+ aPageSizeDelta = pWindow->PixelToLogic( aPageSizeDelta, MapMode( MAP_100TH_MM ) );
+
+ sal_Int32 nNewPageWidth = nFormX + nFormWidth + aPageSizeDelta.Width();
+ sal_Int32 nNewPageHeight = nFormY + nFormHeight + aPageSizeDelta.Height();
+
+ Size aPageSizeMin( DLGED_PAGE_WIDTH_MIN, DLGED_PAGE_HEIGHT_MIN );
+ DBG_ASSERT( pWindow, "DlgEditor::AdjustPageSize: no window!" );
+ if ( pWindow )
+ aPageSizeMin = pWindow->PixelToLogic( aPageSizeMin, MapMode( MAP_100TH_MM ) );
+ sal_Int32 nPageWidthMin = aPageSizeMin.Width();
+ sal_Int32 nPageHeightMin = aPageSizeMin.Height();
+
+ if ( nNewPageWidth < nPageWidthMin )
+ nNewPageWidth = nPageWidthMin;
+
+ if ( nNewPageHeight < nPageHeightMin )
+ nNewPageHeight = nPageHeightMin;
+
+ if ( pDlgEdPage )
+ {
+ Size aPageSize = pDlgEdPage->GetSize();
+ if ( nNewPageWidth != aPageSize.Width() || nNewPageHeight != aPageSize.Height() )
+ {
+ Size aNewPageSize( nNewPageWidth, nNewPageHeight );
+ pDlgEdPage->SetSize( aNewPageSize );
+ DBG_ASSERT( pDlgEdView, "DlgEditor::AdjustPageSize: no view!" );
+ if ( pDlgEdView )
+ pDlgEdView->SetWorkArea( Rectangle( Point( 0, 0 ), aNewPageSize ) );
+ bAdjustedPageSize = true;
+ }
+ }
+ }
+ }
+
+ return bAdjustedPageSize;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/basctl/source/dlged/dlgedclip.cxx b/basctl/source/dlged/dlgedclip.cxx
new file mode 100644
index 000000000000..17392b2510ac
--- /dev/null
+++ b/basctl/source/dlged/dlgedclip.cxx
@@ -0,0 +1,151 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_basctl.hxx"
+#include "dlgedclip.hxx"
+#include <osl/mutex.hxx>
+#include <vcl/svapp.hxx>
+#include <comphelper/processfactory.hxx>
+#include <com/sun/star/datatransfer/XMimeContentType.hpp>
+#include <com/sun/star/datatransfer/XMimeContentTypeFactory.hpp>
+
+
+using namespace comphelper;
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::io;
+using namespace ::com::sun::star::datatransfer;
+using namespace ::com::sun::star::datatransfer::clipboard;
+
+
+//----------------------------------------------------------------------------
+
+DlgEdTransferableImpl::DlgEdTransferableImpl( const Sequence< DataFlavor >& aSeqFlavors, const Sequence< Any >& aSeqData )
+{
+ m_SeqFlavors = aSeqFlavors;
+ m_SeqData = aSeqData;
+}
+
+//----------------------------------------------------------------------------
+
+DlgEdTransferableImpl::~DlgEdTransferableImpl()
+{
+}
+
+//----------------------------------------------------------------------------
+
+sal_Bool DlgEdTransferableImpl::compareDataFlavors( const DataFlavor& lFlavor, const DataFlavor& rFlavor )
+{
+ sal_Bool bRet = sal_False;
+
+ // compare mime content types
+ Reference< lang::XMultiServiceFactory > xMSF = getProcessServiceFactory();
+ Reference< datatransfer::XMimeContentTypeFactory >
+ xMCntTypeFactory( xMSF->createInstance( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.datatransfer.MimeContentTypeFactory" ) ) ), UNO_QUERY );
+
+ if ( xMCntTypeFactory.is( ) )
+ {
+ // compare full media types
+ Reference< datatransfer::XMimeContentType > xLType = xMCntTypeFactory->createMimeContentType( lFlavor.MimeType );
+ Reference< datatransfer::XMimeContentType > xRType = xMCntTypeFactory->createMimeContentType( rFlavor.MimeType );
+
+ ::rtl::OUString aLFullMediaType = xLType->getFullMediaType();
+ ::rtl::OUString aRFullMediaType = xRType->getFullMediaType();
+
+ bRet = aLFullMediaType.equalsIgnoreAsciiCase( aRFullMediaType );
+ }
+
+ return bRet;
+}
+
+// XTransferable
+//----------------------------------------------------------------------------
+
+Any SAL_CALL DlgEdTransferableImpl::getTransferData( const DataFlavor& rFlavor ) throw(UnsupportedFlavorException, IOException, RuntimeException)
+{
+ const SolarMutexGuard aGuard;
+
+ if ( !isDataFlavorSupported( rFlavor ) )
+ throw UnsupportedFlavorException();
+
+ Any aData;
+
+ for ( sal_Int32 i = 0; i < m_SeqFlavors.getLength(); i++ )
+ {
+ if ( compareDataFlavors( m_SeqFlavors[i] , rFlavor ) )
+ {
+ aData = m_SeqData[i];
+ break;
+ }
+ }
+
+ return aData;
+}
+
+//----------------------------------------------------------------------------
+
+Sequence< DataFlavor > SAL_CALL DlgEdTransferableImpl::getTransferDataFlavors( ) throw(RuntimeException)
+{
+ const SolarMutexGuard aGuard;
+
+ return m_SeqFlavors;
+}
+
+//----------------------------------------------------------------------------
+
+sal_Bool SAL_CALL DlgEdTransferableImpl::isDataFlavorSupported( const DataFlavor& rFlavor ) throw(RuntimeException)
+{
+ const SolarMutexGuard aGuard;
+
+ sal_Bool bRet = sal_False;
+
+ for ( sal_Int32 i = 0; i < m_SeqFlavors.getLength(); i++ )
+ {
+ if ( compareDataFlavors( m_SeqFlavors[i] , rFlavor ) )
+ {
+ bRet = sal_True;
+ break;
+ }
+ }
+
+ return bRet;
+}
+
+// XClipboardOwner
+//----------------------------------------------------------------------------
+
+void SAL_CALL DlgEdTransferableImpl::lostOwnership( const Reference< XClipboard >&, const Reference< XTransferable >& ) throw(RuntimeException)
+{
+ const SolarMutexGuard aGuard;
+
+ m_SeqFlavors = Sequence< DataFlavor >();
+ m_SeqData = Sequence< Any >();
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/basctl/source/dlged/dlgedfac.cxx b/basctl/source/dlged/dlgedfac.cxx
new file mode 100644
index 000000000000..9659dda143ed
--- /dev/null
+++ b/basctl/source/dlged/dlgedfac.cxx
@@ -0,0 +1,198 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_basctl.hxx"
+
+
+#include "dlgedfac.hxx"
+#include "dlgedobj.hxx"
+#include <dlgeddef.hxx>
+#include <com/sun/star/container/XNameContainer.hpp>
+#include <com/sun/star/beans/PropertyValue.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/awt/ScrollBarOrientation.hpp>
+
+using namespace ::com::sun::star;
+
+
+DlgEdFactory::DlgEdFactory()
+{
+ SdrObjFactory::InsertMakeObjectHdl( LINK(this, DlgEdFactory, MakeObject) );
+}
+
+
+DlgEdFactory::~DlgEdFactory()
+{
+ SdrObjFactory::RemoveMakeObjectHdl( LINK(this, DlgEdFactory, MakeObject) );
+}
+
+
+IMPL_LINK( DlgEdFactory, MakeObject, SdrObjFactory *, pObjFactory )
+{
+ static sal_Bool bNeedsInit = sal_True;
+ static uno::Reference< lang::XMultiServiceFactory > xDialogSFact;
+
+ if( bNeedsInit )
+ {
+ uno::Reference< lang::XMultiServiceFactory > xMSF = ::comphelper::getProcessServiceFactory();
+ uno::Reference< container::XNameContainer > xC( xMSF->createInstance( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlDialogModel" ) ) ), uno::UNO_QUERY );
+ if( xC.is() )
+ {
+ uno::Reference< lang::XMultiServiceFactory > xModFact( xC, uno::UNO_QUERY );
+ xDialogSFact = xModFact;
+ }
+ bNeedsInit = sal_False;
+ }
+
+ if( (pObjFactory->nInventor == DlgInventor) &&
+ (pObjFactory->nIdentifier >= OBJ_DLG_PUSHBUTTON) &&
+ (pObjFactory->nIdentifier <= OBJ_DLG_TREECONTROL) )
+ {
+ switch( pObjFactory->nIdentifier )
+ {
+ case OBJ_DLG_PUSHBUTTON:
+ pObjFactory->pNewObj = new DlgEdObj( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlButtonModel" )) , xDialogSFact );
+ break;
+ case OBJ_DLG_RADIOBUTTON:
+ pObjFactory->pNewObj = new DlgEdObj( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlRadioButtonModel" )) , xDialogSFact );
+ break;
+ case OBJ_DLG_CHECKBOX:
+ pObjFactory->pNewObj = new DlgEdObj( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlCheckBoxModel" )) , xDialogSFact );
+ break;
+ case OBJ_DLG_LISTBOX:
+ pObjFactory->pNewObj = new DlgEdObj( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlListBoxModel" )) , xDialogSFact );
+ break;
+ case OBJ_DLG_COMBOBOX:
+ {
+ DlgEdObj* pNew = new DlgEdObj( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlComboBoxModel" )) , xDialogSFact );
+ pObjFactory->pNewObj = pNew;
+ try
+ {
+ uno::Reference< beans::XPropertySet > xPSet(pNew->GetUnoControlModel(), uno::UNO_QUERY);
+ if (xPSet.is())
+ {
+ sal_Bool bB = sal_True;
+ xPSet->setPropertyValue( DLGED_PROP_DROPDOWN, uno::Any(&bB,::getBooleanCppuType()));
+ }
+ }
+ catch(...)
+ {
+ }
+ } break;
+ case OBJ_DLG_GROUPBOX:
+ pObjFactory->pNewObj = new DlgEdObj( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlGroupBoxModel" )) , xDialogSFact );
+ break;
+ case OBJ_DLG_EDIT:
+ pObjFactory->pNewObj = new DlgEdObj( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlEditModel" )) , xDialogSFact );
+ break;
+ case OBJ_DLG_FIXEDTEXT:
+ pObjFactory->pNewObj = new DlgEdObj( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlFixedTextModel" )) , xDialogSFact );
+ break;
+ case OBJ_DLG_IMAGECONTROL:
+ pObjFactory->pNewObj = new DlgEdObj( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlImageControlModel" )) , xDialogSFact );
+ break;
+ case OBJ_DLG_PROGRESSBAR:
+ pObjFactory->pNewObj = new DlgEdObj( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlProgressBarModel" )) , xDialogSFact );
+ break;
+ case OBJ_DLG_HSCROLLBAR:
+ pObjFactory->pNewObj = new DlgEdObj( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlScrollBarModel" )) , xDialogSFact );
+ break;
+ case OBJ_DLG_VSCROLLBAR:
+ {
+ DlgEdObj* pNew = new DlgEdObj( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlScrollBarModel" )) , xDialogSFact );
+ pObjFactory->pNewObj = pNew;
+ // set vertical orientation
+ try
+ {
+ uno::Reference< beans::XPropertySet > xPSet(pNew->GetUnoControlModel(), uno::UNO_QUERY);
+ if (xPSet.is())
+ {
+ uno::Any aValue;
+ aValue <<= (sal_Int32) ::com::sun::star::awt::ScrollBarOrientation::VERTICAL;
+ xPSet->setPropertyValue( DLGED_PROP_ORIENTATION, aValue );
+ }
+ }
+ catch(...)
+ {
+ }
+ } break;
+ case OBJ_DLG_HFIXEDLINE:
+ pObjFactory->pNewObj = new DlgEdObj( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlFixedLineModel" )) , xDialogSFact );
+ break;
+ case OBJ_DLG_VFIXEDLINE:
+ {
+ DlgEdObj* pNew = new DlgEdObj( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlFixedLineModel" )) , xDialogSFact );
+ pObjFactory->pNewObj = pNew;
+ // set vertical orientation
+ try
+ {
+ uno::Reference< beans::XPropertySet > xPSet(pNew->GetUnoControlModel(), uno::UNO_QUERY);
+ if (xPSet.is())
+ {
+ uno::Any aValue;
+ aValue <<= (sal_Int32) 1;
+ xPSet->setPropertyValue( DLGED_PROP_ORIENTATION, aValue );
+ }
+ }
+ catch(...)
+ {
+ }
+ } break;
+ case OBJ_DLG_DATEFIELD:
+ pObjFactory->pNewObj = new DlgEdObj( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlDateFieldModel" )) , xDialogSFact );
+ break;
+ case OBJ_DLG_TIMEFIELD:
+ pObjFactory->pNewObj = new DlgEdObj( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlTimeFieldModel" )) , xDialogSFact );
+ break;
+ case OBJ_DLG_NUMERICFIELD:
+ pObjFactory->pNewObj = new DlgEdObj( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlNumericFieldModel" )) , xDialogSFact );
+ break;
+ case OBJ_DLG_CURRENCYFIELD:
+ pObjFactory->pNewObj = new DlgEdObj( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlCurrencyFieldModel" )) , xDialogSFact );
+ break;
+ case OBJ_DLG_FORMATTEDFIELD:
+ pObjFactory->pNewObj = new DlgEdObj( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlFormattedFieldModel" )) , xDialogSFact );
+ break;
+ case OBJ_DLG_PATTERNFIELD:
+ pObjFactory->pNewObj = new DlgEdObj( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlPatternFieldModel" )) , xDialogSFact );
+ break;
+ case OBJ_DLG_FILECONTROL:
+ pObjFactory->pNewObj = new DlgEdObj( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlFileControlModel" )) , xDialogSFact );
+ break;
+ case OBJ_DLG_TREECONTROL:
+ DlgEdObj* pNew = new DlgEdObj( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.tree.TreeControlModel" )) , xDialogSFact );
+ pObjFactory->pNewObj = pNew;
+ break;
+ }
+ }
+
+ return 0;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/basctl/source/dlged/dlgedfunc.cxx b/basctl/source/dlged/dlgedfunc.cxx
new file mode 100644
index 000000000000..607a286b2305
--- /dev/null
+++ b/basctl/source/dlged/dlgedfunc.cxx
@@ -0,0 +1,621 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_basctl.hxx"
+#include <vcl/scrbar.hxx>
+#include <svx/svdview.hxx>
+#include "dlgedfunc.hxx"
+#include "dlged.hxx"
+#include "dlgedview.hxx"
+#include <vcl/seleng.hxx>
+
+
+//----------------------------------------------------------------------------
+
+IMPL_LINK_INLINE_START( DlgEdFunc, ScrollTimeout, Timer *, pTimer )
+{
+ (void)pTimer;
+ Window* pWindow = pParent->GetWindow();
+ Point aPos = pWindow->ScreenToOutputPixel( pWindow->GetPointerPosPixel() );
+ aPos = pWindow->PixelToLogic( aPos );
+ ForceScroll( aPos );
+ return 0;
+}
+IMPL_LINK_INLINE_END( DlgEdFunc, ScrollTimeout, Timer *, pTimer )
+
+//----------------------------------------------------------------------------
+
+void DlgEdFunc::ForceScroll( const Point& rPos )
+{
+ aScrollTimer.Stop();
+
+ Window* pWindow = pParent->GetWindow();
+
+ static Point aDefPoint;
+ Rectangle aOutRect( aDefPoint, pWindow->GetOutputSizePixel() );
+ aOutRect = pWindow->PixelToLogic( aOutRect );
+
+ ScrollBar* pHScroll = pParent->GetHScroll();
+ ScrollBar* pVScroll = pParent->GetVScroll();
+ long nDeltaX = pHScroll->GetLineSize();
+ long nDeltaY = pVScroll->GetLineSize();
+
+ if( !aOutRect.IsInside( rPos ) )
+ {
+ if( rPos.X() < aOutRect.Left() )
+ nDeltaX = -nDeltaX;
+ else
+ if( rPos.X() <= aOutRect.Right() )
+ nDeltaX = 0;
+
+ if( rPos.Y() < aOutRect.Top() )
+ nDeltaY = -nDeltaY;
+ else
+ if( rPos.Y() <= aOutRect.Bottom() )
+ nDeltaY = 0;
+
+ if( nDeltaX )
+ pHScroll->SetThumbPos( pHScroll->GetThumbPos() + nDeltaX );
+ if( nDeltaY )
+ pVScroll->SetThumbPos( pVScroll->GetThumbPos() + nDeltaY );
+
+ if( nDeltaX )
+ pParent->DoScroll( pHScroll );
+ if( nDeltaY )
+ pParent->DoScroll( pVScroll );
+ }
+
+ aScrollTimer.Start();
+}
+
+//----------------------------------------------------------------------------
+
+DlgEdFunc::DlgEdFunc( DlgEditor* pParent_ )
+{
+ DlgEdFunc::pParent = pParent_;
+ aScrollTimer.SetTimeoutHdl( LINK( this, DlgEdFunc, ScrollTimeout ) );
+ aScrollTimer.SetTimeout( SELENG_AUTOREPEAT_INTERVAL );
+}
+
+//----------------------------------------------------------------------------
+
+DlgEdFunc::~DlgEdFunc()
+{
+}
+
+//----------------------------------------------------------------------------
+
+sal_Bool DlgEdFunc::MouseButtonDown( const MouseEvent& )
+{
+ return sal_True;
+}
+
+//----------------------------------------------------------------------------
+
+sal_Bool DlgEdFunc::MouseButtonUp( const MouseEvent& )
+{
+ aScrollTimer.Stop();
+ return sal_True;
+}
+
+//----------------------------------------------------------------------------
+
+sal_Bool DlgEdFunc::MouseMove( const MouseEvent& )
+{
+ return sal_True;
+}
+
+//----------------------------------------------------------------------------
+
+sal_Bool DlgEdFunc::KeyInput( const KeyEvent& rKEvt )
+{
+ sal_Bool bReturn = sal_False;
+
+ SdrView* pView = pParent->GetView();
+ Window* pWindow = pParent->GetWindow();
+
+ KeyCode aCode = rKEvt.GetKeyCode();
+ sal_uInt16 nCode = aCode.GetCode();
+
+ switch ( nCode )
+ {
+ case KEY_ESCAPE:
+ {
+ if ( pView->IsAction() )
+ {
+ pView->BrkAction();
+ bReturn = sal_True;
+ }
+ else if ( pView->AreObjectsMarked() )
+ {
+ const SdrHdlList& rHdlList = pView->GetHdlList();
+ SdrHdl* pHdl = rHdlList.GetFocusHdl();
+ if ( pHdl )
+ ((SdrHdlList&)rHdlList).ResetFocusHdl();
+ else
+ pView->UnmarkAll();
+
+ bReturn = sal_True;
+ }
+ }
+ break;
+ case KEY_TAB:
+ {
+ if ( !aCode.IsMod1() && !aCode.IsMod2() )
+ {
+ // mark next object
+ if ( !pView->MarkNextObj( !aCode.IsShift() ) )
+ {
+ // if no next object, mark first/last
+ pView->UnmarkAllObj();
+ pView->MarkNextObj( !aCode.IsShift() );
+ }
+
+ if ( pView->AreObjectsMarked() )
+ pView->MakeVisible( pView->GetAllMarkedRect(), *pWindow );
+
+ bReturn = sal_True;
+ }
+ else if ( aCode.IsMod1() )
+ {
+ // selected handle
+ const SdrHdlList& rHdlList = pView->GetHdlList();
+ ((SdrHdlList&)rHdlList).TravelFocusHdl( !aCode.IsShift() );
+
+ // guarantee visibility of focused handle
+ SdrHdl* pHdl = rHdlList.GetFocusHdl();
+ if ( pHdl )
+ {
+ Point aHdlPosition( pHdl->GetPos() );
+ Rectangle aVisRect( aHdlPosition - Point( 100, 100 ), Size( 200, 200 ) );
+ pView->MakeVisible( aVisRect, *pWindow );
+ }
+
+ bReturn = sal_True;
+ }
+ }
+ break;
+ case KEY_UP:
+ case KEY_DOWN:
+ case KEY_LEFT:
+ case KEY_RIGHT:
+ {
+ long nX = 0;
+ long nY = 0;
+
+ if ( nCode == KEY_UP )
+ {
+ // scroll up
+ nX = 0;
+ nY = -1;
+ }
+ else if ( nCode == KEY_DOWN )
+ {
+ // scroll down
+ nX = 0;
+ nY = 1;
+ }
+ else if ( nCode == KEY_LEFT )
+ {
+ // scroll left
+ nX = -1;
+ nY = 0;
+ }
+ else if ( nCode == KEY_RIGHT )
+ {
+ // scroll right
+ nX = 1;
+ nY = 0;
+ }
+
+ if ( pView->AreObjectsMarked() && !aCode.IsMod1() )
+ {
+ if ( aCode.IsMod2() )
+ {
+ // move in 1 pixel distance
+ Size aPixelSize = pWindow ? pWindow->PixelToLogic( Size( 1, 1 ) ) : Size( 100, 100 );
+ nX *= aPixelSize.Width();
+ nY *= aPixelSize.Height();
+ }
+ else
+ {
+ // move in 1 mm distance
+ nX *= 100;
+ nY *= 100;
+ }
+
+ const SdrHdlList& rHdlList = pView->GetHdlList();
+ SdrHdl* pHdl = rHdlList.GetFocusHdl();
+
+ if ( pHdl == 0 )
+ {
+ // no handle selected
+ if ( pView->IsMoveAllowed() )
+ {
+ // restrict movement to work area
+ const Rectangle& rWorkArea = pView->GetWorkArea();
+
+ if ( !rWorkArea.IsEmpty() )
+ {
+ Rectangle aMarkRect( pView->GetMarkedObjRect() );
+ aMarkRect.Move( nX, nY );
+
+ if ( !rWorkArea.IsInside( aMarkRect ) )
+ {
+ if ( aMarkRect.Left() < rWorkArea.Left() )
+ nX += rWorkArea.Left() - aMarkRect.Left();
+
+ if ( aMarkRect.Right() > rWorkArea.Right() )
+ nX -= aMarkRect.Right() - rWorkArea.Right();
+
+ if ( aMarkRect.Top() < rWorkArea.Top() )
+ nY += rWorkArea.Top() - aMarkRect.Top();
+
+ if ( aMarkRect.Bottom() > rWorkArea.Bottom() )
+ nY -= aMarkRect.Bottom() - rWorkArea.Bottom();
+ }
+ }
+
+ if ( nX != 0 || nY != 0 )
+ {
+ pView->MoveAllMarked( Size( nX, nY ) );
+ pView->MakeVisible( pView->GetAllMarkedRect(), *pWindow );
+ }
+ }
+ }
+ else
+ {
+ // move the handle
+ if ( pHdl && ( nX || nY ) )
+ {
+ Point aStartPoint( pHdl->GetPos() );
+ Point aEndPoint( pHdl->GetPos() + Point( nX, nY ) );
+ const SdrDragStat& rDragStat = pView->GetDragStat();
+
+ // start dragging
+ pView->BegDragObj( aStartPoint, 0, pHdl, 0 );
+
+ if ( pView->IsDragObj() )
+ {
+ bool bWasNoSnap = rDragStat.IsNoSnap();
+ sal_Bool bWasSnapEnabled = pView->IsSnapEnabled();
+
+ // switch snapping off
+ if ( !bWasNoSnap )
+ ((SdrDragStat&)rDragStat).SetNoSnap( sal_True );
+ if ( bWasSnapEnabled )
+ pView->SetSnapEnabled( sal_False );
+
+ pView->MovAction( aEndPoint );
+ pView->EndDragObj();
+
+ // restore snap
+ if ( !bWasNoSnap )
+ ((SdrDragStat&)rDragStat).SetNoSnap( bWasNoSnap );
+ if ( bWasSnapEnabled )
+ pView->SetSnapEnabled( bWasSnapEnabled );
+ }
+
+ // make moved handle visible
+ Rectangle aVisRect( aEndPoint - Point( 100, 100 ), Size( 200, 200 ) );
+ pView->MakeVisible( aVisRect, *pWindow );
+ }
+ }
+ }
+ else
+ {
+ // scroll page
+ ScrollBar* pScrollBar = ( nX != 0 ) ? pParent->GetHScroll() : pParent->GetVScroll();
+ if ( pScrollBar )
+ {
+ long nRangeMin = pScrollBar->GetRangeMin();
+ long nRangeMax = pScrollBar->GetRangeMax();
+ long nThumbPos = pScrollBar->GetThumbPos() + ( ( nX != 0 ) ? nX : nY ) * pScrollBar->GetLineSize();
+ if ( nThumbPos < nRangeMin )
+ nThumbPos = nRangeMin;
+ if ( nThumbPos > nRangeMax )
+ nThumbPos = nRangeMax;
+ pScrollBar->SetThumbPos( nThumbPos );
+ pParent->DoScroll( pScrollBar );
+ }
+ }
+
+ bReturn = sal_True;
+ }
+ break;
+ default:
+ {
+ }
+ break;
+ }
+
+ if ( bReturn )
+ pWindow->ReleaseMouse();
+
+ return bReturn;
+}
+
+//----------------------------------------------------------------------------
+
+DlgEdFuncInsert::DlgEdFuncInsert( DlgEditor* pParent_ ) :
+ DlgEdFunc( pParent_ )
+{
+ pParent_->GetView()->SetCreateMode( sal_True );
+}
+
+//----------------------------------------------------------------------------
+
+DlgEdFuncInsert::~DlgEdFuncInsert()
+{
+ pParent->GetView()->SetEditMode( sal_True );
+}
+
+//----------------------------------------------------------------------------
+
+sal_Bool DlgEdFuncInsert::MouseButtonDown( const MouseEvent& rMEvt )
+{
+ if( !rMEvt.IsLeft() )
+ return sal_True;
+
+ SdrView* pView = pParent->GetView();
+ Window* pWindow= pParent->GetWindow();
+ pView->SetActualWin( pWindow );
+
+ Point aPos = pWindow->PixelToLogic( rMEvt.GetPosPixel() );
+ sal_uInt16 nHitLog = sal_uInt16 ( pWindow->PixelToLogic(Size(3,0)).Width() );
+ sal_uInt16 nDrgLog = sal_uInt16 ( pWindow->PixelToLogic(Size(3,0)).Width() );
+
+ pWindow->CaptureMouse();
+
+ if ( rMEvt.IsLeft() && rMEvt.GetClicks() == 1 )
+ {
+ SdrHdl* pHdl = pView->PickHandle(aPos);
+
+ // if selected object was hit, drag object
+ if ( pHdl!=NULL || pView->IsMarkedHit(aPos, nHitLog) )
+ pView->BegDragObj(aPos, (OutputDevice*) NULL, pHdl, nDrgLog);
+ else if ( pView->AreObjectsMarked() )
+ pView->UnmarkAll();
+
+ // if no action, create object
+ if ( !pView->IsAction() )
+ pView->BegCreateObj(aPos);
+ }
+ else if ( rMEvt.IsLeft() && rMEvt.GetClicks() == 2 )
+ {
+ // if object was hit, show property browser
+ if ( pView->IsMarkedHit(aPos, nHitLog) && pParent->GetMode() != DLGED_READONLY )
+ pParent->ShowProperties();
+ }
+
+ return sal_True;
+}
+
+//----------------------------------------------------------------------------
+
+sal_Bool DlgEdFuncInsert::MouseButtonUp( const MouseEvent& rMEvt )
+{
+ DlgEdFunc::MouseButtonUp( rMEvt );
+
+ SdrView* pView = pParent->GetView();
+ Window* pWindow= pParent->GetWindow();
+ pView->SetActualWin( pWindow );
+
+ pWindow->ReleaseMouse();
+
+ // object creation active?
+ if ( pView->IsCreateObj() )
+ {
+ pView->EndCreateObj(SDRCREATE_FORCEEND);
+
+ if ( !pView->AreObjectsMarked() )
+ {
+ sal_uInt16 nHitLog = sal_uInt16 ( pWindow->PixelToLogic(Size(3,0)).Width() );
+ Point aPos( pWindow->PixelToLogic( rMEvt.GetPosPixel() ) );
+ pView->MarkObj(aPos, nHitLog);
+ }
+
+ if( pView->AreObjectsMarked() )
+ return sal_True;
+ else
+ return sal_False;
+ }
+ else
+ {
+ if ( pView->IsDragObj() )
+ pView->EndDragObj( rMEvt.IsMod1() );
+ return sal_True;
+ }
+}
+
+//----------------------------------------------------------------------------
+
+sal_Bool DlgEdFuncInsert::MouseMove( const MouseEvent& rMEvt )
+{
+ SdrView* pView = pParent->GetView();
+ Window* pWindow= pParent->GetWindow();
+ pView->SetActualWin( pWindow );
+
+ Point aPos( pWindow->PixelToLogic( rMEvt.GetPosPixel() ) );
+ sal_uInt16 nHitLog = sal_uInt16 ( pWindow->PixelToLogic(Size(3,0)).Width() );
+
+ if ( pView->IsAction() )
+ {
+ ForceScroll(aPos);
+ pView->MovAction(aPos);
+ }
+
+ pWindow->SetPointer( pView->GetPreferedPointer( aPos, pWindow, nHitLog ) );
+
+ return sal_True;
+}
+
+//----------------------------------------------------------------------------
+
+DlgEdFuncSelect::DlgEdFuncSelect( DlgEditor* pParent_ ) :
+ DlgEdFunc( pParent_ ),
+ bMarkAction(sal_False)
+{
+}
+
+//----------------------------------------------------------------------------
+
+DlgEdFuncSelect::~DlgEdFuncSelect()
+{
+}
+
+//----------------------------------------------------------------------------
+
+sal_Bool DlgEdFuncSelect::MouseButtonDown( const MouseEvent& rMEvt )
+{
+ // get view from parent
+ SdrView* pView = pParent->GetView();
+ Window* pWindow = pParent->GetWindow();
+ pView->SetActualWin( pWindow );
+
+ sal_uInt16 nDrgLog = sal_uInt16 ( pWindow->PixelToLogic(Size(3,0)).Width() );
+ sal_uInt16 nHitLog = sal_uInt16 ( pWindow->PixelToLogic(Size(3,0)).Width() );
+ Point aMDPos = pWindow->PixelToLogic( rMEvt.GetPosPixel() );
+
+ if ( rMEvt.IsLeft() && rMEvt.GetClicks() == 1 )
+ {
+ SdrHdl* pHdl = pView->PickHandle(aMDPos);
+ SdrObject* pObj;
+ SdrPageView* pPV;
+
+ // hit selected object?
+ if ( pHdl!=NULL || pView->IsMarkedHit(aMDPos, nHitLog) )
+ {
+ pView->BegDragObj(aMDPos, (OutputDevice*) NULL, pHdl, nDrgLog);
+ }
+ else
+ {
+ // if not multi selection, unmark all
+ if ( !rMEvt.IsShift() )
+ pView->UnmarkAll();
+ else
+ {
+ if( pView->PickObj( aMDPos, nHitLog, pObj, pPV ) )
+ {
+ //if( pObj->ISA( DlgEdForm ) )
+ // pView->UnmarkAll();
+ //else
+ // pParent->UnmarkDialog();
+ }
+ }
+
+ if ( pView->MarkObj(aMDPos, nHitLog) )
+ {
+ // drag object
+ pHdl=pView->PickHandle(aMDPos);
+ pView->BegDragObj(aMDPos, (OutputDevice*) NULL, pHdl, nDrgLog);
+ }
+ else
+ {
+ // select object
+ pView->BegMarkObj(aMDPos);
+ bMarkAction = sal_True;
+ }
+ }
+ }
+ else if ( rMEvt.IsLeft() && rMEvt.GetClicks() == 2 )
+ {
+ // if object was hit, show property browser
+ if ( pView->IsMarkedHit(aMDPos, nHitLog) && pParent->GetMode() != DLGED_READONLY )
+ pParent->ShowProperties();
+ }
+
+ return sal_True;
+}
+
+//----------------------------------------------------------------------------
+
+sal_Bool DlgEdFuncSelect::MouseButtonUp( const MouseEvent& rMEvt )
+{
+ DlgEdFunc::MouseButtonUp( rMEvt );
+
+ // get view from parent
+ SdrView* pView = pParent->GetView();
+ Window* pWindow= pParent->GetWindow();
+ pView->SetActualWin( pWindow );
+
+ Point aPnt( pWindow->PixelToLogic( rMEvt.GetPosPixel() ) );
+ sal_uInt16 nHitLog = sal_uInt16 ( pWindow->PixelToLogic(Size(3,0)).Width() );
+
+ if ( rMEvt.IsLeft() )
+ {
+ if ( pView->IsDragObj() )
+ {
+ // object was dragged
+ pView->EndDragObj( rMEvt.IsMod1() );
+ pView->ForceMarkedToAnotherPage();
+ }
+ else
+ if (pView->IsAction() )
+ {
+ pView->EndAction();
+ }
+ }
+
+ bMarkAction = sal_False;
+
+ pWindow->SetPointer( pView->GetPreferedPointer( aPnt, pWindow, nHitLog ) );
+ pWindow->ReleaseMouse();
+
+ return sal_True;
+}
+
+//----------------------------------------------------------------------------
+
+sal_Bool DlgEdFuncSelect::MouseMove( const MouseEvent& rMEvt )
+{
+ SdrView* pView = pParent->GetView();
+ Window* pWindow= pParent->GetWindow();
+ pView->SetActualWin( pWindow );
+
+ Point aPnt( pWindow->PixelToLogic( rMEvt.GetPosPixel() ) );
+ sal_uInt16 nHitLog = sal_uInt16 ( pWindow->PixelToLogic(Size(3,0)).Width() );
+
+ if ( pView->IsAction() )
+ {
+ Point aPix(rMEvt.GetPosPixel());
+ Point aPnt_(pWindow->PixelToLogic(aPix));
+
+ ForceScroll(aPnt_);
+ pView->MovAction(aPnt_);
+ }
+
+ pWindow->SetPointer( pView->GetPreferedPointer( aPnt, pWindow, nHitLog ) );
+
+ return sal_True;
+}
+
+//----------------------------------------------------------------------------
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/basctl/source/dlged/dlgedlist.cxx b/basctl/source/dlged/dlgedlist.cxx
new file mode 100644
index 000000000000..1cef4b9762ba
--- /dev/null
+++ b/basctl/source/dlged/dlgedlist.cxx
@@ -0,0 +1,116 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_basctl.hxx"
+#include "dlgedlist.hxx"
+#include "dlgedobj.hxx"
+
+//============================================================================
+// DlgEdPropListenerImpl
+//============================================================================
+
+//----------------------------------------------------------------------------
+
+DlgEdPropListenerImpl::DlgEdPropListenerImpl(DlgEdObj* pObj)
+ :pDlgEdObj(pObj)
+{
+}
+
+//----------------------------------------------------------------------------
+
+DlgEdPropListenerImpl::~DlgEdPropListenerImpl()
+{
+}
+
+// XEventListener
+//----------------------------------------------------------------------------
+
+void SAL_CALL DlgEdPropListenerImpl::disposing( const ::com::sun::star::lang::EventObject& ) throw( ::com::sun::star::uno::RuntimeException)
+{
+}
+
+// XPropertyChangeListener
+//----------------------------------------------------------------------------
+
+void SAL_CALL DlgEdPropListenerImpl::propertyChange( const ::com::sun::star::beans::PropertyChangeEvent& evt ) throw( ::com::sun::star::uno::RuntimeException)
+{
+ pDlgEdObj->_propertyChange( evt );
+}
+
+//----------------------------------------------------------------------------
+
+//============================================================================
+// DlgEdEvtContListenerImpl
+//============================================================================
+
+//----------------------------------------------------------------------------
+
+DlgEdEvtContListenerImpl::DlgEdEvtContListenerImpl(DlgEdObj* pObj)
+ :pDlgEdObj(pObj)
+{
+}
+
+//----------------------------------------------------------------------------
+
+DlgEdEvtContListenerImpl::~DlgEdEvtContListenerImpl()
+{
+}
+
+// XEventListener
+//----------------------------------------------------------------------------
+
+void SAL_CALL DlgEdEvtContListenerImpl::disposing( const ::com::sun::star::lang::EventObject& ) throw( ::com::sun::star::uno::RuntimeException)
+{
+}
+
+// XContainerListener
+//----------------------------------------------------------------------------
+
+void SAL_CALL DlgEdEvtContListenerImpl::elementInserted(const ::com::sun::star::container::ContainerEvent& Event) throw(::com::sun::star::uno::RuntimeException)
+{
+ pDlgEdObj->_elementInserted( Event );
+}
+
+//----------------------------------------------------------------------------
+
+void SAL_CALL DlgEdEvtContListenerImpl::elementReplaced(const ::com::sun::star::container::ContainerEvent& Event) throw(::com::sun::star::uno::RuntimeException)
+{
+ pDlgEdObj->_elementReplaced( Event );
+}
+
+//----------------------------------------------------------------------------
+
+void SAL_CALL DlgEdEvtContListenerImpl::elementRemoved(const ::com::sun::star::container::ContainerEvent& Event) throw(::com::sun::star::uno::RuntimeException)
+{
+ pDlgEdObj->_elementRemoved( Event );
+}
+
+//----------------------------------------------------------------------------
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/basctl/source/dlged/dlgedmod.cxx b/basctl/source/dlged/dlgedmod.cxx
new file mode 100644
index 000000000000..ceb5555a1bc2
--- /dev/null
+++ b/basctl/source/dlged/dlgedmod.cxx
@@ -0,0 +1,81 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_basctl.hxx"
+
+
+#include "dlgedmod.hxx"
+#include "dlgedpage.hxx"
+#include <tools/debug.hxx>
+
+
+DBG_NAME(DlgEdModel)
+
+TYPEINIT1(DlgEdModel,SdrModel);
+
+//----------------------------------------------------------------------------
+
+DlgEdModel::DlgEdModel()
+ :SdrModel(NULL, NULL)
+{
+ DBG_CTOR(DlgEdModel,0);
+}
+
+//----------------------------------------------------------------------------
+
+DlgEdModel::~DlgEdModel()
+{
+ DBG_DTOR(DlgEdModel,0);
+}
+
+//----------------------------------------------------------------------------
+
+SdrPage* DlgEdModel::AllocPage(bool bMasterPage)
+{
+ DBG_CHKTHIS(DlgEdModel, 0);
+ return new DlgEdPage(*this, bMasterPage);
+}
+
+//----------------------------------------------------------------------------
+
+void DlgEdModel::DlgEdModelChanged(bool bChanged )
+{
+ SetChanged( bChanged );
+}
+
+//----------------------------------------------------------------------------
+
+Window* DlgEdModel::GetCurDocViewWin()
+{
+ return 0;
+}
+
+//----------------------------------------------------------------------------
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/basctl/source/dlged/dlgedobj.cxx b/basctl/source/dlged/dlgedobj.cxx
new file mode 100644
index 000000000000..315b4a4b7c37
--- /dev/null
+++ b/basctl/source/dlged/dlgedobj.cxx
@@ -0,0 +1,1887 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_basctl.hxx"
+
+#include <vector>
+#include <dlgeddef.hxx>
+#include "dlgedobj.hxx"
+#include "dlged.hxx"
+#include "dlgedmod.hxx"
+#include "dlgedpage.hxx"
+#include "dlgedview.hxx"
+#include "dlgedlist.hxx"
+#include <iderid.hxx>
+#include <localizationmgr.hxx>
+
+#include <dlgresid.hrc>
+#include <tools/resmgr.hxx>
+#include <tools/shl.hxx>
+#include <unotools/sharedunocomponent.hxx>
+#include <com/sun/star/awt/XTabControllerModel.hpp>
+#include <com/sun/star/awt/XUnoControlContainer.hpp>
+#include <com/sun/star/awt/XVclContainerPeer.hpp>
+#include <com/sun/star/awt/XWindow.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+#include <com/sun/star/script/XScriptEventsSupplier.hpp>
+#include <com/sun/star/container/XContainer.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <comphelper/processfactory.hxx>
+#include <comphelper/types.hxx>
+#include <vcl/svapp.hxx>
+
+#include <algorithm>
+#include <functional>
+#include <o3tl/compat_functional.hxx>
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::script;
+using ::rtl::OUString;
+
+
+TYPEINIT1(DlgEdObj, SdrUnoObj);
+DBG_NAME(DlgEdObj);
+
+//----------------------------------------------------------------------------
+
+DlgEdObj::DlgEdObj()
+ :SdrUnoObj(String(), sal_False)
+ ,bIsListening(sal_False)
+ ,pDlgEdForm( NULL )
+{
+ DBG_CTOR(DlgEdObj, NULL);
+}
+
+//----------------------------------------------------------------------------
+
+DlgEdObj::DlgEdObj(const ::rtl::OUString& rModelName,
+ const com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >& rxSFac)
+ :SdrUnoObj(rModelName, rxSFac, sal_False)
+ ,bIsListening(sal_False)
+ ,pDlgEdForm( NULL )
+{
+ DBG_CTOR(DlgEdObj, NULL);
+}
+
+//----------------------------------------------------------------------------
+
+DlgEdObj::~DlgEdObj()
+{
+ DBG_DTOR(DlgEdObj, NULL);
+
+ if ( isListening() )
+ EndListening();
+}
+
+//----------------------------------------------------------------------------
+
+void DlgEdObj::SetPage(SdrPage* _pNewPage)
+{
+ // now set the page
+ SdrUnoObj::SetPage(_pNewPage);
+}
+
+//----------------------------------------------------------------------------
+
+namespace
+{
+ /** returns the DlgEdForm which the given DlgEdObj belongs to
+ (which might in fact be the object itself)
+
+ Failure to obtain the form will be reported with an assertion in the non-product
+ version.
+ */
+ bool lcl_getDlgEdForm( DlgEdObj* _pObject, DlgEdForm*& _out_pDlgEdForm )
+ {
+ _out_pDlgEdForm = dynamic_cast< DlgEdForm* >( _pObject );
+ if ( !_out_pDlgEdForm )
+ _out_pDlgEdForm = _pObject->GetDlgEdForm();
+ DBG_ASSERT( _out_pDlgEdForm, "lcl_getDlgEdForm: no form!" );
+ return ( _out_pDlgEdForm != NULL );
+ }
+}
+
+//----------------------------------------------------------------------------
+
+uno::Reference< awt::XControl > DlgEdObj::GetControl() const
+{
+ const DlgEdForm* pForm = GetDlgEdForm();
+ const DlgEditor* pEditor = pForm ? pForm->GetDlgEditor() : NULL;
+ SdrView* pView = pEditor ? pEditor->GetView() : NULL;
+ Window* pWindow = pEditor ? pEditor->GetWindow() : NULL;
+ OSL_ENSURE( ( pView && pWindow ) || !pForm, "DlgEdObj::GetControl: no view or no window!" );
+
+ uno::Reference< awt::XControl > xControl;
+ if ( pView && pWindow )
+ xControl = GetUnoControl( *pView, *pWindow );
+
+ return xControl;
+}
+
+//----------------------------------------------------------------------------
+
+bool DlgEdObj::TransformSdrToControlCoordinates(
+ sal_Int32 nXIn, sal_Int32 nYIn, sal_Int32 nWidthIn, sal_Int32 nHeightIn,
+ sal_Int32& nXOut, sal_Int32& nYOut, sal_Int32& nWidthOut, sal_Int32& nHeightOut )
+{
+ // input position and size
+ Size aPos( nXIn, nYIn );
+ Size aSize( nWidthIn, nHeightIn );
+
+ // form position
+ DlgEdForm* pForm = NULL;
+ if ( !lcl_getDlgEdForm( this, pForm ) )
+ return false;
+ Rectangle aFormRect = pForm->GetSnapRect();
+ Size aFormPos( aFormRect.Left(), aFormRect.Top() );
+
+ // convert 100th_mm to pixel
+ OutputDevice* pDevice = Application::GetDefaultDevice();
+ DBG_ASSERT( pDevice, "DlgEdObj::TransformSdrToControlCoordinates: missing default device!" );
+ if ( !pDevice )
+ return false;
+ aPos = pDevice->LogicToPixel( aPos, MapMode( MAP_100TH_MM ) );
+ aSize = pDevice->LogicToPixel( aSize, MapMode( MAP_100TH_MM ) );
+ aFormPos = pDevice->LogicToPixel( aFormPos, MapMode( MAP_100TH_MM ) );
+
+ // subtract form position
+ aPos.Width() -= aFormPos.Width();
+ aPos.Height() -= aFormPos.Height();
+
+ // take window borders into account
+ Reference< beans::XPropertySet > xPSetForm( pForm->GetUnoControlModel(), UNO_QUERY );
+ DBG_ASSERT( xPSetForm.is(), "DlgEdObj::TransformFormToSdrCoordinates: no form property set!" );
+ if ( !xPSetForm.is() )
+ return false;
+ bool bDecoration = true;
+ xPSetForm->getPropertyValue( DLGED_PROP_DECORATION ) >>= bDecoration;
+ if( bDecoration )
+ {
+ awt::DeviceInfo aDeviceInfo = pForm->getDeviceInfo();
+ aPos.Width() -= aDeviceInfo.LeftInset;
+ aPos.Height() -= aDeviceInfo.TopInset;
+ }
+
+ // convert pixel to logic units
+ aPos = pDevice->PixelToLogic( aPos, MAP_APPFONT );
+ aSize = pDevice->PixelToLogic( aSize, MAP_APPFONT );
+
+ // set out parameters
+ nXOut = aPos.Width();
+ nYOut = aPos.Height();
+ nWidthOut = aSize.Width();
+ nHeightOut = aSize.Height();
+
+ return true;
+}
+
+//----------------------------------------------------------------------------
+
+bool DlgEdObj::TransformSdrToFormCoordinates(
+ sal_Int32 nXIn, sal_Int32 nYIn, sal_Int32 nWidthIn, sal_Int32 nHeightIn,
+ sal_Int32& nXOut, sal_Int32& nYOut, sal_Int32& nWidthOut, sal_Int32& nHeightOut )
+{
+ // input position and size
+ Size aPos( nXIn, nYIn );
+ Size aSize( nWidthIn, nHeightIn );
+
+ // convert 100th_mm to pixel
+ OutputDevice* pDevice = Application::GetDefaultDevice();
+ DBG_ASSERT( pDevice, "DlgEdObj::TransformSdrToFormCoordinates: missing default device!" );
+ if ( !pDevice )
+ return false;
+ aPos = pDevice->LogicToPixel( aPos, MapMode( MAP_100TH_MM ) );
+ aSize = pDevice->LogicToPixel( aSize, MapMode( MAP_100TH_MM ) );
+
+ // take window borders into account
+ DlgEdForm* pForm = NULL;
+ if ( !lcl_getDlgEdForm( this, pForm ) )
+ return false;
+
+ // take window borders into account
+ Reference< beans::XPropertySet > xPSetForm( pForm->GetUnoControlModel(), UNO_QUERY );
+ DBG_ASSERT( xPSetForm.is(), "DlgEdObj::TransformFormToSdrCoordinates: no form property set!" );
+ if ( !xPSetForm.is() )
+ return false;
+ bool bDecoration = true;
+ xPSetForm->getPropertyValue( DLGED_PROP_DECORATION ) >>= bDecoration;
+ if( bDecoration )
+ {
+ awt::DeviceInfo aDeviceInfo = pForm->getDeviceInfo();
+ aSize.Width() -= aDeviceInfo.LeftInset + aDeviceInfo.RightInset;
+ aSize.Height() -= aDeviceInfo.TopInset + aDeviceInfo.BottomInset;
+ }
+ // convert pixel to logic units
+ aPos = pDevice->PixelToLogic( aPos, MAP_APPFONT );
+ aSize = pDevice->PixelToLogic( aSize, MAP_APPFONT );
+
+ // set out parameters
+ nXOut = aPos.Width();
+ nYOut = aPos.Height();
+ nWidthOut = aSize.Width();
+ nHeightOut = aSize.Height();
+
+ return true;
+}
+
+//----------------------------------------------------------------------------
+
+bool DlgEdObj::TransformControlToSdrCoordinates(
+ sal_Int32 nXIn, sal_Int32 nYIn, sal_Int32 nWidthIn, sal_Int32 nHeightIn,
+ sal_Int32& nXOut, sal_Int32& nYOut, sal_Int32& nWidthOut, sal_Int32& nHeightOut )
+{
+ // input position and size
+ Size aPos( nXIn, nYIn );
+ Size aSize( nWidthIn, nHeightIn );
+
+ // form position
+ DlgEdForm* pForm = NULL;
+ if ( !lcl_getDlgEdForm( this, pForm ) )
+ return false;
+
+ Reference< beans::XPropertySet > xPSetForm( pForm->GetUnoControlModel(), UNO_QUERY );
+ DBG_ASSERT( xPSetForm.is(), "DlgEdObj::TransformControlToSdrCoordinates: no form property set!" );
+ if ( !xPSetForm.is() )
+ return false;
+ sal_Int32 nFormX = 0, nFormY = 0, nFormWidth, nFormHeight;
+ xPSetForm->getPropertyValue( DLGED_PROP_POSITIONX ) >>= nFormX;
+ xPSetForm->getPropertyValue( DLGED_PROP_POSITIONY ) >>= nFormY;
+ xPSetForm->getPropertyValue( DLGED_PROP_WIDTH ) >>= nFormWidth;
+ xPSetForm->getPropertyValue( DLGED_PROP_HEIGHT ) >>= nFormHeight;
+ Size aFormPos( nFormX, nFormY );
+
+ // convert logic units to pixel
+ OutputDevice* pDevice = Application::GetDefaultDevice();
+ DBG_ASSERT( pDevice, "DlgEdObj::TransformControlToSdrCoordinates: missing default device!" );
+ if ( !pDevice )
+ return false;
+ aPos = pDevice->LogicToPixel( aPos, MAP_APPFONT );
+ aSize = pDevice->LogicToPixel( aSize, MAP_APPFONT );
+ aFormPos = pDevice->LogicToPixel( aFormPos, MAP_APPFONT );
+
+ // add form position
+ aPos.Width() += aFormPos.Width();
+ aPos.Height() += aFormPos.Height();
+
+ // take window borders into account
+ bool bDecoration = true;
+ xPSetForm->getPropertyValue( DLGED_PROP_DECORATION ) >>= bDecoration;
+ if( bDecoration )
+ {
+ awt::DeviceInfo aDeviceInfo = pForm->getDeviceInfo();
+ aPos.Width() += aDeviceInfo.LeftInset;
+ aPos.Height() += aDeviceInfo.TopInset;
+ }
+
+ // convert pixel to 100th_mm
+ aPos = pDevice->PixelToLogic( aPos, MapMode( MAP_100TH_MM ) );
+ aSize = pDevice->PixelToLogic( aSize, MapMode( MAP_100TH_MM ) );
+
+ // set out parameters
+ nXOut = aPos.Width();
+ nYOut = aPos.Height();
+ nWidthOut = aSize.Width();
+ nHeightOut = aSize.Height();
+
+ return true;
+}
+
+//----------------------------------------------------------------------------
+
+bool DlgEdObj::TransformFormToSdrCoordinates(
+ sal_Int32 nXIn, sal_Int32 nYIn, sal_Int32 nWidthIn, sal_Int32 nHeightIn,
+ sal_Int32& nXOut, sal_Int32& nYOut, sal_Int32& nWidthOut, sal_Int32& nHeightOut )
+{
+ // input position and size
+ Size aPos( nXIn, nYIn );
+ Size aSize( nWidthIn, nHeightIn );
+
+ // convert logic units to pixel
+ OutputDevice* pDevice = Application::GetDefaultDevice();
+ DBG_ASSERT( pDevice, "DlgEdObj::TransformFormToSdrCoordinates: missing default device!" );
+ if ( !pDevice )
+ return false;
+
+ // take window borders into account
+ DlgEdForm* pForm = NULL;
+ if ( !lcl_getDlgEdForm( this, pForm ) )
+ return false;
+
+ aPos = pDevice->LogicToPixel( aPos, MAP_APPFONT );
+ aSize = pDevice->LogicToPixel( aSize, MAP_APPFONT );
+
+ // take window borders into account
+ Reference< beans::XPropertySet > xPSetForm( pForm->GetUnoControlModel(), UNO_QUERY );
+ DBG_ASSERT( xPSetForm.is(), "DlgEdObj::TransformFormToSdrCoordinates: no form property set!" );
+ if ( !xPSetForm.is() )
+ return false;
+ bool bDecoration = true;
+ xPSetForm->getPropertyValue( DLGED_PROP_DECORATION ) >>= bDecoration;
+ if( bDecoration )
+ {
+ awt::DeviceInfo aDeviceInfo = pForm->getDeviceInfo();
+ aSize.Width() += aDeviceInfo.LeftInset + aDeviceInfo.RightInset;
+ aSize.Height() += aDeviceInfo.TopInset + aDeviceInfo.BottomInset;
+ }
+
+ // convert pixel to 100th_mm
+ aPos = pDevice->PixelToLogic( aPos, MapMode( MAP_100TH_MM ) );
+ aSize = pDevice->PixelToLogic( aSize, MapMode( MAP_100TH_MM ) );
+
+ // set out parameters
+ nXOut = aPos.Width();
+ nYOut = aPos.Height();
+ nWidthOut = aSize.Width();
+ nHeightOut = aSize.Height();
+
+ return true;
+}
+
+//----------------------------------------------------------------------------
+
+void DlgEdObj::SetRectFromProps()
+{
+ // get control position and size from properties
+ Reference< beans::XPropertySet > xPSet( GetUnoControlModel(), UNO_QUERY );
+ if ( xPSet.is() )
+ {
+ sal_Int32 nXIn = 0, nYIn = 0, nWidthIn = 0, nHeightIn = 0;
+ xPSet->getPropertyValue( DLGED_PROP_POSITIONX ) >>= nXIn;
+ xPSet->getPropertyValue( DLGED_PROP_POSITIONY ) >>= nYIn;
+ xPSet->getPropertyValue( DLGED_PROP_WIDTH ) >>= nWidthIn;
+ xPSet->getPropertyValue( DLGED_PROP_HEIGHT ) >>= nHeightIn;
+
+ // transform coordinates
+ sal_Int32 nXOut, nYOut, nWidthOut, nHeightOut;
+ if ( TransformControlToSdrCoordinates( nXIn, nYIn, nWidthIn, nHeightIn, nXOut, nYOut, nWidthOut, nHeightOut ) )
+ {
+ // set rectangle position and size
+ Point aPoint( nXOut, nYOut );
+ Size aSize( nWidthOut, nHeightOut );
+ SetSnapRect( Rectangle( aPoint, aSize ) );
+ }
+ }
+}
+
+//----------------------------------------------------------------------------
+
+void DlgEdObj::SetPropsFromRect()
+{
+ // get control position and size from rectangle
+ Rectangle aRect_ = GetSnapRect();
+ sal_Int32 nXIn = aRect_.Left();
+ sal_Int32 nYIn = aRect_.Top();
+ sal_Int32 nWidthIn = aRect_.GetWidth();
+ sal_Int32 nHeightIn = aRect_.GetHeight();
+
+ // transform coordinates
+ sal_Int32 nXOut, nYOut, nWidthOut, nHeightOut;
+ if ( TransformSdrToControlCoordinates( nXIn, nYIn, nWidthIn, nHeightIn, nXOut, nYOut, nWidthOut, nHeightOut ) )
+ {
+ // set properties
+ Reference< beans::XPropertySet > xPSet( GetUnoControlModel(), UNO_QUERY );
+ if ( xPSet.is() )
+ {
+ Any aValue;
+ aValue <<= nXOut;
+ xPSet->setPropertyValue( DLGED_PROP_POSITIONX, aValue );
+ aValue <<= nYOut;
+ xPSet->setPropertyValue( DLGED_PROP_POSITIONY, aValue );
+ aValue <<= nWidthOut;
+ xPSet->setPropertyValue( DLGED_PROP_WIDTH, aValue );
+ aValue <<= nHeightOut;
+ xPSet->setPropertyValue( DLGED_PROP_HEIGHT, aValue );
+ }
+ }
+}
+
+//----------------------------------------------------------------------------
+
+void DlgEdObj::PositionAndSizeChange( const beans::PropertyChangeEvent& evt )
+{
+ DlgEdPage* pPage_ = 0;
+ if ( pDlgEdForm )
+ {
+ DlgEditor* pEditor = pDlgEdForm->GetDlgEditor();
+ if ( pEditor )
+ pPage_ = pEditor->GetPage();
+ }
+ DBG_ASSERT( pPage_, "DlgEdObj::PositionAndSizeChange: no page!" );
+ if ( pPage_ )
+ {
+ sal_Int32 nPageXIn = 0;
+ sal_Int32 nPageYIn = 0;
+ Size aPageSize = pPage_->GetSize();
+ sal_Int32 nPageWidthIn = aPageSize.Width();
+ sal_Int32 nPageHeightIn = aPageSize.Height();
+ sal_Int32 nPageX, nPageY, nPageWidth, nPageHeight;
+ if ( TransformSdrToControlCoordinates( nPageXIn, nPageYIn, nPageWidthIn, nPageHeightIn, nPageX, nPageY, nPageWidth, nPageHeight ) )
+ {
+ Reference< beans::XPropertySet > xPSet( GetUnoControlModel(), UNO_QUERY );
+ if ( xPSet.is() )
+ {
+ sal_Int32 nX = 0, nY = 0, nWidth = 0, nHeight = 0;
+ xPSet->getPropertyValue( DLGED_PROP_POSITIONX ) >>= nX;
+ xPSet->getPropertyValue( DLGED_PROP_POSITIONY ) >>= nY;
+ xPSet->getPropertyValue( DLGED_PROP_WIDTH ) >>= nWidth;
+ xPSet->getPropertyValue( DLGED_PROP_HEIGHT ) >>= nHeight;
+
+ sal_Int32 nValue = 0;
+ evt.NewValue >>= nValue;
+ sal_Int32 nNewValue = nValue;
+
+ if ( evt.PropertyName == DLGED_PROP_POSITIONX )
+ {
+ if ( nNewValue + nWidth > nPageX + nPageWidth )
+ nNewValue = nPageX + nPageWidth - nWidth;
+ if ( nNewValue < nPageX )
+ nNewValue = nPageX;
+ }
+ else if ( evt.PropertyName == DLGED_PROP_POSITIONY )
+ {
+ if ( nNewValue + nHeight > nPageY + nPageHeight )
+ nNewValue = nPageY + nPageHeight - nHeight;
+ if ( nNewValue < nPageY )
+ nNewValue = nPageY;
+ }
+ else if ( evt.PropertyName == DLGED_PROP_WIDTH )
+ {
+ if ( nX + nNewValue > nPageX + nPageWidth )
+ nNewValue = nPageX + nPageWidth - nX;
+ if ( nNewValue < 1 )
+ nNewValue = 1;
+ }
+ else if ( evt.PropertyName == DLGED_PROP_HEIGHT )
+ {
+ if ( nY + nNewValue > nPageY + nPageHeight )
+ nNewValue = nPageY + nPageHeight - nY;
+ if ( nNewValue < 1 )
+ nNewValue = 1;
+ }
+
+ if ( nNewValue != nValue )
+ {
+ Any aNewValue;
+ aNewValue <<= nNewValue;
+ EndListening( sal_False );
+ xPSet->setPropertyValue( evt.PropertyName, aNewValue );
+ StartListening();
+ }
+ }
+ }
+ }
+
+ SetRectFromProps();
+}
+
+//----------------------------------------------------------------------------
+
+void SAL_CALL DlgEdObj::NameChange( const ::com::sun::star::beans::PropertyChangeEvent& evt ) throw( ::com::sun::star::uno::RuntimeException)
+{
+ // get old name
+ ::rtl::OUString aOldName;
+ evt.OldValue >>= aOldName;
+
+ // get new name
+ ::rtl::OUString aNewName;
+ evt.NewValue >>= aNewName;
+
+ if ( !aNewName.equals(aOldName) )
+ {
+ Reference< container::XNameAccess > xNameAcc((GetDlgEdForm()->GetUnoControlModel()), UNO_QUERY);
+ if ( xNameAcc.is() && xNameAcc->hasByName(aOldName) )
+ {
+ if ( !xNameAcc->hasByName(aNewName) && aNewName.getLength() != 0 )
+ {
+ // remove the control by the old name and insert the control by the new name in the container
+ Reference< container::XNameContainer > xCont(xNameAcc, UNO_QUERY );
+ if ( xCont.is() )
+ {
+ Reference< awt::XControlModel > xCtrl(GetUnoControlModel(), UNO_QUERY);
+ Any aAny;
+ aAny <<= xCtrl;
+ xCont->removeByName( aOldName );
+ xCont->insertByName( aNewName , aAny );
+
+ DlgEditor* pEditor;
+ if ( ISA(DlgEdForm) )
+ pEditor = ((DlgEdForm*)this)->GetDlgEditor();
+ else
+ pEditor = GetDlgEdForm()->GetDlgEditor();
+ LocalizationMgr::renameControlResourceIDsForEditorObject( pEditor, aAny, aNewName );
+ }
+ }
+ else
+ {
+ // set old name property
+ EndListening(sal_False);
+ Reference< beans::XPropertySet > xPSet(GetUnoControlModel(), UNO_QUERY);
+ Any aName;
+ aName <<= aOldName;
+ xPSet->setPropertyValue( DLGED_PROP_NAME, aName );
+ StartListening();
+ }
+ }
+ }
+}
+
+//----------------------------------------------------------------------------
+
+sal_Int32 DlgEdObj::GetStep() const
+{
+ // get step property
+ sal_Int32 nStep = 0;
+ uno::Reference< beans::XPropertySet > xPSet( GetUnoControlModel(), uno::UNO_QUERY );
+ if (xPSet.is())
+ {
+ xPSet->getPropertyValue( DLGED_PROP_STEP ) >>= nStep;
+ }
+ return nStep;
+}
+
+//----------------------------------------------------------------------------
+
+void DlgEdObj::UpdateStep()
+{
+ sal_Int32 nCurStep = GetDlgEdForm()->GetStep();
+ sal_Int32 nStep = GetStep();
+
+ SdrLayerAdmin& rLayerAdmin = GetModel()->GetLayerAdmin();
+ SdrLayerID nHiddenLayerId = rLayerAdmin.GetLayerID( String( RTL_CONSTASCII_USTRINGPARAM( "HiddenLayer" ) ), sal_False );
+ SdrLayerID nControlLayerId = rLayerAdmin.GetLayerID( rLayerAdmin.GetControlLayerName(), sal_False );
+
+ if( nCurStep )
+ {
+ if ( nStep && (nStep != nCurStep) )
+ {
+ SetLayer( nHiddenLayerId );
+ }
+ else
+ {
+ SetLayer( nControlLayerId );
+ }
+ }
+ else
+ {
+ SetLayer( nControlLayerId );
+ }
+}
+
+//----------------------------------------------------------------------------
+
+void DlgEdObj::TabIndexChange( const beans::PropertyChangeEvent& evt ) throw (RuntimeException)
+{
+ DlgEdForm* pForm = GetDlgEdForm();
+ if ( pForm )
+ {
+ // stop listening with all children
+ ::std::vector<DlgEdObj*> aChildList = pForm->GetChilds();
+ ::std::vector<DlgEdObj*>::iterator aIter;
+ for ( aIter = aChildList.begin() ; aIter != aChildList.end() ; ++aIter )
+ {
+ (*aIter)->EndListening( sal_False );
+ }
+
+ Reference< container::XNameAccess > xNameAcc( pForm->GetUnoControlModel() , UNO_QUERY );
+ if ( xNameAcc.is() )
+ {
+ // get sequence of control names
+ Sequence< ::rtl::OUString > aNames = xNameAcc->getElementNames();
+ const ::rtl::OUString* pNames = aNames.getConstArray();
+ sal_Int32 nCtrls = aNames.getLength();
+ sal_Int16 i;
+
+ // create a map of tab indices and control names, sorted by tab index
+ IndexToNameMap aIndexToNameMap;
+ for ( i = 0; i < nCtrls; ++i )
+ {
+ // get control name
+ ::rtl::OUString aName( pNames[i] );
+
+ // get tab index
+ sal_Int16 nTabIndex = -1;
+ Any aCtrl = xNameAcc->getByName( aName );
+ Reference< beans::XPropertySet > xPSet;
+ aCtrl >>= xPSet;
+ if ( xPSet.is() && xPSet == Reference< beans::XPropertySet >( evt.Source, UNO_QUERY ) )
+ evt.OldValue >>= nTabIndex;
+ else if ( xPSet.is() )
+ xPSet->getPropertyValue( DLGED_PROP_TABINDEX ) >>= nTabIndex;
+
+ // insert into map
+ aIndexToNameMap.insert( IndexToNameMap::value_type( nTabIndex, aName ) );
+ }
+
+ // create a helper list of control names, sorted by tab index
+ ::std::vector< ::rtl::OUString > aNameList( aIndexToNameMap.size() );
+ ::std::transform(
+ aIndexToNameMap.begin(), aIndexToNameMap.end(),
+ aNameList.begin(),
+ ::o3tl::select2nd< IndexToNameMap::value_type >( )
+ );
+
+ // check tab index
+ sal_Int16 nOldTabIndex = 0;
+ evt.OldValue >>= nOldTabIndex;
+ sal_Int16 nNewTabIndex = 0;
+ evt.NewValue >>= nNewTabIndex;
+ if ( nNewTabIndex < 0 )
+ nNewTabIndex = 0;
+ else if ( nNewTabIndex > nCtrls - 1 )
+ nNewTabIndex = sal::static_int_cast<sal_Int16>( nCtrls - 1 );
+
+ // reorder helper list
+ ::rtl::OUString aCtrlName = aNameList[nOldTabIndex];
+ aNameList.erase( aNameList.begin() + nOldTabIndex );
+ aNameList.insert( aNameList.begin() + nNewTabIndex , aCtrlName );
+
+ // set new tab indices
+ for ( i = 0; i < nCtrls; ++i )
+ {
+ Any aCtrl = xNameAcc->getByName( aNameList[i] );
+ Reference< beans::XPropertySet > xPSet;
+ aCtrl >>= xPSet;
+ if ( xPSet.is() )
+ {
+ Any aTabIndex;
+ aTabIndex <<= (sal_Int16) i;
+ xPSet->setPropertyValue( DLGED_PROP_TABINDEX, aTabIndex );
+ }
+ }
+
+ // reorder objects in drawing page
+ GetModel()->GetPage(0)->SetObjectOrdNum( nOldTabIndex + 1, nNewTabIndex + 1 );
+
+ // #110559#
+ pForm->UpdateTabOrderAndGroups();
+ }
+
+ // start listening with all children
+ for ( aIter = aChildList.begin() ; aIter != aChildList.end() ; ++aIter )
+ {
+ (*aIter)->StartListening();
+ }
+ }
+}
+
+//----------------------------------------------------------------------------
+
+sal_Bool DlgEdObj::supportsService( const sal_Char* _pServiceName ) const
+{
+ sal_Bool bSupports = sal_False;
+
+ Reference< lang::XServiceInfo > xServiceInfo( GetUnoControlModel() , UNO_QUERY );
+ // TODO: cache xServiceInfo as member?
+ if ( xServiceInfo.is() )
+ bSupports = xServiceInfo->supportsService( ::rtl::OUString::createFromAscii( _pServiceName ) );
+
+ return bSupports;
+}
+
+//----------------------------------------------------------------------------
+
+::rtl::OUString DlgEdObj::GetDefaultName() const
+{
+ sal_uInt16 nResId = 0;
+ ::rtl::OUString aDefaultName;
+ if ( supportsService( "com.sun.star.awt.UnoControlDialogModel" ) )
+ {
+ nResId = RID_STR_CLASS_DIALOG;
+ }
+ else if ( supportsService( "com.sun.star.awt.UnoControlButtonModel" ) )
+ {
+ nResId = RID_STR_CLASS_BUTTON;
+ }
+ else if ( supportsService( "com.sun.star.awt.UnoControlRadioButtonModel" ) )
+ {
+ nResId = RID_STR_CLASS_RADIOBUTTON;
+ }
+ else if ( supportsService( "com.sun.star.awt.UnoControlCheckBoxModel" ) )
+ {
+ nResId = RID_STR_CLASS_CHECKBOX;
+ }
+ else if ( supportsService( "com.sun.star.awt.UnoControlListBoxModel" ) )
+ {
+ nResId = RID_STR_CLASS_LISTBOX;
+ }
+ else if ( supportsService( "com.sun.star.awt.UnoControlComboBoxModel" ) )
+ {
+ nResId = RID_STR_CLASS_COMBOBOX;
+ }
+ else if ( supportsService( "com.sun.star.awt.UnoControlGroupBoxModel" ) )
+ {
+ nResId = RID_STR_CLASS_GROUPBOX;
+ }
+ else if ( supportsService( "com.sun.star.awt.UnoControlEditModel" ) )
+ {
+ nResId = RID_STR_CLASS_EDIT;
+ }
+ else if ( supportsService( "com.sun.star.awt.UnoControlFixedTextModel" ) )
+ {
+ nResId = RID_STR_CLASS_FIXEDTEXT;
+ }
+ else if ( supportsService( "com.sun.star.awt.UnoControlImageControlModel" ) )
+ {
+ nResId = RID_STR_CLASS_IMAGECONTROL;
+ }
+ else if ( supportsService( "com.sun.star.awt.UnoControlProgressBarModel" ) )
+ {
+ nResId = RID_STR_CLASS_PROGRESSBAR;
+ }
+ else if ( supportsService( "com.sun.star.awt.UnoControlScrollBarModel" ) )
+ {
+ nResId = RID_STR_CLASS_SCROLLBAR;
+ }
+ else if ( supportsService( "com.sun.star.awt.UnoControlFixedLineModel" ) )
+ {
+ nResId = RID_STR_CLASS_FIXEDLINE;
+ }
+ else if ( supportsService( "com.sun.star.awt.UnoControlDateFieldModel" ) )
+ {
+ nResId = RID_STR_CLASS_DATEFIELD;
+ }
+ else if ( supportsService( "com.sun.star.awt.UnoControlTimeFieldModel" ) )
+ {
+ nResId = RID_STR_CLASS_TIMEFIELD;
+ }
+ else if ( supportsService( "com.sun.star.awt.UnoControlNumericFieldModel" ) )
+ {
+ nResId = RID_STR_CLASS_NUMERICFIELD;
+ }
+ else if ( supportsService( "com.sun.star.awt.UnoControlCurrencyFieldModel" ) )
+ {
+ nResId = RID_STR_CLASS_CURRENCYFIELD;
+ }
+ else if ( supportsService( "com.sun.star.awt.UnoControlFormattedFieldModel" ) )
+ {
+ nResId = RID_STR_CLASS_FORMATTEDFIELD;
+ }
+ else if ( supportsService( "com.sun.star.awt.UnoControlPatternFieldModel" ) )
+ {
+ nResId = RID_STR_CLASS_PATTERNFIELD;
+ }
+ else if ( supportsService( "com.sun.star.awt.UnoControlFileControlModel" ) )
+ {
+ nResId = RID_STR_CLASS_FILECONTROL;
+ }
+ else if ( supportsService( "com.sun.star.awt.tree.TreeControlModel" ) )
+ {
+ nResId = RID_STR_CLASS_TREECONTROL;
+ }
+
+ else
+ {
+ nResId = RID_STR_CLASS_CONTROL;
+ }
+
+ if (nResId)
+ {
+ aDefaultName = ::rtl::OUString( String(IDEResId(nResId)) );
+ }
+
+ return aDefaultName;
+}
+
+//----------------------------------------------------------------------------
+
+::rtl::OUString DlgEdObj::GetUniqueName() const
+{
+ ::rtl::OUString aUniqueName;
+ uno::Reference< container::XNameAccess > xNameAcc((GetDlgEdForm()->GetUnoControlModel()), uno::UNO_QUERY);
+
+ if ( xNameAcc.is() )
+ {
+ sal_Int32 n = 0;
+ ::rtl::OUString aDefaultName = GetDefaultName();
+
+ do
+ {
+ aUniqueName = aDefaultName + ::rtl::OUString::valueOf(++n);
+ } while (xNameAcc->hasByName(aUniqueName));
+ }
+
+ return aUniqueName;
+}
+
+//----------------------------------------------------------------------------
+
+sal_uInt32 DlgEdObj::GetObjInventor() const
+{
+ return DlgInventor;
+}
+
+//----------------------------------------------------------------------------
+
+sal_uInt16 DlgEdObj::GetObjIdentifier() const
+{
+ if ( supportsService( "com.sun.star.awt.UnoControlDialogModel" ))
+ {
+ return OBJ_DLG_DIALOG;
+ }
+ else if ( supportsService( "com.sun.star.awt.UnoControlButtonModel" ))
+ {
+ return OBJ_DLG_PUSHBUTTON;
+ }
+ else if ( supportsService( "com.sun.star.awt.UnoControlRadioButtonModel" ))
+ {
+ return OBJ_DLG_RADIOBUTTON;
+ }
+ else if ( supportsService( "com.sun.star.awt.UnoControlCheckBoxModel" ))
+ {
+ return OBJ_DLG_CHECKBOX;
+ }
+ else if ( supportsService( "com.sun.star.awt.UnoControlListBoxModel" ))
+ {
+ return OBJ_DLG_LISTBOX;
+ }
+ else if ( supportsService( "com.sun.star.awt.UnoControlComboBoxModel" ))
+ {
+ return OBJ_DLG_COMBOBOX;
+ }
+ else if ( supportsService( "com.sun.star.awt.UnoControlGroupBoxModel" ))
+ {
+ return OBJ_DLG_GROUPBOX;
+ }
+ else if ( supportsService( "com.sun.star.awt.UnoControlEditModel" ))
+ {
+ return OBJ_DLG_EDIT;
+ }
+ else if ( supportsService( "com.sun.star.awt.UnoControlFixedTextModel" ))
+ {
+ return OBJ_DLG_FIXEDTEXT;
+ }
+ else if ( supportsService( "com.sun.star.awt.UnoControlImageControlModel" ))
+ {
+ return OBJ_DLG_IMAGECONTROL;
+ }
+ else if ( supportsService( "com.sun.star.awt.UnoControlProgressBarModel" ))
+ {
+ return OBJ_DLG_PROGRESSBAR;
+ }
+ else if ( supportsService( "com.sun.star.awt.UnoControlScrollBarModel" ))
+ {
+ return OBJ_DLG_HSCROLLBAR;
+ }
+ else if ( supportsService( "com.sun.star.awt.UnoControlFixedLineModel" ))
+ {
+ return OBJ_DLG_HFIXEDLINE;
+ }
+ else if ( supportsService( "com.sun.star.awt.UnoControlDateFieldModel" ))
+ {
+ return OBJ_DLG_DATEFIELD;
+ }
+ else if ( supportsService( "com.sun.star.awt.UnoControlTimeFieldModel" ))
+ {
+ return OBJ_DLG_TIMEFIELD;
+ }
+ else if ( supportsService( "com.sun.star.awt.UnoControlNumericFieldModel" ))
+ {
+ return OBJ_DLG_NUMERICFIELD;
+ }
+ else if ( supportsService( "com.sun.star.awt.UnoControlCurrencyFieldModel" ))
+ {
+ return OBJ_DLG_CURRENCYFIELD;
+ }
+ else if ( supportsService( "com.sun.star.awt.UnoControlFormattedFieldModel" ))
+ {
+ return OBJ_DLG_FORMATTEDFIELD;
+ }
+ else if ( supportsService( "com.sun.star.awt.UnoControlPatternFieldModel" ))
+ {
+ return OBJ_DLG_PATTERNFIELD;
+ }
+ else if ( supportsService( "com.sun.star.awt.UnoControlFileControlModel" ))
+ {
+ return OBJ_DLG_FILECONTROL;
+ }
+ else if ( supportsService( "com.sun.star.awt.tree.TreeControlModel" ))
+ {
+ return OBJ_DLG_TREECONTROL;
+ }
+ else
+ {
+ return OBJ_DLG_CONTROL;
+ }
+}
+
+//----------------------------------------------------------------------------
+
+void DlgEdObj::clonedFrom(const DlgEdObj* _pSource)
+{
+ // set parent form
+ pDlgEdForm = _pSource->pDlgEdForm;
+
+ // add child to parent form
+ pDlgEdForm->AddChild( this );
+
+ Reference< beans::XPropertySet > xPSet( GetUnoControlModel(), UNO_QUERY );
+ if ( xPSet.is() )
+ {
+ // set new name
+ ::rtl::OUString aOUniqueName( GetUniqueName() );
+ Any aUniqueName;
+ aUniqueName <<= aOUniqueName;
+ xPSet->setPropertyValue( DLGED_PROP_NAME, aUniqueName );
+
+ Reference< container::XNameContainer > xCont( GetDlgEdForm()->GetUnoControlModel() , UNO_QUERY );
+ if ( xCont.is() )
+ {
+ // set tabindex
+ Sequence< OUString > aNames = xCont->getElementNames();
+ Any aTabIndex;
+ aTabIndex <<= (sal_Int16) aNames.getLength();
+ xPSet->setPropertyValue( DLGED_PROP_TABINDEX, aTabIndex );
+
+ // insert control model in dialog model
+ Reference< awt::XControlModel > xCtrl( xPSet , UNO_QUERY );
+ Any aCtrl;
+ aCtrl <<= xCtrl;
+ xCont->insertByName( aOUniqueName , aCtrl );
+
+ // #110559#
+ pDlgEdForm->UpdateTabOrderAndGroups();
+ }
+ }
+
+ // start listening
+ StartListening();
+}
+
+//----------------------------------------------------------------------------
+
+DlgEdObj* DlgEdObj::Clone() const
+{
+ DlgEdObj* pDlgEdObj = CloneHelper< DlgEdObj >();
+ DBG_ASSERT( pDlgEdObj != NULL, "DlgEdObj::Clone: invalid clone!" );
+ if ( pDlgEdObj )
+ pDlgEdObj->clonedFrom( this );
+
+ return pDlgEdObj;
+}
+
+//----------------------------------------------------------------------------
+
+SdrObject* DlgEdObj::getFullDragClone() const
+{
+ // no need to really add the clone for dragging, it's a temporary
+ // object
+ SdrObject* pObj = new SdrUnoObj(String());
+ *pObj = *((const SdrUnoObj*)this);
+
+ return pObj;
+}
+
+//----------------------------------------------------------------------------
+
+void DlgEdObj::NbcMove( const Size& rSize )
+{
+ SdrUnoObj::NbcMove( rSize );
+
+ // stop listening
+ EndListening(sal_False);
+
+ // set geometry properties
+ SetPropsFromRect();
+
+ // start listening
+ StartListening();
+
+ // dialog model changed
+ GetDlgEdForm()->GetDlgEditor()->SetDialogModelChanged(sal_True);
+}
+
+//----------------------------------------------------------------------------
+
+void DlgEdObj::NbcResize(const Point& rRef, const Fraction& xFract, const Fraction& yFract)
+{
+ SdrUnoObj::NbcResize( rRef, xFract, yFract );
+
+ // stop listening
+ EndListening(sal_False);
+
+ // set geometry properties
+ SetPropsFromRect();
+
+ // start listening
+ StartListening();
+
+ // dialog model changed
+ GetDlgEdForm()->GetDlgEditor()->SetDialogModelChanged(sal_True);
+}
+
+//----------------------------------------------------------------------------
+
+bool DlgEdObj::EndCreate(SdrDragStat& rStat, SdrCreateCmd eCmd)
+{
+ bool bResult = SdrUnoObj::EndCreate(rStat, eCmd);
+
+ SetDefaults();
+ StartListening();
+
+ return bResult;
+}
+
+//----------------------------------------------------------------------------
+
+void DlgEdObj::SetDefaults()
+{
+ // set parent form
+ pDlgEdForm = ((DlgEdPage*)GetPage())->GetDlgEdForm();
+
+ if ( pDlgEdForm )
+ {
+ // add child to parent form
+ pDlgEdForm->AddChild( this );
+
+ Reference< beans::XPropertySet > xPSet( GetUnoControlModel(), UNO_QUERY );
+ if ( xPSet.is() )
+ {
+ // get unique name
+ ::rtl::OUString aOUniqueName( GetUniqueName() );
+
+ // set name property
+ Any aUniqueName;
+ aUniqueName <<= aOUniqueName;
+ xPSet->setPropertyValue( DLGED_PROP_NAME, aUniqueName );
+
+ // set labels
+ if ( supportsService( "com.sun.star.awt.UnoControlButtonModel" ) ||
+ supportsService( "com.sun.star.awt.UnoControlRadioButtonModel" ) ||
+ supportsService( "com.sun.star.awt.UnoControlCheckBoxModel" ) ||
+ supportsService( "com.sun.star.awt.UnoControlGroupBoxModel" ) ||
+ supportsService( "com.sun.star.awt.UnoControlFixedTextModel" ) )
+ {
+ xPSet->setPropertyValue( DLGED_PROP_LABEL, aUniqueName );
+ }
+
+ // set number formats supplier for formatted field
+ if ( supportsService( "com.sun.star.awt.UnoControlFormattedFieldModel" ) )
+ {
+ Reference< util::XNumberFormatsSupplier > xSupplier = GetDlgEdForm()->GetDlgEditor()->GetNumberFormatsSupplier();
+ if ( xSupplier.is() )
+ {
+ Any aSupplier;
+ aSupplier <<= xSupplier;
+ xPSet->setPropertyValue( DLGED_PROP_FORMATSSUPPLIER, aSupplier );
+ }
+ }
+
+ // set geometry properties
+ SetPropsFromRect();
+
+ Reference< container::XNameContainer > xCont( GetDlgEdForm()->GetUnoControlModel() , UNO_QUERY );
+ if ( xCont.is() )
+ {
+ // set tabindex
+ Sequence< OUString > aNames = xCont->getElementNames();
+ uno::Any aTabIndex;
+ aTabIndex <<= (sal_Int16) aNames.getLength();
+ xPSet->setPropertyValue( DLGED_PROP_TABINDEX, aTabIndex );
+
+ // set step
+ Reference< beans::XPropertySet > xPSetForm( xCont, UNO_QUERY );
+ if ( xPSetForm.is() )
+ {
+ Any aStep = xPSetForm->getPropertyValue( DLGED_PROP_STEP );
+ xPSet->setPropertyValue( DLGED_PROP_STEP, aStep );
+ }
+
+ // insert control model in dialog model
+ Reference< awt::XControlModel > xCtrl( xPSet , UNO_QUERY );
+ Any aAny;
+ aAny <<= xCtrl;
+ xCont->insertByName( aOUniqueName , aAny );
+
+ DlgEditor* pEditor;
+ if ( ISA(DlgEdForm) )
+ pEditor = ((DlgEdForm*)this)->GetDlgEditor();
+ else
+ pEditor = GetDlgEdForm()->GetDlgEditor();
+ LocalizationMgr::setControlResourceIDsForNewEditorObject( pEditor, aAny, aOUniqueName );
+
+ // #110559#
+ pDlgEdForm->UpdateTabOrderAndGroups();
+ }
+ }
+
+ // dialog model changed
+ pDlgEdForm->GetDlgEditor()->SetDialogModelChanged( sal_True );
+ }
+}
+
+//----------------------------------------------------------------------------
+
+IMPL_LINK(DlgEdObj, OnCreate, void*, EMPTYTAG)
+{
+ (void)EMPTYTAG;
+ /*
+ if (pTempView)
+ pTempView->ObjectCreated(this);
+ */
+ return 0;
+}
+
+//----------------------------------------------------------------------------
+
+void DlgEdObj::StartListening()
+{
+ DBG_ASSERT(!isListening(), "DlgEdObj::StartListening: already listening!");
+
+ if (!isListening())
+ {
+ bIsListening = sal_True;
+
+ // XPropertyChangeListener
+ Reference< XPropertySet > xControlModel( GetUnoControlModel() , UNO_QUERY );
+ if (!m_xPropertyChangeListener.is() && xControlModel.is())
+ {
+ // create listener
+ m_xPropertyChangeListener = static_cast< ::com::sun::star::beans::XPropertyChangeListener*>( new DlgEdPropListenerImpl( (DlgEdObj*)this ) );
+
+ // register listener to properties
+ xControlModel->addPropertyChangeListener( ::rtl::OUString() , m_xPropertyChangeListener );
+ }
+
+ // XContainerListener
+ Reference< XScriptEventsSupplier > xEventsSupplier( GetUnoControlModel() , UNO_QUERY );
+ if( !m_xContainerListener.is() && xEventsSupplier.is() )
+ {
+ // create listener
+ m_xContainerListener = static_cast< ::com::sun::star::container::XContainerListener*>( new DlgEdEvtContListenerImpl( (DlgEdObj*)this ) );
+
+ // register listener to script event container
+ Reference< XNameContainer > xEventCont = xEventsSupplier->getEvents();
+ DBG_ASSERT(xEventCont.is(), "DlgEdObj::StartListening: control model has no script event container!");
+ Reference< XContainer > xCont( xEventCont , UNO_QUERY );
+ if (xCont.is())
+ xCont->addContainerListener( m_xContainerListener );
+ }
+ }
+}
+
+//----------------------------------------------------------------------------
+
+void DlgEdObj::EndListening(sal_Bool bRemoveListener)
+{
+ DBG_ASSERT(isListening(), "DlgEdObj::EndListening: not listening currently!");
+
+ if (isListening())
+ {
+ bIsListening = sal_False;
+
+ if (bRemoveListener)
+ {
+ // XPropertyChangeListener
+ Reference< XPropertySet > xControlModel(GetUnoControlModel(), UNO_QUERY);
+ if ( m_xPropertyChangeListener.is() && xControlModel.is() )
+ {
+ // remove listener
+ xControlModel->removePropertyChangeListener( ::rtl::OUString() , m_xPropertyChangeListener );
+ }
+ m_xPropertyChangeListener.clear();
+
+ // XContainerListener
+ Reference< XScriptEventsSupplier > xEventsSupplier( GetUnoControlModel() , UNO_QUERY );
+ if( m_xContainerListener.is() && xEventsSupplier.is() )
+ {
+ // remove listener
+ Reference< XNameContainer > xEventCont = xEventsSupplier->getEvents();
+ DBG_ASSERT(xEventCont.is(), "DlgEdObj::EndListening: control model has no script event container!");
+ Reference< XContainer > xCont( xEventCont , UNO_QUERY );
+ if (xCont.is())
+ xCont->removeContainerListener( m_xContainerListener );
+ }
+ m_xContainerListener.clear();
+ }
+ }
+}
+
+//----------------------------------------------------------------------------
+
+void SAL_CALL DlgEdObj::_propertyChange( const ::com::sun::star::beans::PropertyChangeEvent& evt ) throw( ::com::sun::star::uno::RuntimeException)
+{
+ if (isListening())
+ {
+ DlgEdForm* pRealDlgEdForm = dynamic_cast< DlgEdForm* >(this);
+ if( pRealDlgEdForm == 0 )
+ pRealDlgEdForm = GetDlgEdForm();
+
+ DlgEditor* pDlgEditor = pRealDlgEdForm ? pRealDlgEdForm->GetDlgEditor() : 0;
+
+ if( !pDlgEditor || pDlgEditor->isInPaint() )
+ return;
+
+ // dialog model changed
+ pDlgEditor->SetDialogModelChanged(sal_True);
+
+ // update position and size
+ if ( evt.PropertyName == DLGED_PROP_POSITIONX || evt.PropertyName == DLGED_PROP_POSITIONY ||
+ evt.PropertyName == DLGED_PROP_WIDTH || evt.PropertyName == DLGED_PROP_HEIGHT ||
+ evt.PropertyName == DLGED_PROP_DECORATION )
+ {
+ PositionAndSizeChange( evt );
+
+ if ( evt.PropertyName == DLGED_PROP_DECORATION )
+ {
+ if ( ISA(DlgEdForm) )
+ ((DlgEdForm*)this)->GetDlgEditor()->ResetDialog();
+ else
+ GetDlgEdForm()->GetDlgEditor()->ResetDialog();
+ }
+ }
+ // change name of control in dialog model
+ else if ( evt.PropertyName == DLGED_PROP_NAME )
+ {
+ if ( !ISA(DlgEdForm) )
+ {
+ NameChange(evt);
+ }
+ }
+ // update step
+ else if ( evt.PropertyName == DLGED_PROP_STEP )
+ {
+ UpdateStep();
+ }
+ // change tabindex
+ else if ( evt.PropertyName == DLGED_PROP_TABINDEX )
+ {
+ if ( !ISA(DlgEdForm) )
+ {
+ TabIndexChange(evt);
+ }
+ }
+ }
+}
+
+//----------------------------------------------------------------------------
+
+void SAL_CALL DlgEdObj::_elementInserted(const ::com::sun::star::container::ContainerEvent& ) throw(::com::sun::star::uno::RuntimeException)
+{
+ if (isListening())
+ {
+ // dialog model changed
+ if ( ISA(DlgEdForm) )
+ {
+ ((DlgEdForm*)this)->GetDlgEditor()->SetDialogModelChanged(sal_True);
+ }
+ else
+ {
+ GetDlgEdForm()->GetDlgEditor()->SetDialogModelChanged(sal_True);
+ }
+ }
+}
+
+//----------------------------------------------------------------------------
+
+void SAL_CALL DlgEdObj::_elementReplaced(const ::com::sun::star::container::ContainerEvent& ) throw(::com::sun::star::uno::RuntimeException)
+{
+ if (isListening())
+ {
+ // dialog model changed
+ if ( ISA(DlgEdForm) )
+ {
+ ((DlgEdForm*)this)->GetDlgEditor()->SetDialogModelChanged(sal_True);
+ }
+ else
+ {
+ GetDlgEdForm()->GetDlgEditor()->SetDialogModelChanged(sal_True);
+ }
+ }
+}
+
+//----------------------------------------------------------------------------
+
+void SAL_CALL DlgEdObj::_elementRemoved(const ::com::sun::star::container::ContainerEvent& ) throw(::com::sun::star::uno::RuntimeException)
+{
+ if (isListening())
+ {
+ // dialog model changed
+ if ( ISA(DlgEdForm) )
+ {
+ ((DlgEdForm*)this)->GetDlgEditor()->SetDialogModelChanged(sal_True);
+ }
+ else
+ {
+ GetDlgEdForm()->GetDlgEditor()->SetDialogModelChanged(sal_True);
+ }
+ }
+}
+
+//----------------------------------------------------------------------------
+
+void DlgEdObj::SetLayer(SdrLayerID nLayer)
+{
+ SdrLayerID nOldLayer = GetLayer();
+
+ if ( nLayer != nOldLayer )
+ {
+ SdrUnoObj::SetLayer( nLayer );
+
+ DlgEdHint aHint( DLGED_HINT_LAYERCHANGED, this );
+ GetDlgEdForm()->GetDlgEditor()->Broadcast( aHint );
+ }
+}
+
+//----------------------------------------------------------------------------
+
+TYPEINIT1(DlgEdForm, DlgEdObj);
+DBG_NAME(DlgEdForm);
+
+//----------------------------------------------------------------------------
+
+DlgEdForm::DlgEdForm()
+ :DlgEdObj()
+{
+ DBG_CTOR(DlgEdForm, NULL);
+}
+
+//----------------------------------------------------------------------------
+
+DlgEdForm::~DlgEdForm()
+{
+ DBG_DTOR(DlgEdForm, NULL);
+}
+
+//----------------------------------------------------------------------------
+
+void DlgEdForm::SetDlgEditor( DlgEditor* pEditor )
+{
+ pDlgEditor = pEditor;
+ ImplInvalidateDeviceInfo();
+}
+
+//----------------------------------------------------------------------------
+
+void DlgEdForm::ImplInvalidateDeviceInfo()
+{
+ mpDeviceInfo.reset();
+}
+
+//----------------------------------------------------------------------------
+
+void DlgEdForm::SetRectFromProps()
+{
+ // get form position and size from properties
+ Reference< beans::XPropertySet > xPSet( GetUnoControlModel(), UNO_QUERY );
+ if ( xPSet.is() )
+ {
+ sal_Int32 nXIn = 0, nYIn = 0, nWidthIn = 0, nHeightIn = 0;
+ xPSet->getPropertyValue( DLGED_PROP_POSITIONX ) >>= nXIn;
+ xPSet->getPropertyValue( DLGED_PROP_POSITIONY ) >>= nYIn;
+ xPSet->getPropertyValue( DLGED_PROP_WIDTH ) >>= nWidthIn;
+ xPSet->getPropertyValue( DLGED_PROP_HEIGHT ) >>= nHeightIn;
+
+ // transform coordinates
+ sal_Int32 nXOut, nYOut, nWidthOut, nHeightOut;
+ if ( TransformFormToSdrCoordinates( nXIn, nYIn, nWidthIn, nHeightIn, nXOut, nYOut, nWidthOut, nHeightOut ) )
+ {
+ // set rectangle position and size
+ Point aPoint( nXOut, nYOut );
+ Size aSize( nWidthOut, nHeightOut );
+ SetSnapRect( Rectangle( aPoint, aSize ) );
+ }
+ }
+}
+
+//----------------------------------------------------------------------------
+
+void DlgEdForm::SetPropsFromRect()
+{
+ // get form position and size from rectangle
+ Rectangle aRect_ = GetSnapRect();
+ sal_Int32 nXIn = aRect_.Left();
+ sal_Int32 nYIn = aRect_.Top();
+ sal_Int32 nWidthIn = aRect_.GetWidth();
+ sal_Int32 nHeightIn = aRect_.GetHeight();
+
+ // transform coordinates
+ sal_Int32 nXOut, nYOut, nWidthOut, nHeightOut;
+ if ( TransformSdrToFormCoordinates( nXIn, nYIn, nWidthIn, nHeightIn, nXOut, nYOut, nWidthOut, nHeightOut ) )
+ {
+ // set properties
+ Reference< beans::XPropertySet > xPSet( GetUnoControlModel(), UNO_QUERY );
+ if ( xPSet.is() )
+ {
+ Any aValue;
+ aValue <<= nXOut;
+ xPSet->setPropertyValue( DLGED_PROP_POSITIONX, aValue );
+ aValue <<= nYOut;
+ xPSet->setPropertyValue( DLGED_PROP_POSITIONY, aValue );
+ aValue <<= nWidthOut;
+ xPSet->setPropertyValue( DLGED_PROP_WIDTH, aValue );
+ aValue <<= nHeightOut;
+ xPSet->setPropertyValue( DLGED_PROP_HEIGHT, aValue );
+ }
+ }
+}
+
+//----------------------------------------------------------------------------
+
+void DlgEdForm::AddChild( DlgEdObj* pDlgEdObj )
+{
+ pChilds.push_back( pDlgEdObj );
+}
+
+//----------------------------------------------------------------------------
+
+void DlgEdForm::RemoveChild( DlgEdObj* pDlgEdObj )
+{
+ pChilds.erase( ::std::find( pChilds.begin() , pChilds.end() , pDlgEdObj ) );
+}
+
+//----------------------------------------------------------------------------
+
+void DlgEdForm::PositionAndSizeChange( const beans::PropertyChangeEvent& evt )
+{
+ DlgEditor* pEditor = GetDlgEditor();
+ DBG_ASSERT( pEditor, "DlgEdForm::PositionAndSizeChange: no dialog editor!" );
+ if ( pEditor )
+ {
+ DlgEdPage* pPage_ = pEditor->GetPage();
+ DBG_ASSERT( pPage_, "DlgEdForm::PositionAndSizeChange: no page!" );
+ if ( pPage_ )
+ {
+ sal_Int32 nPageXIn = 0;
+ sal_Int32 nPageYIn = 0;
+ Size aPageSize = pPage_->GetSize();
+ sal_Int32 nPageWidthIn = aPageSize.Width();
+ sal_Int32 nPageHeightIn = aPageSize.Height();
+ sal_Int32 nPageX, nPageY, nPageWidth, nPageHeight;
+ if ( TransformSdrToFormCoordinates( nPageXIn, nPageYIn, nPageWidthIn, nPageHeightIn, nPageX, nPageY, nPageWidth, nPageHeight ) )
+ {
+ Reference< beans::XPropertySet > xPSetForm( GetUnoControlModel(), UNO_QUERY );
+ if ( xPSetForm.is() )
+ {
+ sal_Int32 nValue = 0;
+ evt.NewValue >>= nValue;
+ sal_Int32 nNewValue = nValue;
+
+ if ( evt.PropertyName == DLGED_PROP_POSITIONX )
+ {
+ if ( nNewValue < nPageX )
+ nNewValue = nPageX;
+ }
+ else if ( evt.PropertyName == DLGED_PROP_POSITIONY )
+ {
+ if ( nNewValue < nPageY )
+ nNewValue = nPageY;
+ }
+ else if ( evt.PropertyName == DLGED_PROP_WIDTH )
+ {
+ if ( nNewValue < 1 )
+ nNewValue = 1;
+ }
+ else if ( evt.PropertyName == DLGED_PROP_HEIGHT )
+ {
+ if ( nNewValue < 1 )
+ nNewValue = 1;
+ }
+
+ if ( nNewValue != nValue )
+ {
+ Any aNewValue;
+ aNewValue <<= nNewValue;
+ EndListening( sal_False );
+ xPSetForm->setPropertyValue( evt.PropertyName, aNewValue );
+ StartListening();
+ }
+ }
+ }
+
+ bool bAdjustedPageSize = pEditor->AdjustPageSize();
+ SetRectFromProps();
+ ::std::vector< DlgEdObj* >::iterator aIter;
+ ::std::vector< DlgEdObj* > aChildList = ((DlgEdForm*)this)->GetChilds();
+
+ if ( bAdjustedPageSize )
+ {
+ pEditor->InitScrollBars();
+ aPageSize = pPage_->GetSize();
+ nPageWidthIn = aPageSize.Width();
+ nPageHeightIn = aPageSize.Height();
+ if ( TransformSdrToControlCoordinates( nPageXIn, nPageYIn, nPageWidthIn, nPageHeightIn, nPageX, nPageY, nPageWidth, nPageHeight ) )
+ {
+ for ( aIter = aChildList.begin(); aIter != aChildList.end(); aIter++ )
+ {
+ Reference< beans::XPropertySet > xPSet( (*aIter)->GetUnoControlModel(), UNO_QUERY );
+ if ( xPSet.is() )
+ {
+ sal_Int32 nX = 0, nY = 0, nWidth = 0, nHeight = 0;
+ xPSet->getPropertyValue( DLGED_PROP_POSITIONX ) >>= nX;
+ xPSet->getPropertyValue( DLGED_PROP_POSITIONY ) >>= nY;
+ xPSet->getPropertyValue( DLGED_PROP_WIDTH ) >>= nWidth;
+ xPSet->getPropertyValue( DLGED_PROP_HEIGHT ) >>= nHeight;
+
+ sal_Int32 nNewX = nX;
+ if ( nX + nWidth > nPageX + nPageWidth )
+ {
+ nNewX = nPageX + nPageWidth - nWidth;
+ if ( nNewX < nPageX )
+ nNewX = nPageX;
+ }
+ if ( nNewX != nX )
+ {
+ Any aValue;
+ aValue <<= nNewX;
+ EndListening( sal_False );
+ xPSet->setPropertyValue( DLGED_PROP_POSITIONX, aValue );
+ StartListening();
+ }
+
+ sal_Int32 nNewY = nY;
+ if ( nY + nHeight > nPageY + nPageHeight )
+ {
+ nNewY = nPageY + nPageHeight - nHeight;
+ if ( nNewY < nPageY )
+ nNewY = nPageY;
+ }
+ if ( nNewY != nY )
+ {
+ Any aValue;
+ aValue <<= nNewY;
+ EndListening( sal_False );
+ xPSet->setPropertyValue( DLGED_PROP_POSITIONY, aValue );
+ StartListening();
+ }
+ }
+ }
+ }
+ }
+
+ for ( aIter = aChildList.begin(); aIter != aChildList.end(); aIter++ )
+ {
+ (*aIter)->SetRectFromProps();
+ }
+ }
+ }
+}
+
+//----------------------------------------------------------------------------
+
+void DlgEdForm::UpdateStep()
+{
+ sal_uLong nObjCount;
+ SdrPage* pSdrPage = GetPage();
+
+ if ( pSdrPage && ( ( nObjCount = pSdrPage->GetObjCount() ) > 0 ) )
+ {
+ for ( sal_uLong i = 0 ; i < nObjCount ; i++ )
+ {
+ SdrObject* pObj = pSdrPage->GetObj(i);
+ DlgEdObj* pDlgEdObj = PTR_CAST(DlgEdObj, pObj);
+ if ( pDlgEdObj && !pDlgEdObj->ISA(DlgEdForm) )
+ pDlgEdObj->UpdateStep();
+ }
+ }
+}
+
+//----------------------------------------------------------------------------
+
+void DlgEdForm::UpdateTabIndices()
+{
+ // stop listening with all children
+ ::std::vector<DlgEdObj*>::iterator aIter;
+ for ( aIter = pChilds.begin() ; aIter != pChilds.end() ; ++aIter )
+ {
+ (*aIter)->EndListening( sal_False );
+ }
+
+ Reference< ::com::sun::star::container::XNameAccess > xNameAcc( GetUnoControlModel() , UNO_QUERY );
+ if ( xNameAcc.is() )
+ {
+ // get sequence of control names
+ Sequence< ::rtl::OUString > aNames = xNameAcc->getElementNames();
+ const ::rtl::OUString* pNames = aNames.getConstArray();
+ sal_Int32 nCtrls = aNames.getLength();
+
+ // create a map of tab indices and control names, sorted by tab index
+ IndexToNameMap aIndexToNameMap;
+ for ( sal_Int16 i = 0; i < nCtrls; ++i )
+ {
+ // get name
+ ::rtl::OUString aName( pNames[i] );
+
+ // get tab index
+ sal_Int16 nTabIndex = -1;
+ Any aCtrl = xNameAcc->getByName( aName );
+ Reference< ::com::sun::star::beans::XPropertySet > xPSet;
+ aCtrl >>= xPSet;
+ if ( xPSet.is() )
+ xPSet->getPropertyValue( DLGED_PROP_TABINDEX ) >>= nTabIndex;
+
+ // insert into map
+ aIndexToNameMap.insert( IndexToNameMap::value_type( nTabIndex, aName ) );
+ }
+
+ // set new tab indices
+ sal_Int16 nNewTabIndex = 0;
+ for ( IndexToNameMap::iterator aIt = aIndexToNameMap.begin(); aIt != aIndexToNameMap.end(); ++aIt )
+ {
+ Any aCtrl = xNameAcc->getByName( aIt->second );
+ Reference< beans::XPropertySet > xPSet;
+ aCtrl >>= xPSet;
+ if ( xPSet.is() )
+ {
+ Any aTabIndex;
+ aTabIndex <<= (sal_Int16) nNewTabIndex++;
+ xPSet->setPropertyValue( DLGED_PROP_TABINDEX, aTabIndex );
+ }
+ }
+
+ // #110559#
+ UpdateTabOrderAndGroups();
+ }
+
+ // start listening with all children
+ for ( aIter = pChilds.begin() ; aIter != pChilds.end() ; ++aIter )
+ {
+ (*aIter)->StartListening();
+ }
+}
+
+//----------------------------------------------------------------------------
+
+void DlgEdForm::UpdateTabOrder()
+{
+ // #110559#
+ // When the tabindex of a control model changes, the dialog control is
+ // notified about those changes. Due to #109067# (bad performance of
+ // dialog editor) the dialog control doesn't activate the tab order
+ // in design mode. When the dialog editor has reordered all
+ // tabindices, this method allows to activate the taborder afterwards.
+
+ Reference< awt::XUnoControlContainer > xCont( GetControl(), UNO_QUERY );
+ if ( xCont.is() )
+ {
+ Sequence< Reference< awt::XTabController > > aSeqTabCtrls = xCont->getTabControllers();
+ const Reference< awt::XTabController >* pTabCtrls = aSeqTabCtrls.getConstArray();
+ sal_Int32 nCount = aSeqTabCtrls.getLength();
+ for ( sal_Int32 i = 0; i < nCount; ++i )
+ pTabCtrls[i]->activateTabOrder();
+ }
+}
+
+//----------------------------------------------------------------------------
+
+void DlgEdForm::UpdateGroups()
+{
+ // #110559#
+ // The grouping of radio buttons in a dialog is done by vcl.
+ // In the dialog editor we have two views (=controls) for one
+ // radio button model. One control is owned by the dialog control,
+ // but not visible in design mode. The other control is owned by
+ // the drawing layer object. Whereas the grouping of the first
+ // control is done by vcl, the grouping of the control in the
+ // drawing layer has to be done here.
+
+ Reference< awt::XTabControllerModel > xTabModel( GetUnoControlModel() , UNO_QUERY );
+ if ( xTabModel.is() )
+ {
+ // create a global list of controls that belong to the dialog
+ ::std::vector<DlgEdObj*> aChildList = GetChilds();
+ sal_uInt32 nSize = aChildList.size();
+ Sequence< Reference< awt::XControl > > aSeqControls( nSize );
+ for ( sal_uInt32 i = 0; i < nSize; ++i )
+ aSeqControls.getArray()[i] = Reference< awt::XControl >( aChildList[i]->GetControl(), UNO_QUERY );
+
+ sal_Int32 nGroupCount = xTabModel->getGroupCount();
+ for ( sal_Int32 nGroup = 0; nGroup < nGroupCount; ++nGroup )
+ {
+ // get a list of control models that belong to this group
+ ::rtl::OUString aName;
+ Sequence< Reference< awt::XControlModel > > aSeqModels;
+ xTabModel->getGroup( nGroup, aSeqModels, aName );
+ const Reference< awt::XControlModel >* pModels = aSeqModels.getConstArray();
+ sal_Int32 nModelCount = aSeqModels.getLength();
+
+ // create a list of peers that belong to this group
+ Sequence< Reference< awt::XWindow > > aSeqPeers( nModelCount );
+ for ( sal_Int32 nModel = 0; nModel < nModelCount; ++nModel )
+ {
+ // for each control model find the corresponding control in the global list
+ const Reference< awt::XControl >* pControls = aSeqControls.getConstArray();
+ sal_Int32 nControlCount = aSeqControls.getLength();
+ for ( sal_Int32 nControl = 0; nControl < nControlCount; ++nControl )
+ {
+ const Reference< awt::XControl > xCtrl( pControls[nControl] );
+ if ( xCtrl.is() )
+ {
+ Reference< awt::XControlModel > xCtrlModel( xCtrl->getModel() );
+ if ( (awt::XControlModel*)xCtrlModel.get() == (awt::XControlModel*)pModels[nModel].get() )
+ {
+ // get the control peer and insert into the list of peers
+ aSeqPeers.getArray()[ nModel ] = Reference< awt::XWindow >( xCtrl->getPeer(), UNO_QUERY );
+ break;
+ }
+ }
+ }
+ }
+
+ // set the group at the dialog peer
+ Reference< awt::XControl > xDlg( GetControl(), UNO_QUERY );
+ if ( xDlg.is() )
+ {
+ Reference< awt::XVclContainerPeer > xDlgPeer( xDlg->getPeer(), UNO_QUERY );
+ if ( xDlgPeer.is() )
+ xDlgPeer->setGroup( aSeqPeers );
+ }
+ }
+ }
+}
+
+//----------------------------------------------------------------------------
+
+void DlgEdForm::UpdateTabOrderAndGroups()
+{
+ UpdateTabOrder();
+ UpdateGroups();
+}
+
+//----------------------------------------------------------------------------
+
+void DlgEdForm::NbcMove( const Size& rSize )
+{
+ SdrUnoObj::NbcMove( rSize );
+
+ // set geometry properties of form
+ EndListening(sal_False);
+ SetPropsFromRect();
+ StartListening();
+
+ // set geometry properties of all childs
+ ::std::vector<DlgEdObj*>::iterator aIter;
+ for ( aIter = pChilds.begin() ; aIter != pChilds.end() ; aIter++ )
+ {
+ (*aIter)->EndListening(sal_False);
+ (*aIter)->SetPropsFromRect();
+ (*aIter)->StartListening();
+ }
+
+ // dialog model changed
+ GetDlgEditor()->SetDialogModelChanged(sal_True);
+}
+
+//----------------------------------------------------------------------------
+
+void DlgEdForm::NbcResize(const Point& rRef, const Fraction& xFract, const Fraction& yFract)
+{
+ SdrUnoObj::NbcResize( rRef, xFract, yFract );
+
+ // set geometry properties of form
+ EndListening(sal_False);
+ SetPropsFromRect();
+ StartListening();
+
+ // set geometry properties of all childs
+ ::std::vector<DlgEdObj*>::iterator aIter;
+ for ( aIter = pChilds.begin() ; aIter != pChilds.end() ; aIter++ )
+ {
+ (*aIter)->EndListening(sal_False);
+ (*aIter)->SetPropsFromRect();
+ (*aIter)->StartListening();
+ }
+
+ // dialog model changed
+ GetDlgEditor()->SetDialogModelChanged(sal_True);
+}
+
+//----------------------------------------------------------------------------
+
+bool DlgEdForm::EndCreate(SdrDragStat& rStat, SdrCreateCmd eCmd)
+{
+ bool bResult = SdrUnoObj::EndCreate(rStat, eCmd);
+
+ // stop listening
+ EndListening(sal_False);
+
+ // set geometry properties
+ SetPropsFromRect();
+
+ // dialog model changed
+ GetDlgEditor()->SetDialogModelChanged(sal_True);
+
+ // start listening
+ StartListening();
+
+ return bResult;
+}
+
+//----------------------------------------------------------------------------
+
+awt::DeviceInfo DlgEdForm::getDeviceInfo() const
+{
+ awt::DeviceInfo aDeviceInfo;
+
+ DlgEditor* pEditor = GetDlgEditor();
+ DBG_ASSERT( pEditor, "DlgEdForm::getDeviceInfo: no editor associated with the form object!" );
+ if ( !pEditor )
+ return aDeviceInfo;
+
+ Window* pWindow = pEditor->GetWindow();
+ DBG_ASSERT( pWindow, "DlgEdForm::getDeviceInfo: no window associated with the editor!" );
+ if ( !pWindow )
+ return aDeviceInfo;
+
+ // obtain an XControl
+ ::utl::SharedUNOComponent< awt::XControl > xDialogControl; // ensures auto-disposal, if needed
+ xDialogControl.reset( GetControl(), ::utl::SharedUNOComponent< awt::XControl >::NoTakeOwnership );
+ if ( !xDialogControl.is() )
+ {
+ // don't create a temporary control all the time, this method here is called
+ // way too often. Instead, use a cached DeviceInfo.
+ // #i74065#
+ if ( !!mpDeviceInfo )
+ return *mpDeviceInfo;
+
+ Reference< awt::XControlContainer > xEditorControlContainer( pEditor->GetWindowControlContainer() );
+ xDialogControl.reset(
+ GetTemporaryControlForWindow( *pWindow, xEditorControlContainer ),
+ ::utl::SharedUNOComponent< awt::XControl >::TakeOwnership );
+ }
+
+ Reference< awt::XDevice > xDialogDevice;
+ if ( xDialogControl.is() )
+ xDialogDevice.set( xDialogControl->getPeer(), UNO_QUERY );
+ DBG_ASSERT( xDialogDevice.is(), "DlgEdForm::getDeviceInfo: no device!" );
+ if ( xDialogDevice.is() )
+ aDeviceInfo = xDialogDevice->getInfo();
+
+ mpDeviceInfo.reset( aDeviceInfo );
+
+ return aDeviceInfo;
+}
+
+//----------------------------------------------------------------------------
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/basctl/source/dlged/dlgedpage.cxx b/basctl/source/dlged/dlgedpage.cxx
new file mode 100644
index 000000000000..67858c66c5ec
--- /dev/null
+++ b/basctl/source/dlged/dlgedpage.cxx
@@ -0,0 +1,89 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_basctl.hxx"
+
+
+#include "dlgedpage.hxx"
+#include "dlged.hxx"
+#include "dlgedmod.hxx"
+#include "dlgedobj.hxx"
+
+
+TYPEINIT1( DlgEdPage, SdrPage );
+
+//----------------------------------------------------------------------------
+
+DlgEdPage::DlgEdPage( DlgEdModel& rModel, bool bMasterPage )
+ :SdrPage( rModel, bMasterPage )
+{
+}
+
+//----------------------------------------------------------------------------
+
+DlgEdPage::DlgEdPage( const DlgEdPage& rPage )
+ :SdrPage( rPage )
+{
+ pDlgEdForm = rPage.pDlgEdForm;
+}
+
+//----------------------------------------------------------------------------
+
+DlgEdPage::~DlgEdPage()
+{
+ Clear();
+}
+
+//----------------------------------------------------------------------------
+
+SdrPage* DlgEdPage::Clone() const
+{
+ return new DlgEdPage( *this );
+}
+
+//----------------------------------------------------------------------------
+
+SdrObject* DlgEdPage::SetObjectOrdNum(sal_uLong nOldObjNum, sal_uLong nNewObjNum)
+{
+ SdrObject* pObj = SdrPage::SetObjectOrdNum( nOldObjNum, nNewObjNum );
+
+ DlgEdHint aHint( DLGED_HINT_OBJORDERCHANGED );
+ if ( pDlgEdForm )
+ {
+ DlgEditor* pDlgEditor = pDlgEdForm->GetDlgEditor();
+ if ( pDlgEditor )
+ pDlgEditor->Broadcast( aHint );
+ }
+
+ return pObj;
+}
+
+//----------------------------------------------------------------------------
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/basctl/source/dlged/dlgedview.cxx b/basctl/source/dlged/dlgedview.cxx
new file mode 100644
index 000000000000..7b1e22f82b7d
--- /dev/null
+++ b/basctl/source/dlged/dlgedview.cxx
@@ -0,0 +1,217 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_basctl.hxx"
+
+
+#include "dlgedview.hxx"
+#include "dlged.hxx"
+#include <dlgedpage.hxx>
+
+#include <svx/svxids.hrc>
+#include <sfx2/viewfrm.hxx>
+
+#include <basidesh.hxx>
+#include <iderdll.hxx>
+#include "dlgedobj.hxx"
+
+TYPEINIT1( DlgEdView, SdrView );
+
+//----------------------------------------------------------------------------
+
+DlgEdView::DlgEdView( SdrModel* pModel, OutputDevice* pOut, DlgEditor* pEditor )
+ :SdrView( pModel, pOut )
+ ,pDlgEditor( pEditor )
+{
+ // #114898#
+ SetBufferedOutputAllowed(true);
+ SetBufferedOverlayAllowed(true);
+}
+
+//----------------------------------------------------------------------------
+
+DlgEdView::~DlgEdView()
+{
+}
+
+//----------------------------------------------------------------------------
+
+void DlgEdView::MarkListHasChanged()
+{
+ SdrView::MarkListHasChanged();
+
+ DlgEdHint aHint( DLGED_HINT_SELECTIONCHANGED );
+ if ( pDlgEditor )
+ {
+ pDlgEditor->Broadcast( aHint );
+ pDlgEditor->UpdatePropertyBrowserDelayed();
+ }
+}
+
+//----------------------------------------------------------------------------
+
+void DlgEdView::MakeVisible( const Rectangle& rRect, Window& rWin )
+{
+ // visible area
+ MapMode aMap( rWin.GetMapMode() );
+ Point aOrg( aMap.GetOrigin() );
+ Size aVisSize( rWin.GetOutputSize() );
+ Rectangle RectTmp( Point(-aOrg.X(),-aOrg.Y()), aVisSize );
+ Rectangle aVisRect( RectTmp );
+
+ // check, if rectangle is inside visible area
+ if ( !aVisRect.IsInside( rRect ) )
+ {
+ // calculate scroll distance; the rectangle must be inside the visible area
+ sal_Int32 nScrollX = 0, nScrollY = 0;
+
+ sal_Int32 nVisLeft = aVisRect.Left();
+ sal_Int32 nVisRight = aVisRect.Right();
+ sal_Int32 nVisTop = aVisRect.Top();
+ sal_Int32 nVisBottom = aVisRect.Bottom();
+
+ sal_Int32 nDeltaX = pDlgEditor->GetHScroll()->GetLineSize();
+ sal_Int32 nDeltaY = pDlgEditor->GetVScroll()->GetLineSize();
+
+ while ( rRect.Right() > nVisRight + nScrollX )
+ nScrollX += nDeltaX;
+
+ while ( rRect.Left() < nVisLeft + nScrollX )
+ nScrollX -= nDeltaX;
+
+ while ( rRect.Bottom() > nVisBottom + nScrollY )
+ nScrollY += nDeltaY;
+
+ while ( rRect.Top() < nVisTop + nScrollY )
+ nScrollY -= nDeltaY;
+
+ // don't scroll beyond the page size
+ Size aPageSize = pDlgEditor->GetPage()->GetSize();
+ sal_Int32 nPageWidth = aPageSize.Width();
+ sal_Int32 nPageHeight = aPageSize.Height();
+
+ if ( nVisRight + nScrollX > nPageWidth )
+ nScrollX = nPageWidth - nVisRight;
+
+ if ( nVisLeft + nScrollX < 0 )
+ nScrollX = -nVisLeft;
+
+ if ( nVisBottom + nScrollY > nPageHeight )
+ nScrollY = nPageHeight - nVisBottom;
+
+ if ( nVisTop + nScrollY < 0 )
+ nScrollY = -nVisTop;
+
+ // scroll window
+ rWin.Update();
+ rWin.Scroll( -nScrollX, -nScrollY );
+ aMap.SetOrigin( Point( aOrg.X() - nScrollX, aOrg.Y() - nScrollY ) );
+ rWin.SetMapMode( aMap );
+ rWin.Update();
+ rWin.Invalidate();
+
+ // update scroll bars
+ if ( pDlgEditor )
+ pDlgEditor->UpdateScrollBars();
+
+ DlgEdHint aHint( DLGED_HINT_WINDOWSCROLLED );
+ if ( pDlgEditor )
+ pDlgEditor->Broadcast( aHint );
+ }
+}
+
+//----------------------------------------------------------------------------
+
+SdrObject* impLocalHitCorrection(SdrObject* pRetval, const Point& rPnt, sal_uInt16 nTol)
+{
+ DlgEdObj* pDlgEdObj = dynamic_cast< DlgEdObj* >(pRetval);
+
+ if(pDlgEdObj)
+ {
+ bool bExcludeInner(false);
+
+ if(0 != dynamic_cast< DlgEdForm* >(pRetval))
+ {
+ // from DlgEdForm::CheckHit; exclude inner for DlgEdForm
+ bExcludeInner = true;
+ }
+ else if(pDlgEdObj->supportsService("com.sun.star.awt.UnoControlGroupBoxModel"))
+ {
+ // from DlgEdObj::CheckHit; exclude inner for group shapes
+ bExcludeInner = true;
+ }
+
+ if(bExcludeInner)
+ {
+ // use direct model data; it's a DlgEdObj, so GetLastBoundRect()
+ // will access aOutRect directly
+ const Rectangle aOuterRectangle(pDlgEdObj->GetLastBoundRect());
+
+ if(!aOuterRectangle.IsEmpty()
+ && RECT_EMPTY != aOuterRectangle.Right()
+ && RECT_EMPTY != aOuterRectangle.Bottom())
+ {
+ basegfx::B2DRange aOuterRange(
+ aOuterRectangle.Left(), aOuterRectangle.Top(),
+ aOuterRectangle.Right(), aOuterRectangle.Bottom());
+
+ if(nTol)
+ {
+ aOuterRange.grow(-1.0 * nTol);
+ }
+
+ if(aOuterRange.isInside(basegfx::B2DPoint(rPnt.X(), rPnt.Y())))
+ {
+ pRetval = 0;
+ }
+ }
+ }
+ }
+
+ return pRetval;
+}
+
+SdrObject* DlgEdView::CheckSingleSdrObjectHit(const Point& rPnt, sal_uInt16 nTol, SdrObject* pObj, SdrPageView* pPV, sal_uLong nOptions, const SetOfByte* pMVisLay) const
+{
+ // call parent
+ SdrObject* pRetval = SdrView::CheckSingleSdrObjectHit(rPnt, nTol, pObj, pPV, nOptions, pMVisLay);
+
+ if(pRetval)
+ {
+ // check hitted object locally
+ pRetval = impLocalHitCorrection(pRetval, rPnt, nTol);
+ }
+
+ return pRetval;
+}
+
+//----------------------------------------------------------------------------
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/basctl/source/dlged/dlgresid.src b/basctl/source/dlged/dlgresid.src
new file mode 100644
index 000000000000..ee37d82233e1
--- /dev/null
+++ b/basctl/source/dlged/dlgresid.src
@@ -0,0 +1,175 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "dlgresid.hrc"
+
+// Dialog Controls ---------------------------------------------------------------
+
+String RID_STR_CLASS_CONTROL
+{
+ Text = "Control" ;
+};
+String RID_STR_CLASS_DIALOG
+{
+ Text = "Dialog" ;
+};
+String RID_STR_CLASS_BUTTON
+{
+ Text = "CommandButton" ;
+};
+String RID_STR_CLASS_RADIOBUTTON
+{
+ Text = "OptionButton" ;
+};
+String RID_STR_CLASS_CHECKBOX
+{
+ Text = "CheckBox" ;
+};
+String RID_STR_CLASS_LISTBOX
+{
+ Text = "ListBox" ;
+};
+String RID_STR_CLASS_COMBOBOX
+{
+ Text = "ComboBox" ;
+};
+String RID_STR_CLASS_GROUPBOX
+{
+ Text = "FrameControl" ;
+};
+String RID_STR_CLASS_EDIT
+{
+ Text = "TextField" ;
+};
+String RID_STR_CLASS_FIXEDTEXT
+{
+ Text = "Label" ;
+};
+String RID_STR_CLASS_IMAGECONTROL
+{
+ Text = "ImageControl" ;
+};
+String RID_STR_CLASS_PROGRESSBAR
+{
+ Text = "ProgressBar" ;
+};
+String RID_STR_CLASS_SCROLLBAR
+{
+ Text = "ScrollBar" ;
+};
+String RID_STR_CLASS_FIXEDLINE
+{
+ Text = "FixedLine" ;
+};
+String RID_STR_CLASS_DATEFIELD
+{
+ Text = "DateField" ;
+};
+String RID_STR_CLASS_TIMEFIELD
+{
+ Text = "TimeField" ;
+};
+String RID_STR_CLASS_NUMERICFIELD
+{
+ Text = "NumericField" ;
+};
+String RID_STR_CLASS_CURRENCYFIELD
+{
+ Text = "CurrencyField" ;
+};
+String RID_STR_CLASS_FORMATTEDFIELD
+{
+ Text = "FormattedField" ;
+};
+String RID_STR_CLASS_PATTERNFIELD
+{
+ Text = "PatternField" ;
+};
+String RID_STR_CLASS_FILECONTROL
+{
+ Text = "FileControl" ;
+};
+String RID_STR_CLASS_TREECONTROL
+{
+ Text = "TreeControl" ;
+};
+
+
+// Property Browser Headline ----------------------------------------------------------------
+
+String RID_STR_BRWTITLE_PROPERTIES
+{
+ Text [ en-US ] = "Properties: ";
+};
+String RID_STR_BRWTITLE_NO_PROPERTIES
+{
+ Text [ en-US ] = "No Control marked";
+};
+String RID_STR_BRWTITLE_MULTISELECT
+{
+ Text [ en-US ] = "Multiselection";
+};
+
+// -----------------------------------------------------------------------
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/basctl/source/dlged/makefile.mk b/basctl/source/dlged/makefile.mk
new file mode 100644
index 000000000000..6eacc9c2dd1e
--- /dev/null
+++ b/basctl/source/dlged/makefile.mk
@@ -0,0 +1,63 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ=..$/..
+
+PRJNAME=basctl
+TARGET=dlged
+AUTOSEG=true
+VISIBILITY_HIDDEN=TRUE
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+
+# --- Files --------------------------------------------------------
+
+EXCEPTIONSFILES= \
+ $(SLO)$/dlged.obj \
+ $(SLO)$/dlgedclip.obj \
+ $(SLO)$/dlgedfac.obj \
+ $(SLO)$/dlgedfunc.obj \
+ $(SLO)$/dlgedlist.obj \
+ $(SLO)$/dlgedmod.obj \
+ $(SLO)$/dlgedobj.obj \
+ $(SLO)$/dlgedpage.obj \
+ $(SLO)$/dlgedview.obj \
+ $(SLO)$/managelang.obj \
+ $(SLO)$/propbrw.obj
+
+SLOFILES= $(EXCEPTIONSFILES)
+
+SRS1NAME=$(TARGET)
+SRC1FILES= dlgresid.src \
+ managelang.src
+
+# --- Targets -------------------------------------------------------
+
+.INCLUDE : target.mk
+
diff --git a/basctl/source/dlged/managelang.cxx b/basctl/source/dlged/managelang.cxx
new file mode 100644
index 000000000000..dfdf30d63300
--- /dev/null
+++ b/basctl/source/dlged/managelang.cxx
@@ -0,0 +1,427 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_basctl.hxx"
+
+#include "managelang.hxx"
+#include "iderid.hxx"
+#include "localizationmgr.hxx"
+#include "iderdll.hxx"
+#include "basidesh.hxx"
+#include "basobj.hxx"
+
+#include "managelang.hrc"
+#include "dlgresid.hrc"
+#include "helpid.hrc"
+
+#include <com/sun/star/i18n/XBreakIterator.hpp>
+#include <com/sun/star/i18n/WordType.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/resource/XStringResourceManager.hpp>
+#include <comphelper/processfactory.hxx>
+#include <vcl/unohelp.hxx>
+#include <vcl/svapp.hxx>
+#include <vcl/msgbox.hxx>
+#include <unotools/localedatawrapper.hxx>
+#include <editeng/unolingu.hxx>
+
+#include <svtools/langtab.hxx>
+
+#include <sfx2/bindings.hxx>
+
+using namespace ::com::sun::star::i18n;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::resource;
+using namespace ::com::sun::star::uno;
+
+bool localesAreEqual( const Locale& rLocaleLeft, const Locale& rLocaleRight )
+{
+ bool bRet = ( rLocaleLeft.Language.equals( rLocaleRight.Language ) &&
+ rLocaleLeft.Country.equals( rLocaleRight.Country ) &&
+ rLocaleLeft.Variant.equals( rLocaleRight.Variant ) );
+ return bRet;
+}
+
+namespace {
+ long getLongestWordWidth( const String& rText, const Window& rWin )
+ {
+ long nWidth = 0;
+ Reference< XBreakIterator > xBreakIter( vcl::unohelper::CreateBreakIterator() );
+ sal_Int32 nStartPos = 0;
+ const Locale aLocale = Application::GetSettings().GetUILocale();
+ Boundary aBoundary = xBreakIter->getWordBoundary(
+ rText, nStartPos, aLocale, WordType::ANYWORD_IGNOREWHITESPACES, sal_True );
+
+ while ( aBoundary.startPos != aBoundary.endPos )
+ {
+ nStartPos = aBoundary.endPos;
+ String sWord( rText.Copy(
+ (sal_uInt16)aBoundary.startPos,
+ (sal_uInt16)aBoundary.endPos - (sal_uInt16)aBoundary.startPos ) );
+ long nTemp = rWin.GetCtrlTextWidth( sWord );
+ if ( nTemp > nWidth )
+ nWidth = nTemp;
+ aBoundary = xBreakIter->nextWord(
+ rText, nStartPos, aLocale, WordType::ANYWORD_IGNOREWHITESPACES );
+ }
+
+ return nWidth;
+ }
+}
+
+ManageLanguageDialog::ManageLanguageDialog( Window* pParent, LocalizationMgr* _pLMgr ) :
+
+ ModalDialog( pParent, IDEResId( RID_DLG_MANAGE_LANGUAGE ) ),
+
+ m_aLanguageFT ( this, IDEResId( FT_LANGUAGE ) ),
+ m_aLanguageLB ( this, IDEResId( LB_LANGUAGE ) ),
+ m_aAddPB ( this, IDEResId( PB_ADD_LANG ) ),
+ m_aDeletePB ( this, IDEResId( PB_DEL_LANG ) ),
+ m_aMakeDefPB ( this, IDEResId( PB_MAKE_DEFAULT ) ),
+ m_aInfoFT ( this, IDEResId( FT_INFO ) ),
+ m_aBtnLine ( this, IDEResId( FL_BUTTONS ) ),
+ m_aHelpBtn ( this, IDEResId( PB_HELP ) ),
+ m_aCloseBtn ( this, IDEResId( PB_CLOSE ) ),
+ m_pLocalizationMgr ( _pLMgr ),
+ m_sDefLangStr ( IDEResId( STR_DEF_LANG ) ),
+ m_sDeleteStr ( IDEResId( STR_DELETE ) ),
+ m_sCreateLangStr ( IDEResId( STR_CREATE_LANG ) )
+
+{
+ FreeResource();
+
+ Init();
+ FillLanguageBox();
+ SelectHdl( NULL );
+}
+
+ManageLanguageDialog::~ManageLanguageDialog()
+{
+ ClearLanguageBox();
+}
+
+void ManageLanguageDialog::Init()
+{
+ // get current IDE
+ BasicIDEShell* pIDEShell = IDE_DLL()->GetShell();
+ String sLibName = pIDEShell->GetCurLibName();
+ // set dialog title with library name
+ String sText = GetText();
+ sText.SearchAndReplace( String::CreateFromAscii("$1"), sLibName );
+ SetText( sText );
+ // set handler
+ m_aAddPB.SetClickHdl( LINK( this, ManageLanguageDialog, AddHdl ) );
+ m_aDeletePB.SetClickHdl( LINK( this, ManageLanguageDialog, DeleteHdl ) );
+ m_aMakeDefPB.SetClickHdl( LINK( this, ManageLanguageDialog, MakeDefHdl ) );
+ m_aLanguageLB.SetSelectHdl( LINK( this, ManageLanguageDialog, SelectHdl ) );
+
+ m_aLanguageLB.EnableMultiSelection( sal_True );
+ CalcInfoSize();
+}
+
+void ManageLanguageDialog::CalcInfoSize()
+{
+ String sInfoStr = m_aInfoFT.GetText();
+ long nInfoWidth = m_aInfoFT.GetSizePixel().Width();
+ long nLongWord = getLongestWordWidth( sInfoStr, m_aInfoFT );
+ long nTxtWidth = m_aInfoFT.GetCtrlTextWidth( sInfoStr ) + nLongWord;
+ long nLines = ( nTxtWidth / nInfoWidth ) + 1;
+ if ( nLines > INFO_LINES_COUNT )
+ {
+ Size aFTSize = m_aLanguageFT.GetSizePixel();
+ Size aSize = m_aInfoFT.GetSizePixel();
+ long nNewHeight = aFTSize.Height() * nLines;
+ long nDelta = nNewHeight - aSize.Height();
+ aSize.Height() = nNewHeight;
+ m_aInfoFT.SetSizePixel( aSize );
+
+ aSize = m_aLanguageLB.GetSizePixel();
+ aSize.Height() -= nDelta;
+ m_aLanguageLB.SetSizePixel( aSize );
+
+ Point aNewPos = m_aInfoFT.GetPosPixel();
+ aNewPos.Y() -= nDelta;
+ m_aInfoFT.SetPosPixel( aNewPos );
+ aNewPos = m_aMakeDefPB.GetPosPixel();
+ aNewPos.Y() -= nDelta;
+ m_aMakeDefPB.SetPosPixel( aNewPos );
+ }
+}
+
+void ManageLanguageDialog::FillLanguageBox()
+{
+ DBG_ASSERT( m_pLocalizationMgr, "ManageLanguageDialog::FillLanguageBox(): no localization manager" );
+
+ if ( m_pLocalizationMgr->isLibraryLocalized() )
+ {
+ SvtLanguageTable aLangTable;
+ Locale aDefaultLocale = m_pLocalizationMgr->getStringResourceManager()->getDefaultLocale();
+ Sequence< Locale > aLocaleSeq = m_pLocalizationMgr->getStringResourceManager()->getLocales();
+ const Locale* pLocale = aLocaleSeq.getConstArray();
+ sal_Int32 i, nCount = aLocaleSeq.getLength();
+ for ( i = 0; i < nCount; ++i )
+ {
+ bool bIsDefault = localesAreEqual( aDefaultLocale, pLocale[i] );
+ LanguageType eLangType = SvxLocaleToLanguage( pLocale[i] );
+ String sLanguage = aLangTable.GetString( eLangType );
+ if ( bIsDefault )
+ {
+ sLanguage += ' ';
+ sLanguage += m_sDefLangStr;
+ }
+ sal_uInt16 nPos = m_aLanguageLB.InsertEntry( sLanguage );
+ m_aLanguageLB.SetEntryData( nPos, new LanguageEntry( sLanguage, pLocale[i], bIsDefault ) );
+ }
+ }
+ else
+ m_aLanguageLB.InsertEntry( m_sCreateLangStr );
+}
+
+void ManageLanguageDialog::ClearLanguageBox()
+{
+ sal_uInt16 i, nCount = m_aLanguageLB.GetEntryCount();
+ for ( i = 0; i < nCount; ++i )
+ {
+ LanguageEntry* pEntry = (LanguageEntry*)( m_aLanguageLB.GetEntryData(i) );
+ if ( pEntry )
+ delete pEntry;
+ }
+ m_aLanguageLB.Clear();
+}
+
+IMPL_LINK( ManageLanguageDialog, AddHdl, Button *, EMPTYARG )
+{
+ SetDefaultLanguageDialog aDlg( this, m_pLocalizationMgr );
+ if ( RET_OK == aDlg.Execute() )
+ {
+ // add new locales
+ Sequence< Locale > aLocaleSeq = aDlg.GetLocales();
+ m_pLocalizationMgr->handleAddLocales( aLocaleSeq );
+ // update listbox
+ ClearLanguageBox();
+ FillLanguageBox();
+
+ SfxBindings* pBindings = BasicIDE::GetBindingsPtr();
+ if ( pBindings )
+ pBindings->Invalidate( SID_BASICIDE_CURRENT_LANG );
+ }
+ return 1;
+}
+
+IMPL_LINK( ManageLanguageDialog, DeleteHdl, Button *, EMPTYARG )
+{
+ QueryBox aQBox( this, IDEResId( RID_QRYBOX_LANGUAGE ) );
+ aQBox.SetButtonText( RET_OK, m_sDeleteStr );
+ if ( aQBox.Execute() == RET_OK )
+ {
+ sal_uInt16 i, nCount = m_aLanguageLB.GetSelectEntryCount();
+ sal_uInt16 nPos = m_aLanguageLB.GetSelectEntryPos();
+ // remove locales
+ Sequence< Locale > aLocaleSeq( nCount );
+ for ( i = 0; i < nCount; ++i )
+ {
+ sal_uInt16 nSelPos = m_aLanguageLB.GetSelectEntryPos(i);
+ LanguageEntry* pEntry = (LanguageEntry*)( m_aLanguageLB.GetEntryData( nSelPos ) );
+ if ( pEntry )
+ aLocaleSeq[i] = pEntry->m_aLocale;
+ }
+ m_pLocalizationMgr->handleRemoveLocales( aLocaleSeq );
+ // update listbox
+ ClearLanguageBox();
+ FillLanguageBox();
+ // reset selection
+ nCount = m_aLanguageLB.GetEntryCount();
+ if ( nCount <= nPos )
+ nPos = nCount - 1;
+ m_aLanguageLB.SelectEntryPos( nPos );
+ SelectHdl( NULL );
+ }
+ return 1;
+}
+
+IMPL_LINK( ManageLanguageDialog, MakeDefHdl, Button *, EMPTYARG )
+{
+ sal_uInt16 nPos = m_aLanguageLB.GetSelectEntryPos();
+ LanguageEntry* pSelectEntry = (LanguageEntry*)( m_aLanguageLB.GetEntryData( nPos ) );
+ if ( pSelectEntry && !pSelectEntry->m_bIsDefault )
+ {
+ // set new default entry
+ m_pLocalizationMgr->handleSetDefaultLocale( pSelectEntry->m_aLocale );
+ // update Listbox
+ ClearLanguageBox();
+ FillLanguageBox();
+ // reset selection
+ m_aLanguageLB.SelectEntryPos( nPos );
+ SelectHdl( NULL );
+ }
+
+ return 1;
+}
+
+IMPL_LINK( ManageLanguageDialog, SelectHdl, ListBox *, EMPTYARG )
+{
+ sal_uInt16 nCount = m_aLanguageLB.GetEntryCount();
+ bool bEmpty = ( !nCount ||
+ m_aLanguageLB.GetEntryPos( m_sCreateLangStr ) != LISTBOX_ENTRY_NOTFOUND );
+ bool bSelect = ( m_aLanguageLB.GetSelectEntryPos() != LISTBOX_ENTRY_NOTFOUND );
+ bool bEnable = ( !bEmpty && bSelect != false );
+
+ m_aDeletePB.Enable( bEnable != false );
+ m_aMakeDefPB.Enable( bEnable != false && nCount > 1 && m_aLanguageLB.GetSelectEntryCount() == 1 );
+
+ return 1;
+}
+
+// class SetDefaultLanguageDialog -----------------------------------------------
+
+SetDefaultLanguageDialog::SetDefaultLanguageDialog( Window* pParent, LocalizationMgr* _pLMgr ) :
+
+ ModalDialog( pParent, IDEResId( RID_DLG_SETDEF_LANGUAGE ) ),
+
+ m_aLanguageFT ( this, IDEResId( FT_DEF_LANGUAGE ) ),
+ m_pLanguageLB ( new SvxLanguageBox( this, IDEResId( LB_DEF_LANGUAGE ) ) ),
+ m_pCheckLangLB ( NULL ),
+ m_aInfoFT ( this, IDEResId( FT_DEF_INFO ) ),
+ m_aBtnLine ( this, IDEResId( FL_DEF_BUTTONS ) ),
+ m_aOKBtn ( this, IDEResId( PB_DEF_OK ) ),
+ m_aCancelBtn ( this, IDEResId( PB_DEF_CANCEL ) ),
+ m_aHelpBtn ( this, IDEResId( PB_DEF_HELP ) ),
+
+ m_pLocalizationMgr( _pLMgr )
+
+{
+ if ( m_pLocalizationMgr->isLibraryLocalized() )
+ {
+ // change to "Add Interface Language" mode
+ SetHelpId( HID_BASICIDE_ADDNEW_LANGUAGE );
+ m_pCheckLangLB = new SvxCheckListBox( this, IDEResId( LB_ADD_LANGUAGE ) );
+ SetText( String( IDEResId( STR_ADDLANG_TITLE ) ) );
+ m_aLanguageFT.SetText( String( IDEResId( STR_ADDLANG_LABEL ) ) );
+ m_aInfoFT.SetText( String( IDEResId( STR_ADDLANG_INFO ) ) );
+ }
+
+ FreeResource();
+
+ FillLanguageBox();
+ CalcInfoSize();
+}
+
+SetDefaultLanguageDialog::~SetDefaultLanguageDialog()
+{
+ delete m_pLanguageLB;
+ delete m_pCheckLangLB;
+}
+
+void SetDefaultLanguageDialog::FillLanguageBox()
+{
+ // fill list with all languages
+ m_pLanguageLB->SetLanguageList( LANG_LIST_ALL, sal_False );
+ // remove the already localized languages
+ Sequence< Locale > aLocaleSeq = m_pLocalizationMgr->getStringResourceManager()->getLocales();
+ const Locale* pLocale = aLocaleSeq.getConstArray();
+ sal_Int32 i, nCount = aLocaleSeq.getLength();
+ for ( i = 0; i < nCount; ++i )
+ m_pLanguageLB->RemoveLanguage( SvxLocaleToLanguage( pLocale[i] ) );
+
+ // fill checklistbox if not in default mode
+ if ( m_pLocalizationMgr->isLibraryLocalized() )
+ {
+ sal_uInt16 j, nCount_ = m_pLanguageLB->GetEntryCount();
+ for ( j = 0; j < nCount_; ++j )
+ {
+ m_pCheckLangLB->InsertEntry(
+ m_pLanguageLB->GetEntry(j), LISTBOX_APPEND, m_pLanguageLB->GetEntryData(j) );
+ }
+ delete m_pLanguageLB;
+ m_pLanguageLB = NULL;
+ }
+ else
+ // preselect current UI language
+ m_pLanguageLB->SelectLanguage( Application::GetSettings().GetUILanguage() );
+}
+
+void SetDefaultLanguageDialog::CalcInfoSize()
+{
+ String sInfoStr = m_aInfoFT.GetText();
+ long nInfoWidth = m_aInfoFT.GetSizePixel().Width();
+ long nLongWord = getLongestWordWidth( sInfoStr, m_aInfoFT );
+ long nTxtWidth = m_aInfoFT.GetCtrlTextWidth( sInfoStr ) + nLongWord;
+ long nLines = ( nTxtWidth / nInfoWidth ) + 1;
+ if ( nLines > INFO_LINES_COUNT )
+ {
+ Size aFTSize = m_aLanguageFT.GetSizePixel();
+ Size aSize = m_aInfoFT.GetSizePixel();
+ long nNewHeight = aFTSize.Height() * nLines;
+ long nDelta = nNewHeight - aSize.Height();
+ aSize.Height() = nNewHeight;
+ m_aInfoFT.SetSizePixel( aSize );
+
+ Window* pWin = ( m_pLanguageLB != NULL ) ? dynamic_cast< Window* >( m_pLanguageLB )
+ : dynamic_cast< Window* >( m_pCheckLangLB );
+ aSize = pWin->GetSizePixel();
+ aSize.Height() -= nDelta;
+ pWin->SetSizePixel( aSize );
+
+ Point aNewPos = m_aInfoFT.GetPosPixel();
+ aNewPos.Y() -= nDelta;
+ m_aInfoFT.SetPosPixel( aNewPos );
+ }
+}
+
+Sequence< Locale > SetDefaultLanguageDialog::GetLocales() const
+{
+ bool bNotLocalized = !m_pLocalizationMgr->isLibraryLocalized();
+ sal_Int32 nSize = bNotLocalized ? 1 : m_pCheckLangLB->GetCheckedEntryCount();
+ Sequence< Locale > aLocaleSeq( nSize );
+ if ( bNotLocalized )
+ {
+ Locale aLocale;
+ SvxLanguageToLocale( aLocale, m_pLanguageLB->GetSelectLanguage() );
+ aLocaleSeq[0] = aLocale;
+ }
+ else
+ {
+ sal_uInt16 i, nCount = static_cast< sal_uInt16 >( m_pCheckLangLB->GetEntryCount() );
+ sal_Int32 j = 0;
+ for ( i = 0; i < nCount; ++i )
+ {
+ if ( m_pCheckLangLB->IsChecked(i) )
+ {
+ LanguageType eType = LanguageType( (sal_uLong)m_pCheckLangLB->GetEntryData(i) );
+ Locale aLocale;
+ SvxLanguageToLocale( aLocale, eType );
+ aLocaleSeq[j++] = aLocale;
+ }
+ }
+ DBG_ASSERT( nSize == j, "SetDefaultLanguageDialog::GetLocales(): invalid indexes" );
+ }
+ return aLocaleSeq;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/basctl/source/dlged/managelang.hrc b/basctl/source/dlged/managelang.hrc
new file mode 100644
index 000000000000..e3a7f7f1edde
--- /dev/null
+++ b/basctl/source/dlged/managelang.hrc
@@ -0,0 +1,106 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _BASCTL_MANAGELANG_HRC
+#define _BASCTL_MANAGELANG_HRC
+
+// Include -----------------------------------------------------------------------
+
+#include <svtools/controldims.hrc>
+
+// Dialog Control Id's -----------------------------------------------------------
+
+#define FT_LANGUAGE 1
+#define LB_LANGUAGE 2
+#define PB_ADD_LANG 3
+#define PB_DEL_LANG 4
+#define PB_MAKE_DEFAULT 5
+#define FT_INFO 6
+#define FL_BUTTONS 7
+#define PB_HELP 8
+#define PB_CLOSE 9
+#define STR_DEF_LANG 10
+#define STR_DELETE 11
+#define STR_CREATE_LANG 12
+
+#define FT_DEF_LANGUAGE 1
+#define LB_DEF_LANGUAGE 2
+#define LB_ADD_LANGUAGE 3
+#define FT_DEF_INFO 4
+#define FL_DEF_BUTTONS 5
+#define PB_DEF_OK 6
+#define PB_DEF_CANCEL 7
+#define PB_DEF_HELP 8
+#define STR_ADDLANG_TITLE 9
+#define STR_ADDLANG_LABEL 10
+#define STR_ADDLANG_INFO 11
+
+// Metrics -----------------------------------------------------------------------
+
+#define MANAGE_DLG_WIDTH 240
+#define MANAGE_DLG_HEIGHT 180
+#define INFO_LINES_COUNT 3
+
+#define MANAGE_COL1 RSC_SP_DLG_INNERBORDER_LEFT
+#define MANAGE_COL2 (MANAGE_DLG_WIDTH - RSC_SP_DLG_INNERBORDER_RIGHT - 2*RSC_CD_PUSHBUTTON_WIDTH - RSC_SP_CTRL_X)
+#define MANAGE_COL3 (MANAGE_COL2 + RSC_CD_PUSHBUTTON_WIDTH + RSC_SP_CTRL_X)
+
+#define MANAGE_ROW1 RSC_SP_DLG_INNERBORDER_TOP
+#define MANAGE_ROW2 (MANAGE_ROW1 + RSC_CD_FIXEDTEXT_HEIGHT + RSC_SP_CTRL_DESC_Y)
+#define MANAGE_ROW3 (MANAGE_ROW2 + RSC_CD_PUSHBUTTON_HEIGHT + RSC_SP_CTRL_GROUP_Y)
+
+#define MANAGE_ROW7 (MANAGE_DLG_HEIGHT - RSC_SP_DLG_INNERBORDER_BOTTOM - RSC_CD_PUSHBUTTON_HEIGHT)
+#define MANAGE_ROW6 (MANAGE_ROW7 - RSC_SP_FLGR_SPACE_Y - RSC_CD_FIXEDLINE_HEIGHT)
+#define MANAGE_ROW5 (MANAGE_ROW6 - RSC_SP_FLGR_SPACE_Y - INFO_LINES_COUNT*RSC_CD_FIXEDTEXT_HEIGHT)
+#define MANAGE_ROW4 (MANAGE_ROW5 - RSC_SP_CTRL_GROUP_Y - RSC_CD_PUSHBUTTON_HEIGHT)
+#define MANAGE_ROW4A (MANAGE_ROW4 + RSC_CD_PUSHBUTTON_HEIGHT)
+
+#define MANAGE_LB_WIDTH (MANAGE_COL3 - RSC_SP_CTRL_X - RSC_SP_DLG_INNERBORDER_LEFT)
+#define MANAGE_LB_HEIGHT (MANAGE_ROW4A - MANAGE_ROW2)
+
+#define SETDEF_DLG_WIDTH 180
+#define SETDEF_DLG_HEIGHT 165
+
+#define SETDEF_COL1 RSC_SP_DLG_INNERBORDER_LEFT
+#define SETDEF_COL2 (SETDEF_DLG_WIDTH - RSC_SP_DLG_INNERBORDER_RIGHT - 3*RSC_CD_PUSHBUTTON_WIDTH - RSC_SP_CTRL_GROUP_X - RSC_SP_CTRL_X)
+#define SETDEF_COL3 (SETDEF_COL2 + RSC_CD_PUSHBUTTON_WIDTH + RSC_SP_CTRL_GROUP_X)
+#define SETDEF_COL4 (SETDEF_COL3 + RSC_CD_PUSHBUTTON_WIDTH + RSC_SP_CTRL_X)
+#define SETDEF_COL4A (SETDEF_COL4 + RSC_CD_PUSHBUTTON_WIDTH)
+
+#define SETDEF_ROW1 RSC_SP_DLG_INNERBORDER_TOP
+#define SETDEF_ROW2 (SETDEF_ROW1 + RSC_CD_FIXEDTEXT_HEIGHT + RSC_SP_CTRL_DESC_Y)
+
+#define SETDEF_ROW5 (SETDEF_DLG_HEIGHT - RSC_SP_DLG_INNERBORDER_BOTTOM - RSC_CD_PUSHBUTTON_HEIGHT)
+#define SETDEF_ROW4 (SETDEF_ROW5 - RSC_SP_FLGR_SPACE_Y - RSC_CD_FIXEDLINE_HEIGHT)
+#define SETDEF_ROW3 (SETDEF_ROW4 - RSC_SP_FLGR_SPACE_Y - INFO_LINES_COUNT*RSC_CD_FIXEDTEXT_HEIGHT)
+#define SETDEF_ROW3A (SETDEF_ROW3 - RSC_SP_CTRL_GROUP_Y)
+
+#define SETDEF_LB_WIDTH (SETDEF_COL4A - SETDEF_COL1)
+#define SETDEF_LB_HEIGHT (SETDEF_ROW3A - SETDEF_ROW2)
+
+#endif // _BASCTL_MANAGELANG_HRC
+
diff --git a/basctl/source/dlged/managelang.src b/basctl/source/dlged/managelang.src
new file mode 100644
index 000000000000..c83af6be6e38
--- /dev/null
+++ b/basctl/source/dlged/managelang.src
@@ -0,0 +1,237 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "dlgresid.hrc"
+#include "managelang.hrc"
+#include "helpid.hrc"
+
+ModalDialog RID_DLG_MANAGE_LANGUAGE
+{
+ HelpId = HID_BASICIDE_MANAGE_LANGUAGE ;
+ OutputSize = TRUE ;
+ Size = MAP_APPFONT ( MANAGE_DLG_WIDTH , MANAGE_DLG_HEIGHT ) ;
+ Moveable = TRUE ;
+ Closeable = TRUE ;
+ Text [ en-US ] = "Manage User Interface Languages [$1]" ;
+ FixedText FT_LANGUAGE
+ {
+ Pos = MAP_APPFONT ( MANAGE_COL1 , MANAGE_ROW1 ) ;
+ Size = MAP_APPFONT ( MANAGE_LB_WIDTH , RSC_CD_FIXEDTEXT_HEIGHT ) ;
+ Text [ en-US ] = "Present Languages" ;
+ };
+ ListBox LB_LANGUAGE
+ {
+ HelpID = "basctl:ListBox:RID_DLG_MANAGE_LANGUAGE:LB_LANGUAGE";
+ Pos = MAP_APPFONT ( MANAGE_COL1 , MANAGE_ROW2 ) ;
+ Size = MAP_APPFONT ( MANAGE_LB_WIDTH , MANAGE_LB_HEIGHT ) ;
+ Border = TRUE;
+ AutoHScroll = TRUE ;
+ };
+ PushButton PB_ADD_LANG
+ {
+ HelpID = "basctl:PushButton:RID_DLG_MANAGE_LANGUAGE:PB_ADD_LANG";
+ Pos = MAP_APPFONT ( MANAGE_COL3 , MANAGE_ROW2 ) ;
+ Size = MAP_APPFONT ( RSC_CD_PUSHBUTTON_WIDTH , RSC_CD_PUSHBUTTON_HEIGHT ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "Add..." ;
+ };
+ PushButton PB_DEL_LANG
+ {
+ HelpID = "basctl:PushButton:RID_DLG_MANAGE_LANGUAGE:PB_DEL_LANG";
+ Pos = MAP_APPFONT ( MANAGE_COL3 , MANAGE_ROW3 ) ;
+ Size = MAP_APPFONT ( RSC_CD_PUSHBUTTON_WIDTH , RSC_CD_PUSHBUTTON_HEIGHT ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "Delete" ;
+ };
+ PushButton PB_MAKE_DEFAULT
+ {
+ HelpID = "basctl:PushButton:RID_DLG_MANAGE_LANGUAGE:PB_MAKE_DEFAULT";
+ Pos = MAP_APPFONT ( MANAGE_COL3 , MANAGE_ROW4 ) ;
+ Size = MAP_APPFONT ( RSC_CD_PUSHBUTTON_WIDTH , RSC_CD_PUSHBUTTON_HEIGHT ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "Default" ;
+ };
+ FixedText FT_INFO
+ {
+ Pos = MAP_APPFONT ( MANAGE_COL1 , MANAGE_ROW5 ) ;
+ Size = MAP_APPFONT ( MANAGE_DLG_WIDTH - 2*RSC_SP_FLGR_INNERBORDER_LEFT, INFO_LINES_COUNT*RSC_CD_FIXEDTEXT_HEIGHT ) ;
+ WordBreak = TRUE ;
+ Text [ en-US ] = "The default language is used if no localization for a user interface locale is present. Furthermore all strings from the default language are copied to resources of newly added languages." ;
+ };
+ FixedLine FL_BUTTONS
+ {
+ Pos = MAP_APPFONT ( 0 , MANAGE_ROW6 ) ;
+ Size = MAP_APPFONT ( MANAGE_DLG_WIDTH, RSC_CD_FIXEDLINE_HEIGHT ) ;
+ };
+ HelpButton PB_HELP
+ {
+ Pos = MAP_APPFONT ( MANAGE_COL2 , MANAGE_ROW7 ) ;
+ Size = MAP_APPFONT ( RSC_CD_PUSHBUTTON_WIDTH , RSC_CD_PUSHBUTTON_HEIGHT ) ;
+ TabStop = TRUE ;
+ };
+ OKButton PB_CLOSE
+ {
+ Pos = MAP_APPFONT ( MANAGE_COL3 , MANAGE_ROW7 ) ;
+ Size = MAP_APPFONT ( RSC_CD_PUSHBUTTON_WIDTH , RSC_CD_PUSHBUTTON_HEIGHT ) ;
+ TabStop = TRUE ;
+ DefButton = TRUE ;
+ Text [ en-US ] = "~Close" ;
+ };
+ String STR_DEF_LANG
+ {
+ Text [ en-US ] = "[Default Language]" ;
+ };
+ String STR_DELETE
+ {
+ Text [ en-US ] = "~Delete" ;
+ };
+ String STR_CREATE_LANG
+ {
+ Text [ en-US ] = "<Press 'Add' to create language resources>" ;
+ };
+};
+
+QueryBox RID_QRYBOX_LANGUAGE
+{
+ Title [ en-US ] = "Delete Language Resources" ;
+ Message [ en-US ] = "You are about to delete the resources for the selected language(s). All user interface strings for this language(s) will be deleted.\n\nDo you want to delete the resources of the selected language(s)?";
+ BUTTONS = WB_OK_CANCEL ;
+ DEFBUTTON = WB_DEF_CANCEL ;
+};
+
+ModalDialog RID_DLG_SETDEF_LANGUAGE
+{
+ HelpId = HID_BASICIDE_SETDEFAULT_LANGUAGE ;
+ OutputSize = TRUE ;
+ Size = MAP_APPFONT ( SETDEF_DLG_WIDTH , SETDEF_DLG_HEIGHT ) ;
+ Moveable = TRUE ;
+ Closeable = TRUE ;
+ Text [ en-US ] = "Set Default User Interface Language" ;
+ FixedText FT_DEF_LANGUAGE
+ {
+ Pos = MAP_APPFONT ( SETDEF_COL1 , SETDEF_ROW1 ) ;
+ Size = MAP_APPFONT ( SETDEF_LB_WIDTH , RSC_CD_FIXEDTEXT_HEIGHT ) ;
+ Text [ en-US ] = "Default language" ;
+ };
+ ListBox LB_DEF_LANGUAGE
+ {
+ HelpID = "basctl:ListBox:RID_DLG_SETDEF_LANGUAGE:LB_DEF_LANGUAGE";
+ Pos = MAP_APPFONT ( SETDEF_COL1 , SETDEF_ROW2 ) ;
+ Size = MAP_APPFONT ( SETDEF_LB_WIDTH , SETDEF_LB_HEIGHT ) ;
+ Border = TRUE;
+ AutoHScroll = TRUE ;
+ };
+ Control LB_ADD_LANGUAGE
+ {
+ HelpId = HID_BASICIDE_ADDNEW_CONTROL ;
+ Pos = MAP_APPFONT ( SETDEF_COL1 , SETDEF_ROW2 ) ;
+ Size = MAP_APPFONT ( SETDEF_LB_WIDTH , SETDEF_LB_HEIGHT ) ;
+ };
+ FixedText FT_DEF_INFO
+ {
+ Pos = MAP_APPFONT ( SETDEF_COL1 , SETDEF_ROW3 ) ;
+ Size = MAP_APPFONT ( SETDEF_LB_WIDTH, INFO_LINES_COUNT*RSC_CD_FIXEDTEXT_HEIGHT ) ;
+ WordBreak = TRUE ;
+ Text [ en-US ] = "Select a language to define the default user interface language. All currently present strings will be assigned to the resources created for the selected language." ;
+ };
+ FixedLine FL_DEF_BUTTONS
+ {
+ Pos = MAP_APPFONT ( 0 , SETDEF_ROW4 ) ;
+ Size = MAP_APPFONT ( SETDEF_DLG_WIDTH, RSC_CD_FIXEDLINE_HEIGHT ) ;
+ };
+ OKButton PB_DEF_OK
+ {
+ Pos = MAP_APPFONT ( SETDEF_COL2 , SETDEF_ROW5 ) ;
+ Size = MAP_APPFONT ( RSC_CD_PUSHBUTTON_WIDTH , RSC_CD_PUSHBUTTON_HEIGHT ) ;
+ TabStop = TRUE ;
+ DefButton = TRUE ;
+ };
+ CancelButton PB_DEF_CANCEL
+ {
+ Pos = MAP_APPFONT ( SETDEF_COL3 , SETDEF_ROW5 ) ;
+ Size = MAP_APPFONT ( RSC_CD_PUSHBUTTON_WIDTH , RSC_CD_PUSHBUTTON_HEIGHT ) ;
+ TabStop = TRUE ;
+ };
+ HelpButton PB_DEF_HELP
+ {
+ Pos = MAP_APPFONT ( SETDEF_COL4 , SETDEF_ROW5 ) ;
+ Size = MAP_APPFONT ( RSC_CD_PUSHBUTTON_WIDTH , RSC_CD_PUSHBUTTON_HEIGHT ) ;
+ TabStop = TRUE ;
+ };
+ String STR_ADDLANG_TITLE
+ {
+ Text [ en-US ] = "Add User Interface Languages" ;
+ };
+ String STR_ADDLANG_LABEL
+ {
+ Text [ en-US ] = "Available Languages" ;
+ };
+ String STR_ADDLANG_INFO
+ {
+ Text [ en-US ] = "Select languages to be added. Resources for these languages will be created in the library. Strings of the current default user interface language will be copied to these new resources by default." ;
+ };
+};
+
+// -----------------------------------------------------------------------
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/basctl/source/dlged/propbrw.cxx b/basctl/source/dlged/propbrw.cxx
new file mode 100644
index 000000000000..ed6b49f130c1
--- /dev/null
+++ b/basctl/source/dlged/propbrw.cxx
@@ -0,0 +1,596 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_basctl.hxx"
+
+#include <sal/macros.h>
+#include "propbrw.hxx"
+#include "dlgedobj.hxx"
+
+#include "basidesh.hxx"
+#include <iderid.hxx>
+
+#include <dlgresid.hrc>
+#include <tools/debug.hxx>
+#include <tools/diagnose_ex.h>
+#include <sfx2/bindings.hxx>
+#include <sfx2/childwin.hxx>
+#include <sfx2/objitem.hxx>
+
+#include <svx/svxids.hrc>
+#include <tools/shl.hxx>
+#include <vcl/stdtext.hxx>
+#include <svx/svdview.hxx>
+#include <svx/svdogrp.hxx>
+#include <svx/svdpage.hxx>
+#include <svx/svditer.hxx>
+#include <sfx2/viewsh.hxx>
+
+#include <toolkit/unohlp.hxx>
+#include <comphelper/property.hxx>
+#include <comphelper/composedprops.hxx>
+#include <comphelper/stl_types.hxx>
+#include <comphelper/types.hxx>
+#include <com/sun/star/beans/PropertyValue.hpp>
+#include <com/sun/star/awt/PosSize.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/inspection/XObjectInspector.hpp>
+#include <comphelper/processfactory.hxx>
+#include <cppuhelper/component_context.hxx>
+
+#include <sfx2/dispatch.hxx>
+#include <sfx2/viewfrm.hxx>
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::frame;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::container;
+using namespace ::comphelper;
+
+
+SFX_IMPL_FLOATINGWINDOW(PropBrwMgr, SID_SHOW_PROPERTYBROWSER)
+
+
+PropBrwMgr::PropBrwMgr( Window* _pParent, sal_uInt16 nId,
+ SfxBindings *pBindings, SfxChildWinInfo* pInfo)
+ :SfxChildWindow( _pParent, nId )
+{
+ // set current selection
+ SfxViewShell* pShell = SfxViewShell::Current();
+ pWindow = new PropBrw(
+ ::comphelper::getProcessServiceFactory(),
+ pBindings,
+ this,
+ _pParent,
+ pShell ? pShell->GetCurrentDocument() : Reference< XModel >()
+ );
+
+ eChildAlignment = SFX_ALIGN_NOALIGNMENT;
+ ((SfxFloatingWindow*)pWindow)->Initialize( pInfo );
+
+ ((PropBrw*)pWindow)->Update( pShell );
+}
+
+
+void PropBrw::Update( const SfxViewShell* _pShell )
+{
+ const BasicIDEShell* pBasicIDEShell = dynamic_cast< const BasicIDEShell* >( _pShell );
+ OSL_ENSURE( pBasicIDEShell || !_pShell, "PropBrw::Update: invalid shell!" );
+ if ( pBasicIDEShell )
+ {
+ ImplUpdate( pBasicIDEShell->GetCurrentDocument(), pBasicIDEShell->GetCurDlgView() );
+ }
+ else if ( _pShell )
+ {
+ ImplUpdate( NULL, _pShell->GetDrawView() );
+ }
+ else
+ {
+ ImplUpdate( NULL, NULL );
+ }
+}
+
+
+const long STD_WIN_SIZE_X = 300;
+const long STD_WIN_SIZE_Y = 350;
+
+const long STD_MIN_SIZE_X = 250;
+const long STD_MIN_SIZE_Y = 250;
+
+const long STD_WIN_POS_X = 50;
+const long STD_WIN_POS_Y = 50;
+const long WIN_BORDER = 2;
+const long MIN_WIN_SIZE_X = 50;
+const long MIN_WIN_SIZE_Y = 50;
+
+
+DBG_NAME(PropBrw)
+
+
+PropBrw::PropBrw( const Reference< XMultiServiceFactory >& _xORB, SfxBindings* _pBindings, PropBrwMgr* _pMgr, Window* _pParent,
+ const Reference< XModel >& _rxContextDocument )
+ :SfxFloatingWindow( _pBindings, _pMgr, _pParent, WinBits( WB_STDMODELESS | WB_SIZEABLE | WB_3DLOOK | WB_ROLLABLE ) )
+ ,m_bInitialStateChange(sal_True)
+ ,m_xORB(_xORB)
+ ,m_xContextDocument( _rxContextDocument )
+ ,pView( NULL )
+{
+ DBG_CTOR(PropBrw,NULL);
+
+ Size aPropWinSize(STD_WIN_SIZE_X,STD_WIN_SIZE_Y);
+ SetMinOutputSizePixel(Size(STD_MIN_SIZE_X,STD_MIN_SIZE_Y));
+ SetOutputSizePixel(aPropWinSize);
+
+ try
+ {
+ // create a frame wrapper for myself
+ m_xMeAsFrame = Reference< XFrame >(m_xORB->createInstance(::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.frame.Frame" ))), UNO_QUERY);
+ if (m_xMeAsFrame.is())
+ {
+ m_xMeAsFrame->initialize( VCLUnoHelper::GetInterface ( this ) );
+ m_xMeAsFrame->setName(::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "form property browser" ))); // change name!
+ }
+ }
+ catch (Exception&)
+ {
+ OSL_FAIL("PropBrw::PropBrw: could not create/initialize my frame!");
+ m_xMeAsFrame.clear();
+ }
+
+ ImplReCreateController();
+}
+
+
+void PropBrw::ImplReCreateController()
+{
+ OSL_PRECOND( m_xMeAsFrame.is(), "PropBrw::ImplCreateController: no frame for myself!" );
+ if ( !m_xMeAsFrame.is() )
+ return;
+
+ if ( m_xBrowserController.is() )
+ ImplDestroyController();
+
+ try
+ {
+ Reference< XPropertySet > xFactoryProperties( m_xORB, UNO_QUERY_THROW );
+ Reference< XComponentContext > xOwnContext(
+ xFactoryProperties->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DefaultContext" ) ) ),
+ UNO_QUERY_THROW );
+
+ // a ComponentContext for the
+ ::cppu::ContextEntry_Init aHandlerContextInfo[] =
+ {
+ ::cppu::ContextEntry_Init( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DialogParentWindow" ) ), makeAny( VCLUnoHelper::GetInterface ( this ) ) ),
+ ::cppu::ContextEntry_Init( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ContextDocument" ) ), makeAny( m_xContextDocument ) )
+ };
+ Reference< XComponentContext > xInspectorContext(
+ ::cppu::createComponentContext( aHandlerContextInfo, SAL_N_ELEMENTS( aHandlerContextInfo ), xOwnContext ) );
+
+ // create a property browser controller
+ Reference< XMultiComponentFactory > xFactory( xInspectorContext->getServiceManager(), UNO_QUERY_THROW );
+ static const ::rtl::OUString s_sControllerServiceName( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.PropertyBrowserController" ));
+ m_xBrowserController = Reference< XPropertySet >(
+ xFactory->createInstanceWithContext( s_sControllerServiceName, xInspectorContext ), UNO_QUERY
+ );
+ if ( !m_xBrowserController.is() )
+ {
+ ShowServiceNotAvailableError( GetParent(), s_sControllerServiceName, sal_True );
+ }
+ else
+ {
+ Reference< XController > xAsXController( m_xBrowserController, UNO_QUERY );
+ DBG_ASSERT(xAsXController.is(), "PropBrw::PropBrw: invalid controller object!");
+ if (!xAsXController.is())
+ {
+ ::comphelper::disposeComponent(m_xBrowserController);
+ m_xBrowserController.clear();
+ }
+ else
+ {
+ xAsXController->attachFrame(m_xMeAsFrame);
+ m_xBrowserComponentWindow = m_xMeAsFrame->getComponentWindow();
+ DBG_ASSERT(m_xBrowserComponentWindow.is(), "PropBrw::PropBrw: attached the controller, but have no component window!");
+ }
+ }
+
+ Point aPropWinPos = Point( WIN_BORDER, WIN_BORDER );
+ Size aPropWinSize(STD_WIN_SIZE_X,STD_WIN_SIZE_Y);
+ aPropWinSize.Width() -= (2*WIN_BORDER);
+ aPropWinSize.Height() -= (2*WIN_BORDER);
+
+ if ( m_xBrowserComponentWindow.is() )
+ {
+ m_xBrowserComponentWindow->setPosSize(aPropWinPos.X(), aPropWinPos.Y(), aPropWinSize.Width(), aPropWinSize.Height(),
+ ::com::sun::star::awt::PosSize::WIDTH | ::com::sun::star::awt::PosSize::HEIGHT |
+ ::com::sun::star::awt::PosSize::X | ::com::sun::star::awt::PosSize::Y);
+ m_xBrowserComponentWindow->setVisible(sal_True);
+ }
+ }
+ catch (Exception&)
+ {
+ OSL_FAIL("PropBrw::PropBrw: could not create/initialize the browser controller!");
+ try
+ {
+ ::comphelper::disposeComponent(m_xBrowserController);
+ ::comphelper::disposeComponent(m_xBrowserComponentWindow);
+ }
+ catch(Exception&)
+ {
+ }
+
+ m_xBrowserController.clear();
+ m_xBrowserComponentWindow.clear();
+ }
+
+ Resize();
+}
+
+
+PropBrw::~PropBrw()
+{
+ if ( m_xBrowserController.is() )
+ ImplDestroyController();
+
+ DBG_DTOR(PropBrw,NULL);
+}
+
+
+void PropBrw::ImplDestroyController()
+{
+ implSetNewObject( Reference< XPropertySet >() );
+
+ if ( m_xMeAsFrame.is() )
+ m_xMeAsFrame->setComponent( NULL, NULL );
+
+ Reference< XController > xAsXController( m_xBrowserController, UNO_QUERY );
+ if ( xAsXController.is() )
+ xAsXController->attachFrame( NULL );
+
+ try
+ {
+ ::comphelper::disposeComponent( m_xBrowserController );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ m_xBrowserController.clear();
+}
+
+
+sal_Bool PropBrw::Close()
+{
+ ImplDestroyController();
+
+ if( IsRollUp() )
+ RollDown();
+
+ sal_Bool bClose = SfxFloatingWindow::Close();
+
+ return bClose;
+}
+
+
+Sequence< Reference< XInterface > >
+ PropBrw::CreateMultiSelectionSequence( const SdrMarkList& _rMarkList )
+{
+ Sequence< Reference< XInterface > > aSeq;
+ InterfaceArray aInterfaces;
+
+ sal_uInt32 nMarkCount = _rMarkList.GetMarkCount();
+ for( sal_uInt32 i = 0 ; i < nMarkCount ; i++ )
+ {
+ SdrObject* pCurrent = _rMarkList.GetMark(i)->GetMarkedSdrObj();
+
+ SdrObjListIter* pGroupIterator = NULL;
+ if (pCurrent->IsGroupObject())
+ {
+ pGroupIterator = new SdrObjListIter(*pCurrent->GetSubList());
+ pCurrent = pGroupIterator->IsMore() ? pGroupIterator->Next() : NULL;
+ }
+
+ while (pCurrent)
+ {
+ DlgEdObj* pDlgEdObj = PTR_CAST(DlgEdObj, pCurrent);
+ if (pDlgEdObj)
+ {
+ Reference< XInterface > xControlInterface(pDlgEdObj->GetUnoControlModel(), UNO_QUERY);
+ if (xControlInterface.is())
+ aInterfaces.push_back(xControlInterface);
+ }
+
+ // next element
+ pCurrent = pGroupIterator && pGroupIterator->IsMore() ? pGroupIterator->Next() : NULL;
+ }
+ if (pGroupIterator)
+ delete pGroupIterator;
+ }
+
+ sal_Int32 nCount = aInterfaces.size();
+ aSeq.realloc( nCount );
+ Reference< XInterface >* pInterfaces = aSeq.getArray();
+ for( sal_Int32 i = 0 ; i < nCount ; i++ )
+ pInterfaces[i] = aInterfaces[i];
+
+ return aSeq;
+}
+
+
+void PropBrw::implSetNewObjectSequence
+ ( const Sequence< Reference< XInterface > >& _rObjectSeq )
+{
+ Reference< inspection::XObjectInspector > xObjectInspector(m_xBrowserController, UNO_QUERY);
+ if ( xObjectInspector.is() )
+ {
+ xObjectInspector->inspect( _rObjectSeq );
+
+ ::rtl::OUString aText = ::rtl::OUString(String(IDEResId(RID_STR_BRWTITLE_PROPERTIES)));
+ aText += ::rtl::OUString(String(IDEResId(RID_STR_BRWTITLE_MULTISELECT)));
+ SetText( aText );
+ }
+}
+
+
+void PropBrw::implSetNewObject( const Reference< XPropertySet >& _rxObject )
+{
+ if ( m_xBrowserController.is() )
+ {
+ m_xBrowserController->setPropertyValue(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IntrospectedObject" )),
+ makeAny( _rxObject )
+ );
+
+ // set the new title according to the selected object
+ SetText( GetHeadlineName( _rxObject ) );
+ }
+}
+
+
+::rtl::OUString PropBrw::GetHeadlineName( const Reference< XPropertySet >& _rxObject )
+{
+ ::rtl::OUString aName;
+ Reference< lang::XServiceInfo > xServiceInfo( _rxObject, UNO_QUERY );
+
+ if (xServiceInfo.is()) // single selection
+ {
+ sal_uInt16 nResId = 0;
+ aName = ::rtl::OUString(String(IDEResId(RID_STR_BRWTITLE_PROPERTIES)));
+
+ if ( xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlDialogModel" ) ) ) )
+ {
+ nResId = RID_STR_CLASS_DIALOG;
+ }
+ else if ( xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlButtonModel" ) ) ) )
+ {
+ nResId = RID_STR_CLASS_BUTTON;
+ }
+ else if ( xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlRadioButtonModel" ) ) ) )
+ {
+ nResId = RID_STR_CLASS_RADIOBUTTON;
+ }
+ else if ( xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlCheckBoxModel" ) ) ) )
+ {
+ nResId = RID_STR_CLASS_CHECKBOX;
+ }
+ else if ( xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlListBoxModel" ) ) ) )
+ {
+ nResId = RID_STR_CLASS_LISTBOX;
+ }
+ else if ( xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlComboBoxModel" ) ) ) )
+ {
+ nResId = RID_STR_CLASS_COMBOBOX;
+ }
+ else if ( xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlGroupBoxModel" ) ) ) )
+ {
+ nResId = RID_STR_CLASS_GROUPBOX;
+ }
+ else if ( xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlEditModel" ) ) ) )
+ {
+ nResId = RID_STR_CLASS_EDIT;
+ }
+ else if ( xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlFixedTextModel" ) ) ) )
+ {
+ nResId = RID_STR_CLASS_FIXEDTEXT;
+ }
+ else if ( xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlImageControlModel" ) ) ) )
+ {
+ nResId = RID_STR_CLASS_IMAGECONTROL;
+ }
+ else if ( xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlProgressBarModel" ) ) ) )
+ {
+ nResId = RID_STR_CLASS_PROGRESSBAR;
+ }
+ else if ( xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlScrollBarModel" ) ) ) )
+ {
+ nResId = RID_STR_CLASS_SCROLLBAR;
+ }
+ else if ( xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlFixedLineModel" ) ) ) )
+ {
+ nResId = RID_STR_CLASS_FIXEDLINE;
+ }
+ else if ( xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlDateFieldModel" ) ) ) )
+ {
+ nResId = RID_STR_CLASS_DATEFIELD;
+ }
+ else if ( xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlTimeFieldModel" ) ) ) )
+ {
+ nResId = RID_STR_CLASS_TIMEFIELD;
+ }
+ else if ( xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlNumericFieldModel" ) ) ) )
+ {
+ nResId = RID_STR_CLASS_NUMERICFIELD;
+ }
+ else if ( xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlCurrencyFieldModel" ) ) ) )
+ {
+ nResId = RID_STR_CLASS_CURRENCYFIELD;
+ }
+ else if ( xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlFormattedFieldModel" ) ) ) )
+ {
+ nResId = RID_STR_CLASS_FORMATTEDFIELD;
+ }
+ else if ( xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlPatternFieldModel" ) ) ) )
+ {
+ nResId = RID_STR_CLASS_PATTERNFIELD;
+ }
+ else if ( xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlFileControlModel" ) ) ) )
+ {
+ nResId = RID_STR_CLASS_FILECONTROL;
+ }
+ else if ( xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.tree.TreeControlModel" ) ) ) )
+ {
+ nResId = RID_STR_CLASS_TREECONTROL;
+ }
+ else
+ {
+ nResId = RID_STR_CLASS_CONTROL;
+ }
+
+ if (nResId)
+ {
+ aName += ::rtl::OUString( String(IDEResId(nResId)) );
+ }
+ }
+ else if (!_rxObject.is()) // no properties
+ {
+ aName = ::rtl::OUString(String(IDEResId(RID_STR_BRWTITLE_NO_PROPERTIES)));
+ }
+
+ return aName;
+}
+
+
+void PropBrw::FillInfo( SfxChildWinInfo& rInfo ) const
+{
+ rInfo.bVisible = sal_False;
+}
+
+
+void PropBrw::Resize()
+{
+ SfxFloatingWindow::Resize();
+
+ // adjust size
+ Size aSize_ = GetOutputSizePixel();
+ Size aPropWinSize( aSize_ );
+ aPropWinSize.Width() -= (2*WIN_BORDER);
+ aPropWinSize.Height() -= (2*WIN_BORDER);
+
+ if (m_xBrowserComponentWindow.is())
+ {
+ m_xBrowserComponentWindow->setPosSize(0, 0, aPropWinSize.Width(), aPropWinSize.Height(),
+ ::com::sun::star::awt::PosSize::WIDTH | ::com::sun::star::awt::PosSize::HEIGHT);
+ }
+}
+
+
+void PropBrw::ImplUpdate( const Reference< XModel >& _rxContextDocument, SdrView* pNewView )
+{
+ Reference< XModel > xContextDocument( _rxContextDocument );
+
+ // if we should simply "empty" ourself, assume the context document didn't change
+ if ( !pNewView )
+ {
+ OSL_ENSURE( !_rxContextDocument.is(), "PropBrw::ImplUpdate: no view, but a document?!" );
+ xContextDocument = m_xContextDocument;
+ }
+
+ if ( xContextDocument != m_xContextDocument )
+ {
+ m_xContextDocument = xContextDocument;
+ ImplReCreateController();
+ }
+
+ try
+ {
+ if ( pView )
+ {
+ EndListening( *(pView->GetModel()) );
+ pView = NULL;
+ }
+
+ if ( !pNewView )
+ return;
+
+ pView = pNewView;
+
+ // set focus on initialization
+ if ( m_bInitialStateChange )
+ {
+ if ( m_xBrowserComponentWindow.is() )
+ m_xBrowserComponentWindow->setFocus();
+ m_bInitialStateChange = sal_False;
+ }
+
+ const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
+ sal_uInt32 nMarkCount = rMarkList.GetMarkCount();
+
+ if ( nMarkCount == 0 )
+ {
+ EndListening( *(pView->GetModel()) );
+ pView = NULL;
+ implSetNewObject( NULL );
+ return;
+ }
+
+ Reference< XPropertySet > xNewObject;
+ Sequence< Reference< XInterface > > aNewObjects;
+ if ( nMarkCount == 1 )
+ {
+ DlgEdObj* pDlgEdObj = PTR_CAST( DlgEdObj, rMarkList.GetMark(0)->GetMarkedSdrObj() );
+ if ( pDlgEdObj )
+ {
+ if ( pDlgEdObj->IsGroupObject() ) // group object
+ aNewObjects = CreateMultiSelectionSequence( rMarkList );
+ else // single selection
+ xNewObject = xNewObject.query( pDlgEdObj->GetUnoControlModel() );
+ }
+ }
+ else if ( nMarkCount > 1 ) // multiple selection
+ {
+ aNewObjects = CreateMultiSelectionSequence( rMarkList );
+ }
+
+ if ( aNewObjects.getLength() )
+ implSetNewObjectSequence( aNewObjects );
+ else
+ implSetNewObject( xNewObject );
+
+ StartListening( *(pView->GetModel()) );
+ }
+ catch ( const PropertyVetoException& ) { /* silence */ }
+ catch ( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */