/* -*- 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 .
*/
ProgressMonitor::ProgressMonitor( const css::uno::Reference< XComponentContext >& rxContext )
: ProgressMonitor_BASE(rxContext)
{ // It's not allowed to work with member in this method (refcounter !!!) // But with a HACK (++refcount) its "OK" :-(
osl_atomic_increment(&m_refCount);
// Create instances for fixedtext, button and progress ...
// Safe impossible cases // Check valid call of this method.
DBG_ASSERT ( impl_debug_checkParameter ( rTopic, rText ), "ProgressMonitor::addText()\nCall without valid parameters!\n");
DBG_ASSERT ( !(impl_searchTopic ( rTopic, bbeforeProgress ) != nullptr ), "ProgressMonitor::addText()\nThe text already exist.\n" );
// Do nothing (in Release), if topic already exist. if ( impl_searchTopic ( rTopic, bbeforeProgress ) != nullptr )
{ return;
}
// Else ... take memory for new item ...
IMPL_TextlistItem aTextItem;
// Set values ...
aTextItem.sTopic = rTopic;
aTextItem.sText = rText;
// ... and insert it in right list. if ( bbeforeProgress )
{
maTextlist_Top.push_back( aTextItem );
} else
{
maTextlist_Bottom.push_back( aTextItem );
}
// If user forget to call "setPosSize()", we have still a correct size. // And a "MinimumSize" IS A "MinimumSize"! // We change not the position of control at this point.
Size aDefaultSize = getMinimumSize ();
setPosSize ( 0, 0, aDefaultSize.Width, aDefaultSize.Height, PosSize::SIZE );
}
}
// XControl
sal_Bool SAL_CALL ProgressMonitor::setModel ( const css::uno::Reference< XControlModel > & /*rModel*/ )
{ // We have no model. returnfalse;
}
// XControl
css::uno::Reference< XControlModel > SAL_CALL ProgressMonitor::getModel ()
{ // We have no model. // return (XControlModel*)this; return css::uno::Reference< XControlModel > ();
}
// don't use "...->clear ()" or "... = XFixedText ()" // when other hold a reference at this object !!!
xRef_Topic_Top->dispose ();
xRef_Text_Top->dispose ();
xRef_Topic_Bottom->dispose ();
xRef_Text_Bottom->dispose ();
xRef_Button->dispose ();
m_xProgressBar->dispose();
// if position or size changed if (
( nWidth != aBasePosSize.Width ) ||
( nHeight != aBasePosSize.Height)
)
{ // calc new layout for controls
impl_recalcLayout (); // clear background (!) // [Children were repainted in "recalcLayout" by setPosSize() automatically!]
getPeer()->invalidate(2); // and repaint the control
impl_paint ( 0, 0, impl_getGraphicsPeer() );
}
}
// calc position and size of child controls // Button has preferred size!
nWidth_Button = aButtonSize.Width;
nHeight_Button = aButtonSize.Height;
// Left column before progressbar has preferred size and fixed position. // But "Width" is oriented on left column below progressbar to!!! "max(...)"
nX_Topic_Top = PROGRESSMONITOR_FREEBORDER;
nY_Topic_Top = PROGRESSMONITOR_FREEBORDER;
nWidth_Topic_Top = std::max( aTopicSize_Top.Width, aTopicSize_Bottom.Width );
nHeight_Topic_Top = aTopicSize_Top.Height;
// Right column before progressbar has relative position to left column ... // ... and a size as rest of dialog size!
nX_Text_Top = nX_Topic_Top+nWidth_Topic_Top+PROGRESSMONITOR_FREEBORDER;
nY_Text_Top = nY_Topic_Top;
nWidth_Text_Top = std::max ( aTextSize_Top.Width, aTextSize_Bottom.Width ); // Fix size of this column to minimum!
sal_Int32 nSummaryWidth = nWidth_Text_Top+nWidth_Topic_Top+(3*PROGRESSMONITOR_FREEBORDER); if ( nSummaryWidth < PROGRESSMONITOR_DEFAULT_WIDTH )
nWidth_Text_Top = PROGRESSMONITOR_DEFAULT_WIDTH-nWidth_Topic_Top-(3*PROGRESSMONITOR_FREEBORDER); // Fix size of column to maximum! if ( nSummaryWidth > impl_getWidth() )
nWidth_Text_Top = impl_getWidth()-nWidth_Topic_Top-(3*PROGRESSMONITOR_FREEBORDER);
nHeight_Text_Top = nHeight_Topic_Top;
// Position of progressbar is relative to columns before. // Progressbar.Width = Dialog.Width !!! // Progressbar.Height = Button.Height
nX_ProgressBar = nX_Topic_Top;
nY_ProgressBar = nY_Topic_Top+nHeight_Topic_Top+PROGRESSMONITOR_FREEBORDER;
nWidth_ProgressBar = PROGRESSMONITOR_FREEBORDER+nWidth_Topic_Top+nWidth_Text_Top;
nHeight_ProgressBar = nHeight_Button;
// Oriented by left column before progressbar.
nX_Topic_Bottom = nX_Topic_Top;
nY_Topic_Bottom = nY_ProgressBar+nHeight_ProgressBar+PROGRESSMONITOR_FREEBORDER;
nWidth_Topic_Bottom = nWidth_Topic_Top;
nHeight_Topic_Bottom = aTopicSize_Bottom.Height;
// Oriented by right column before progressbar.
nX_Text_Bottom = nX_Topic_Bottom+nWidth_Topic_Bottom+PROGRESSMONITOR_FREEBORDER;
nY_Text_Bottom = nY_Topic_Bottom;
nWidth_Text_Bottom = nWidth_Text_Top;
nHeight_Text_Bottom = nHeight_Topic_Bottom;
// Oriented by progressbar.
nX_Button = nX_ProgressBar+nWidth_ProgressBar-nWidth_Button;
nY_Button = nY_Topic_Bottom+nHeight_Topic_Bottom+PROGRESSMONITOR_FREEBORDER;
// Calc offsets to center controls
sal_Int32 nDx;
sal_Int32 nDy;
// All childcontrols make an implicit repaint in setPosSize()! // Make it also for this 3D-line ...
css::uno::Reference< XGraphics > xGraphics = impl_getGraphicsPeer ();
// Rebuild left site of text if (m_xTopic_Top.is())
{
OUStringBuffer aCollectString;
// Collect all topics from list and format text. // "\n" MUST BE at the end of line!!! => Else ... topic and his text are not in the same line!!! for (autoconst & rSearchItem : maTextlist_Top)
{
aCollectString.append(rSearchItem.sTopic + "\n");
}
// Rebuild right site of text if (m_xText_Top.is())
{
OUStringBuffer aCollectString;
// Collect all topics from list and format text. // "\n" MUST BE at the end of line!!! => Else ... topic and his text are not in the same line!!! for (autoconst & rSearchItem : maTextlist_Top)
{
aCollectString.append(rSearchItem.sText + "\n");
}
// Rebuild left site of text if (m_xTopic_Bottom.is())
{
OUStringBuffer aCollectString;
// Collect all topics from list and format text. // "\n" MUST BE at the end of line!!! => Else ... topic and his text are not in the same line!!! for (autoconst & rSearchItem : maTextlist_Bottom)
{
aCollectString.append(rSearchItem.sTopic + "\n");
}
// Rebuild right site of text if (!m_xText_Bottom.is()) return;
OUStringBuffer aCollectString;
// Collect all topics from list and format text. // "\n" MUST BE at the end of line!!! => Else ... topic and his text are not in the same line!!! for (autoconst & rSearchItem : maTextlist_Bottom)
{
aCollectString.append(rSearchItem.sText + "\n");
}
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.