From 0b14725c7b188b78eddafae7ea6761865dfc81ab Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Fri, 8 Jan 2016 10:53:34 +0000 Subject: implement the style pane right toolbar the same as the left toolbar Change-Id: I1a031facad52afbc84b06610f9bdd0a9f118ebeb --- sfx2/source/dialog/templdlg.cxx | 75 +++++++++++++++++++++++++++++------------ sfx2/source/dialog/templdlg.hrc | 21 ------------ sfx2/source/dialog/templdlg.src | 32 ------------------ 3 files changed, 54 insertions(+), 74 deletions(-) delete mode 100644 sfx2/source/dialog/templdlg.hrc diff --git a/sfx2/source/dialog/templdlg.cxx b/sfx2/source/dialog/templdlg.cxx index 473ef30ae56e..bbfed85b0a1a 100644 --- a/sfx2/source/dialog/templdlg.cxx +++ b/sfx2/source/dialog/templdlg.cxx @@ -50,7 +50,6 @@ #include #include -#include "templdlg.hrc" #include #include "dialog.hrc" #include "arrdecl.hxx" @@ -2200,13 +2199,65 @@ std::unique_ptr SfxCommonTemplateDialog_Impl::CreateContextMenu() return pMenu; } +static OUString lcl_GetLabel(uno::Any& rAny) +{ + OUString sRet; + uno::Sequence< beans::PropertyValue >aPropSeq; + if ( rAny >>= aPropSeq ) + { + for( sal_Int32 i = 0; i < aPropSeq.getLength(); i++ ) + { + if ( aPropSeq[i].Name == "Label" ) + { + aPropSeq[i].Value >>= sRet; + break; + } + } + } + return sRet; +} + SfxTemplateDialog_Impl::SfxTemplateDialog_Impl(SfxBindings* pB, SfxTemplatePanelControl* pDlgWindow) : SfxCommonTemplateDialog_Impl(pB, pDlgWindow, true) , m_pFloat(pDlgWindow) , m_bZoomIn(false) , m_aActionTbL(VclPtrInstance(pDlgWindow, this)) - , m_aActionTbR(VclPtrInstance (pDlgWindow, SfxResId(TB_ACTION))) + , m_aActionTbR(VclPtrInstance(pDlgWindow)) { + try + { + uno::Reference< container::XNameAccess > xNameAccess( + frame::theUICommandDescription::get( + ::comphelper::getProcessComponentContext()) ); + uno::Reference< container::XNameAccess > xUICommands; + OUString sTextDoc("com.sun.star.text.TextDocument"); + if(xNameAccess->hasByName(sTextDoc)) + { + uno::Any a = xNameAccess->getByName( sTextDoc ); + a >>= xUICommands; + } + if (xUICommands.is()) + { + uno::Any aCommand = xUICommands->getByName(".uno:StyleApply"); + OUString sLabel = lcl_GetLabel( aCommand ); + m_aActionTbR->InsertItem( SID_STYLE_WATERCAN, sLabel ); + m_aActionTbR->SetHelpId(SID_STYLE_WATERCAN, HID_TEMPLDLG_WATERCAN); + + aCommand = xUICommands->getByName(".uno:StyleNewByExample"); + sLabel = lcl_GetLabel( aCommand ); + m_aActionTbR->InsertItem( SID_STYLE_NEW_BY_EXAMPLE, sLabel ); + m_aActionTbR->SetHelpId(SID_STYLE_NEW_BY_EXAMPLE, HID_TEMPLDLG_NEWBYEXAMPLE); + + aCommand = xUICommands->getByName(".uno:StyleUpdateByExample"); + sLabel = lcl_GetLabel( aCommand ); + m_aActionTbR->InsertItem( SID_STYLE_UPDATE_BY_EXAMPLE, sLabel ); + m_aActionTbR->SetHelpId(SID_STYLE_UPDATE_BY_EXAMPLE, HID_TEMPLDLG_UPDATEBYEXAMPLE); + } + } + catch (const uno::Exception&) + { + } + pDlgWindow->FreeResource(); Initialize(); } @@ -2443,24 +2494,6 @@ IMPL_LINK_TYPED( SfxTemplateDialog_Impl, ToolBoxLSelect, ToolBox *, pBox, void ) FamilySelect(nEntry); } -static OUString lcl_GetLabel(uno::Any& rAny) -{ - OUString sRet; - uno::Sequence< beans::PropertyValue >aPropSeq; - if ( rAny >>= aPropSeq ) - { - for( sal_Int32 i = 0; i < aPropSeq.getLength(); i++ ) - { - if ( aPropSeq[i].Name == "Label" ) - { - aPropSeq[i].Value >>= sRet; - break; - } - } - } - return sRet; -} - IMPL_LINK_TYPED( SfxTemplateDialog_Impl, ToolBoxRSelect, ToolBox *, pBox, void ) { const sal_uInt16 nEntry = pBox->GetCurItemId(); @@ -2513,7 +2546,7 @@ IMPL_LINK_TYPED( SfxTemplateDialog_Impl, ToolBoxRClick, ToolBox *, pBox, void ) PopupMenuFlags::ExecuteDown ); pBox->EndSelection(); } - catch(uno::Exception&) + catch (const uno::Exception&) { } pBox->Invalidate(); diff --git a/sfx2/source/dialog/templdlg.hrc b/sfx2/source/dialog/templdlg.hrc deleted file mode 100644 index 3c128df11677..000000000000 --- a/sfx2/source/dialog/templdlg.hrc +++ /dev/null @@ -1,21 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * 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 . - */ -#define TB_ACTION 15 - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sfx2/source/dialog/templdlg.src b/sfx2/source/dialog/templdlg.src index fd9c11d2b1e6..2fddb59d5212 100644 --- a/sfx2/source/dialog/templdlg.src +++ b/sfx2/source/dialog/templdlg.src @@ -19,7 +19,6 @@ #include #include "dialog.hrc" -#include "templdlg.hrc" #include "helpid.hrc" ImageList DLG_STYLE_DESIGNER @@ -49,8 +48,6 @@ String STR_STYLE_FILTER_HIERARCHICAL // DLG_STYLE_DESIGNER ---------------------------------------------------- DockingWindow DLG_STYLE_DESIGNER { - Text [ en-US ] = "Styles and Formatting" ; - HelpId = CMD_SID_STYLE_DESIGNER ; OutputSize = TRUE ; Hide = TRUE ; @@ -64,35 +61,6 @@ DockingWindow DLG_STYLE_DESIGNER EnableResizing = TRUE ; Border = TRUE ; Moveable = TRUE ; - ToolBox TB_ACTION - { - Pos = MAP_APPFONT ( 3 , 3 ) ; - Size = MAP_APPFONT ( 57 , 42 ) ; - LineCount = 1 ; - ItemImageList = DLG_STYLE_DESIGNER ; - HelpId = HID_TEMPLDLG_TOOLBOX_RIGHT ; - ItemList = - { - ToolBoxItem - { - HelpId = HID_TEMPLDLG_WATERCAN ; - Identifier = SID_STYLE_WATERCAN ; - Text [ en-US ] = "Fill Format Mode" ; - }; - ToolBoxItem - { - HelpId = HID_TEMPLDLG_NEWBYEXAMPLE ; - Identifier = SID_STYLE_NEW_BY_EXAMPLE ; - Text [ en-US ] = "New Style from Selection" ; - }; - ToolBoxItem - { - HelpId = HID_TEMPLDLG_UPDATEBYEXAMPLE ; - Identifier = SID_STYLE_UPDATE_BY_EXAMPLE ; - Text [ en-US ] = "Update Style" ; - }; - }; - }; }; /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ -- cgit