weld SwFramePage
Change-Id: I12f868611860867df26bd29474aa19189c2b9a96 Reviewed-on: https://gerrit.libreoffice.org/63818 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
This commit is contained in:
@@ -250,9 +250,6 @@
|
||||
<glade-widget-class title="NUP Preview" name="vcllo-ShowNupOrderWindow"
|
||||
generic-name="NUP Preview" parent="GtkDrawingArea"
|
||||
icon-name="widget-gtk-drawingarea"/>
|
||||
<glade-widget-class title="Frame Preview" name="svxlo-SvxSwFrameExample"
|
||||
generic-name="Frame Preview" parent="GtkDrawingArea"
|
||||
icon-name="widget-gtk-drawingarea"/>
|
||||
<glade-widget-class title="Presentation Preview" name="sduilo-PresLayoutPreview"
|
||||
generic-name="Presentation Preview" parent="GtkDrawingArea"
|
||||
icon-name="widget-gtk-drawingarea"/>
|
||||
|
@@ -27,7 +27,7 @@
|
||||
#include <vcl/window.hxx>
|
||||
#include <com/sun/star/text/WrapTextMode.hpp>
|
||||
|
||||
class SVX_DLLPUBLIC SvxSwFrameExample : public vcl::Window
|
||||
class SVX_DLLPUBLIC SwFrameExample : public weld::CustomWidgetController
|
||||
{
|
||||
Color m_aTransColor; ///< transparency
|
||||
Color m_aBgCol; ///< background
|
||||
@@ -63,16 +63,16 @@ class SVX_DLLPUBLIC SvxSwFrameExample : public vcl::Window
|
||||
|
||||
void InitColors_Impl();
|
||||
void InitAllRects_Impl(vcl::RenderContext& rRenderContext);
|
||||
void CalcBoundRect_Impl(tools::Rectangle &rRect);
|
||||
void CalcBoundRect_Impl(vcl::RenderContext& rRenderContext, tools::Rectangle &rRect);
|
||||
tools::Rectangle DrawInnerFrame_Impl(vcl::RenderContext& rRenderContext, const tools::Rectangle &rRect, const Color &rFillColor, const Color &rBorderColor);
|
||||
|
||||
virtual void StyleUpdated() override;
|
||||
virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle&) override;
|
||||
virtual Size GetOptimalSize() const override;
|
||||
protected:
|
||||
virtual void DataChanged( const DataChangedEvent& rDCEvt ) override;
|
||||
public:
|
||||
|
||||
SvxSwFrameExample(vcl::Window* pParent, WinBits nStyle);
|
||||
SwFrameExample();
|
||||
|
||||
virtual void SetDrawingArea(weld::DrawingArea* pDrawingArea) override;
|
||||
|
||||
void SetWrap(css::text::WrapTextMode nW) { nWrap = nW; }
|
||||
|
||||
@@ -88,62 +88,6 @@ public:
|
||||
void SetRelPos(const Point& rP);
|
||||
};
|
||||
|
||||
class SVX_DLLPUBLIC SwFrameExample : public weld::CustomWidgetController
|
||||
{
|
||||
Color m_aTransColor; ///< transparency
|
||||
Color m_aBgCol; ///< background
|
||||
Color m_aFrameColor; ///< graphic frame
|
||||
Color m_aAlignColor; ///< align anchor
|
||||
Color m_aBorderCol; ///< frame of doc
|
||||
Color m_aPrintAreaCol; ///< frame of printable area of doc
|
||||
Color m_aTxtCol; ///< symbolised text
|
||||
Color m_aBlankCol; ///< area of symbol for blank
|
||||
Color m_aBlankFrameCol; ///< frame of symbol for blank
|
||||
|
||||
tools::Rectangle aPage;
|
||||
tools::Rectangle aPagePrtArea;
|
||||
tools::Rectangle aTextLine;
|
||||
tools::Rectangle aPara;
|
||||
tools::Rectangle aParaPrtArea;
|
||||
tools::Rectangle aFrameAtFrame;
|
||||
tools::Rectangle aDrawObj;
|
||||
tools::Rectangle aAutoCharFrame;
|
||||
Size aFrmSize;
|
||||
|
||||
short nHAlign;
|
||||
short nHRel;
|
||||
|
||||
short nVAlign;
|
||||
short nVRel;
|
||||
|
||||
RndStdIds nAnchor;
|
||||
|
||||
Point aRelPos;
|
||||
|
||||
void InitColors_Impl();
|
||||
void InitAllRects_Impl(vcl::RenderContext& rRenderContext);
|
||||
void CalcBoundRect_Impl(vcl::RenderContext& rRenderContext, tools::Rectangle &rRect);
|
||||
tools::Rectangle DrawInnerFrame_Impl(vcl::RenderContext& rRenderContext, const tools::Rectangle &rRect, const Color &rFillColor, const Color &rBorderColor);
|
||||
|
||||
virtual void StyleUpdated() override;
|
||||
virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle&) override;
|
||||
public:
|
||||
|
||||
SwFrameExample();
|
||||
|
||||
virtual void SetDrawingArea(weld::DrawingArea* pDrawingArea) override;
|
||||
|
||||
void SetHAlign(short nH) { nHAlign = nH; }
|
||||
void SetHoriRel(short nR) { nHRel = nR; }
|
||||
|
||||
void SetVAlign(short nV) { nVAlign = nV; }
|
||||
void SetVertRel(short nR) { nVRel = nR; }
|
||||
|
||||
void SetAnchor(RndStdIds nA) { nAnchor = nA; }
|
||||
|
||||
void SetRelPos(const Point& rP);
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif // INCLUDED_SVX_SWFRAMEEXAMPLE_HXX
|
||||
|
@@ -509,7 +509,6 @@ custom_widgets = [
|
||||
'SvxNoSpaceEdit',
|
||||
'SvxPathControl',
|
||||
'SvxRelativeField',
|
||||
'SvxSwFrameExample',
|
||||
'SvxTextEncodingBox',
|
||||
'SvxTextEncodingBox',
|
||||
'SwAddressPreview',
|
||||
|
@@ -45,683 +45,14 @@ void DrawRect_Impl(vcl::RenderContext& rRenderContext, const tools::Rectangle &r
|
||||
|
||||
}
|
||||
|
||||
SvxSwFrameExample::SvxSwFrameExample( vcl::Window *pParent, WinBits nStyle ) :
|
||||
|
||||
Window(pParent, nStyle),
|
||||
|
||||
nHAlign (HoriOrientation::CENTER),
|
||||
nHRel (RelOrientation::FRAME),
|
||||
nVAlign (VertOrientation::TOP),
|
||||
nVRel (RelOrientation::PRINT_AREA),
|
||||
nWrap (WrapTextMode_NONE),
|
||||
nAnchor (RndStdIds::FLY_AT_PAGE),
|
||||
bTrans (false),
|
||||
aRelPos (Point(0,0))
|
||||
{
|
||||
InitColors_Impl();
|
||||
}
|
||||
|
||||
VCL_BUILDER_FACTORY_ARGS(SvxSwFrameExample, 0)
|
||||
|
||||
Size SvxSwFrameExample::GetOptimalSize() const
|
||||
{
|
||||
return LogicToPixel(Size(52, 86), MapMode(MapUnit::MapAppFont));
|
||||
}
|
||||
|
||||
void SvxSwFrameExample::InitColors_Impl()
|
||||
{
|
||||
const StyleSettings& rSettings = GetSettings().GetStyleSettings();
|
||||
m_aBgCol = rSettings.GetWindowColor();
|
||||
|
||||
bool bHC = rSettings.GetHighContrastMode();
|
||||
|
||||
m_aFrameColor = COL_LIGHTGREEN;
|
||||
m_aAlignColor = COL_LIGHTRED;
|
||||
m_aTransColor = COL_TRANSPARENT;
|
||||
|
||||
m_aTxtCol = bHC?
|
||||
svtools::ColorConfig().GetColorValue(svtools::FONTCOLOR).nColor :
|
||||
COL_GRAY;
|
||||
m_aPrintAreaCol = bHC? m_aTxtCol : COL_GRAY;
|
||||
m_aBorderCol = m_aTxtCol;
|
||||
m_aBlankCol = bHC? m_aTxtCol : COL_LIGHTGRAY;
|
||||
m_aBlankFrameCol = bHC? m_aTxtCol : COL_GRAY;
|
||||
}
|
||||
|
||||
void SvxSwFrameExample::DataChanged(const DataChangedEvent& rDCEvt)
|
||||
{
|
||||
Window::DataChanged(rDCEvt);
|
||||
|
||||
if (rDCEvt.GetType() == DataChangedEventType::SETTINGS && (rDCEvt.GetFlags() & AllSettingsFlags::STYLE))
|
||||
InitColors_Impl();
|
||||
}
|
||||
|
||||
void SvxSwFrameExample::InitAllRects_Impl(vcl::RenderContext& rRenderContext)
|
||||
{
|
||||
aPage.SetSize(GetOutputSizePixel());
|
||||
|
||||
sal_uInt32 nOutWPix = aPage.GetWidth();
|
||||
sal_uInt32 nOutHPix = aPage.GetHeight();
|
||||
|
||||
// PrintArea
|
||||
sal_uInt32 nLBorder;
|
||||
sal_uInt32 nRBorder;
|
||||
sal_uInt32 nTBorder;
|
||||
sal_uInt32 nBBorder;
|
||||
|
||||
sal_uInt32 nLTxtBorder;
|
||||
sal_uInt32 nRTxtBorder;
|
||||
sal_uInt32 nTTxtBorder;
|
||||
sal_uInt32 nBTxtBorder;
|
||||
|
||||
if (nAnchor != RndStdIds::FLY_AS_CHAR)
|
||||
{
|
||||
nLBorder = 14;
|
||||
nRBorder = 10;
|
||||
nTBorder = 10;
|
||||
nBBorder = 15;
|
||||
|
||||
nLTxtBorder = 8;
|
||||
nRTxtBorder = 4;
|
||||
nTTxtBorder = 2;
|
||||
nBTxtBorder = 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
nLBorder = 2;
|
||||
nRBorder = 2;
|
||||
nTBorder = 2;
|
||||
nBBorder = 2;
|
||||
|
||||
nLTxtBorder = 2;
|
||||
nRTxtBorder = 2;
|
||||
nTTxtBorder = 2;
|
||||
nBTxtBorder = 2;
|
||||
}
|
||||
aPagePrtArea = tools::Rectangle(Point(nLBorder, nTBorder), Point((nOutWPix - 1) - nRBorder, (nOutHPix - 1) - nBBorder));
|
||||
|
||||
// Example text: Preparing for the text output
|
||||
// A line of text
|
||||
aTextLine = aPagePrtArea;
|
||||
aTextLine.SetSize(Size(aTextLine.GetWidth(), 2));
|
||||
aTextLine.AdjustLeft(nLTxtBorder );
|
||||
aTextLine.AdjustRight( -sal_Int32(nRTxtBorder) );
|
||||
aTextLine.Move(0, nTTxtBorder);
|
||||
|
||||
// Rectangle to edges including paragraph
|
||||
sal_uInt16 nLines = static_cast<sal_uInt16>((aPagePrtArea.GetHeight() / 2 - nTTxtBorder - nBTxtBorder)
|
||||
/ (aTextLine.GetHeight() + 2));
|
||||
aPara = aPagePrtArea;
|
||||
aPara.SetSize(Size(aPara.GetWidth(),
|
||||
(aTextLine.GetHeight() + 2) * nLines + nTTxtBorder + nBTxtBorder));
|
||||
|
||||
// Rectangle around paragraph without borders
|
||||
aParaPrtArea = aPara;
|
||||
aParaPrtArea.AdjustLeft(nLTxtBorder );
|
||||
aParaPrtArea.AdjustRight( -sal_Int32(nRTxtBorder) );
|
||||
aParaPrtArea.AdjustTop(nTTxtBorder );
|
||||
aParaPrtArea.AdjustBottom( -sal_Int32(nBTxtBorder) );
|
||||
|
||||
if (nAnchor == RndStdIds::FLY_AS_CHAR || nAnchor == RndStdIds::FLY_AT_CHAR)
|
||||
{
|
||||
vcl::Font aFont = OutputDevice::GetDefaultFont(
|
||||
DefaultFontType::LATIN_TEXT, Application::GetSettings().GetLanguageTag().getLanguageType(),
|
||||
GetDefaultFontFlags::OnlyOne, this );
|
||||
aFont.SetColor( m_aTxtCol );
|
||||
aFont.SetFillColor( m_aBgCol );
|
||||
aFont.SetWeight(WEIGHT_NORMAL);
|
||||
|
||||
if (nAnchor == RndStdIds::FLY_AS_CHAR)
|
||||
{
|
||||
aFont.SetFontSize(Size(0, aParaPrtArea.GetHeight() - 2));
|
||||
SetFont(aFont);
|
||||
aParaPrtArea.SetSize(Size(GetTextWidth(DEMOTEXT), GetTextHeight()));
|
||||
}
|
||||
else
|
||||
{
|
||||
aFont.SetFontSize(Size(0, aParaPrtArea.GetHeight() / 2));
|
||||
rRenderContext.SetFont(aFont);
|
||||
aAutoCharFrame.SetSize(Size(GetTextWidth(OUString('A')), GetTextHeight()));
|
||||
aAutoCharFrame.SetPos(Point(aParaPrtArea.Left() + (aParaPrtArea.GetWidth() - aAutoCharFrame.GetWidth()) / 2,
|
||||
aParaPrtArea.Top() + (aParaPrtArea.GetHeight() - aAutoCharFrame.GetHeight()) / 2));
|
||||
}
|
||||
}
|
||||
|
||||
// Inner Frame anchored at the Frame
|
||||
aFrameAtFrame = aPara;
|
||||
aFrameAtFrame.AdjustLeft(9 );
|
||||
aFrameAtFrame.AdjustRight( -5 );
|
||||
aFrameAtFrame.AdjustBottom(5 );
|
||||
aFrameAtFrame.SetPos(Point(aFrameAtFrame.Left() + 2, (aPagePrtArea.Bottom() - aFrameAtFrame.GetHeight()) / 2 + 5));
|
||||
|
||||
// Size of the frame to be positioned
|
||||
if (nAnchor != RndStdIds::FLY_AS_CHAR)
|
||||
{
|
||||
sal_uInt32 nLFBorder = nAnchor == RndStdIds::FLY_AT_PAGE ? nLBorder : nLTxtBorder;
|
||||
sal_uInt32 nRFBorder = nAnchor == RndStdIds::FLY_AT_PAGE ? nRBorder : nRTxtBorder;
|
||||
|
||||
switch (nHRel)
|
||||
{
|
||||
case RelOrientation::PAGE_LEFT:
|
||||
case RelOrientation::FRAME_LEFT:
|
||||
aFrmSize = Size(nLFBorder - 4, (aTextLine.GetHeight() + 2) * 3);
|
||||
break;
|
||||
|
||||
case RelOrientation::PAGE_RIGHT:
|
||||
case RelOrientation::FRAME_RIGHT:
|
||||
aFrmSize = Size(nRFBorder - 4, (aTextLine.GetHeight() + 2) * 3);
|
||||
break;
|
||||
|
||||
default:
|
||||
aFrmSize = Size(nLBorder - 3, (aTextLine.GetHeight() + 2) * 3);
|
||||
break;
|
||||
}
|
||||
aFrmSize.setWidth( std::max(5L, aFrmSize.Width()) );
|
||||
aFrmSize.setHeight( std::max(5L, aFrmSize.Height()) );
|
||||
}
|
||||
else
|
||||
{
|
||||
sal_uInt32 nFreeWidth = aPagePrtArea.GetWidth() - GetTextWidth(DEMOTEXT);
|
||||
|
||||
aFrmSize = Size(nFreeWidth / 2, (aTextLine.GetHeight() + 2) * 3);
|
||||
aDrawObj.SetSize(Size(std::max(5L, static_cast<long>(nFreeWidth) / 3L), std::max(5L, aFrmSize.Height() * 3L)));
|
||||
aDrawObj.SetPos(Point(aParaPrtArea.Right() + 1, aParaPrtArea.Bottom() / 2));
|
||||
aParaPrtArea.SetRight( aDrawObj.Right() );
|
||||
}
|
||||
}
|
||||
|
||||
void SvxSwFrameExample::CalcBoundRect_Impl(tools::Rectangle &rRect)
|
||||
{
|
||||
switch (nAnchor)
|
||||
{
|
||||
case RndStdIds::FLY_AT_PAGE:
|
||||
{
|
||||
switch (nHRel)
|
||||
{
|
||||
case RelOrientation::FRAME:
|
||||
case RelOrientation::PAGE_FRAME:
|
||||
rRect.SetLeft( aPage.Left() );
|
||||
rRect.SetRight( aPage.Right() );
|
||||
break;
|
||||
|
||||
case RelOrientation::PRINT_AREA:
|
||||
case RelOrientation::PAGE_PRINT_AREA:
|
||||
rRect.SetLeft( aPagePrtArea.Left() );
|
||||
rRect.SetRight( aPagePrtArea.Right() );
|
||||
break;
|
||||
|
||||
case RelOrientation::PAGE_LEFT:
|
||||
rRect.SetLeft( aPage.Left() );
|
||||
rRect.SetRight( aPagePrtArea.Left() );
|
||||
break;
|
||||
|
||||
case RelOrientation::PAGE_RIGHT:
|
||||
rRect.SetLeft( aPagePrtArea.Right() );
|
||||
rRect.SetRight( aPage.Right() );
|
||||
break;
|
||||
}
|
||||
|
||||
switch (nVRel)
|
||||
{
|
||||
case RelOrientation::PRINT_AREA:
|
||||
case RelOrientation::PAGE_PRINT_AREA:
|
||||
rRect.SetTop( aPagePrtArea.Top() );
|
||||
rRect.SetBottom( aPagePrtArea.Bottom() );
|
||||
break;
|
||||
|
||||
case RelOrientation::FRAME:
|
||||
case RelOrientation::PAGE_FRAME:
|
||||
rRect.SetTop( aPage.Top() );
|
||||
rRect.SetBottom( aPage.Bottom() );
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case RndStdIds::FLY_AT_FLY:
|
||||
{
|
||||
switch (nHRel)
|
||||
{
|
||||
case RelOrientation::FRAME:
|
||||
case RelOrientation::PAGE_FRAME:
|
||||
rRect.SetLeft( aFrameAtFrame.Left() );
|
||||
rRect.SetRight( aFrameAtFrame.Right() );
|
||||
break;
|
||||
|
||||
case RelOrientation::PRINT_AREA:
|
||||
case RelOrientation::PAGE_PRINT_AREA:
|
||||
rRect.SetLeft( aFrameAtFrame.Left() + FLYINFLY_BORDER );
|
||||
rRect.SetRight( aFrameAtFrame.Right() - FLYINFLY_BORDER );
|
||||
break;
|
||||
|
||||
case RelOrientation::PAGE_RIGHT:
|
||||
rRect.SetLeft( aFrameAtFrame.Left() );
|
||||
rRect.SetRight( aFrameAtFrame.Left() + FLYINFLY_BORDER );
|
||||
break;
|
||||
|
||||
case RelOrientation::PAGE_LEFT:
|
||||
rRect.SetLeft( aFrameAtFrame.Right() );
|
||||
rRect.SetRight( aFrameAtFrame.Right() - FLYINFLY_BORDER );
|
||||
break;
|
||||
}
|
||||
|
||||
switch (nVRel)
|
||||
{
|
||||
case RelOrientation::FRAME:
|
||||
case RelOrientation::PAGE_FRAME:
|
||||
rRect.SetTop( aFrameAtFrame.Top() );
|
||||
rRect.SetBottom( aFrameAtFrame.Bottom() );
|
||||
break;
|
||||
|
||||
case RelOrientation::PRINT_AREA:
|
||||
case RelOrientation::PAGE_PRINT_AREA:
|
||||
rRect.SetTop( aFrameAtFrame.Top() + FLYINFLY_BORDER );
|
||||
rRect.SetBottom( aFrameAtFrame.Bottom() - FLYINFLY_BORDER );
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case RndStdIds::FLY_AT_PARA:
|
||||
case RndStdIds::FLY_AT_CHAR:
|
||||
{
|
||||
switch (nHRel)
|
||||
{
|
||||
case RelOrientation::FRAME:
|
||||
rRect.SetLeft( aPara.Left() );
|
||||
rRect.SetRight( aPara.Right() );
|
||||
break;
|
||||
|
||||
case RelOrientation::PRINT_AREA:
|
||||
rRect.SetLeft( aParaPrtArea.Left() );
|
||||
rRect.SetRight( aParaPrtArea.Right() );
|
||||
break;
|
||||
|
||||
case RelOrientation::PAGE_LEFT:
|
||||
rRect.SetLeft( aPage.Left() );
|
||||
rRect.SetRight( aPagePrtArea.Left() );
|
||||
break;
|
||||
|
||||
case RelOrientation::PAGE_RIGHT:
|
||||
rRect.SetLeft( aPagePrtArea.Right() );
|
||||
rRect.SetRight( aPage.Right() );
|
||||
break;
|
||||
|
||||
case RelOrientation::PAGE_FRAME:
|
||||
rRect.SetLeft( aPage.Left() );
|
||||
rRect.SetRight( aPage.Right() );
|
||||
break;
|
||||
|
||||
case RelOrientation::PAGE_PRINT_AREA:
|
||||
rRect.SetLeft( aPagePrtArea.Left() );
|
||||
rRect.SetRight( aPagePrtArea.Right() );
|
||||
break;
|
||||
|
||||
case RelOrientation::FRAME_LEFT:
|
||||
rRect.SetLeft( aPara.Left() );
|
||||
rRect.SetRight( aParaPrtArea.Left() );
|
||||
break;
|
||||
|
||||
case RelOrientation::FRAME_RIGHT:
|
||||
rRect.SetLeft( aParaPrtArea.Right() );
|
||||
rRect.SetRight( aPara.Right() );
|
||||
break;
|
||||
|
||||
case RelOrientation::CHAR:
|
||||
rRect.SetLeft( aAutoCharFrame.Left() );
|
||||
rRect.SetRight( aAutoCharFrame.Left() );
|
||||
break;
|
||||
}
|
||||
|
||||
switch (nVRel)
|
||||
{
|
||||
case RelOrientation::FRAME:
|
||||
rRect.SetTop( aPara.Top() );
|
||||
rRect.SetBottom( aPara.Bottom() );
|
||||
break;
|
||||
|
||||
case RelOrientation::PRINT_AREA:
|
||||
rRect.SetTop( aParaPrtArea.Top() );
|
||||
rRect.SetBottom( aParaPrtArea.Bottom() );
|
||||
break;
|
||||
|
||||
case RelOrientation::CHAR:
|
||||
if (nVAlign != VertOrientation::NONE &&
|
||||
nVAlign != VertOrientation::CHAR_BOTTOM)
|
||||
rRect.SetTop( aAutoCharFrame.Top() );
|
||||
else
|
||||
rRect.SetTop( aAutoCharFrame.Bottom() );
|
||||
rRect.SetBottom( aAutoCharFrame.Bottom() );
|
||||
break;
|
||||
// OD 12.11.2003 #i22341#
|
||||
case RelOrientation::TEXT_LINE:
|
||||
rRect.SetTop( aAutoCharFrame.Top() );
|
||||
rRect.SetBottom( aAutoCharFrame.Top() );
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case RndStdIds::FLY_AS_CHAR:
|
||||
rRect.SetLeft( aParaPrtArea.Left() );
|
||||
rRect.SetRight( aParaPrtArea.Right() );
|
||||
|
||||
switch (nVAlign)
|
||||
{
|
||||
case VertOrientation::NONE:
|
||||
case VertOrientation::TOP:
|
||||
case VertOrientation::CENTER:
|
||||
case VertOrientation::BOTTOM:
|
||||
{
|
||||
FontMetric aMetric(GetFontMetric());
|
||||
|
||||
rRect.SetTop( aParaPrtArea.Bottom() - aMetric.GetDescent() );
|
||||
rRect.SetBottom( rRect.Top() );
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
case VertOrientation::LINE_TOP:
|
||||
case VertOrientation::LINE_CENTER:
|
||||
case VertOrientation::LINE_BOTTOM:
|
||||
rRect.SetTop( aParaPrtArea.Top() );
|
||||
rRect.SetBottom( aDrawObj.Bottom() );
|
||||
break;
|
||||
|
||||
case VertOrientation::CHAR_TOP:
|
||||
case VertOrientation::CHAR_CENTER:
|
||||
case VertOrientation::CHAR_BOTTOM:
|
||||
rRect.SetTop( aParaPrtArea.Top() );
|
||||
rRect.SetBottom( aParaPrtArea.Bottom() );
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
tools::Rectangle SvxSwFrameExample::DrawInnerFrame_Impl(vcl::RenderContext& rRenderContext, const tools::Rectangle &rRect,
|
||||
const Color &rFillColor, const Color &rBorderColor)
|
||||
{
|
||||
DrawRect_Impl(rRenderContext, rRect, rFillColor, rBorderColor);
|
||||
|
||||
// determine the area relative to which the positioning happens
|
||||
tools::Rectangle aRect(rRect); // aPagePrtArea = Default
|
||||
CalcBoundRect_Impl(aRect);
|
||||
|
||||
if (nAnchor == RndStdIds::FLY_AT_FLY && &rRect == &aPagePrtArea)
|
||||
{
|
||||
// draw text paragraph
|
||||
tools::Rectangle aTxt(aTextLine);
|
||||
sal_Int32 nStep = aTxt.GetHeight() + 2;
|
||||
sal_uInt16 nLines = static_cast<sal_uInt16>(aParaPrtArea.GetHeight() / (aTextLine.GetHeight() + 2));
|
||||
|
||||
for (sal_uInt16 i = 0; i < nLines; i++)
|
||||
{
|
||||
if (i == nLines - 1)
|
||||
aTxt.SetSize(Size(aTxt.GetWidth() / 2, aTxt.GetHeight()));
|
||||
DrawRect_Impl(rRenderContext, aTxt, m_aTxtCol, m_aTransColor);
|
||||
aTxt.Move(0, nStep);
|
||||
}
|
||||
}
|
||||
|
||||
return aRect;
|
||||
}
|
||||
|
||||
void SvxSwFrameExample::Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle&)
|
||||
{
|
||||
rRenderContext.SetMapMode(MapMode(MapUnit::MapPixel));
|
||||
|
||||
InitAllRects_Impl(rRenderContext);
|
||||
|
||||
// Draw page
|
||||
DrawRect_Impl(rRenderContext, aPage, m_aBgCol, m_aBorderCol);
|
||||
|
||||
// Draw PrintArea
|
||||
tools::Rectangle aRect = DrawInnerFrame_Impl(rRenderContext, aPagePrtArea, m_aTransColor, m_aPrintAreaCol);
|
||||
|
||||
if (nAnchor == RndStdIds::FLY_AT_FLY)
|
||||
aRect = DrawInnerFrame_Impl(rRenderContext, aFrameAtFrame, m_aBgCol, m_aBorderCol);
|
||||
|
||||
long lXPos = 0;
|
||||
long lYPos = 0;
|
||||
|
||||
// Horizontal alignment
|
||||
if (nAnchor != RndStdIds::FLY_AS_CHAR)
|
||||
{
|
||||
switch (nHAlign)
|
||||
{
|
||||
case HoriOrientation::RIGHT:
|
||||
{
|
||||
lXPos = aRect.Right() - aFrmSize.Width() + 1;
|
||||
break;
|
||||
}
|
||||
case HoriOrientation::CENTER:
|
||||
{
|
||||
lXPos = aRect.Left() + (aRect.GetWidth() - aFrmSize.Width()) / 2;
|
||||
break;
|
||||
}
|
||||
case HoriOrientation::NONE:
|
||||
{
|
||||
lXPos = aRect.Left() + aRelPos.X();
|
||||
break;
|
||||
}
|
||||
|
||||
default: // HoriOrientation::LEFT
|
||||
lXPos = aRect.Left();
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
lXPos = aRect.Right() + 2;
|
||||
}
|
||||
|
||||
// Vertical Alignment
|
||||
if (nAnchor != RndStdIds::FLY_AS_CHAR)
|
||||
{
|
||||
switch (nVAlign)
|
||||
{
|
||||
case VertOrientation::BOTTOM:
|
||||
case VertOrientation::LINE_BOTTOM:
|
||||
{
|
||||
// #i22341#
|
||||
if ( nVRel != RelOrientation::TEXT_LINE )
|
||||
{
|
||||
lYPos = aRect.Bottom() - aFrmSize.Height() + 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
lYPos = aRect.Top();
|
||||
}
|
||||
break;
|
||||
}
|
||||
case VertOrientation::CENTER:
|
||||
case VertOrientation::LINE_CENTER:
|
||||
{
|
||||
lYPos = aRect.Top() + (aRect.GetHeight() - aFrmSize.Height()) / 2;
|
||||
break;
|
||||
}
|
||||
case VertOrientation::NONE:
|
||||
{
|
||||
// #i22341#
|
||||
if ( nVRel != RelOrientation::CHAR && nVRel != RelOrientation::TEXT_LINE )
|
||||
lYPos = aRect.Top() + aRelPos.Y();
|
||||
else
|
||||
lYPos = aRect.Top() - aRelPos.Y();
|
||||
break;
|
||||
}
|
||||
default:
|
||||
// #i22341#
|
||||
if ( nVRel != RelOrientation::TEXT_LINE )
|
||||
{
|
||||
lYPos = aRect.Top();
|
||||
}
|
||||
else
|
||||
{
|
||||
lYPos = aRect.Bottom() - aFrmSize.Height() + 1;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
switch(nVAlign)
|
||||
{
|
||||
case VertOrientation::CENTER:
|
||||
case VertOrientation::CHAR_CENTER:
|
||||
case VertOrientation::LINE_CENTER:
|
||||
lYPos = aRect.Top() + (aRect.GetHeight() - aFrmSize.Height()) / 2;
|
||||
break;
|
||||
|
||||
case VertOrientation::TOP:
|
||||
case VertOrientation::CHAR_BOTTOM:
|
||||
case VertOrientation::LINE_BOTTOM:
|
||||
lYPos = aRect.Bottom() - aFrmSize.Height() + 1;
|
||||
break;
|
||||
|
||||
default:
|
||||
lYPos = aRect.Top() - aRelPos.Y();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
tools::Rectangle aFrmRect(Point(lXPos, lYPos), aFrmSize);
|
||||
|
||||
tools::Rectangle* pOuterFrame = &aPage;
|
||||
|
||||
if (nAnchor == RndStdIds::FLY_AT_FLY)
|
||||
pOuterFrame = &aFrameAtFrame;
|
||||
|
||||
if (aFrmRect.Left() < pOuterFrame->Left())
|
||||
aFrmRect.Move(pOuterFrame->Left() - aFrmRect.Left(), 0);
|
||||
if (aFrmRect.Right() > pOuterFrame->Right())
|
||||
aFrmRect.Move(pOuterFrame->Right() - aFrmRect.Right(), 0);
|
||||
|
||||
if (aFrmRect.Top() < pOuterFrame->Top())
|
||||
aFrmRect.Move(0, pOuterFrame->Top() - aFrmRect.Top());
|
||||
if (aFrmRect.Bottom() > pOuterFrame->Bottom())
|
||||
aFrmRect.Move(0, pOuterFrame->Bottom() - aFrmRect.Bottom());
|
||||
|
||||
// Draw Test paragraph
|
||||
const long nTxtLineHeight = aTextLine.GetHeight();
|
||||
tools::Rectangle aTxt(aTextLine);
|
||||
sal_Int32 nStep;
|
||||
sal_uInt16 nLines;
|
||||
|
||||
if (nAnchor == RndStdIds::FLY_AT_FLY)
|
||||
{
|
||||
aTxt.SetLeft( aFrameAtFrame.Left() + FLYINFLY_BORDER );
|
||||
aTxt.SetRight( aFrameAtFrame.Right() - FLYINFLY_BORDER );
|
||||
aTxt.SetTop( aFrameAtFrame.Top() + FLYINFLY_BORDER );
|
||||
aTxt.SetBottom( aTxt.Top() + aTextLine.GetHeight() - 1 );
|
||||
|
||||
nStep = aTxt.GetHeight() + 2;
|
||||
nLines = static_cast<sal_uInt16>(((aFrameAtFrame.GetHeight() - 2 * FLYINFLY_BORDER) * 2 / 3)
|
||||
/ (aTxt.GetHeight() + 2));
|
||||
}
|
||||
else
|
||||
{
|
||||
nStep = aTxt.GetHeight() + 2;
|
||||
nLines = static_cast<sal_uInt16>(aParaPrtArea.GetHeight() / (aTextLine.GetHeight() + 2));
|
||||
}
|
||||
|
||||
if (nAnchor != RndStdIds::FLY_AS_CHAR)
|
||||
{
|
||||
// Simulate text
|
||||
const long nOldR = aTxt.Right();
|
||||
const long nOldL = aTxt.Left();
|
||||
|
||||
// #i22341#
|
||||
const bool bIgnoreWrap = nAnchor == RndStdIds::FLY_AT_CHAR &&
|
||||
( nHRel == RelOrientation::CHAR || nVRel == RelOrientation::CHAR ||
|
||||
nVRel == RelOrientation::TEXT_LINE );
|
||||
|
||||
for (sal_uInt16 i = 0; i < nLines; ++i)
|
||||
{
|
||||
if (i == (nLines - 1))
|
||||
aTxt.SetSize(Size(aTxt.GetWidth() / 2, aTxt.GetHeight()));
|
||||
|
||||
if (aTxt.IsOver(aFrmRect) && nAnchor != RndStdIds::FLY_AS_CHAR && !bIgnoreWrap)
|
||||
{
|
||||
switch(nWrap)
|
||||
{
|
||||
case WrapTextMode_NONE:
|
||||
aTxt.SetTop( aFrmRect.Bottom() + nTxtLineHeight );
|
||||
aTxt.SetBottom( aTxt.Top() + nTxtLineHeight - 1 );
|
||||
break;
|
||||
|
||||
case WrapTextMode_LEFT:
|
||||
aTxt.SetRight( aFrmRect.Left() );
|
||||
break;
|
||||
|
||||
case WrapTextMode_RIGHT:
|
||||
aTxt.SetLeft( aFrmRect.Right() );
|
||||
break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
if (pOuterFrame->IsInside(aTxt))
|
||||
DrawRect_Impl(rRenderContext, aTxt, m_aTxtCol, m_aTransColor );
|
||||
|
||||
aTxt.Move(0, nStep);
|
||||
aTxt.SetRight( nOldR );
|
||||
aTxt.SetLeft( nOldL );
|
||||
}
|
||||
aTxt.Move(0, -nStep);
|
||||
|
||||
if (nAnchor != RndStdIds::FLY_AT_FLY && aTxt.Bottom() > aParaPrtArea.Bottom())
|
||||
{
|
||||
// Text has been replaced by frame, so adjust parameters height
|
||||
sal_Int32 nDiff = aTxt.Bottom() - aParaPrtArea.Bottom();
|
||||
aParaPrtArea.AdjustBottom(nDiff );
|
||||
aPara.AdjustBottom(nDiff );
|
||||
|
||||
CalcBoundRect_Impl(aRect);
|
||||
|
||||
aParaPrtArea.AdjustBottom( -nDiff );
|
||||
aPara.AdjustBottom( -nDiff );
|
||||
}
|
||||
if (nAnchor == RndStdIds::FLY_AT_CHAR && bIgnoreWrap)
|
||||
rRenderContext.DrawText(aAutoCharFrame, OUString('A'));
|
||||
}
|
||||
else
|
||||
{
|
||||
rRenderContext.DrawText(aParaPrtArea, OUString(DEMOTEXT));
|
||||
DrawRect_Impl(rRenderContext, aDrawObj, m_aBlankCol, m_aBlankFrameCol );
|
||||
}
|
||||
|
||||
// Draw rectangle on which the frame is aligned:
|
||||
DrawRect_Impl(rRenderContext, aRect, m_aTransColor, m_aAlignColor);
|
||||
|
||||
// Frame View
|
||||
bool bDontFill = (nAnchor == RndStdIds::FLY_AT_CHAR && aFrmRect.IsOver(aAutoCharFrame)) || bTrans;
|
||||
DrawRect_Impl(rRenderContext, aFrmRect, bDontFill? m_aTransColor : m_aBgCol, m_aFrameColor);
|
||||
}
|
||||
|
||||
void SvxSwFrameExample::SetRelPos(const Point& rP)
|
||||
{
|
||||
aRelPos = rP;
|
||||
|
||||
if (aRelPos.X() > 0)
|
||||
aRelPos.setX( 5 );
|
||||
if (aRelPos.X() < 0)
|
||||
aRelPos.setX( -5 );
|
||||
|
||||
if (aRelPos.Y() > 0)
|
||||
aRelPos.setY( 5 );
|
||||
if (aRelPos.Y() < 0)
|
||||
aRelPos.setY( -5 );
|
||||
}
|
||||
|
||||
SwFrameExample::SwFrameExample()
|
||||
: nHAlign(HoriOrientation::CENTER)
|
||||
, nHRel(RelOrientation::FRAME)
|
||||
, nVAlign(VertOrientation::TOP)
|
||||
, nVRel(RelOrientation::PRINT_AREA)
|
||||
, nWrap(WrapTextMode_NONE)
|
||||
, nAnchor(RndStdIds::FLY_AT_PAGE)
|
||||
, bTrans(false)
|
||||
, aRelPos(Point(0,0))
|
||||
{
|
||||
InitColors_Impl();
|
||||
@@ -1310,8 +641,22 @@ void SwFrameExample::Paint(vcl::RenderContext& rRenderContext, const tools::Rect
|
||||
|
||||
if (aTxt.IsOver(aFrmRect) && nAnchor != RndStdIds::FLY_AS_CHAR && !bIgnoreWrap)
|
||||
{
|
||||
aTxt.SetTop( aFrmRect.Bottom() + nTxtLineHeight );
|
||||
aTxt.SetBottom( aTxt.Top() + nTxtLineHeight - 1 );
|
||||
switch(nWrap)
|
||||
{
|
||||
case WrapTextMode_NONE:
|
||||
aTxt.SetTop( aFrmRect.Bottom() + nTxtLineHeight );
|
||||
aTxt.SetBottom( aTxt.Top() + nTxtLineHeight - 1 );
|
||||
break;
|
||||
|
||||
case WrapTextMode_LEFT:
|
||||
aTxt.SetRight( aFrmRect.Left() );
|
||||
break;
|
||||
|
||||
case WrapTextMode_RIGHT:
|
||||
aTxt.SetLeft( aFrmRect.Right() );
|
||||
break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
if (pOuterFrame->IsInside(aTxt))
|
||||
DrawRect_Impl(rRenderContext, aTxt, m_aTxtCol, m_aTransColor );
|
||||
@@ -1347,7 +692,7 @@ void SwFrameExample::Paint(vcl::RenderContext& rRenderContext, const tools::Rect
|
||||
DrawRect_Impl(rRenderContext, aRect, m_aTransColor, m_aAlignColor);
|
||||
|
||||
// Frame View
|
||||
bool bDontFill = (nAnchor == RndStdIds::FLY_AT_CHAR && aFrmRect.IsOver(aAutoCharFrame));
|
||||
bool bDontFill = (nAnchor == RndStdIds::FLY_AT_CHAR && aFrmRect.IsOver(aAutoCharFrame)) || bTrans;
|
||||
DrawRect_Impl(rRenderContext, aFrmRect, bDontFill? m_aTransColor : m_aBgCol, m_aFrameColor);
|
||||
}
|
||||
|
||||
|
@@ -558,8 +558,8 @@ void SwColumnPage::Reset(const SfxItemSet *rSet)
|
||||
m_xDistEd1->SetMetric(aMetric);
|
||||
m_xDistEd2->SetMetric(aMetric);
|
||||
//default spacing between cols = 0.5cm
|
||||
m_xDistEd1->SetPrcntValue(50, FieldUnit::CM);
|
||||
m_xDistEd2->SetPrcntValue(50, FieldUnit::CM);
|
||||
m_xDistEd1->set_value(50, FieldUnit::CM);
|
||||
m_xDistEd2->set_value(50, FieldUnit::CM);
|
||||
|
||||
m_xColMgr.reset(new SwColMgr(*rSet));
|
||||
m_nCols = m_xColMgr->GetCount() ;
|
||||
@@ -963,7 +963,7 @@ IMPL_LINK(SwColumnPage, GapModify, weld::MetricSpinButton&, rMetricField, void)
|
||||
if(nActValue > nMaxGap)
|
||||
{
|
||||
nActValue = nMaxGap;
|
||||
m_xDistEd1->SetPrcntValue(m_xDistEd1->NormalizePercent(nMaxGap), FieldUnit::TWIP);
|
||||
m_xDistEd1->set_value(m_xDistEd1->NormalizePercent(nMaxGap), FieldUnit::TWIP);
|
||||
}
|
||||
m_xColMgr->SetGutterWidth(static_cast<sal_uInt16>(nActValue));
|
||||
for(sal_uInt16 i = 0; i < m_nCols; i++)
|
||||
@@ -1122,29 +1122,29 @@ void SwColumnPage::Update(const weld::MetricSpinButton* pInteractiveField)
|
||||
//fdo#87612 if we're interacting with this widget and the value will be the same
|
||||
//then leave it alone (i.e. don't change equivalent values of e.g. .8 -> 0.8)
|
||||
if (nNewValue != nCurrentValue || pInteractiveField != m_xEd1->get())
|
||||
m_xEd1->SetPrcntValue(nNewValue, FieldUnit::TWIP);
|
||||
m_xEd1->set_value(nNewValue, FieldUnit::TWIP);
|
||||
|
||||
nCurrentValue = m_xDistEd1->NormalizePercent(m_xDistEd1->DenormalizePercent(m_xDistEd1->get_value(FieldUnit::TWIP)));
|
||||
nNewValue = m_xDistEd1->NormalizePercent(m_nColDist[m_nFirstVis]);
|
||||
if (nNewValue != nCurrentValue || pInteractiveField != m_xDistEd1->get())
|
||||
m_xDistEd1->SetPrcntValue(nNewValue, FieldUnit::TWIP);
|
||||
m_xDistEd1->set_value(nNewValue, FieldUnit::TWIP);
|
||||
|
||||
nCurrentValue = m_xEd2->NormalizePercent(m_xEd2->DenormalizePercent(m_xEd2->get_value(FieldUnit::TWIP)));
|
||||
nNewValue = m_xEd2->NormalizePercent(m_nColWidth[m_nFirstVis+1]);
|
||||
if (nNewValue != nCurrentValue || pInteractiveField != m_xEd2->get())
|
||||
m_xEd2->SetPrcntValue(nNewValue, FieldUnit::TWIP);
|
||||
m_xEd2->set_value(nNewValue, FieldUnit::TWIP);
|
||||
|
||||
if(m_nCols >= 3)
|
||||
{
|
||||
nCurrentValue = m_xDistEd2->NormalizePercent(m_xDistEd2->DenormalizePercent(m_xDistEd2->get_value(FieldUnit::TWIP)));
|
||||
nNewValue = m_xDistEd2->NormalizePercent(m_nColDist[m_nFirstVis+1]);
|
||||
if (nNewValue != nCurrentValue || pInteractiveField != m_xDistEd2->get())
|
||||
m_xDistEd2->SetPrcntValue(nNewValue, FieldUnit::TWIP);
|
||||
m_xDistEd2->set_value(nNewValue, FieldUnit::TWIP);
|
||||
|
||||
nCurrentValue = m_xEd3->NormalizePercent(m_xEd3->DenormalizePercent(m_xEd3->get_value(FieldUnit::TWIP)));
|
||||
nNewValue = m_xEd3->NormalizePercent(m_nColWidth[m_nFirstVis+2]);
|
||||
if (nNewValue != nCurrentValue || pInteractiveField != m_xEd3->get())
|
||||
m_xEd3->SetPrcntValue(nNewValue, FieldUnit::TWIP);
|
||||
m_xEd3->set_value(nNewValue, FieldUnit::TWIP);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1280,7 +1280,7 @@ IMPL_LINK(SwColumnPage, SetDefaultsHdl, SvtValueSet *, pVS, void)
|
||||
{
|
||||
m_xCLNrEdt->set_value(nItem);
|
||||
m_xAutoWidthBox->set_active(true);
|
||||
m_xDistEd1->SetPrcntValue(50, FieldUnit::CM);
|
||||
m_xDistEd1->set_value(50, FieldUnit::CM);
|
||||
ColModify(nullptr);
|
||||
}
|
||||
else
|
||||
@@ -1288,18 +1288,18 @@ IMPL_LINK(SwColumnPage, SetDefaultsHdl, SvtValueSet *, pVS, void)
|
||||
m_bLockUpdate = true;
|
||||
m_xCLNrEdt->set_value(2);
|
||||
m_xAutoWidthBox->set_active(false);
|
||||
m_xDistEd1->SetPrcntValue(50, FieldUnit::CM);
|
||||
m_xDistEd1->set_value(50, FieldUnit::CM);
|
||||
ColModify(nullptr);
|
||||
// now set the width ratio to 2 : 1 or 1 : 2 respectively
|
||||
const long nSmall = static_cast< long >(m_xColMgr->GetActualSize() / 3);
|
||||
if(nItem == 4)
|
||||
{
|
||||
m_xEd2->SetPrcntValue(m_xEd2->NormalizePercent(nSmall), FieldUnit::TWIP);
|
||||
m_xEd2->set_value(m_xEd2->NormalizePercent(nSmall), FieldUnit::TWIP);
|
||||
m_pModifiedField = m_xEd2.get();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_xEd1->SetPrcntValue(m_xEd1->NormalizePercent(nSmall), FieldUnit::TWIP);
|
||||
m_xEd1->set_value(m_xEd1->NormalizePercent(nSmall), FieldUnit::TWIP);
|
||||
m_pModifiedField = m_xEd1.get();
|
||||
}
|
||||
m_bLockUpdate = false;
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -160,8 +160,8 @@ IMPL_LINK( SwFormatTablePage, RelWidthClickHdl, weld::ToggleButton&, rBtn, void
|
||||
m_xRightMF->SetMetricFieldMin(0); //dito
|
||||
m_xLeftMF->SetMetricFieldMax(99);
|
||||
m_xRightMF->SetMetricFieldMax(99);
|
||||
m_xLeftMF->SetPrcntValue(m_xLeftMF->NormalizePercent(nLeft ), FieldUnit::TWIP );
|
||||
m_xRightMF->SetPrcntValue(m_xRightMF->NormalizePercent(nRight ), FieldUnit::TWIP );
|
||||
m_xLeftMF->set_value(m_xLeftMF->NormalizePercent(nLeft ), FieldUnit::TWIP );
|
||||
m_xRightMF->set_value(m_xRightMF->NormalizePercent(nRight ), FieldUnit::TWIP );
|
||||
}
|
||||
else
|
||||
ModifyHdl(*m_xLeftMF->get()); //correct values again
|
||||
@@ -184,27 +184,27 @@ IMPL_LINK_NOARG(SwFormatTablePage, AutoClickHdl, weld::ToggleButton&, void)
|
||||
bOthers = true;
|
||||
if (m_xFullBtn->get_active())
|
||||
{
|
||||
m_xLeftMF->SetPrcntValue(0);
|
||||
m_xRightMF->SetPrcntValue(0);
|
||||
m_xLeftMF->set_value(0);
|
||||
m_xRightMF->set_value(0);
|
||||
nSaveWidth = static_cast<SwTwips>(m_xWidthMF->DenormalizePercent(m_xWidthMF->get_value(FieldUnit::TWIP)));
|
||||
m_xWidthMF->SetPrcntValue(m_xWidthMF->NormalizePercent(pTableData->GetSpace()), FieldUnit::TWIP);
|
||||
m_xWidthMF->set_value(m_xWidthMF->NormalizePercent(pTableData->GetSpace()), FieldUnit::TWIP);
|
||||
bFull = true;
|
||||
bRestore = false;
|
||||
}
|
||||
else if (m_xLeftBtn->get_active())
|
||||
{
|
||||
bRightEnable = bWidthEnable = true;
|
||||
m_xLeftMF->SetPrcntValue(0);
|
||||
m_xLeftMF->set_value(0);
|
||||
}
|
||||
else if (m_xFromLeftBtn->get_active())
|
||||
{
|
||||
bLeftEnable = bWidthEnable = true;
|
||||
m_xRightMF->SetPrcntValue(0);
|
||||
m_xRightMF->set_value(0);
|
||||
}
|
||||
else if (m_xRightBtn->get_active())
|
||||
{
|
||||
bLeftEnable = bWidthEnable = true;
|
||||
m_xRightMF->SetPrcntValue(0);
|
||||
m_xRightMF->set_value(0);
|
||||
}
|
||||
else if (m_xCenterBtn->get_active())
|
||||
{
|
||||
@@ -233,7 +233,7 @@ IMPL_LINK_NOARG(SwFormatTablePage, AutoClickHdl, weld::ToggleButton&, void)
|
||||
//After being switched on automatic, the width was pinned
|
||||
//in order to restore the width while switching back to.
|
||||
bFull = false;
|
||||
m_xWidthMF->SetPrcntValue(m_xWidthMF->NormalizePercent(nSaveWidth ), FieldUnit::TWIP );
|
||||
m_xWidthMF->set_value(m_xWidthMF->NormalizePercent(nSaveWidth ), FieldUnit::TWIP );
|
||||
}
|
||||
ModifyHdl(*m_xWidthMF->get());
|
||||
bModified = true;
|
||||
@@ -358,9 +358,9 @@ void SwFormatTablePage::ModifyHdl(const weld::MetricSpinButton& rEdit)
|
||||
}
|
||||
}
|
||||
if (nCurWidth != nPrevWidth )
|
||||
m_xWidthMF->SetPrcntValue( m_xWidthMF->NormalizePercent( nCurWidth ), FieldUnit::TWIP );
|
||||
m_xRightMF->SetPrcntValue( m_xRightMF->NormalizePercent( nRight ), FieldUnit::TWIP );
|
||||
m_xLeftMF->SetPrcntValue( m_xLeftMF->NormalizePercent( nLeft ), FieldUnit::TWIP );
|
||||
m_xWidthMF->set_value( m_xWidthMF->NormalizePercent( nCurWidth ), FieldUnit::TWIP );
|
||||
m_xRightMF->set_value( m_xRightMF->NormalizePercent( nRight ), FieldUnit::TWIP );
|
||||
m_xLeftMF->set_value( m_xLeftMF->NormalizePercent( nLeft ), FieldUnit::TWIP );
|
||||
bModified = true;
|
||||
}
|
||||
|
||||
@@ -451,14 +451,14 @@ void SwFormatTablePage::Reset( const SfxItemSet* )
|
||||
{
|
||||
m_xRelWidthCB->set_active(true);
|
||||
RelWidthClickHdl(*m_xRelWidthCB);
|
||||
m_xWidthMF->SetPrcntValue(pTableData->GetWidthPercent(), FieldUnit::PERCENT);
|
||||
m_xWidthMF->set_value(pTableData->GetWidthPercent(), FieldUnit::PERCENT);
|
||||
|
||||
m_xWidthMF->save_value();
|
||||
nSaveWidth = static_cast< SwTwips >(m_xWidthMF->get_value(FieldUnit::PERCENT));
|
||||
}
|
||||
else
|
||||
{
|
||||
m_xWidthMF->SetPrcntValue(m_xWidthMF->NormalizePercent(
|
||||
m_xWidthMF->set_value(m_xWidthMF->NormalizePercent(
|
||||
pTableData->GetWidth()), FieldUnit::TWIP);
|
||||
m_xWidthMF->save_value();
|
||||
nSaveWidth = pTableData->GetWidth();
|
||||
@@ -467,9 +467,9 @@ void SwFormatTablePage::Reset( const SfxItemSet* )
|
||||
|
||||
m_xWidthMF->SetRefValue(pTableData->GetSpace());
|
||||
|
||||
m_xLeftMF->SetPrcntValue(m_xLeftMF->NormalizePercent(
|
||||
m_xLeftMF->set_value(m_xLeftMF->NormalizePercent(
|
||||
pTableData->GetLeftSpace()), FieldUnit::TWIP);
|
||||
m_xRightMF->SetPrcntValue(m_xRightMF->NormalizePercent(
|
||||
m_xRightMF->set_value(m_xRightMF->NormalizePercent(
|
||||
pTableData->GetRightSpace()), FieldUnit::TWIP);
|
||||
m_xLeftMF->save_value();
|
||||
m_xRightMF->save_value();
|
||||
@@ -565,14 +565,14 @@ void SwFormatTablePage::ActivatePage( const SfxItemSet& rSet )
|
||||
if(pTableData->GetWidthPercent() == 0 &&
|
||||
nCurWidth != m_xWidthMF->DenormalizePercent(m_xWidthMF->get_value(FieldUnit::TWIP)))
|
||||
{
|
||||
m_xWidthMF->SetPrcntValue(m_xWidthMF->NormalizePercent(
|
||||
m_xWidthMF->set_value(m_xWidthMF->NormalizePercent(
|
||||
nCurWidth), FieldUnit::TWIP);
|
||||
m_xWidthMF->save_value();
|
||||
nSaveWidth = nCurWidth;
|
||||
m_xLeftMF->SetPrcntValue(m_xLeftMF->NormalizePercent(
|
||||
m_xLeftMF->set_value(m_xLeftMF->NormalizePercent(
|
||||
pTableData->GetLeftSpace()), FieldUnit::TWIP);
|
||||
m_xLeftMF->save_value();
|
||||
m_xRightMF->SetPrcntValue(m_xRightMF->NormalizePercent(
|
||||
m_xRightMF->set_value(m_xRightMF->NormalizePercent(
|
||||
pTableData->GetRightSpace()), FieldUnit::TWIP);
|
||||
m_xRightMF->save_value();
|
||||
}
|
||||
@@ -784,7 +784,7 @@ void SwTableColumnPage::Reset( const SfxItemSet* )
|
||||
sal_Int64 nMaxTwips = m_aFieldArr[0].NormalizePercent( nTableWidth );
|
||||
for( sal_uInt16 i = 0; (i < nMetFields) && (i < nNoOfVisibleCols); i++ )
|
||||
{
|
||||
m_aFieldArr[i].SetPrcntValue( m_aFieldArr[i].NormalizePercent(
|
||||
m_aFieldArr[i].set_value( m_aFieldArr[i].NormalizePercent(
|
||||
GetVisibleWidth(i) ), FieldUnit::TWIP );
|
||||
m_aFieldArr[i].set_min(nMinTwips, FieldUnit::TWIP);
|
||||
m_aFieldArr[i].set_max(nMaxTwips, FieldUnit::TWIP);
|
||||
@@ -1027,7 +1027,7 @@ void SwTableColumnPage::UpdateCols( sal_uInt16 nCurrentPos )
|
||||
|
||||
for( sal_uInt16 i = 0; ( i < nNoOfVisibleCols ) && ( i < nMetFields ); i++)
|
||||
{
|
||||
m_aFieldArr[i].SetPrcntValue(m_aFieldArr[i].NormalizePercent(
|
||||
m_aFieldArr[i].set_value(m_aFieldArr[i].NormalizePercent(
|
||||
GetVisibleWidth(aValueTable[i]) ), FieldUnit::TWIP);
|
||||
}
|
||||
}
|
||||
|
@@ -43,54 +43,6 @@ struct SwPosition;
|
||||
// frame dialog
|
||||
class SwFramePage: public SfxTabPage
|
||||
{
|
||||
// size
|
||||
VclPtr<FixedText> m_pWidthFT;
|
||||
VclPtr<FixedText> m_pWidthAutoFT;
|
||||
PercentField m_aWidthED;
|
||||
VclPtr<CheckBox> m_pRelWidthCB;
|
||||
VclPtr<ListBox> m_pRelWidthRelationLB;
|
||||
VclPtr<CheckBox> m_pAutoWidthCB;
|
||||
|
||||
VclPtr<FixedText> m_pHeightFT;
|
||||
VclPtr<FixedText> m_pHeightAutoFT;
|
||||
PercentField m_aHeightED;
|
||||
VclPtr<CheckBox> m_pRelHeightCB;
|
||||
VclPtr<ListBox> m_pRelHeightRelationLB;
|
||||
VclPtr<CheckBox> m_pAutoHeightCB;
|
||||
|
||||
VclPtr<CheckBox> m_pFixedRatioCB;
|
||||
VclPtr<PushButton> m_pRealSizeBT;
|
||||
|
||||
// anchor
|
||||
VclPtr<VclContainer> m_pAnchorFrame;
|
||||
VclPtr<RadioButton> m_pAnchorAtPageRB;
|
||||
VclPtr<RadioButton> m_pAnchorAtParaRB;
|
||||
VclPtr<RadioButton> m_pAnchorAtCharRB;
|
||||
VclPtr<RadioButton> m_pAnchorAsCharRB;
|
||||
VclPtr<RadioButton> m_pAnchorAtFrameRB;
|
||||
|
||||
// position
|
||||
VclPtr<FixedText> m_pHorizontalFT;
|
||||
VclPtr<ListBox> m_pHorizontalDLB;
|
||||
VclPtr<FixedText> m_pAtHorzPosFT;
|
||||
VclPtr<MetricField> m_pAtHorzPosED;
|
||||
VclPtr<FixedText> m_pHoriRelationFT;
|
||||
VclPtr<ListBox> m_pHoriRelationLB;
|
||||
|
||||
VclPtr<CheckBox> m_pMirrorPagesCB;
|
||||
|
||||
VclPtr<FixedText> m_pVerticalFT;
|
||||
VclPtr<ListBox> m_pVerticalDLB;
|
||||
VclPtr<FixedText> m_pAtVertPosFT;
|
||||
VclPtr<MetricField> m_pAtVertPosED;
|
||||
VclPtr<FixedText> m_pVertRelationFT;
|
||||
VclPtr<ListBox> m_pVertRelationLB;
|
||||
// #i18732# - check box for new option 'FollowTextFlow'
|
||||
VclPtr<CheckBox> m_pFollowTextFlowCB;
|
||||
|
||||
// example
|
||||
VclPtr<SvxSwFrameExample> m_pExampleWN;
|
||||
|
||||
bool m_bAtHorzPosModified;
|
||||
bool m_bAtVertPosModified;
|
||||
|
||||
@@ -126,48 +78,98 @@ class SwFramePage: public SfxTabPage
|
||||
bool m_bIsMathOLE;
|
||||
bool m_bIsMathBaselineAlignment;
|
||||
|
||||
SwFrameExample m_aExampleWN;
|
||||
|
||||
// size
|
||||
std::unique_ptr<weld::Label> m_xWidthFT;
|
||||
std::unique_ptr<weld::Label> m_xWidthAutoFT;
|
||||
std::unique_ptr<weld::CheckButton> m_xRelWidthCB;
|
||||
std::unique_ptr<weld::ComboBox> m_xRelWidthRelationLB;
|
||||
std::unique_ptr<weld::CheckButton> m_xAutoWidthCB;
|
||||
|
||||
std::unique_ptr<weld::Label> m_xHeightFT;
|
||||
std::unique_ptr<weld::Label> m_xHeightAutoFT;
|
||||
std::unique_ptr<weld::CheckButton> m_xRelHeightCB;
|
||||
std::unique_ptr<weld::ComboBox> m_xRelHeightRelationLB;
|
||||
std::unique_ptr<weld::CheckButton> m_xAutoHeightCB;
|
||||
|
||||
std::unique_ptr<weld::CheckButton> m_xFixedRatioCB;
|
||||
std::unique_ptr<weld::Button> m_xRealSizeBT;
|
||||
|
||||
// anchor
|
||||
std::unique_ptr<weld::Widget> m_xAnchorFrame;
|
||||
std::unique_ptr<weld::RadioButton> m_xAnchorAtPageRB;
|
||||
std::unique_ptr<weld::RadioButton> m_xAnchorAtParaRB;
|
||||
std::unique_ptr<weld::RadioButton> m_xAnchorAtCharRB;
|
||||
std::unique_ptr<weld::RadioButton> m_xAnchorAsCharRB;
|
||||
std::unique_ptr<weld::RadioButton> m_xAnchorAtFrameRB;
|
||||
|
||||
// position
|
||||
std::unique_ptr<weld::Label> m_xHorizontalFT;
|
||||
std::unique_ptr<weld::ComboBox> m_xHorizontalDLB;
|
||||
std::unique_ptr<weld::Label> m_xAtHorzPosFT;
|
||||
std::unique_ptr<weld::MetricSpinButton> m_xAtHorzPosED;
|
||||
std::unique_ptr<weld::Label> m_xHoriRelationFT;
|
||||
std::unique_ptr<weld::ComboBox> m_xHoriRelationLB;
|
||||
|
||||
std::unique_ptr<weld::CheckButton> m_xMirrorPagesCB;
|
||||
|
||||
std::unique_ptr<weld::Label> m_xVerticalFT;
|
||||
std::unique_ptr<weld::ComboBox> m_xVerticalDLB;
|
||||
std::unique_ptr<weld::Label> m_xAtVertPosFT;
|
||||
std::unique_ptr<weld::MetricSpinButton> m_xAtVertPosED;
|
||||
std::unique_ptr<weld::Label> m_xVertRelationFT;
|
||||
std::unique_ptr<weld::ComboBox> m_xVertRelationLB;
|
||||
// #i18732# - check box for new option 'FollowTextFlow'
|
||||
std::unique_ptr<weld::CheckButton> m_xFollowTextFlowCB;
|
||||
|
||||
// example
|
||||
std::unique_ptr<weld::CustomWeld> m_xExampleWN;
|
||||
|
||||
std::unique_ptr<SwPercentField> m_xWidthED;
|
||||
std::unique_ptr<SwPercentField> m_xHeightED;
|
||||
|
||||
virtual void ActivatePage(const SfxItemSet& rSet) override;
|
||||
virtual DeactivateRC DeactivatePage(SfxItemSet *pSet) override;
|
||||
|
||||
DECL_LINK(RangeModifyLoseFocusHdl, Control&, void);
|
||||
DECL_LINK(RangeModifyClickHdl, Button*, void);
|
||||
DECL_LINK(RangeModifyClickHdl, weld::ToggleButton&, void);
|
||||
void RangeModifyHdl();
|
||||
DECL_LINK(AnchorTypeHdl, Button*, void);
|
||||
DECL_LINK( PosHdl, ListBox&, void );
|
||||
DECL_LINK( RelHdl, ListBox&, void );
|
||||
DECL_LINK(AnchorTypeHdl, weld::ToggleButton&, void);
|
||||
DECL_LINK(PosHdl, weld::ComboBox&, void);
|
||||
DECL_LINK(RelHdl, weld::ComboBox&, void);
|
||||
void InitPos(RndStdIds eId, sal_Int16 nH, sal_Int16 nHRel,
|
||||
sal_Int16 nV, sal_Int16 nVRel,
|
||||
long nX, long nY);
|
||||
|
||||
DECL_LINK(RealSizeHdl, Button *, void);
|
||||
DECL_LINK( RelSizeClickHdl, Button *, void );
|
||||
DECL_LINK(MirrorHdl, Button *, void);
|
||||
DECL_LINK(RealSizeHdl, weld::Button&, void);
|
||||
DECL_LINK(RelSizeClickHdl, weld::ToggleButton&, void);
|
||||
DECL_LINK(MirrorHdl, weld::ToggleButton&, void);
|
||||
|
||||
DECL_LINK( AutoWidthClickHdl, Button *, void);
|
||||
DECL_LINK( AutoHeightClickHdl, Button *, void);
|
||||
DECL_LINK(AutoWidthClickHdl, weld::ToggleButton&, void);
|
||||
DECL_LINK(AutoHeightClickHdl, weld::ToggleButton&, void);
|
||||
|
||||
// update example
|
||||
void UpdateExample();
|
||||
DECL_LINK( ModifyHdl, Edit&, void );
|
||||
DECL_LINK(ModifyHdl, weld::MetricSpinButton&, void);
|
||||
|
||||
void Init(const SfxItemSet& rSet, bool bReset = false);
|
||||
void Init(const SfxItemSet& rSet);
|
||||
// OD 12.11.2003 #i22341# - adjustment to handle maps, that are ambiguous
|
||||
// in the alignment.
|
||||
sal_Int32 FillPosLB( const FrameMap* _pMap,
|
||||
const sal_Int16 _nAlign,
|
||||
const sal_Int16 _nRel,
|
||||
ListBox& _rLB );
|
||||
weld::ComboBox& _rLB );
|
||||
// OD 14.11.2003 #i22341# - adjustment to handle maps, that are ambiguous
|
||||
// in their string entries.
|
||||
void FillRelLB( const FrameMap* _pMap,
|
||||
const sal_uInt16 _nLBSelPos,
|
||||
const sal_Int16 _nAlign,
|
||||
const sal_Int16 _nRel,
|
||||
ListBox& _rLB,
|
||||
FixedText& _rFT );
|
||||
static sal_Int32 GetMapPos(const FrameMap *pMap, ListBox const &rAlignLB);
|
||||
static sal_Int16 GetAlignment(FrameMap const *pMap, sal_Int32 nMapPos, ListBox const &rRelationLB);
|
||||
static sal_Int16 GetRelation(ListBox const &rRelationLB);
|
||||
weld::ComboBox& _rLB,
|
||||
weld::Label& _rFT );
|
||||
static sal_Int32 GetMapPos(const FrameMap *pMap, const weld::ComboBox& rAlignLB);
|
||||
static sal_Int16 GetAlignment(FrameMap const *pMap, sal_Int32 nMapPos, const weld::ComboBox& rRelationLB);
|
||||
static sal_Int16 GetRelation(const weld::ComboBox& rRelationLB);
|
||||
RndStdIds GetAnchor();
|
||||
|
||||
void setOptimalFrameWidth();
|
||||
@@ -183,9 +185,8 @@ class SwFramePage: public SfxTabPage
|
||||
static const sal_uInt16 aPageRg[];
|
||||
|
||||
public:
|
||||
SwFramePage(vcl::Window *pParent, const SfxItemSet &rSet);
|
||||
SwFramePage(TabPageParent pParent, const SfxItemSet &rSet);
|
||||
virtual ~SwFramePage() override;
|
||||
virtual void dispose() override;
|
||||
|
||||
static VclPtr<SfxTabPage> Create(TabPageParent pParent, const SfxItemSet *rSet);
|
||||
static const sal_uInt16* GetRanges() { return aPageRg; }
|
||||
|
@@ -25,69 +25,6 @@
|
||||
#include <swdllapi.h>
|
||||
#include "uitool.hxx"
|
||||
|
||||
class SW_DLLPUBLIC PercentField
|
||||
{
|
||||
VclPtr<MetricField> m_pField;
|
||||
|
||||
sal_Int64 nRefValue; // 100% value for conversion (in Twips)
|
||||
sal_Int64 nOldMax;
|
||||
sal_Int64 nOldMin;
|
||||
sal_Int64 nOldSpinSize;
|
||||
sal_Int64 nOldBaseValue;
|
||||
sal_Int64 nLastPercent;
|
||||
sal_Int64 nLastValue;
|
||||
sal_uInt16 nOldDigits;
|
||||
FieldUnit eOldUnit;
|
||||
bool bLockAutoCalculation; //prevent recalculation of percent values when the
|
||||
//reference value is changed
|
||||
|
||||
SAL_DLLPRIVATE static sal_Int64 ImpPower10(sal_uInt16 n);
|
||||
|
||||
public:
|
||||
|
||||
PercentField();
|
||||
void set(MetricField *pField);
|
||||
const MetricField* get() const { return m_pField; }
|
||||
MetricField* get() { return m_pField; }
|
||||
void SetModifyHdl(const Link<Edit&,void>& rLink) { m_pField->SetModifyHdl(rLink); }
|
||||
void SetLoseFocusHdl(const Link<Control&,void>& rLink) { m_pField->SetLoseFocusHdl(rLink); }
|
||||
void SetMetric(FieldUnit eUnit) { ::SetMetric(*m_pField, eUnit); }
|
||||
void Enable(bool bEnable = true) { m_pField->Enable(bEnable); }
|
||||
void Disable() { m_pField->Disable(); }
|
||||
|
||||
void SetValue(sal_Int64 nNewValue) { m_pField->SetValue(nNewValue, FieldUnit::NONE); }
|
||||
|
||||
void SetPrcntValue(sal_Int64 nNewValue, FieldUnit eInUnit = FieldUnit::NONE);
|
||||
|
||||
void SetUserValue(sal_Int64 nNewValue, FieldUnit eInUnit);
|
||||
|
||||
void SetBaseValue(sal_Int64 nNewValue, FieldUnit eInUnit);
|
||||
|
||||
sal_Int64 GetValue(FieldUnit eOutUnit = FieldUnit::NONE);
|
||||
|
||||
bool IsValueModified();
|
||||
|
||||
void SetMax(sal_Int64 nNewMax, FieldUnit eInUnit);
|
||||
|
||||
void SetMin(sal_Int64 nNewMin, FieldUnit eInUnit);
|
||||
|
||||
sal_Int64 GetMin() const { return m_pField->GetMin(); }
|
||||
|
||||
sal_Int64 NormalizePercent(sal_Int64 nValue);
|
||||
sal_Int64 DenormalizePercent(sal_Int64 nValue);
|
||||
|
||||
sal_Int64 Normalize( sal_Int64 nValue ) const { return m_pField->Normalize(nValue); }
|
||||
|
||||
void SetRefValue(sal_Int64 nValue);
|
||||
sal_Int64 GetRealValue(FieldUnit eOutUnit);
|
||||
|
||||
sal_Int64 Convert(sal_Int64 nValue, FieldUnit eInUnit, FieldUnit eOutUnit);
|
||||
|
||||
void ShowPercent(bool bPercent);
|
||||
|
||||
void LockAutoCalculation(bool bLock) {bLockAutoCalculation = bLock;}
|
||||
};
|
||||
|
||||
class SW_DLLPUBLIC SwPercentField
|
||||
{
|
||||
std::unique_ptr<weld::MetricSpinButton> m_pField;
|
||||
@@ -101,6 +38,8 @@ class SW_DLLPUBLIC SwPercentField
|
||||
int nLastValue;
|
||||
sal_uInt16 nOldDigits;
|
||||
FieldUnit eOldUnit;
|
||||
bool bLockAutoCalculation; //prevent recalculation of percent values when the
|
||||
//reference value is changed
|
||||
|
||||
SAL_DLLPRIVATE static int ImpPower10(sal_uInt16 n);
|
||||
|
||||
@@ -121,16 +60,19 @@ public:
|
||||
void SetMetricFieldMin(int nNewMin) { m_pField->set_min(nNewMin, FieldUnit::NONE); }
|
||||
void SetMetricFieldMax(int nNewMax) { m_pField->set_max(nNewMax, FieldUnit::NONE); }
|
||||
|
||||
void SetPrcntValue(int nNewValue, FieldUnit eInUnit = FieldUnit::NONE);
|
||||
|
||||
void set_value(int nNewValue, FieldUnit eInUnit = FieldUnit::NONE);
|
||||
int get_value(FieldUnit eOutUnit = FieldUnit::NONE);
|
||||
|
||||
void set_min(int nNewMin, FieldUnit eInUnit);
|
||||
void set_max(int nNewMax, FieldUnit eInUnit);
|
||||
|
||||
int get_min(FieldUnit eOutUnit = FieldUnit::NONE) const { return m_pField->get_min(eOutUnit); }
|
||||
|
||||
int NormalizePercent(int nValue);
|
||||
int DenormalizePercent(int nValue);
|
||||
|
||||
int normalize(int nValue) const { return m_pField->normalize(nValue); }
|
||||
|
||||
void SetRefValue(int nValue);
|
||||
int GetRealValue(FieldUnit eOutUnit);
|
||||
|
||||
@@ -138,6 +80,7 @@ public:
|
||||
|
||||
void ShowPercent(bool bPercent);
|
||||
|
||||
void LockAutoCalculation(bool bLock) {bLockAutoCalculation = bLock;}
|
||||
};
|
||||
|
||||
|
||||
|
@@ -19,266 +19,6 @@
|
||||
|
||||
#include <prcntfld.hxx>
|
||||
|
||||
PercentField::PercentField()
|
||||
: m_pField(nullptr)
|
||||
, nRefValue(0)
|
||||
, nOldMax(0)
|
||||
, nOldMin(0)
|
||||
, nOldSpinSize(0)
|
||||
, nOldBaseValue(0)
|
||||
, nLastPercent(-1)
|
||||
, nLastValue(-1)
|
||||
, nOldDigits(0)
|
||||
, eOldUnit(FieldUnit::NONE)
|
||||
, bLockAutoCalculation(false)
|
||||
{
|
||||
}
|
||||
|
||||
void PercentField::set(MetricField *pField)
|
||||
{
|
||||
m_pField = pField;
|
||||
nOldSpinSize = m_pField->GetSpinSize();
|
||||
nRefValue = DenormalizePercent(m_pField->GetMax(FieldUnit::TWIP));
|
||||
nOldDigits = m_pField->GetDecimalDigits();
|
||||
m_pField->SetCustomUnitText(OUString('%'));
|
||||
}
|
||||
|
||||
void PercentField::SetRefValue(sal_Int64 nValue)
|
||||
{
|
||||
sal_Int64 nRealValue = GetRealValue(eOldUnit);
|
||||
|
||||
nRefValue = nValue;
|
||||
|
||||
if (!bLockAutoCalculation && (m_pField->GetUnit() == FieldUnit::CUSTOM))
|
||||
SetPrcntValue(nRealValue, eOldUnit);
|
||||
}
|
||||
|
||||
void PercentField::ShowPercent(bool bPercent)
|
||||
{
|
||||
if ((bPercent && m_pField->GetUnit() == FieldUnit::CUSTOM) ||
|
||||
(!bPercent && m_pField->GetUnit() != FieldUnit::CUSTOM))
|
||||
return;
|
||||
|
||||
sal_Int64 nOldValue;
|
||||
|
||||
if (bPercent)
|
||||
{
|
||||
sal_Int64 nCurrentWidth, nPercent;
|
||||
|
||||
nOldValue = GetValue();
|
||||
|
||||
eOldUnit = m_pField->GetUnit();
|
||||
nOldDigits = m_pField->GetDecimalDigits();
|
||||
nOldMin = m_pField->GetMin();
|
||||
nOldMax = m_pField->GetMax();
|
||||
nOldSpinSize = m_pField->GetSpinSize();
|
||||
nOldBaseValue = m_pField->GetBaseValue();
|
||||
m_pField->SetUnit(FieldUnit::CUSTOM);
|
||||
m_pField->SetDecimalDigits( 0 );
|
||||
|
||||
nCurrentWidth = MetricField::ConvertValue(nOldMin, 0, nOldDigits, eOldUnit, FieldUnit::TWIP);
|
||||
// round to 0.5 percent
|
||||
nPercent = ((nCurrentWidth * 10) / nRefValue + 5) / 10;
|
||||
|
||||
m_pField->SetMin(std::max(static_cast< sal_Int64 >(1), nPercent));
|
||||
m_pField->SetMax(100);
|
||||
m_pField->SetSpinSize(5);
|
||||
m_pField->SetBaseValue(0);
|
||||
if (nOldValue != nLastValue)
|
||||
{
|
||||
nCurrentWidth = MetricField::ConvertValue(nOldValue, 0, nOldDigits, eOldUnit, FieldUnit::TWIP);
|
||||
nPercent = ((nCurrentWidth * 10) / nRefValue + 5) / 10;
|
||||
m_pField->SetValue(nPercent);
|
||||
nLastPercent = nPercent;
|
||||
nLastValue = nOldValue;
|
||||
}
|
||||
else
|
||||
m_pField->SetValue(nLastPercent);
|
||||
}
|
||||
else
|
||||
{
|
||||
sal_Int64 nOldPercent = GetValue(FieldUnit::CUSTOM);
|
||||
|
||||
nOldValue = Convert(GetValue(), m_pField->GetUnit(), eOldUnit);
|
||||
|
||||
m_pField->SetUnit(eOldUnit);
|
||||
m_pField->SetDecimalDigits(nOldDigits);
|
||||
m_pField->SetMin(nOldMin);
|
||||
m_pField->SetMax(nOldMax);
|
||||
m_pField->SetSpinSize(nOldSpinSize);
|
||||
m_pField->SetBaseValue(nOldBaseValue);
|
||||
|
||||
if (nOldPercent != nLastPercent)
|
||||
{
|
||||
SetPrcntValue(nOldValue, eOldUnit);
|
||||
nLastPercent = nOldPercent;
|
||||
nLastValue = nOldValue;
|
||||
}
|
||||
else
|
||||
SetPrcntValue(nLastValue, eOldUnit);
|
||||
}
|
||||
}
|
||||
|
||||
void PercentField::SetPrcntValue(sal_Int64 nNewValue, FieldUnit eInUnit)
|
||||
{
|
||||
if (m_pField->GetUnit() != FieldUnit::CUSTOM || eInUnit == FieldUnit::CUSTOM)
|
||||
m_pField->SetValue(Convert(nNewValue, eInUnit, m_pField->GetUnit()));
|
||||
else
|
||||
{
|
||||
// Overwrite output value, do not restore later
|
||||
sal_Int64 nPercent, nCurrentWidth;
|
||||
if(eInUnit == FieldUnit::TWIP)
|
||||
{
|
||||
nCurrentWidth = MetricField::ConvertValue(nNewValue, 0, nOldDigits, FieldUnit::TWIP, FieldUnit::TWIP);
|
||||
}
|
||||
else
|
||||
{
|
||||
sal_Int64 nValue = Convert(nNewValue, eInUnit, eOldUnit);
|
||||
nCurrentWidth = MetricField::ConvertValue(nValue, 0, nOldDigits, eOldUnit, FieldUnit::TWIP);
|
||||
}
|
||||
nPercent = ((nCurrentWidth * 10) / nRefValue + 5) / 10;
|
||||
m_pField->SetValue(nPercent);
|
||||
}
|
||||
}
|
||||
|
||||
void PercentField::SetBaseValue(sal_Int64 nNewValue, FieldUnit eInUnit)
|
||||
{
|
||||
if (m_pField->GetUnit() == FieldUnit::CUSTOM)
|
||||
nOldBaseValue = MetricField::ConvertValue(nNewValue, 0, nOldDigits, eInUnit, eOldUnit);
|
||||
else
|
||||
m_pField->SetBaseValue(nNewValue, eInUnit);
|
||||
}
|
||||
|
||||
sal_Int64 PercentField::GetValue(FieldUnit eOutUnit)
|
||||
{
|
||||
return Convert(m_pField->GetValue(), m_pField->GetUnit(), eOutUnit);
|
||||
}
|
||||
|
||||
void PercentField::SetMin(sal_Int64 nNewMin, FieldUnit eInUnit)
|
||||
{
|
||||
if (m_pField->GetUnit() != FieldUnit::CUSTOM)
|
||||
m_pField->SetMin(nNewMin, eInUnit);
|
||||
else
|
||||
{
|
||||
if (eInUnit == FieldUnit::NONE)
|
||||
eInUnit = eOldUnit;
|
||||
nOldMin = Convert(nNewMin, eInUnit, eOldUnit);
|
||||
|
||||
sal_Int64 nPercent = Convert(nNewMin, eInUnit, FieldUnit::CUSTOM);
|
||||
m_pField->SetMin(std::max( static_cast< sal_Int64 >(1), nPercent));
|
||||
}
|
||||
}
|
||||
|
||||
void PercentField::SetMax(sal_Int64 nNewMax, FieldUnit eInUnit)
|
||||
{
|
||||
if (m_pField->GetUnit() != FieldUnit::CUSTOM)
|
||||
m_pField->SetMax(nNewMax, eInUnit);
|
||||
}
|
||||
|
||||
sal_Int64 PercentField::NormalizePercent(sal_Int64 nValue)
|
||||
{
|
||||
if (m_pField->GetUnit() != FieldUnit::CUSTOM)
|
||||
nValue = m_pField->Normalize(nValue);
|
||||
else
|
||||
nValue = nValue * ImpPower10(nOldDigits);
|
||||
return nValue;
|
||||
}
|
||||
|
||||
sal_Int64 PercentField::DenormalizePercent(sal_Int64 nValue)
|
||||
{
|
||||
if (m_pField->GetUnit() != FieldUnit::CUSTOM)
|
||||
nValue = m_pField->Denormalize(nValue);
|
||||
else
|
||||
{
|
||||
sal_Int64 nFactor = ImpPower10(nOldDigits);
|
||||
nValue = ((nValue+(nFactor/2)) / nFactor);
|
||||
}
|
||||
return nValue;
|
||||
}
|
||||
|
||||
bool PercentField::IsValueModified()
|
||||
{
|
||||
if (m_pField->GetUnit() == FieldUnit::CUSTOM)
|
||||
return true;
|
||||
else
|
||||
return m_pField->IsValueModified();
|
||||
}
|
||||
|
||||
void PercentField::SetUserValue(sal_Int64 nNewValue, FieldUnit eInUnit)
|
||||
{
|
||||
if (m_pField->GetUnit() != FieldUnit::CUSTOM || eInUnit == FieldUnit::CUSTOM)
|
||||
m_pField->SetUserValue(Convert(nNewValue, eInUnit, m_pField->GetUnit()),FieldUnit::NONE);
|
||||
else
|
||||
{
|
||||
// Overwrite output value, do not restore later
|
||||
sal_Int64 nPercent, nCurrentWidth;
|
||||
if (eInUnit == FieldUnit::TWIP)
|
||||
{
|
||||
nCurrentWidth = MetricField::ConvertValue(nNewValue, 0, nOldDigits, FieldUnit::TWIP, FieldUnit::TWIP);
|
||||
}
|
||||
else
|
||||
{
|
||||
sal_Int64 nValue = Convert(nNewValue, eInUnit, eOldUnit);
|
||||
nCurrentWidth = MetricField::ConvertValue(nValue, 0, nOldDigits, eOldUnit, FieldUnit::TWIP);
|
||||
}
|
||||
nPercent = ((nCurrentWidth * 10) / nRefValue + 5) / 10;
|
||||
m_pField->SetUserValue(nPercent,FieldUnit::NONE);
|
||||
}
|
||||
}
|
||||
|
||||
sal_Int64 PercentField::ImpPower10(sal_uInt16 n)
|
||||
{
|
||||
sal_Int64 nValue = 1;
|
||||
|
||||
for (sal_uInt16 i=0; i < n; ++i)
|
||||
nValue *= 10;
|
||||
|
||||
return nValue;
|
||||
}
|
||||
|
||||
sal_Int64 PercentField::GetRealValue(FieldUnit eOutUnit)
|
||||
{
|
||||
if (m_pField->GetUnit() != FieldUnit::CUSTOM)
|
||||
return GetValue(eOutUnit);
|
||||
else
|
||||
return Convert(GetValue(), m_pField->GetUnit(), eOutUnit);
|
||||
}
|
||||
|
||||
sal_Int64 PercentField::Convert(sal_Int64 nValue, FieldUnit eInUnit, FieldUnit eOutUnit)
|
||||
{
|
||||
if (eInUnit == eOutUnit ||
|
||||
(eInUnit == FieldUnit::NONE && eOutUnit == m_pField->GetUnit()) ||
|
||||
(eOutUnit == FieldUnit::NONE && eInUnit == m_pField->GetUnit()))
|
||||
return nValue;
|
||||
|
||||
if (eInUnit == FieldUnit::CUSTOM)
|
||||
{
|
||||
// Convert to metric
|
||||
sal_Int64 nTwipValue = (nRefValue * nValue + 50) / 100;
|
||||
|
||||
if (eOutUnit == FieldUnit::TWIP) // Only convert if necessary
|
||||
return NormalizePercent(nTwipValue);
|
||||
else
|
||||
return MetricField::ConvertValue(NormalizePercent(nTwipValue), 0, nOldDigits, FieldUnit::TWIP, eOutUnit);
|
||||
}
|
||||
|
||||
if (eOutUnit == FieldUnit::CUSTOM)
|
||||
{
|
||||
// Convert to percent
|
||||
sal_Int64 nCurrentWidth;
|
||||
nValue = DenormalizePercent(nValue);
|
||||
|
||||
if (eInUnit == FieldUnit::TWIP) // Only convert if necessary
|
||||
nCurrentWidth = nValue;
|
||||
else
|
||||
nCurrentWidth = MetricField::ConvertValue(nValue, 0, nOldDigits, eInUnit, FieldUnit::TWIP);
|
||||
// Round to 0.5 percent
|
||||
return ((nCurrentWidth * 1000) / nRefValue + 5) / 10;
|
||||
}
|
||||
|
||||
return MetricField::ConvertValue(nValue, 0, nOldDigits, eInUnit, eOutUnit);
|
||||
}
|
||||
|
||||
SwPercentField::SwPercentField(std::unique_ptr<weld::MetricSpinButton> pControl)
|
||||
: m_pField(std::move(pControl))
|
||||
, nOldMax(0)
|
||||
@@ -287,6 +27,7 @@ SwPercentField::SwPercentField(std::unique_ptr<weld::MetricSpinButton> pControl)
|
||||
, nLastValue(-1)
|
||||
, nOldDigits(m_pField->get_digits())
|
||||
, eOldUnit(FieldUnit::NONE)
|
||||
, bLockAutoCalculation(false)
|
||||
{
|
||||
int nMin, nMax;
|
||||
m_pField->get_range(nMin, nMax, FieldUnit::TWIP);
|
||||
@@ -300,8 +41,8 @@ void SwPercentField::SetRefValue(int nValue)
|
||||
|
||||
nRefValue = nValue;
|
||||
|
||||
if (m_pField->get_unit() == FieldUnit::PERCENT)
|
||||
SetPrcntValue(nRealValue, eOldUnit);
|
||||
if (!bLockAutoCalculation && (m_pField->get_unit() == FieldUnit::PERCENT))
|
||||
set_value(nRealValue, eOldUnit);
|
||||
}
|
||||
|
||||
void SwPercentField::ShowPercent(bool bPercent)
|
||||
@@ -355,16 +96,16 @@ void SwPercentField::ShowPercent(bool bPercent)
|
||||
|
||||
if (nOldPercent != nLastPercent)
|
||||
{
|
||||
SetPrcntValue(nOldValue, eOldUnit);
|
||||
set_value(nOldValue, eOldUnit);
|
||||
nLastPercent = nOldPercent;
|
||||
nLastValue = nOldValue;
|
||||
}
|
||||
else
|
||||
SetPrcntValue(nLastValue, eOldUnit);
|
||||
set_value(nLastValue, eOldUnit);
|
||||
}
|
||||
}
|
||||
|
||||
void SwPercentField::SetPrcntValue(int nNewValue, FieldUnit eInUnit)
|
||||
void SwPercentField::set_value(int nNewValue, FieldUnit eInUnit)
|
||||
{
|
||||
if (m_pField->get_unit() != FieldUnit::PERCENT || eInUnit == FieldUnit::PERCENT)
|
||||
m_pField->set_value(Convert(nNewValue, eInUnit, m_pField->get_unit()), FieldUnit::NONE);
|
||||
|
@@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- Generated with glade 3.18.3 -->
|
||||
<!-- Generated with glade 3.22.1 -->
|
||||
<interface domain="sw">
|
||||
<requires lib="gtk+" version="3.18"/>
|
||||
<requires lib="LibreOffice" version="1.0"/>
|
||||
@@ -15,6 +15,18 @@
|
||||
<property name="step_increment">1</property>
|
||||
<property name="page_increment">10</property>
|
||||
</object>
|
||||
<object class="GtkAdjustment" id="adjustment3">
|
||||
<property name="lower">0.050000000000000003</property>
|
||||
<property name="upper">99.989999999999995</property>
|
||||
<property name="step_increment">1</property>
|
||||
<property name="page_increment">10</property>
|
||||
</object>
|
||||
<object class="GtkAdjustment" id="adjustment4">
|
||||
<property name="lower">-99.989999999999995</property>
|
||||
<property name="upper">99.989999999999995</property>
|
||||
<property name="step_increment">1</property>
|
||||
<property name="page_increment">10</property>
|
||||
</object>
|
||||
<object class="GtkGrid" id="FrameTypePage">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
@@ -56,9 +68,10 @@
|
||||
<property name="row_spacing">6</property>
|
||||
<property name="column_spacing">12</property>
|
||||
<child>
|
||||
<object class="GtkSpinButton" id="width:0.00cm">
|
||||
<object class="GtkSpinButton" id="width">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="activates_default">True</property>
|
||||
<property name="adjustment">adjustment1</property>
|
||||
<property name="digits">2</property>
|
||||
</object>
|
||||
@@ -95,7 +108,7 @@
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label" translatable="yes" context="frmtypepage|autowidthft">_Width (at least)</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="mnemonic_widget">width:0.00cm</property>
|
||||
<property name="mnemonic_widget">width</property>
|
||||
<property name="xalign">0</property>
|
||||
</object>
|
||||
<packing>
|
||||
@@ -109,7 +122,7 @@
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label" translatable="yes" context="frmtypepage|widthft">_Width</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="mnemonic_widget">width:0.00cm</property>
|
||||
<property name="mnemonic_widget">width</property>
|
||||
<property name="xalign">0</property>
|
||||
</object>
|
||||
<packing>
|
||||
@@ -180,10 +193,11 @@
|
||||
<property name="row_spacing">6</property>
|
||||
<property name="column_spacing">12</property>
|
||||
<child>
|
||||
<object class="GtkSpinButton" id="height:0.00cm">
|
||||
<object class="GtkSpinButton" id="height">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="adjustment">adjustment1</property>
|
||||
<property name="activates_default">True</property>
|
||||
<property name="adjustment">adjustment3</property>
|
||||
<property name="digits">2</property>
|
||||
</object>
|
||||
<packing>
|
||||
@@ -219,7 +233,7 @@
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label" translatable="yes" context="frmtypepage|autoheightft">H_eight (at least)</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="mnemonic_widget">height:0.00cm</property>
|
||||
<property name="mnemonic_widget">height</property>
|
||||
<property name="xalign">0</property>
|
||||
</object>
|
||||
<packing>
|
||||
@@ -233,7 +247,7 @@
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label" translatable="yes" context="frmtypepage|heightft">H_eight</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="mnemonic_widget">height:0.00cm</property>
|
||||
<property name="mnemonic_widget">height</property>
|
||||
<property name="xalign">0</property>
|
||||
</object>
|
||||
<packing>
|
||||
@@ -351,7 +365,7 @@
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<child>
|
||||
<object class="svxlo-SvxSwFrameExample" id="preview">
|
||||
<object class="GtkDrawingArea" id="preview">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="halign">center</property>
|
||||
@@ -398,7 +412,6 @@
|
||||
<property name="xalign">0</property>
|
||||
<property name="active">True</property>
|
||||
<property name="draw_indicator">True</property>
|
||||
<property name="group">topara</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">0</property>
|
||||
@@ -414,7 +427,7 @@
|
||||
<property name="use_underline">True</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="draw_indicator">True</property>
|
||||
<property name="group">tochar</property>
|
||||
<property name="group">topage</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">0</property>
|
||||
@@ -430,7 +443,7 @@
|
||||
<property name="use_underline">True</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="draw_indicator">True</property>
|
||||
<property name="group">aschar</property>
|
||||
<property name="group">topage</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">0</property>
|
||||
@@ -446,7 +459,7 @@
|
||||
<property name="use_underline">True</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="draw_indicator">True</property>
|
||||
<property name="group">toframe</property>
|
||||
<property name="group">topage</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">0</property>
|
||||
@@ -533,7 +546,7 @@
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label" translatable="yes" context="frmtypepage|horibyft">b_y</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="mnemonic_widget">byhori:0.00cm</property>
|
||||
<property name="mnemonic_widget">byhori</property>
|
||||
<property name="xalign">0</property>
|
||||
</object>
|
||||
<packing>
|
||||
@@ -547,7 +560,7 @@
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label" translatable="yes" context="frmtypepage|vertbyft">by</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="mnemonic_widget">byvert:0.00cm</property>
|
||||
<property name="mnemonic_widget">byvert</property>
|
||||
<property name="xalign">0</property>
|
||||
</object>
|
||||
<packing>
|
||||
@@ -570,9 +583,10 @@
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkSpinButton" id="byhori:0.00cm">
|
||||
<object class="GtkSpinButton" id="byhori">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="activates_default">True</property>
|
||||
<property name="adjustment">adjustment2</property>
|
||||
<property name="digits">2</property>
|
||||
</object>
|
||||
@@ -626,10 +640,11 @@
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkSpinButton" id="byvert:0.00cm">
|
||||
<object class="GtkSpinButton" id="byvert">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="adjustment">adjustment2</property>
|
||||
<property name="activates_default">True</property>
|
||||
<property name="adjustment">adjustment4</property>
|
||||
<property name="digits">2</property>
|
||||
</object>
|
||||
<packing>
|
||||
|
Reference in New Issue
Block a user