2010-10-12 15:57:08 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2012-10-04 11:25:41 +01:00
|
|
|
/*
|
|
|
|
* This file is part of the LibreOffice project.
|
|
|
|
*
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
*
|
|
|
|
* This file incorporates work covered by the following license notice:
|
|
|
|
*
|
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed
|
|
|
|
* with this work for additional information regarding copyright
|
|
|
|
* ownership. The ASF licenses this file to you under the Apache
|
|
|
|
* License, Version 2.0 (the "License"); you may not use this file
|
|
|
|
* except in compliance with the License. You may obtain a copy of
|
|
|
|
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
|
|
|
|
*/
|
2009-10-31 00:36:06 +01:00
|
|
|
|
|
|
|
#include "cfgutil.hxx"
|
|
|
|
|
|
|
|
#include <com/sun/star/beans/XPropertySet.hpp>
|
2013-05-13 08:20:58 +02:00
|
|
|
#include <com/sun/star/container/XEnumerationAccess.hpp>
|
|
|
|
#include <com/sun/star/container/XEnumeration.hpp>
|
|
|
|
#include <com/sun/star/document/XScriptInvocationContext.hpp>
|
|
|
|
#include <com/sun/star/frame/ModuleManager.hpp>
|
|
|
|
#include <com/sun/star/frame/Desktop.hpp>
|
|
|
|
#include <com/sun/star/frame/UICommandDescription.hpp>
|
2009-10-31 00:36:06 +01:00
|
|
|
#include <com/sun/star/frame/XDispatchInformationProvider.hpp>
|
|
|
|
#include <com/sun/star/script/browse/XBrowseNode.hpp>
|
|
|
|
#include <com/sun/star/script/browse/BrowseNodeTypes.hpp>
|
2013-05-14 14:19:58 +02:00
|
|
|
#include <com/sun/star/script/browse/theBrowseNodeFactory.hpp>
|
2009-10-31 00:36:06 +01:00
|
|
|
#include <com/sun/star/script/browse/BrowseNodeFactoryViewTypes.hpp>
|
2013-05-13 08:20:58 +02:00
|
|
|
#include <com/sun/star/script/provider/XScriptProviderSupplier.hpp>
|
|
|
|
#include <com/sun/star/script/provider/XScriptProvider.hpp>
|
2009-10-31 00:36:06 +01:00
|
|
|
#include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
|
2013-05-13 08:20:58 +02:00
|
|
|
#include <com/sun/star/uno/RuntimeException.hpp>
|
|
|
|
#include <com/sun/star/ui/UICategoryDescription.hpp>
|
2009-10-31 00:36:06 +01:00
|
|
|
|
|
|
|
#include "acccfg.hrc"
|
|
|
|
#include "helpid.hrc"
|
|
|
|
#include <basic/sbx.hxx>
|
|
|
|
#include <basic/basicmanagerrepository.hxx>
|
|
|
|
#include <basic/sbstar.hxx>
|
|
|
|
#include <basic/sbxmeth.hxx>
|
|
|
|
#include <basic/sbmod.hxx>
|
|
|
|
#include <basic/basmgr.hxx>
|
|
|
|
#include <tools/urlobj.hxx>
|
2009-11-02 20:49:14 +01:00
|
|
|
#include "cuires.hrc"
|
2009-10-31 00:36:06 +01:00
|
|
|
#include <sfx2/app.hxx>
|
|
|
|
#include <sfx2/minfitem.hxx>
|
|
|
|
#include <comphelper/documentinfo.hxx>
|
2012-01-02 10:55:27 +00:00
|
|
|
#include <comphelper/processfactory.hxx>
|
|
|
|
#include <comphelper/sequenceashashmap.hxx>
|
|
|
|
#include <comphelper/string.hxx>
|
2009-10-31 00:36:06 +01:00
|
|
|
#include <svtools/imagemgr.hxx>
|
2012-11-16 16:14:53 -05:00
|
|
|
#include "svtools/treelistentry.hxx"
|
2009-10-31 00:36:06 +01:00
|
|
|
#include <rtl/ustrbuf.hxx>
|
|
|
|
#include <unotools/configmgr.hxx>
|
2009-11-02 20:49:14 +01:00
|
|
|
#include "dialmgr.hxx"
|
2009-10-31 00:36:06 +01:00
|
|
|
#include <svl/stritem.hxx>
|
2014-01-23 11:41:20 +00:00
|
|
|
#include <vcl/builder.hxx>
|
2009-10-31 00:36:06 +01:00
|
|
|
|
|
|
|
using namespace ::com::sun::star;
|
|
|
|
using namespace ::com::sun::star::uno;
|
|
|
|
using namespace ::com::sun::star::script;
|
|
|
|
using namespace ::com::sun::star::frame;
|
|
|
|
using namespace ::com::sun::star::document;
|
|
|
|
|
|
|
|
SfxStylesInfo_Impl::SfxStylesInfo_Impl()
|
|
|
|
{}
|
|
|
|
|
|
|
|
void SfxStylesInfo_Impl::setModel(const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& xModel)
|
|
|
|
{
|
|
|
|
m_xDoc = xModel;
|
|
|
|
}
|
|
|
|
|
2013-02-23 19:28:39 +01:00
|
|
|
static OUString CMDURL_SPART (".uno:StyleApply?Style:string=");
|
|
|
|
static OUString CMDURL_FPART2 ("&FamilyName:string=");
|
2009-10-31 00:36:06 +01:00
|
|
|
|
2013-02-23 19:28:39 +01:00
|
|
|
static OUString CMDURL_STYLEPROT_ONLY (".uno:StyleApply?");
|
|
|
|
static OUString CMDURL_SPART_ONLY ("Style:string=");
|
|
|
|
static OUString CMDURL_FPART_ONLY ("FamilyName:string=");
|
2009-10-31 00:36:06 +01:00
|
|
|
|
2013-02-23 19:28:39 +01:00
|
|
|
static OUString STYLEPROP_UINAME ("DisplayName");
|
2009-10-31 00:36:06 +01:00
|
|
|
|
2013-02-23 19:28:39 +01:00
|
|
|
OUString SfxStylesInfo_Impl::generateCommand(const OUString& sFamily, const OUString& sStyle)
|
2009-10-31 00:36:06 +01:00
|
|
|
{
|
2013-02-23 19:28:39 +01:00
|
|
|
OUStringBuffer sCommand(1024);
|
2009-10-31 00:36:06 +01:00
|
|
|
sCommand.append(CMDURL_SPART );
|
|
|
|
sCommand.append(sStyle );
|
|
|
|
sCommand.append(CMDURL_FPART2);
|
|
|
|
sCommand.append(sFamily );
|
|
|
|
return sCommand.makeStringAndClear();
|
|
|
|
}
|
|
|
|
|
|
|
|
sal_Bool SfxStylesInfo_Impl::parseStyleCommand(SfxStyleInfo_Impl& aStyle)
|
|
|
|
{
|
|
|
|
static sal_Int32 LEN_STYLEPROT = CMDURL_STYLEPROT_ONLY.getLength();
|
|
|
|
static sal_Int32 LEN_SPART = CMDURL_SPART_ONLY.getLength();
|
|
|
|
static sal_Int32 LEN_FPART = CMDURL_FPART_ONLY.getLength();
|
|
|
|
|
2013-10-25 16:43:20 +02:00
|
|
|
if (!aStyle.sCommand.startsWith(CMDURL_STYLEPROT_ONLY))
|
2009-10-31 00:36:06 +01:00
|
|
|
return sal_False;
|
|
|
|
|
2013-02-23 19:28:39 +01:00
|
|
|
aStyle.sFamily = OUString();
|
|
|
|
aStyle.sStyle = OUString();
|
2009-10-31 00:36:06 +01:00
|
|
|
|
|
|
|
sal_Int32 nCmdLen = aStyle.sCommand.getLength();
|
2013-02-23 19:28:39 +01:00
|
|
|
OUString sCmdArgs = aStyle.sCommand.copy(LEN_STYLEPROT, nCmdLen-LEN_STYLEPROT);
|
2009-10-31 00:36:06 +01:00
|
|
|
sal_Int32 i = sCmdArgs.indexOf('&');
|
|
|
|
if (i<0)
|
|
|
|
return sal_False;
|
|
|
|
|
2013-02-23 19:28:39 +01:00
|
|
|
OUString sArg = sCmdArgs.copy(0, i);
|
2013-10-25 16:43:20 +02:00
|
|
|
if (sArg.startsWith(CMDURL_SPART_ONLY))
|
2009-10-31 00:36:06 +01:00
|
|
|
aStyle.sStyle = sArg.copy(LEN_SPART, sArg.getLength()-LEN_SPART);
|
2013-10-25 16:43:20 +02:00
|
|
|
else if (sArg.startsWith(CMDURL_FPART_ONLY))
|
2009-10-31 00:36:06 +01:00
|
|
|
aStyle.sFamily = sArg.copy(LEN_FPART, sArg.getLength()-LEN_FPART);
|
|
|
|
|
|
|
|
sArg = sCmdArgs.copy(i+1, sCmdArgs.getLength()-i-1);
|
2013-10-25 16:43:20 +02:00
|
|
|
if (sArg.startsWith(CMDURL_SPART_ONLY))
|
2009-10-31 00:36:06 +01:00
|
|
|
aStyle.sStyle = sArg.copy(LEN_SPART, sArg.getLength()-LEN_SPART);
|
2013-10-25 16:43:20 +02:00
|
|
|
else if (sArg.startsWith(CMDURL_FPART_ONLY))
|
2009-10-31 00:36:06 +01:00
|
|
|
aStyle.sFamily = sArg.copy(LEN_FPART, sArg.getLength()-LEN_FPART);
|
|
|
|
|
2011-12-16 17:29:07 -02:00
|
|
|
if (!(aStyle.sFamily.isEmpty() || aStyle.sStyle.isEmpty()))
|
2009-10-31 00:36:06 +01:00
|
|
|
return sal_True;
|
|
|
|
|
|
|
|
return sal_False;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SfxStylesInfo_Impl::getLabel4Style(SfxStyleInfo_Impl& aStyle)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
css::uno::Reference< css::style::XStyleFamiliesSupplier > xModel(m_xDoc, css::uno::UNO_QUERY);
|
|
|
|
|
|
|
|
css::uno::Reference< css::container::XNameAccess > xFamilies;
|
|
|
|
if (xModel.is())
|
|
|
|
xFamilies = xModel->getStyleFamilies();
|
|
|
|
|
|
|
|
css::uno::Reference< css::container::XNameAccess > xStyleSet;
|
|
|
|
if (xFamilies.is())
|
|
|
|
xFamilies->getByName(aStyle.sFamily) >>= xStyleSet;
|
|
|
|
|
|
|
|
css::uno::Reference< css::beans::XPropertySet > xStyle;
|
|
|
|
if (xStyleSet.is())
|
|
|
|
xStyleSet->getByName(aStyle.sStyle) >>= xStyle;
|
|
|
|
|
2013-02-23 19:28:39 +01:00
|
|
|
aStyle.sLabel = OUString();
|
2009-10-31 00:36:06 +01:00
|
|
|
if (xStyle.is())
|
|
|
|
xStyle->getPropertyValue(STYLEPROP_UINAME) >>= aStyle.sLabel;
|
|
|
|
}
|
2012-02-05 10:49:59 +01:00
|
|
|
catch(const css::uno::RuntimeException&)
|
|
|
|
{ throw; }
|
2009-10-31 00:36:06 +01:00
|
|
|
catch(const css::uno::Exception&)
|
2013-02-23 19:28:39 +01:00
|
|
|
{ aStyle.sLabel = OUString(); }
|
2009-10-31 00:36:06 +01:00
|
|
|
|
2011-12-16 17:29:07 -02:00
|
|
|
if (aStyle.sLabel.isEmpty())
|
2009-10-31 00:36:06 +01:00
|
|
|
{
|
|
|
|
aStyle.sLabel = aStyle.sCommand;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
::std::vector< SfxStyleInfo_Impl > SfxStylesInfo_Impl::getStyleFamilies()
|
|
|
|
{
|
|
|
|
// Its an optional interface!
|
|
|
|
css::uno::Reference< css::style::XStyleFamiliesSupplier > xModel(m_xDoc, css::uno::UNO_QUERY);
|
|
|
|
if (!xModel.is())
|
|
|
|
return ::std::vector< SfxStyleInfo_Impl >();
|
|
|
|
|
|
|
|
css::uno::Reference< css::container::XNameAccess > xCont = xModel->getStyleFamilies();
|
2013-02-23 19:28:39 +01:00
|
|
|
css::uno::Sequence< OUString > lFamilyNames = xCont->getElementNames();
|
2009-10-31 00:36:06 +01:00
|
|
|
::std::vector< SfxStyleInfo_Impl > lFamilies;
|
|
|
|
sal_Int32 c = lFamilyNames.getLength();
|
|
|
|
sal_Int32 i = 0;
|
|
|
|
for(i=0; i<c; ++i)
|
|
|
|
{
|
|
|
|
SfxStyleInfo_Impl aFamilyInfo;
|
|
|
|
aFamilyInfo.sFamily = lFamilyNames[i];
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
css::uno::Reference< css::beans::XPropertySet > xFamilyInfo;
|
|
|
|
xCont->getByName(aFamilyInfo.sFamily) >>= xFamilyInfo;
|
|
|
|
if (!xFamilyInfo.is())
|
|
|
|
{
|
|
|
|
// TODO_AS currently there is no support for an UIName property .. use internal family name instead
|
|
|
|
aFamilyInfo.sLabel = aFamilyInfo.sFamily;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
xFamilyInfo->getPropertyValue(STYLEPROP_UINAME) >>= aFamilyInfo.sLabel;
|
|
|
|
}
|
2012-02-05 10:49:59 +01:00
|
|
|
catch(const css::uno::RuntimeException&)
|
|
|
|
{ throw; }
|
2009-10-31 00:36:06 +01:00
|
|
|
catch(const css::uno::Exception&)
|
|
|
|
{ return ::std::vector< SfxStyleInfo_Impl >(); }
|
|
|
|
|
|
|
|
lFamilies.push_back(aFamilyInfo);
|
|
|
|
}
|
|
|
|
|
|
|
|
return lFamilies;
|
|
|
|
}
|
|
|
|
|
2013-02-23 19:28:39 +01:00
|
|
|
::std::vector< SfxStyleInfo_Impl > SfxStylesInfo_Impl::getStyles(const OUString& sFamily)
|
2009-10-31 00:36:06 +01:00
|
|
|
{
|
2013-02-23 19:28:39 +01:00
|
|
|
static OUString PROP_UINAME ("DisplayName");
|
2009-10-31 00:36:06 +01:00
|
|
|
|
2013-02-23 19:28:39 +01:00
|
|
|
css::uno::Sequence< OUString > lStyleNames;
|
2009-10-31 00:36:06 +01:00
|
|
|
css::uno::Reference< css::style::XStyleFamiliesSupplier > xModel(m_xDoc, css::uno::UNO_QUERY_THROW);
|
|
|
|
css::uno::Reference< css::container::XNameAccess > xFamilies = xModel->getStyleFamilies();
|
|
|
|
css::uno::Reference< css::container::XNameAccess > xStyleSet;
|
|
|
|
try
|
|
|
|
{
|
|
|
|
xFamilies->getByName(sFamily) >>= xStyleSet;
|
|
|
|
lStyleNames = xStyleSet->getElementNames();
|
|
|
|
}
|
2012-02-05 10:49:59 +01:00
|
|
|
catch(const css::uno::RuntimeException&)
|
|
|
|
{ throw; }
|
2009-10-31 00:36:06 +01:00
|
|
|
catch(const css::uno::Exception&)
|
|
|
|
{ return ::std::vector< SfxStyleInfo_Impl >(); }
|
|
|
|
|
|
|
|
::std::vector< SfxStyleInfo_Impl > lStyles;
|
|
|
|
sal_Int32 c = lStyleNames.getLength();
|
|
|
|
sal_Int32 i = 0;
|
|
|
|
for (i=0; i<c; ++i)
|
|
|
|
{
|
|
|
|
SfxStyleInfo_Impl aStyleInfo;
|
|
|
|
aStyleInfo.sFamily = sFamily;
|
|
|
|
aStyleInfo.sStyle = lStyleNames[i];
|
|
|
|
aStyleInfo.sCommand = SfxStylesInfo_Impl::generateCommand(aStyleInfo.sFamily, aStyleInfo.sStyle);
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
css::uno::Reference< css::beans::XPropertySet > xStyle;
|
|
|
|
xStyleSet->getByName(aStyleInfo.sStyle) >>= xStyle;
|
|
|
|
if (!xStyle.is())
|
|
|
|
continue;
|
|
|
|
xStyle->getPropertyValue(PROP_UINAME) >>= aStyleInfo.sLabel;
|
|
|
|
}
|
2012-02-05 10:49:59 +01:00
|
|
|
catch(const css::uno::RuntimeException&)
|
|
|
|
{ throw; }
|
2009-10-31 00:36:06 +01:00
|
|
|
catch(const css::uno::Exception&)
|
|
|
|
{ continue; }
|
|
|
|
|
|
|
|
lStyles.push_back(aStyleInfo);
|
|
|
|
}
|
|
|
|
return lStyles;
|
|
|
|
}
|
2012-06-10 18:00:37 +02:00
|
|
|
|
2014-01-23 11:41:20 +00:00
|
|
|
SfxConfigFunctionListBox::SfxConfigFunctionListBox(Window* pParent, const ResId& rResId)
|
2009-10-31 00:36:06 +01:00
|
|
|
: SvTreeListBox( pParent, rResId )
|
|
|
|
, pCurEntry( 0 )
|
|
|
|
, pStylesInfo( 0 )
|
|
|
|
{
|
2010-09-03 17:53:47 +02:00
|
|
|
SetStyle( GetStyle() | WB_CLIPCHILDREN | WB_HSCROLL | WB_SORT );
|
2009-10-31 00:36:06 +01:00
|
|
|
GetModel()->SetSortMode( SortAscending );
|
|
|
|
|
2010-11-02 13:40:45 +00:00
|
|
|
// Timer for the BallonHelp
|
2009-10-31 00:36:06 +01:00
|
|
|
aTimer.SetTimeout( 200 );
|
|
|
|
aTimer.SetTimeoutHdl(
|
2014-01-23 12:08:58 +00:00
|
|
|
LINK( this, SfxConfigFunctionListBox, TimerHdl ) );
|
2009-10-31 00:36:06 +01:00
|
|
|
}
|
|
|
|
|
2014-01-23 11:41:20 +00:00
|
|
|
SfxConfigFunctionListBox::SfxConfigFunctionListBox(Window* pParent, WinBits nStyle)
|
|
|
|
: SvTreeListBox( pParent, nStyle )
|
|
|
|
, pCurEntry( 0 )
|
|
|
|
, pStylesInfo( 0 )
|
|
|
|
{
|
|
|
|
SetStyle( GetStyle() | WB_CLIPCHILDREN | WB_HSCROLL | WB_SORT );
|
|
|
|
GetModel()->SetSortMode( SortAscending );
|
|
|
|
|
|
|
|
// Timer for the BallonHelp
|
|
|
|
aTimer.SetTimeout( 200 );
|
|
|
|
aTimer.SetTimeoutHdl(
|
|
|
|
LINK( this, SfxConfigFunctionListBox, TimerHdl ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
extern "C" SAL_DLLPUBLIC_EXPORT Window* SAL_CALL makeSfxConfigFunctionListBox(Window *pParent, VclBuilder::stringmap &rMap)
|
|
|
|
{
|
|
|
|
WinBits nWinBits = WB_TABSTOP;
|
|
|
|
|
|
|
|
OString sBorder = VclBuilder::extractCustomProperty(rMap);
|
|
|
|
if (!sBorder.isEmpty())
|
|
|
|
nWinBits |= WB_BORDER;
|
|
|
|
|
|
|
|
return new SfxConfigFunctionListBox(pParent, nWinBits);
|
|
|
|
}
|
|
|
|
|
2014-01-23 12:08:58 +00:00
|
|
|
SfxConfigFunctionListBox::~SfxConfigFunctionListBox()
|
2009-10-31 00:36:06 +01:00
|
|
|
{
|
|
|
|
ClearAll();
|
|
|
|
}
|
|
|
|
|
2014-01-23 12:08:58 +00:00
|
|
|
void SfxConfigFunctionListBox::MouseMove( const MouseEvent& )
|
2009-10-31 00:36:06 +01:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2014-01-23 12:08:58 +00:00
|
|
|
IMPL_LINK( SfxConfigFunctionListBox, TimerHdl, Timer*, pTimer)
|
2012-04-15 17:50:21 +02:00
|
|
|
/* Description
|
|
|
|
Timer-handler for showing a help-text. If the mouse pointer is
|
|
|
|
still on the currently selected entry after the timer has run out,
|
|
|
|
the entry's help-text is shown as a balloon-help.
|
2009-10-31 00:36:06 +01:00
|
|
|
*/
|
|
|
|
{
|
|
|
|
(void)pTimer; // unused
|
|
|
|
return 0L;
|
|
|
|
}
|
|
|
|
|
2014-01-23 12:08:58 +00:00
|
|
|
void SfxConfigFunctionListBox::ClearAll()
|
2012-04-15 17:50:21 +02:00
|
|
|
/* Description
|
|
|
|
Deletes all entries in the FunctionListBox, all UserData and all
|
|
|
|
possibly existing MacroInfo.
|
2009-10-31 00:36:06 +01:00
|
|
|
*/
|
|
|
|
{
|
2012-06-10 18:00:37 +02:00
|
|
|
sal_uInt16 nCount = aArr.size();
|
2011-03-09 16:20:50 -06:00
|
|
|
for ( sal_uInt16 i=0; i<nCount; ++i )
|
2009-10-31 00:36:06 +01:00
|
|
|
{
|
2012-06-10 18:00:37 +02:00
|
|
|
SfxGroupInfo_Impl *pData = &aArr[i];
|
2009-10-31 00:36:06 +01:00
|
|
|
|
2010-11-01 15:32:51 +01:00
|
|
|
if ( pData->nKind == SFX_CFGFUNCTION_SCRIPT )
|
2009-10-31 00:36:06 +01:00
|
|
|
{
|
2013-09-26 08:30:52 +02:00
|
|
|
OUString* pScriptURI = (OUString*)pData->pObject;
|
2010-11-01 15:32:51 +01:00
|
|
|
delete pScriptURI;
|
2009-10-31 00:36:06 +01:00
|
|
|
}
|
|
|
|
|
2012-06-10 18:00:37 +02:00
|
|
|
if ( pData->nKind == SFX_CFGGROUP_SCRIPTCONTAINER )
|
2009-10-31 00:36:06 +01:00
|
|
|
{
|
|
|
|
XInterface* xi = static_cast<XInterface *>(pData->pObject);
|
|
|
|
if (xi != NULL)
|
|
|
|
{
|
|
|
|
xi->release();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-06-10 18:00:37 +02:00
|
|
|
aArr.clear();
|
2009-10-31 00:36:06 +01:00
|
|
|
Clear();
|
|
|
|
}
|
|
|
|
|
2014-01-23 12:08:58 +00:00
|
|
|
OUString SfxConfigFunctionListBox::GetSelectedScriptURI()
|
2009-10-31 00:36:06 +01:00
|
|
|
{
|
2012-10-18 16:28:20 +02:00
|
|
|
SvTreeListEntry *pEntry = FirstSelected();
|
2009-10-31 00:36:06 +01:00
|
|
|
if ( pEntry )
|
|
|
|
{
|
|
|
|
SfxGroupInfo_Impl *pData = (SfxGroupInfo_Impl*) pEntry->GetUserData();
|
2010-11-01 15:32:51 +01:00
|
|
|
if ( pData && ( pData->nKind == SFX_CFGFUNCTION_SCRIPT ) )
|
2013-09-26 08:30:52 +02:00
|
|
|
return *(OUString*)pData->pObject;
|
2009-10-31 00:36:06 +01:00
|
|
|
}
|
2013-09-26 08:30:52 +02:00
|
|
|
return OUString();
|
2009-10-31 00:36:06 +01:00
|
|
|
}
|
|
|
|
|
2014-01-23 12:08:58 +00:00
|
|
|
OUString SfxConfigFunctionListBox::GetCurCommand()
|
2009-10-31 00:36:06 +01:00
|
|
|
{
|
2012-10-18 16:28:20 +02:00
|
|
|
SvTreeListEntry *pEntry = FirstSelected();
|
2009-10-31 00:36:06 +01:00
|
|
|
if (!pEntry)
|
2013-09-26 08:30:52 +02:00
|
|
|
return OUString();
|
2009-10-31 00:36:06 +01:00
|
|
|
SfxGroupInfo_Impl *pData = (SfxGroupInfo_Impl*) pEntry->GetUserData();
|
|
|
|
if (!pData)
|
2013-09-26 08:30:52 +02:00
|
|
|
return OUString();
|
2009-10-31 00:36:06 +01:00
|
|
|
return pData->sCommand;
|
|
|
|
}
|
|
|
|
|
2014-01-23 12:08:58 +00:00
|
|
|
OUString SfxConfigFunctionListBox::GetCurLabel()
|
2009-10-31 00:36:06 +01:00
|
|
|
{
|
2012-10-18 16:28:20 +02:00
|
|
|
SvTreeListEntry *pEntry = FirstSelected();
|
2009-10-31 00:36:06 +01:00
|
|
|
if (!pEntry)
|
2013-09-26 08:30:52 +02:00
|
|
|
return OUString();
|
2009-10-31 00:36:06 +01:00
|
|
|
SfxGroupInfo_Impl *pData = (SfxGroupInfo_Impl*) pEntry->GetUserData();
|
|
|
|
if (!pData)
|
2013-09-26 08:30:52 +02:00
|
|
|
return OUString();
|
|
|
|
if (!pData->sLabel.isEmpty())
|
2009-10-31 00:36:06 +01:00
|
|
|
return pData->sLabel;
|
|
|
|
return pData->sCommand;
|
|
|
|
}
|
|
|
|
|
2014-01-23 12:08:58 +00:00
|
|
|
void SfxConfigFunctionListBox::FunctionSelected()
|
2012-04-15 17:50:21 +02:00
|
|
|
/* Description
|
|
|
|
Resets the balloon-help because it shall
|
|
|
|
always show the help-text of the selected entry.
|
2009-10-31 00:36:06 +01:00
|
|
|
*/
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2014-01-23 12:08:58 +00:00
|
|
|
void SfxConfigFunctionListBox::SetStylesInfo(SfxStylesInfo_Impl* pStyles)
|
2009-10-31 00:36:06 +01:00
|
|
|
{
|
|
|
|
pStylesInfo = pStyles;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct SvxConfigGroupBoxResource_Impl : public Resource
|
|
|
|
{
|
|
|
|
Image m_hdImage;
|
|
|
|
Image m_libImage;
|
|
|
|
Image m_macImage;
|
|
|
|
Image m_docImage;
|
2013-02-23 19:28:39 +01:00
|
|
|
OUString m_sMyMacros;
|
|
|
|
OUString m_sProdMacros;
|
2013-09-26 08:30:52 +02:00
|
|
|
OUString m_sMacros;
|
|
|
|
OUString m_sDlgMacros;
|
|
|
|
OUString m_aHumanAppName;
|
|
|
|
OUString m_aStrGroupStyles;
|
2009-10-31 00:36:06 +01:00
|
|
|
Image m_collapsedImage;
|
|
|
|
Image m_expandedImage;
|
|
|
|
|
|
|
|
SvxConfigGroupBoxResource_Impl();
|
|
|
|
};
|
|
|
|
|
|
|
|
SvxConfigGroupBoxResource_Impl::SvxConfigGroupBoxResource_Impl() :
|
2009-11-02 20:49:14 +01:00
|
|
|
Resource(CUI_RES(RID_SVXPAGE_CONFIGGROUPBOX)),
|
2012-11-05 10:35:09 +00:00
|
|
|
m_hdImage(CUI_RES(RID_CUIIMG_HARDDISK)),
|
|
|
|
m_libImage(CUI_RES(RID_CUIIMG_LIB)),
|
|
|
|
m_macImage(CUI_RES(RID_CUIIMG_MACRO)),
|
|
|
|
m_docImage(CUI_RES(RID_CUIIMG_DOC)),
|
|
|
|
m_sMyMacros(CUI_RESSTR(RID_SVXSTR_MYMACROS)),
|
|
|
|
m_sProdMacros(CUI_RESSTR(RID_SVXSTR_PRODMACROS)),
|
|
|
|
m_sMacros(CUI_RESSTR(STR_BASICMACROS)),
|
|
|
|
m_sDlgMacros(CUI_RESSTR(RID_SVXSTR_PRODMACROS)),
|
|
|
|
m_aHumanAppName(CUI_RESSTR(STR_HUMAN_APPNAME)),
|
|
|
|
m_aStrGroupStyles(CUI_RESSTR(STR_GROUP_STYLES)),
|
2009-11-02 20:49:14 +01:00
|
|
|
m_collapsedImage(CUI_RES(BMP_COLLAPSED)),
|
2010-11-09 20:07:12 -08:00
|
|
|
m_expandedImage(CUI_RES(BMP_EXPANDED))
|
2009-10-31 00:36:06 +01:00
|
|
|
{
|
|
|
|
FreeResource();
|
|
|
|
}
|
|
|
|
|
2014-01-23 11:41:20 +00:00
|
|
|
SfxConfigGroupListBox::SfxConfigGroupListBox(Window* pParent, const ResId& rResId)
|
|
|
|
: SvTreeListBox( pParent, rResId )
|
|
|
|
, pImp(new SvxConfigGroupBoxResource_Impl()), pFunctionListBox(0), pStylesInfo(0)
|
2009-10-31 00:36:06 +01:00
|
|
|
{
|
2010-09-03 17:53:47 +02:00
|
|
|
SetStyle( GetStyle() | WB_CLIPCHILDREN | WB_HSCROLL | WB_HASBUTTONS | WB_HASLINES | WB_HASLINESATROOT | WB_HASBUTTONSATROOT );
|
2010-11-09 20:07:12 -08:00
|
|
|
SetNodeBitmaps( pImp->m_collapsedImage, pImp->m_expandedImage );
|
2009-10-31 00:36:06 +01:00
|
|
|
}
|
|
|
|
|
2014-01-23 11:41:20 +00:00
|
|
|
SfxConfigGroupListBox::SfxConfigGroupListBox(Window* pParent, WinBits nStyle)
|
|
|
|
: SvTreeListBox(pParent, nStyle)
|
|
|
|
, pImp(new SvxConfigGroupBoxResource_Impl()), pFunctionListBox(0), pStylesInfo(0)
|
|
|
|
{
|
|
|
|
SetStyle( GetStyle() | WB_CLIPCHILDREN | WB_HSCROLL | WB_HASBUTTONS | WB_HASLINES | WB_HASLINESATROOT | WB_HASBUTTONSATROOT );
|
|
|
|
SetNodeBitmaps( pImp->m_collapsedImage, pImp->m_expandedImage );
|
|
|
|
}
|
|
|
|
|
|
|
|
extern "C" SAL_DLLPUBLIC_EXPORT Window* SAL_CALL makeSfxConfigGroupListBox(Window *pParent, VclBuilder::stringmap &rMap)
|
|
|
|
{
|
|
|
|
WinBits nWinBits = WB_TABSTOP;
|
|
|
|
|
|
|
|
OString sBorder = VclBuilder::extractCustomProperty(rMap);
|
|
|
|
if (!sBorder.isEmpty())
|
|
|
|
nWinBits |= WB_BORDER;
|
|
|
|
|
|
|
|
return new SfxConfigGroupListBox(pParent, nWinBits);
|
|
|
|
}
|
2009-10-31 00:36:06 +01:00
|
|
|
|
2014-01-23 12:06:11 +00:00
|
|
|
SfxConfigGroupListBox::~SfxConfigGroupListBox()
|
2009-10-31 00:36:06 +01:00
|
|
|
{
|
|
|
|
ClearAll();
|
|
|
|
}
|
|
|
|
|
2014-01-23 12:06:11 +00:00
|
|
|
void SfxConfigGroupListBox::ClearAll()
|
2009-10-31 00:36:06 +01:00
|
|
|
{
|
2012-06-10 18:00:37 +02:00
|
|
|
sal_uInt16 nCount = aArr.size();
|
2011-03-09 16:20:50 -06:00
|
|
|
for ( sal_uInt16 i=0; i<nCount; ++i )
|
2009-10-31 00:36:06 +01:00
|
|
|
{
|
2012-06-10 18:00:37 +02:00
|
|
|
SfxGroupInfo_Impl *pData = &aArr[i];
|
|
|
|
if (pData->nKind == SFX_CFGGROUP_SCRIPTCONTAINER)
|
2009-10-31 00:36:06 +01:00
|
|
|
{
|
|
|
|
XInterface* xi = static_cast<XInterface *>(pData->pObject);
|
|
|
|
if (xi != NULL)
|
|
|
|
{
|
|
|
|
xi->release();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-06-10 18:00:37 +02:00
|
|
|
aArr.clear();
|
2009-10-31 00:36:06 +01:00
|
|
|
Clear();
|
|
|
|
}
|
|
|
|
|
2014-01-23 12:06:11 +00:00
|
|
|
void SfxConfigGroupListBox::SetStylesInfo(SfxStylesInfo_Impl* pStyles)
|
2009-10-31 00:36:06 +01:00
|
|
|
{
|
|
|
|
pStylesInfo = pStyles;
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------
|
2014-01-23 12:06:11 +00:00
|
|
|
void SfxConfigGroupListBox::InitModule()
|
2009-10-31 00:36:06 +01:00
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
css::uno::Reference< css::frame::XDispatchInformationProvider > xProvider(m_xFrame, css::uno::UNO_QUERY_THROW);
|
|
|
|
css::uno::Sequence< sal_Int16 > lGroups = xProvider->getSupportedCommandGroups();
|
|
|
|
sal_Int32 c1 = lGroups.getLength();
|
|
|
|
sal_Int32 i1 = 0;
|
|
|
|
|
|
|
|
for (i1=0; i1<c1; ++i1)
|
|
|
|
{
|
|
|
|
sal_Int16& rGroupID = lGroups[i1];
|
2013-08-21 15:07:31 +02:00
|
|
|
OUString sGroupID = OUString::number(rGroupID);
|
2013-02-23 19:28:39 +01:00
|
|
|
OUString sGroupName ;
|
2009-10-31 00:36:06 +01:00
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
m_xModuleCategoryInfo->getByName(sGroupID) >>= sGroupName;
|
2011-12-16 17:29:07 -02:00
|
|
|
if (sGroupName.isEmpty())
|
2009-10-31 00:36:06 +01:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
catch(const css::container::NoSuchElementException&)
|
|
|
|
{ continue; }
|
|
|
|
|
2012-10-18 16:28:20 +02:00
|
|
|
SvTreeListEntry* pEntry = InsertEntry(sGroupName, NULL);
|
2009-10-31 00:36:06 +01:00
|
|
|
SfxGroupInfo_Impl* pInfo = new SfxGroupInfo_Impl(SFX_CFGGROUP_FUNCTION, rGroupID);
|
|
|
|
pEntry->SetUserData(pInfo);
|
|
|
|
}
|
|
|
|
}
|
2012-02-05 10:49:59 +01:00
|
|
|
catch(const css::uno::RuntimeException&)
|
|
|
|
{ throw; }
|
2009-10-31 00:36:06 +01:00
|
|
|
catch(const css::uno::Exception&)
|
|
|
|
{}
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------
|
2014-01-23 12:06:11 +00:00
|
|
|
void SfxConfigGroupListBox::InitBasic()
|
2009-10-31 00:36:06 +01:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------
|
2014-01-23 12:06:11 +00:00
|
|
|
void SfxConfigGroupListBox::InitStyles()
|
2009-10-31 00:36:06 +01:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------
|
|
|
|
namespace
|
|
|
|
{
|
|
|
|
//...........................................
|
|
|
|
/** examines a component whether it supports XEmbeddedScripts, or provides access to such a
|
|
|
|
component by implementing XScriptInvocationContext.
|
|
|
|
@return
|
|
|
|
the model which supports the embedded scripts, or <NULL/> if it cannot find such a
|
|
|
|
model
|
|
|
|
*/
|
|
|
|
static Reference< XModel > lcl_getDocumentWithScripts_throw( const Reference< XInterface >& _rxComponent )
|
|
|
|
{
|
|
|
|
Reference< XEmbeddedScripts > xScripts( _rxComponent, UNO_QUERY );
|
|
|
|
if ( !xScripts.is() )
|
|
|
|
{
|
|
|
|
Reference< XScriptInvocationContext > xContext( _rxComponent, UNO_QUERY );
|
|
|
|
if ( xContext.is() )
|
|
|
|
xScripts.set( xContext->getScriptContainer(), UNO_QUERY );
|
|
|
|
}
|
|
|
|
|
|
|
|
return Reference< XModel >( xScripts, UNO_QUERY );
|
|
|
|
}
|
|
|
|
|
|
|
|
//...........................................
|
|
|
|
static Reference< XModel > lcl_getScriptableDocument_nothrow( const Reference< XFrame >& _rxFrame )
|
|
|
|
{
|
|
|
|
Reference< XModel > xDocument;
|
|
|
|
|
|
|
|
// examine our associated frame
|
|
|
|
try
|
|
|
|
{
|
|
|
|
OSL_ENSURE( _rxFrame.is(), "lcl_getScriptableDocument_nothrow: you need to pass a frame to this dialog/tab page!" );
|
|
|
|
if ( _rxFrame.is() )
|
|
|
|
{
|
|
|
|
// first try the model in the frame
|
|
|
|
Reference< XController > xController( _rxFrame->getController(), UNO_SET_THROW );
|
|
|
|
xDocument = lcl_getDocumentWithScripts_throw( xController->getModel() );
|
|
|
|
|
|
|
|
if ( !xDocument.is() )
|
|
|
|
{
|
|
|
|
// if there is no suitable document in the frame, try the controller
|
|
|
|
xDocument = lcl_getDocumentWithScripts_throw( _rxFrame->getController() );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch( const Exception& )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
return xDocument;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------
|
2014-01-23 12:06:11 +00:00
|
|
|
void SfxConfigGroupListBox::Init(const css::uno::Reference< css::uno::XComponentContext >& xContext,
|
2014-01-23 11:41:20 +00:00
|
|
|
const css::uno::Reference< css::frame::XFrame >& xFrame,
|
|
|
|
const OUString& sModuleLongName,
|
|
|
|
bool bEventMode)
|
2009-10-31 00:36:06 +01:00
|
|
|
{
|
2011-01-14 12:41:27 +01:00
|
|
|
SetUpdateMode(sal_False);
|
2009-10-31 00:36:06 +01:00
|
|
|
ClearAll(); // Remove all old entries from treelist box
|
|
|
|
|
|
|
|
m_xFrame = xFrame;
|
2013-05-13 08:20:58 +02:00
|
|
|
if( xContext.is() )
|
2009-10-31 00:36:06 +01:00
|
|
|
{
|
2013-05-13 08:20:58 +02:00
|
|
|
m_xContext = xContext;
|
2009-10-31 00:36:06 +01:00
|
|
|
m_sModuleLongName = sModuleLongName;
|
|
|
|
|
2013-05-13 08:20:58 +02:00
|
|
|
m_xGlobalCategoryInfo = css::ui::UICategoryDescription::create( m_xContext );
|
|
|
|
m_xModuleCategoryInfo = css::uno::Reference< css::container::XNameAccess >(m_xGlobalCategoryInfo->getByName(m_sModuleLongName), css::uno::UNO_QUERY_THROW);
|
|
|
|
m_xUICmdDescription = css::frame::UICommandDescription::create( m_xContext );
|
2009-10-31 00:36:06 +01:00
|
|
|
|
|
|
|
InitModule();
|
|
|
|
InitBasic();
|
|
|
|
InitStyles();
|
|
|
|
}
|
|
|
|
|
2010-11-01 15:17:34 +01:00
|
|
|
OSL_TRACE("** ** About to initialise SF Scripts");
|
|
|
|
// Add Scripting Framework entries
|
|
|
|
Reference< browse::XBrowseNode > rootNode;
|
2012-09-29 17:20:22 +02:00
|
|
|
Reference< XComponentContext > xCtx(
|
|
|
|
comphelper::getProcessComponentContext() );
|
2010-11-01 15:17:34 +01:00
|
|
|
try
|
2009-10-31 00:36:06 +01:00
|
|
|
{
|
2013-05-14 14:19:58 +02:00
|
|
|
Reference< browse::XBrowseNodeFactory > xFac = browse::theBrowseNodeFactory::get( xCtx );
|
2010-11-01 15:17:34 +01:00
|
|
|
rootNode.set( xFac->createView( browse::BrowseNodeFactoryViewTypes::MACROSELECTOR ) );
|
2009-10-31 00:36:06 +01:00
|
|
|
}
|
2010-11-01 15:17:34 +01:00
|
|
|
catch( Exception& e )
|
2009-10-31 00:36:06 +01:00
|
|
|
{
|
2010-11-01 15:17:34 +01:00
|
|
|
OSL_TRACE(" Caught some exception whilst retrieving browse nodes from factory... Exception: %s",
|
2013-02-23 19:28:39 +01:00
|
|
|
OUStringToOString( e.Message , RTL_TEXTENCODING_ASCII_US ).pData->buffer );
|
2010-11-01 15:17:34 +01:00
|
|
|
// TODO exception handling
|
2009-10-31 00:36:06 +01:00
|
|
|
}
|
|
|
|
|
2010-11-01 15:17:34 +01:00
|
|
|
|
|
|
|
if ( rootNode.is() )
|
2009-10-31 00:36:06 +01:00
|
|
|
{
|
2014-01-23 11:41:20 +00:00
|
|
|
if ( bEventMode )
|
2009-10-31 00:36:06 +01:00
|
|
|
{
|
2010-11-01 15:17:34 +01:00
|
|
|
//We call acquire on the XBrowseNode so that it does not
|
|
|
|
//get autodestructed and become invalid when accessed later.
|
|
|
|
rootNode->acquire();
|
|
|
|
|
|
|
|
SfxGroupInfo_Impl *pInfo =
|
|
|
|
new SfxGroupInfo_Impl( SFX_CFGGROUP_SCRIPTCONTAINER, 0,
|
|
|
|
static_cast<void *>(rootNode.get()));
|
|
|
|
|
2013-09-26 08:30:52 +02:00
|
|
|
OUString aTitle(pImp->m_sDlgMacros);
|
2012-10-18 16:28:20 +02:00
|
|
|
SvTreeListEntry *pNewEntry = InsertEntry( aTitle, NULL );
|
2010-11-01 15:17:34 +01:00
|
|
|
pNewEntry->SetUserData( pInfo );
|
2011-12-07 02:33:51 -08:00
|
|
|
pNewEntry->EnableChildrenOnDemand( sal_True );
|
2012-06-10 18:00:37 +02:00
|
|
|
aArr.push_back( pInfo );
|
2009-10-31 00:36:06 +01:00
|
|
|
}
|
2010-11-01 15:17:34 +01:00
|
|
|
else
|
2009-10-31 00:36:06 +01:00
|
|
|
{
|
2010-11-01 15:17:34 +01:00
|
|
|
//We are only showing scripts not slot APIs so skip
|
|
|
|
//Root node and show location nodes
|
|
|
|
try {
|
|
|
|
if ( rootNode->hasChildNodes() )
|
|
|
|
{
|
|
|
|
Sequence< Reference< browse::XBrowseNode > > children =
|
|
|
|
rootNode->getChildNodes();
|
2011-02-07 13:06:08 +01:00
|
|
|
sal_Bool bIsRootNode = sal_False;
|
2009-10-31 00:36:06 +01:00
|
|
|
|
2013-02-23 19:28:39 +01:00
|
|
|
OUString user("user");
|
|
|
|
OUString share("share");
|
2012-04-06 14:09:04 +02:00
|
|
|
if ( rootNode->getName() == "Root" )
|
2009-10-31 00:36:06 +01:00
|
|
|
{
|
2011-02-07 13:06:08 +01:00
|
|
|
bIsRootNode = sal_True;
|
2010-11-01 15:17:34 +01:00
|
|
|
}
|
2009-10-31 00:36:06 +01:00
|
|
|
|
2010-11-01 15:17:34 +01:00
|
|
|
//To mimic current starbasic behaviour we
|
|
|
|
//need to make sure that only the current document
|
|
|
|
//is displayed in the config tree. Tests below
|
|
|
|
//set the bDisplay flag to FALSE if the current
|
|
|
|
//node is a first level child of the Root and is NOT
|
|
|
|
//either the current document, user or share
|
2013-02-23 19:28:39 +01:00
|
|
|
OUString currentDocTitle;
|
2010-11-01 15:17:34 +01:00
|
|
|
Reference< XModel > xDocument( lcl_getScriptableDocument_nothrow( m_xFrame ) );
|
|
|
|
if ( xDocument.is() )
|
|
|
|
{
|
|
|
|
currentDocTitle = ::comphelper::DocumentInfo::getDocumentTitle( xDocument );
|
|
|
|
}
|
2009-10-31 00:36:06 +01:00
|
|
|
|
2011-03-09 16:20:50 -06:00
|
|
|
for ( sal_Int32 n = 0; n < children.getLength(); ++n )
|
2010-11-01 15:17:34 +01:00
|
|
|
{
|
|
|
|
Reference< browse::XBrowseNode >& theChild = children[n];
|
2011-02-07 13:06:08 +01:00
|
|
|
sal_Bool bDisplay = sal_True;
|
2013-02-23 19:28:39 +01:00
|
|
|
OUString uiName = theChild->getName();
|
2010-11-01 15:17:34 +01:00
|
|
|
if ( bIsRootNode )
|
2009-10-31 00:36:06 +01:00
|
|
|
{
|
2010-11-01 15:17:34 +01:00
|
|
|
if ( ! ((theChild->getName().equals( user ) || theChild->getName().equals( share ) ||
|
|
|
|
theChild->getName().equals( currentDocTitle ) ) ) )
|
2009-10-31 00:36:06 +01:00
|
|
|
{
|
2011-02-07 13:06:08 +01:00
|
|
|
bDisplay=sal_False;
|
2010-11-01 15:17:34 +01:00
|
|
|
}
|
|
|
|
else
|
2009-10-31 00:36:06 +01:00
|
|
|
{
|
2010-11-01 15:17:34 +01:00
|
|
|
if ( uiName.equals( user ) )
|
2009-10-31 00:36:06 +01:00
|
|
|
{
|
2010-11-01 15:17:34 +01:00
|
|
|
uiName = pImp->m_sMyMacros;
|
2009-10-31 00:36:06 +01:00
|
|
|
}
|
2010-11-01 15:17:34 +01:00
|
|
|
else if ( uiName.equals( share ) )
|
2009-10-31 00:36:06 +01:00
|
|
|
{
|
2010-11-01 15:17:34 +01:00
|
|
|
uiName = pImp->m_sProdMacros;
|
2009-10-31 00:36:06 +01:00
|
|
|
}
|
|
|
|
}
|
2010-11-01 15:17:34 +01:00
|
|
|
}
|
|
|
|
if (children[n]->getType() != browse::BrowseNodeTypes::SCRIPT && bDisplay )
|
|
|
|
{
|
2010-11-16 18:59:15 -08:00
|
|
|
// We call acquire on the XBrowseNode so that it does not
|
|
|
|
// get autodestructed and become invalid when accessed later.
|
2010-11-01 15:17:34 +01:00
|
|
|
theChild->acquire();
|
2009-10-31 00:36:06 +01:00
|
|
|
|
2010-11-01 15:17:34 +01:00
|
|
|
SfxGroupInfo_Impl* pInfo =
|
|
|
|
new SfxGroupInfo_Impl(SFX_CFGGROUP_SCRIPTCONTAINER,
|
|
|
|
0, static_cast<void *>( theChild.get()));
|
2009-10-31 00:36:06 +01:00
|
|
|
|
2011-03-09 16:20:50 -06:00
|
|
|
Image aImage = GetImage( theChild, xCtx, bIsRootNode );
|
2012-10-18 16:28:20 +02:00
|
|
|
SvTreeListEntry* pNewEntry =
|
2010-11-01 15:17:34 +01:00
|
|
|
InsertEntry( uiName, NULL);
|
2011-03-09 16:20:50 -06:00
|
|
|
SetExpandedEntryBmp( pNewEntry, aImage );
|
|
|
|
SetCollapsedEntryBmp( pNewEntry, aImage );
|
2009-10-31 00:36:06 +01:00
|
|
|
|
2010-11-01 15:17:34 +01:00
|
|
|
pNewEntry->SetUserData( pInfo );
|
2012-06-10 18:00:37 +02:00
|
|
|
aArr.push_back( pInfo );
|
2009-10-31 00:36:06 +01:00
|
|
|
|
2010-11-01 15:17:34 +01:00
|
|
|
if ( children[n]->hasChildNodes() )
|
|
|
|
{
|
|
|
|
Sequence< Reference< browse::XBrowseNode > > grandchildren =
|
|
|
|
children[n]->getChildNodes();
|
2009-10-31 00:36:06 +01:00
|
|
|
|
2011-03-09 16:20:50 -06:00
|
|
|
for ( sal_Int32 m = 0; m < grandchildren.getLength(); ++m )
|
2010-11-01 15:17:34 +01:00
|
|
|
{
|
|
|
|
if ( grandchildren[m]->getType() == browse::BrowseNodeTypes::CONTAINER )
|
2009-10-31 00:36:06 +01:00
|
|
|
{
|
2011-12-07 02:33:51 -08:00
|
|
|
pNewEntry->EnableChildrenOnDemand( sal_True );
|
2010-11-01 15:17:34 +01:00
|
|
|
m = grandchildren.getLength();
|
2009-10-31 00:36:06 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2010-11-01 15:17:34 +01:00
|
|
|
}
|
|
|
|
catch (RuntimeException&) {
|
|
|
|
// do nothing, the entry will not be displayed in the UI
|
2009-10-31 00:36:06 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// add styles
|
2013-05-13 08:20:58 +02:00
|
|
|
if ( m_xContext.is() )
|
2009-10-31 00:36:06 +01:00
|
|
|
{
|
2013-09-26 08:30:52 +02:00
|
|
|
OUString sStyle( pImp->m_aStrGroupStyles );
|
2012-10-18 16:28:20 +02:00
|
|
|
SvTreeListEntry *pEntry = InsertEntry( sStyle, 0 );
|
2009-10-31 00:36:06 +01:00
|
|
|
SfxGroupInfo_Impl *pInfo = new SfxGroupInfo_Impl( SFX_CFGGROUP_STYLES, 0, 0 ); // TODO last parameter should contain user data
|
2012-06-10 18:00:37 +02:00
|
|
|
aArr.push_back( pInfo );
|
2009-10-31 00:36:06 +01:00
|
|
|
pEntry->SetUserData( pInfo );
|
2011-12-07 02:33:51 -08:00
|
|
|
pEntry->EnableChildrenOnDemand( sal_True );
|
2009-10-31 00:36:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
MakeVisible( GetEntry( 0,0 ) );
|
2011-01-14 12:41:27 +01:00
|
|
|
SetUpdateMode( sal_True );
|
2009-10-31 00:36:06 +01:00
|
|
|
}
|
2014-01-23 12:06:11 +00:00
|
|
|
Image SfxConfigGroupListBox::GetImage(
|
2010-11-16 18:59:15 -08:00
|
|
|
Reference< browse::XBrowseNode > node,
|
|
|
|
Reference< XComponentContext > xCtx,
|
|
|
|
bool bIsRootNode
|
|
|
|
)
|
2009-10-31 00:36:06 +01:00
|
|
|
{
|
|
|
|
Image aImage;
|
|
|
|
if ( bIsRootNode )
|
|
|
|
{
|
2013-02-23 19:28:39 +01:00
|
|
|
OUString user("user");
|
|
|
|
OUString share("share");
|
2009-10-31 00:36:06 +01:00
|
|
|
if (node->getName().equals( user ) || node->getName().equals(share ) )
|
|
|
|
{
|
2010-11-16 14:32:13 +00:00
|
|
|
aImage = pImp->m_hdImage;
|
2009-10-31 00:36:06 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-02-23 19:28:39 +01:00
|
|
|
OUString factoryURL;
|
|
|
|
OUString nodeName = node->getName();
|
2009-10-31 00:36:06 +01:00
|
|
|
Reference<XInterface> xDocumentModel = getDocumentModel(xCtx, nodeName );
|
|
|
|
if ( xDocumentModel.is() )
|
|
|
|
{
|
2012-09-04 14:56:48 +02:00
|
|
|
Reference< frame::XModuleManager2 > xModuleManager( frame::ModuleManager::create(xCtx) );
|
2009-10-31 00:36:06 +01:00
|
|
|
// get the long name of the document:
|
2013-02-23 19:28:39 +01:00
|
|
|
OUString appModule( xModuleManager->identify(
|
2009-10-31 00:36:06 +01:00
|
|
|
xDocumentModel ) );
|
|
|
|
Sequence<beans::PropertyValue> moduleDescr;
|
2012-09-05 14:55:34 +02:00
|
|
|
Any aAny = xModuleManager->getByName(appModule);
|
2014-01-22 00:39:26 +01:00
|
|
|
if( !( aAny >>= moduleDescr ) )
|
2009-10-31 00:36:06 +01:00
|
|
|
{
|
2013-06-29 21:24:12 +02:00
|
|
|
throw RuntimeException("SFTreeListBox::Init: failed to get PropertyValue", Reference< XInterface >());
|
2009-10-31 00:36:06 +01:00
|
|
|
}
|
|
|
|
beans::PropertyValue const * pmoduleDescr =
|
|
|
|
moduleDescr.getConstArray();
|
|
|
|
for ( sal_Int32 pos = moduleDescr.getLength(); pos--; )
|
|
|
|
{
|
2012-04-06 19:49:53 +02:00
|
|
|
if ( pmoduleDescr[ pos ].Name == "ooSetupFactoryEmptyDocumentURL" )
|
2009-10-31 00:36:06 +01:00
|
|
|
{
|
|
|
|
pmoduleDescr[ pos ].Value >>= factoryURL;
|
|
|
|
OSL_TRACE("factory url for doc images is %s",
|
2013-02-23 19:28:39 +01:00
|
|
|
OUStringToOString( factoryURL , RTL_TEXTENCODING_ASCII_US ).pData->buffer );
|
2009-10-31 00:36:06 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-12-16 17:29:07 -02:00
|
|
|
if( !factoryURL.isEmpty() )
|
2009-10-31 00:36:06 +01:00
|
|
|
{
|
2010-11-16 18:59:15 -08:00
|
|
|
aImage = SvFileInformationManager::GetFileImage( INetURLObject(factoryURL), false );
|
2009-10-31 00:36:06 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-11-16 14:32:13 +00:00
|
|
|
aImage = pImp->m_docImage;
|
2009-10-31 00:36:06 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if( node->getType() == browse::BrowseNodeTypes::SCRIPT )
|
2010-11-16 14:32:13 +00:00
|
|
|
aImage = pImp->m_macImage;
|
2009-10-31 00:36:06 +01:00
|
|
|
else
|
2010-11-16 14:32:13 +00:00
|
|
|
aImage = pImp->m_libImage;
|
2009-10-31 00:36:06 +01:00
|
|
|
}
|
|
|
|
return aImage;
|
|
|
|
}
|
|
|
|
|
|
|
|
Reference< XInterface >
|
2014-01-23 12:06:11 +00:00
|
|
|
SfxConfigGroupListBox::getDocumentModel( Reference< XComponentContext >& xCtx, OUString& docName )
|
2009-10-31 00:36:06 +01:00
|
|
|
{
|
|
|
|
Reference< XInterface > xModel;
|
2012-12-14 12:58:00 +02:00
|
|
|
Reference< frame::XDesktop2 > desktop = frame::Desktop::create( xCtx );
|
2009-10-31 00:36:06 +01:00
|
|
|
|
|
|
|
Reference< container::XEnumerationAccess > componentsAccess =
|
|
|
|
desktop->getComponents();
|
|
|
|
Reference< container::XEnumeration > components =
|
|
|
|
componentsAccess->createEnumeration();
|
|
|
|
while (components->hasMoreElements())
|
|
|
|
{
|
|
|
|
Reference< frame::XModel > model(
|
|
|
|
components->nextElement(), UNO_QUERY );
|
|
|
|
if ( model.is() )
|
|
|
|
{
|
2013-02-23 19:28:39 +01:00
|
|
|
OUString sTdocUrl =
|
2009-10-31 00:36:06 +01:00
|
|
|
::comphelper::DocumentInfo::getDocumentTitle( model );
|
|
|
|
if( sTdocUrl.equals( docName ) )
|
|
|
|
{
|
|
|
|
xModel = model;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return xModel;
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------
|
2014-01-23 12:06:11 +00:00
|
|
|
OUString SfxConfigGroupListBox::MapCommand2UIName(const OUString& sCommand)
|
2009-10-31 00:36:06 +01:00
|
|
|
{
|
2013-02-23 19:28:39 +01:00
|
|
|
OUString sUIName;
|
2009-10-31 00:36:06 +01:00
|
|
|
try
|
|
|
|
{
|
|
|
|
css::uno::Reference< css::container::XNameAccess > xModuleConf;
|
|
|
|
m_xUICmdDescription->getByName(m_sModuleLongName) >>= xModuleConf;
|
|
|
|
if (xModuleConf.is())
|
|
|
|
{
|
|
|
|
::comphelper::SequenceAsHashMap lProps(xModuleConf->getByName(sCommand));
|
2013-06-29 21:24:12 +02:00
|
|
|
sUIName = lProps.getUnpackedValueOrDefault("Name", OUString());
|
2009-10-31 00:36:06 +01:00
|
|
|
}
|
|
|
|
}
|
2012-02-05 10:49:59 +01:00
|
|
|
catch(const css::uno::RuntimeException&)
|
|
|
|
{ throw; }
|
2009-10-31 00:36:06 +01:00
|
|
|
catch(css::uno::Exception&)
|
2013-02-23 19:28:39 +01:00
|
|
|
{ sUIName = OUString(); }
|
2009-10-31 00:36:06 +01:00
|
|
|
|
|
|
|
// fallback for missing UINames !?
|
2011-12-16 17:29:07 -02:00
|
|
|
if (sUIName.isEmpty())
|
2009-10-31 00:36:06 +01:00
|
|
|
{
|
|
|
|
sUIName = sCommand;
|
|
|
|
}
|
|
|
|
|
|
|
|
return sUIName;
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------
|
2014-01-23 12:06:11 +00:00
|
|
|
void SfxConfigGroupListBox::GroupSelected()
|
2012-04-15 17:50:21 +02:00
|
|
|
/* Description
|
|
|
|
A function group or a basic module has been selected.
|
|
|
|
All functions/macros are displayed in the functionlistbox.
|
2009-10-31 00:36:06 +01:00
|
|
|
*/
|
|
|
|
{
|
2012-10-18 16:28:20 +02:00
|
|
|
SvTreeListEntry *pEntry = FirstSelected();
|
2009-10-31 00:36:06 +01:00
|
|
|
SfxGroupInfo_Impl *pInfo = (SfxGroupInfo_Impl*) pEntry->GetUserData();
|
2011-01-14 12:41:27 +01:00
|
|
|
pFunctionListBox->SetUpdateMode(sal_False);
|
2009-10-31 00:36:06 +01:00
|
|
|
pFunctionListBox->ClearAll();
|
|
|
|
if ( pInfo->nKind != SFX_CFGGROUP_FUNCTION &&
|
|
|
|
pInfo->nKind != SFX_CFGGROUP_SCRIPTCONTAINER &&
|
|
|
|
pInfo->nKind != SFX_CFGGROUP_STYLES )
|
|
|
|
{
|
2011-01-14 12:41:27 +01:00
|
|
|
pFunctionListBox->SetUpdateMode(sal_True);
|
2009-10-31 00:36:06 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch ( pInfo->nKind )
|
|
|
|
{
|
|
|
|
case SFX_CFGGROUP_FUNCTION :
|
|
|
|
{
|
2011-02-07 13:06:08 +01:00
|
|
|
sal_uInt16 nGroup = pInfo->nUniqueID;
|
2009-10-31 00:36:06 +01:00
|
|
|
css::uno::Reference< css::frame::XDispatchInformationProvider > xProvider (m_xFrame, css::uno::UNO_QUERY_THROW);
|
|
|
|
css::uno::Sequence< css::frame::DispatchInformation > lCommands = xProvider->getConfigurableDispatchInformation(nGroup);
|
|
|
|
sal_Int32 c = lCommands.getLength();
|
|
|
|
sal_Int32 i = 0;
|
|
|
|
|
|
|
|
for (i=0; i<c; ++i)
|
|
|
|
{
|
|
|
|
const css::frame::DispatchInformation& rInfo = lCommands[i];
|
2013-02-23 19:28:39 +01:00
|
|
|
OUString sUIName = MapCommand2UIName(rInfo.Command);
|
2012-10-18 16:28:20 +02:00
|
|
|
SvTreeListEntry* pFuncEntry = pFunctionListBox->InsertEntry(sUIName, NULL);
|
2009-10-31 00:36:06 +01:00
|
|
|
SfxGroupInfo_Impl* pGrpInfo = new SfxGroupInfo_Impl(SFX_CFGFUNCTION_SLOT, 0);
|
|
|
|
pGrpInfo->sCommand = rInfo.Command;
|
|
|
|
pGrpInfo->sLabel = sUIName;
|
|
|
|
pFuncEntry->SetUserData(pGrpInfo);
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case SFX_CFGGROUP_SCRIPTCONTAINER:
|
|
|
|
{
|
|
|
|
if ( !GetChildCount( pEntry ) )
|
|
|
|
{
|
|
|
|
Reference< browse::XBrowseNode > rootNode(
|
|
|
|
reinterpret_cast< browse::XBrowseNode* >( pInfo->pObject ) ) ;
|
|
|
|
|
|
|
|
try {
|
|
|
|
if ( rootNode->hasChildNodes() )
|
|
|
|
{
|
|
|
|
Sequence< Reference< browse::XBrowseNode > > children =
|
|
|
|
rootNode->getChildNodes();
|
|
|
|
|
2010-12-27 09:29:07 +01:00
|
|
|
for ( sal_Int32 n = 0; n < children.getLength(); ++n )
|
2009-10-31 00:36:06 +01:00
|
|
|
{
|
|
|
|
if (children[n]->getType() == browse::BrowseNodeTypes::SCRIPT)
|
|
|
|
{
|
2013-02-23 19:28:39 +01:00
|
|
|
OUString uri;
|
2009-10-31 00:36:06 +01:00
|
|
|
|
|
|
|
Reference < beans::XPropertySet >xPropSet( children[n], UNO_QUERY );
|
|
|
|
if (!xPropSet.is())
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
Any value =
|
2013-06-29 21:24:12 +02:00
|
|
|
xPropSet->getPropertyValue("URI");
|
2009-10-31 00:36:06 +01:00
|
|
|
value >>= uri;
|
|
|
|
|
2013-09-26 08:30:52 +02:00
|
|
|
OUString* pScriptURI = new OUString( uri );
|
2010-11-01 15:32:51 +01:00
|
|
|
SfxGroupInfo_Impl* pGrpInfo = new SfxGroupInfo_Impl( SFX_CFGFUNCTION_SCRIPT, 0, pScriptURI );
|
2009-10-31 00:36:06 +01:00
|
|
|
|
2010-11-16 14:32:13 +00:00
|
|
|
Image aImage = GetImage( children[n], Reference< XComponentContext >(), sal_False );
|
2012-10-18 16:28:20 +02:00
|
|
|
SvTreeListEntry* pNewEntry =
|
2009-10-31 00:36:06 +01:00
|
|
|
pFunctionListBox->InsertEntry( children[n]->getName(), NULL );
|
2010-11-09 20:07:12 -08:00
|
|
|
pFunctionListBox->SetExpandedEntryBmp( pNewEntry, aImage );
|
|
|
|
pFunctionListBox->SetCollapsedEntryBmp(pNewEntry, aImage );
|
2009-10-31 00:36:06 +01:00
|
|
|
|
|
|
|
pGrpInfo->sCommand = uri;
|
|
|
|
pGrpInfo->sLabel = children[n]->getName();
|
|
|
|
pNewEntry->SetUserData( pGrpInfo );
|
|
|
|
|
2012-06-10 18:00:37 +02:00
|
|
|
pFunctionListBox->aArr.push_back( pGrpInfo );
|
2009-10-31 00:36:06 +01:00
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (RuntimeException&) {
|
|
|
|
// do nothing, the entry will not be displayed in the UI
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case SFX_CFGGROUP_STYLES :
|
|
|
|
{
|
|
|
|
SfxStyleInfo_Impl* pFamily = (SfxStyleInfo_Impl*)(pInfo->pObject);
|
|
|
|
if (pFamily)
|
|
|
|
{
|
|
|
|
const ::std::vector< SfxStyleInfo_Impl > lStyles = pStylesInfo->getStyles(pFamily->sFamily);
|
|
|
|
::std::vector< SfxStyleInfo_Impl >::const_iterator pIt;
|
|
|
|
for ( pIt = lStyles.begin();
|
|
|
|
pIt != lStyles.end() ;
|
|
|
|
++pIt )
|
|
|
|
{
|
|
|
|
SfxStyleInfo_Impl* pStyle = new SfxStyleInfo_Impl(*pIt);
|
2012-10-18 16:28:20 +02:00
|
|
|
SvTreeListEntry* pFuncEntry = pFunctionListBox->InsertEntry( pStyle->sLabel, NULL );
|
2009-10-31 00:36:06 +01:00
|
|
|
SfxGroupInfo_Impl *pGrpInfo = new SfxGroupInfo_Impl( SFX_CFGGROUP_STYLES, 0, pStyle );
|
2012-06-10 18:00:37 +02:00
|
|
|
pFunctionListBox->aArr.push_back( pGrpInfo );
|
2009-10-31 00:36:06 +01:00
|
|
|
pGrpInfo->sCommand = pStyle->sCommand;
|
|
|
|
pGrpInfo->sLabel = pStyle->sLabel;
|
|
|
|
pFuncEntry->SetUserData( pGrpInfo );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
default:
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( pFunctionListBox->GetEntryCount() )
|
|
|
|
pFunctionListBox->Select( pFunctionListBox->GetEntry( 0, 0 ) );
|
|
|
|
|
2011-01-14 12:41:27 +01:00
|
|
|
pFunctionListBox->SetUpdateMode(sal_True);
|
2009-10-31 00:36:06 +01:00
|
|
|
}
|
|
|
|
|
2014-01-23 12:06:11 +00:00
|
|
|
sal_Bool SfxConfigGroupListBox::Expand( SvTreeListEntry* pParent )
|
2009-10-31 00:36:06 +01:00
|
|
|
{
|
2011-01-14 12:41:27 +01:00
|
|
|
sal_Bool bRet = SvTreeListBox::Expand( pParent );
|
2009-10-31 00:36:06 +01:00
|
|
|
if ( bRet )
|
|
|
|
{
|
2011-01-14 12:41:27 +01:00
|
|
|
sal_uLong nEntries = GetOutputSizePixel().Height() / GetEntryHeight();
|
2009-10-31 00:36:06 +01:00
|
|
|
|
2011-01-14 12:41:27 +01:00
|
|
|
sal_uLong nChildCount = GetVisibleChildCount( pParent );
|
2009-10-31 00:36:06 +01:00
|
|
|
|
|
|
|
if ( nChildCount+1 > nEntries )
|
|
|
|
{
|
2011-01-14 12:41:27 +01:00
|
|
|
MakeVisible( pParent, sal_True );
|
2009-10-31 00:36:06 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-10-18 16:28:20 +02:00
|
|
|
SvTreeListEntry *pEntry = GetFirstEntryInView();
|
2011-01-14 12:41:27 +01:00
|
|
|
sal_uLong nParentPos = 0;
|
2009-10-31 00:36:06 +01:00
|
|
|
while ( pEntry && pEntry != pParent )
|
|
|
|
{
|
2010-12-27 09:29:07 +01:00
|
|
|
++nParentPos;
|
2009-10-31 00:36:06 +01:00
|
|
|
pEntry = GetNextEntryInView( pEntry );
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( nParentPos + nChildCount + 1 > nEntries )
|
|
|
|
ScrollOutputArea( (short)( nEntries - ( nParentPos + nChildCount + 1 ) ) );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return bRet;
|
|
|
|
}
|
|
|
|
|
2014-01-23 12:06:11 +00:00
|
|
|
void SfxConfigGroupListBox::RequestingChildren( SvTreeListEntry *pEntry )
|
2012-04-15 17:50:21 +02:00
|
|
|
/* Description
|
|
|
|
A basic or a library is opened.
|
2009-10-31 00:36:06 +01:00
|
|
|
*/
|
|
|
|
{
|
|
|
|
SfxGroupInfo_Impl *pInfo = (SfxGroupInfo_Impl*) pEntry->GetUserData();
|
2011-01-14 12:41:27 +01:00
|
|
|
pInfo->bWasOpened = sal_True;
|
2009-10-31 00:36:06 +01:00
|
|
|
switch ( pInfo->nKind )
|
|
|
|
{
|
|
|
|
case SFX_CFGGROUP_SCRIPTCONTAINER:
|
|
|
|
{
|
|
|
|
if ( !GetChildCount( pEntry ) )
|
|
|
|
{
|
|
|
|
Reference< browse::XBrowseNode > rootNode(
|
|
|
|
reinterpret_cast< browse::XBrowseNode* >( pInfo->pObject ) ) ;
|
|
|
|
|
|
|
|
try {
|
|
|
|
if ( rootNode->hasChildNodes() )
|
|
|
|
{
|
|
|
|
Sequence< Reference< browse::XBrowseNode > > children =
|
|
|
|
rootNode->getChildNodes();
|
2011-01-14 12:41:27 +01:00
|
|
|
sal_Bool bIsRootNode = sal_False;
|
2009-10-31 00:36:06 +01:00
|
|
|
|
2013-02-23 19:28:39 +01:00
|
|
|
OUString user("user");
|
|
|
|
OUString share("share" );
|
2012-04-06 14:09:04 +02:00
|
|
|
if ( rootNode->getName() == "Root" )
|
2009-10-31 00:36:06 +01:00
|
|
|
{
|
2011-01-14 12:41:27 +01:00
|
|
|
bIsRootNode = sal_True;
|
2009-10-31 00:36:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* To mimic current starbasic behaviour we
|
|
|
|
need to make sure that only the current document
|
|
|
|
is displayed in the config tree. Tests below
|
2011-01-14 12:41:27 +01:00
|
|
|
set the bDisplay flag to sal_False if the current
|
2009-10-31 00:36:06 +01:00
|
|
|
node is a first level child of the Root and is NOT
|
|
|
|
either the current document, user or share */
|
2013-02-23 19:28:39 +01:00
|
|
|
OUString currentDocTitle;
|
2009-10-31 00:36:06 +01:00
|
|
|
Reference< XModel > xDocument( lcl_getScriptableDocument_nothrow( m_xFrame ) );
|
|
|
|
if ( xDocument.is() )
|
|
|
|
{
|
|
|
|
currentDocTitle = ::comphelper::DocumentInfo::getDocumentTitle( xDocument );
|
|
|
|
}
|
|
|
|
|
|
|
|
sal_Int32 nLen = children.getLength();
|
2010-12-27 09:29:07 +01:00
|
|
|
for ( sal_Int32 n = 0; n < nLen; ++n )
|
2009-10-31 00:36:06 +01:00
|
|
|
{
|
|
|
|
Reference< browse::XBrowseNode >& theChild = children[n];
|
2013-02-23 19:28:39 +01:00
|
|
|
OUString aName( theChild->getName() );
|
2011-01-14 12:41:27 +01:00
|
|
|
sal_Bool bDisplay = sal_True;
|
2009-10-31 00:36:06 +01:00
|
|
|
if ( bIsRootNode )
|
|
|
|
{
|
|
|
|
if ( !( (aName.equals(user) || aName.equals(share) || aName.equals(currentDocTitle) ) ) )
|
2011-01-14 12:41:27 +01:00
|
|
|
bDisplay=sal_False;
|
2009-10-31 00:36:06 +01:00
|
|
|
}
|
|
|
|
if ( children[n].is() && children[n]->getType() != browse::BrowseNodeTypes::SCRIPT && bDisplay )
|
|
|
|
{
|
|
|
|
|
|
|
|
/*
|
|
|
|
We call acquire on the XBrowseNode so that it does not
|
|
|
|
get autodestructed and become invalid when accessed later.
|
|
|
|
*/
|
|
|
|
theChild->acquire();
|
|
|
|
|
|
|
|
SfxGroupInfo_Impl* pGrpInfo =
|
|
|
|
new SfxGroupInfo_Impl(SFX_CFGGROUP_SCRIPTCONTAINER,
|
|
|
|
0, static_cast<void *>( theChild.get()));
|
|
|
|
|
2010-11-16 14:32:13 +00:00
|
|
|
Image aImage = GetImage( theChild, Reference< XComponentContext >(), sal_False );
|
2012-10-18 16:28:20 +02:00
|
|
|
SvTreeListEntry* pNewEntry =
|
2009-10-31 00:36:06 +01:00
|
|
|
InsertEntry( theChild->getName(), pEntry );
|
2010-11-09 20:07:12 -08:00
|
|
|
SetExpandedEntryBmp( pNewEntry, aImage );
|
|
|
|
SetCollapsedEntryBmp(pNewEntry, aImage );
|
2009-10-31 00:36:06 +01:00
|
|
|
|
|
|
|
pNewEntry->SetUserData( pGrpInfo );
|
2012-06-10 18:00:37 +02:00
|
|
|
aArr.push_back( pGrpInfo );
|
2009-10-31 00:36:06 +01:00
|
|
|
|
|
|
|
if ( children[n]->hasChildNodes() )
|
|
|
|
{
|
|
|
|
Sequence< Reference< browse::XBrowseNode > > grandchildren =
|
|
|
|
children[n]->getChildNodes();
|
|
|
|
|
2010-12-27 09:29:07 +01:00
|
|
|
for ( sal_Int32 m = 0; m < grandchildren.getLength(); ++m )
|
2009-10-31 00:36:06 +01:00
|
|
|
{
|
|
|
|
if ( grandchildren[m]->getType() == browse::BrowseNodeTypes::CONTAINER )
|
|
|
|
{
|
2011-12-07 02:33:51 -08:00
|
|
|
pNewEntry->EnableChildrenOnDemand( sal_True );
|
2009-10-31 00:36:06 +01:00
|
|
|
m = grandchildren.getLength();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (RuntimeException&) {
|
|
|
|
// do nothing, the entry will not be displayed in the UI
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case SFX_CFGGROUP_STYLES:
|
|
|
|
{
|
|
|
|
if ( !GetChildCount( pEntry ) )
|
|
|
|
{
|
|
|
|
const ::std::vector< SfxStyleInfo_Impl > lStyleFamilies = pStylesInfo->getStyleFamilies();
|
|
|
|
::std::vector< SfxStyleInfo_Impl >::const_iterator pIt;
|
|
|
|
for ( pIt = lStyleFamilies.begin();
|
|
|
|
pIt != lStyleFamilies.end() ;
|
|
|
|
++pIt )
|
|
|
|
{
|
|
|
|
SfxStyleInfo_Impl* pFamily = new SfxStyleInfo_Impl(*pIt);
|
2012-10-18 16:28:20 +02:00
|
|
|
SvTreeListEntry* pStyleEntry = InsertEntry( pFamily->sLabel, pEntry );
|
2009-10-31 00:36:06 +01:00
|
|
|
SfxGroupInfo_Impl *pGrpInfo = new SfxGroupInfo_Impl( SFX_CFGGROUP_STYLES, 0, pFamily );
|
2012-06-10 18:00:37 +02:00
|
|
|
aArr.push_back( pGrpInfo );
|
2009-10-31 00:36:06 +01:00
|
|
|
pStyleEntry->SetUserData( pGrpInfo );
|
2011-12-07 02:33:51 -08:00
|
|
|
pStyleEntry->EnableChildrenOnDemand( sal_False );
|
2009-10-31 00:36:06 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
default:
|
2011-03-01 17:55:09 +01:00
|
|
|
OSL_FAIL( "Falscher Gruppentyp!" );
|
2009-10-31 00:36:06 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-01-23 12:06:11 +00:00
|
|
|
void SfxConfigGroupListBox::SelectMacro( const SfxMacroInfoItem *pItem )
|
2009-10-31 00:36:06 +01:00
|
|
|
{
|
|
|
|
SelectMacro( pItem->GetBasicManager()->GetName(),
|
|
|
|
pItem->GetQualifiedName() );
|
|
|
|
}
|
|
|
|
|
2014-01-23 12:06:11 +00:00
|
|
|
void SfxConfigGroupListBox::SelectMacro( const OUString& rBasic,
|
2013-09-26 08:30:52 +02:00
|
|
|
const OUString& rMacro )
|
2009-10-31 00:36:06 +01:00
|
|
|
{
|
2013-09-26 08:30:52 +02:00
|
|
|
OUString aBasicName( rBasic );
|
|
|
|
aBasicName += " ";
|
2009-10-31 00:36:06 +01:00
|
|
|
aBasicName += pImp->m_sMacros;
|
2013-09-26 08:30:52 +02:00
|
|
|
OUString aLib, aModule, aMethod;
|
2012-01-02 10:55:27 +00:00
|
|
|
sal_uInt16 nCount = comphelper::string::getTokenCount(rMacro, '.');
|
2013-09-26 08:30:52 +02:00
|
|
|
aMethod = rMacro.getToken( nCount-1, '.' );
|
2009-10-31 00:36:06 +01:00
|
|
|
if ( nCount > 2 )
|
|
|
|
{
|
2013-09-26 08:30:52 +02:00
|
|
|
aLib = rMacro.getToken( 0, '.' );
|
|
|
|
aModule = rMacro.getToken( nCount-2, '.' );
|
2009-10-31 00:36:06 +01:00
|
|
|
}
|
|
|
|
|
2012-10-18 16:28:20 +02:00
|
|
|
SvTreeListEntry *pEntry = FirstChild(0);
|
2009-10-31 00:36:06 +01:00
|
|
|
while ( pEntry )
|
|
|
|
{
|
2013-09-26 08:30:52 +02:00
|
|
|
OUString aEntryBas = GetEntryText( pEntry );
|
2009-10-31 00:36:06 +01:00
|
|
|
if ( aEntryBas == aBasicName )
|
|
|
|
{
|
|
|
|
Expand( pEntry );
|
2012-10-18 16:28:20 +02:00
|
|
|
SvTreeListEntry *pLib = FirstChild( pEntry );
|
2009-10-31 00:36:06 +01:00
|
|
|
while ( pLib )
|
|
|
|
{
|
2013-09-26 08:30:52 +02:00
|
|
|
OUString aEntryLib = GetEntryText( pLib );
|
2009-10-31 00:36:06 +01:00
|
|
|
if ( aEntryLib == aLib )
|
|
|
|
{
|
|
|
|
Expand( pLib );
|
2012-10-18 16:28:20 +02:00
|
|
|
SvTreeListEntry *pMod = FirstChild( pLib );
|
2009-10-31 00:36:06 +01:00
|
|
|
while ( pMod )
|
|
|
|
{
|
2013-09-26 08:30:52 +02:00
|
|
|
OUString aEntryMod = GetEntryText( pMod );
|
2009-10-31 00:36:06 +01:00
|
|
|
if ( aEntryMod == aModule )
|
|
|
|
{
|
|
|
|
Expand( pMod );
|
|
|
|
MakeVisible( pMod );
|
|
|
|
Select( pMod );
|
2012-10-18 16:28:20 +02:00
|
|
|
SvTreeListEntry *pMethod = pFunctionListBox->First();
|
2009-10-31 00:36:06 +01:00
|
|
|
while ( pMethod )
|
|
|
|
{
|
2013-09-26 08:30:52 +02:00
|
|
|
OUString aEntryMethod = GetEntryText( pMethod );
|
2009-10-31 00:36:06 +01:00
|
|
|
if ( aEntryMethod == aMethod )
|
|
|
|
{
|
|
|
|
pFunctionListBox->Select( pMethod );
|
|
|
|
pFunctionListBox->MakeVisible( pMethod );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
pMethod = pFunctionListBox->Next( pMethod );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
pMod = NextSibling( pMod );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
pLib = NextSibling( pLib );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
pEntry = NextSibling( pEntry );
|
|
|
|
}
|
|
|
|
}
|
2010-10-12 15:57:08 +02:00
|
|
|
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|