/* -*- 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 .
*/
if ( rEvent.FeatureURL.Complete == m_aCommandURL )
{ if (m_pToolbar)
m_pToolbar->set_item_sensitive(m_aCommandURL, rEvent.IsEnabled); else
pToolBox->EnableItem( nId, rEvent.IsEnabled );
}
m_xBtnUpdater->Update(rEvent);
SfxObjectShell* pSh = SfxObjectShell::Current(); if (!pSh) return;
const SvxDashListItem* pItem = pSh->GetItem( SID_DASH_LIST ); if (!pItem) return;
XDashListRef xList = pItem->GetDashList(); int nIndex = m_xBtnUpdater->GetStyleIndex(); bool bNoneLineStyle = false; switch (nIndex)
{ case -1: case 0:
{
BitmapEx aEmpty(xList->GetBitmapForUISolidLine());
aEmpty.Erase(Application::GetSettings().GetStyleSettings().GetFieldColor()); if (m_pToolbar)
{
Graphic aGraf(aEmpty);
m_pToolbar->set_item_image(m_aCommandURL, aGraf.GetXGraphic());
} else
pToolBox->SetItemImage(nId, Image(aEmpty));
bNoneLineStyle = true; break;
} case 1: if (m_pToolbar)
{
Graphic aGraf(xList->GetBitmapForUISolidLine());
m_pToolbar->set_item_image(m_aCommandURL, aGraf.GetXGraphic());
} else
pToolBox->SetItemImage(nId, Image(xList->GetBitmapForUISolidLine())); break; default: if (m_pToolbar)
{
Graphic aGraf(xList->GetUiBitmap(nIndex - 2));
m_pToolbar->set_item_image(m_aCommandURL, aGraf.GetXGraphic());
} else
pToolBox->SetItemImage(nId, Image(xList->GetUiBitmap(nIndex - 2))); break;
} if (m_aLineStyleIsNoneFunction)
m_aLineStyleIsNoneFunction(bNoneLineStyle);
}
void SAL_CALL SvxLineStyleToolBoxControl::execute(sal_Int16 /*KeyModifier*/)
{ if (m_pToolbar)
{ // Toggle the popup also when toolbutton is activated
m_pToolbar->set_menu_item_active(m_aCommandURL, !m_pToolbar->get_menu_item_active(m_aCommandURL));
} else
{ // Open the popup also when Enter key is pressed.
createPopupWindow();
}
}
class SvxLineEndToolBoxControl final : public svt::PopupWindowController
{ public: explicit SvxLineEndToolBoxControl( const css::uno::Reference<css::uno::XComponentContext>& rContext );
if( nId == 1 )
{
pLineStartItem.reset(new XLineStartItem());
} elseif( nId == 2 )
{
pLineEndItem.reset(new XLineEndItem());
} elseif( nId % 2 ) // beginning of line
{ const XLineEndEntry* pEntry = mpLineEndList->GetLineEnd( (nId - 1) / 2 - 1 );
pLineStartItem.reset(new XLineStartItem(pEntry->GetName(), pEntry->GetLineEnd()));
} else// end of line
{ const XLineEndEntry* pEntry = mpLineEndList->GetLineEnd( nId / 2 - 2 );
pLineEndItem.reset(new XLineEndItem(pEntry->GetName(), pEntry->GetLineEnd()));
}
OUString name;
Any a;
if ( pLineStartItem )
{
name = "LineStart";
pLineStartItem->QueryValue( a );
} else
{
name = "LineEnd";
pLineEndItem->QueryValue( a );
}
Sequence< PropertyValue > aArgs{ comphelper::makePropertyValue(name, a) };
/* #i33380# DR 2004-09-03 Moved the following line above the Dispatch() call. This instance may be deleted in the meantime (i.e. when a dialog is opened
while in Dispatch()), accessing members will crash in this case. */
mxLineEndSet->SetNoSelection();
// First entry: no line end. // An entry is temporarily added to get the UI bitmap
basegfx::B2DPolyPolygon aNothing;
mpLineEndList->Insert(std::make_unique<XLineEndEntry>(aNothing,
comphelper::LibreOfficeKit::isActive() ? SvxResId(RID_SVXSTR_INVISIBLE)
: SvxResId(RID_SVXSTR_NONE))); const XLineEndEntry* pEntry = mpLineEndList->GetLineEnd(nCount);
BitmapEx aBmp = mpLineEndList->GetUiBitmap( nCount );
OSL_ENSURE( !aBmp.IsEmpty(), "UI bitmap was not created" );
for( tools::Long i = 0; i < nCount; i++ )
{
pEntry = mpLineEndList->GetLineEnd( i );
assert(pEntry && "Could not access LineEndEntry");
aBmp = mpLineEndList->GetUiBitmap( i );
OSL_ENSURE( !aBmp.IsEmpty(), "UI bitmap was not created" );
// The list of line ends (LineEndList) has changed
css::uno::Reference< css::uno::XWeak > xWeak; if ( rEvent.State >>= xWeak )
{
mpLineEndList.set( static_cast< XLineEndList* >( xWeak.get() ) );
DBG_ASSERT( mpLineEndList.is(), "LineEndList not found" );
void SAL_CALL SvxLineEndToolBoxControl::execute(sal_Int16 /*KeyModifier*/)
{ if (m_pToolbar)
{ // Toggle the popup also when toolbutton is activated
m_pToolbar->set_menu_item_active(m_aCommandURL, !m_pToolbar->get_menu_item_active(m_aCommandURL));
} else
{ // Open the popup also when Enter key is pressed.
createPopupWindow();
}
}
IMPL_LINK_NOARG(SvxLineBox, SelectHdl, ValueSet*, void)
{
drawing::LineStyle eXLS;
sal_Int32 nPos = mxLineStyleSet->GetSelectedItemId();
--nPos; // ids start at 1, get the pos of the id
default:
{
eXLS = drawing::LineStyle_DASH; const SfxObjectShell* pObjSh = SfxObjectShell::Current(); if (nPos != -1 && pObjSh && pObjSh->GetItem(SID_DASH_LIST))
{ // LineDashItem will only be sent if it also has a dash. // Notify cares!
SvxDashListItem const * pItem = pObjSh->GetItem( SID_DASH_LIST ); const XDashEntry* pEntry = pItem->GetDashList()->GetDash(nPos - 2);
XLineDashItem aLineDashItem(pEntry->GetName(), pEntry->GetDash());
Any a;
aLineDashItem.QueryValue ( a );
Sequence< PropertyValue > aArgs{ comphelper::makePropertyValue(u"LineDash"_ustr, a) };
mxControl->dispatchLineStyleCommand(u".uno:LineDash"_ustr, aArgs);
// set also cap style using the toolbar line style selection popup
css::drawing::DashStyle eStyle = pEntry->GetDash().GetDashStyle();
XLineCapItem aLineCapItem(
eStyle == drawing::DashStyle_RECT || eStyle == drawing::DashStyle_RECTRELATIVE
? css::drawing::LineCap_BUTT
: css::drawing::LineCap_ROUND );
aLineCapItem.QueryValue ( a );
Sequence< PropertyValue > aArgs2{ comphelper::makePropertyValue(u"LineCap"_ustr, a) };
mxControl->dispatchLineStyleCommand(u".uno:LineCap"_ustr, aArgs2);
}
} break;
}
XLineStyleItem aLineStyleItem( eXLS );
Any a;
aLineStyleItem.QueryValue ( a );
Sequence< PropertyValue > aArgs{ comphelper::makePropertyValue(u"XLineStyle"_ustr, a) };
mxControl->dispatchLineStyleCommand(u".uno:XLineStyle"_ustr, aArgs);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.