summaryrefslogtreecommitdiff
path: root/editeng
diff options
context:
space:
mode:
authorCédric Bosdonnat <cedricbosdo@openoffice.org>2011-01-03 14:08:36 +0100
committerCédric Bosdonnat <cedricbosdo@openoffice.org>2011-03-19 17:57:16 +0100
commit0b5e60bc602da708ce31565a01d886af43bf0a15 (patch)
tree1d114254b556fdd62b87cddc4926847f649aa9cc /editeng
parentf32570fa1dd3808ba4ebde6e8e359e5132cc9cdf (diff)
Documented and Unit-tested the SvxBorderLine::SetLinesWidth
Diffstat (limited to 'editeng')
-rwxr-xr-xediteng/CppunitTest_editeng_borderline.mk64
-rwxr-xr-xediteng/Library_editeng.mk1
-rwxr-xr-xediteng/inc/editeng/borderline.hxx41
-rwxr-xr-xediteng/prj/build.lst1
-rw-r--r--editeng/qa/items/borderline_test.cxx110
-rw-r--r--editeng/qa/items/makefile.mk94
-rw-r--r--editeng/qa/items/version.map34
-rw-r--r--editeng/source/items/borderline.cxx473
-rw-r--r--editeng/source/items/frmitems.cxx384
-rw-r--r--editeng/source/items/makefile.mk1
10 files changed, 813 insertions, 390 deletions
diff --git a/editeng/CppunitTest_editeng_borderline.mk b/editeng/CppunitTest_editeng_borderline.mk
new file mode 100755
index 0000000000..6a8e847276
--- /dev/null
+++ b/editeng/CppunitTest_editeng_borderline.mk
@@ -0,0 +1,64 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2011 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+$(eval $(call gb_CppunitTest_CppunitTest,editeng_borderline))
+
+$(eval $(call gb_CppunitTest_add_exception_objects,editeng_borderline, \
+ editeng/qa/items/borderline_test \
+))
+
+$(eval $(call gb_CppunitTest_add_linked_libs,editeng_borderline, \
+ xo \
+ basegfx \
+ editeng \
+ lng \
+ svt \
+ tk \
+ vcl \
+ svl \
+ sot \
+ utl \
+ tl \
+ comphelper \
+ ucbhelper \
+ cppuhelper \
+ cppu \
+ sal \
+ salhelper \
+ icuuc \
+ i18nisolang1 \
+ i18npaper \
+ $(gb_STDLIBS) \
+))
+
+$(eval $(call gb_CppunitTest_set_include,editeng_borderline,\
+ $$(INCLUDE) \
+ -I$(OUTDIR)/inc/offuh \
+ -I$(OUTDIR)/inc \
+))
+
+# vim: set noet sw=4 ts=4:
diff --git a/editeng/Library_editeng.mk b/editeng/Library_editeng.mk
index 408d8deb8d..df11ba7fb5 100755
--- a/editeng/Library_editeng.mk
+++ b/editeng/Library_editeng.mk
@@ -82,6 +82,7 @@ $(eval $(call gb_Library_add_exception_objects,editeng,\
editeng/source/editeng/impedit4 \
editeng/source/editeng/impedit5 \
editeng/source/editeng/textconv \
+ editeng/source/items/borderline \
editeng/source/items/bulitem \
editeng/source/items/charhiddenitem \
editeng/source/items/flditem \
diff --git a/editeng/inc/editeng/borderline.hxx b/editeng/inc/editeng/borderline.hxx
index 51bea3ecea..68be9986ad 100755
--- a/editeng/inc/editeng/borderline.hxx
+++ b/editeng/inc/editeng/borderline.hxx
@@ -107,7 +107,8 @@ enum SvxBorderStyle
EMBOSSED,
ENGRAVED,
OUTSET,
- INSET
+ INSET,
+ NONE = -1
};
class EDITENG_DLLPUBLIC SvxBorderLine
@@ -115,7 +116,8 @@ class EDITENG_DLLPUBLIC SvxBorderLine
protected:
Color aColor;
- double m_nWidth;
+ long m_nWidth;
+ bool m_bMirrorWidths;
BorderWidthImpl m_aWidthImpl;
long m_nMult;
long m_nDiv;
@@ -148,10 +150,39 @@ public:
Color GetColorGap() const;
void SetWidth( long nWidth = 0 ) { m_nWidth = nWidth; }
+ /** Guess the style and width from the three lines widths values.
+
+ When the value of nStyle is SvxBorderLine::DOUBLE, the style set will be guessed
+ using the three values to match the best possible style among the following:
+ - SvxBorderLine::DOUBLE
+ - SvxBorderLine::THINTHICK_SMALLGAP
+ - SvxBorderLine::THINTHICK_MEDIUMGAP
+ - SvxBorderLine::THINTHICK_LARGEGAP
+ - SvxBorderLine::THICKTHIN_SMALLGAP
+ - SvxBorderLine::THICKTHIN_MEDIUMGAP
+ - SvxBorderLine::THICKTHIN_LARGEGAP
+
+ If no styles matches the width, then the width is set to 0.
+
+ There is one known case that could fit several styles: \a nIn = \a nDist = 0.75 pt,
+ \a nOut = 1.5 pt. This case fits SvxBorderLine::THINTHICK_SMALLGAP and
+ SvxBorderLine::THINTHICK_MEDIUMGAP with a 1.5 pt width and
+ SvxBorderLine::THINTHICK_LARGEGAP with a 0.75 pt width. The same case happens
+ also for thick-thin styles.
+
+ \param nStyle the border style used to guess the width.
+ \param nIn the width of the inner line in 1th pt
+ \param nOut the width of the outer line in 1th pt
+ \param nDist the width of the gap between the lines in 1th pt
+ */
void SetLinesWidths( SvxBorderStyle nStyle, sal_uInt16 nIn, sal_uInt16 nOut, sal_uInt16 nDist );
- sal_uInt16 GetOutWidth() const;
+
+ // TODO Hacky method to mirror lines in only a few cases
+ void SetMirrorWidths( bool bMirror = true ) { m_bMirrorWidths = bMirror; }
+ long GetWidth( ) const { return m_nWidth; }
+ sal_uInt16 GetOutWidth() const;
sal_uInt16 GetInWidth() const;
- sal_uInt16 GetDistance() const;
+ sal_uInt16 GetDistance() const;
SvxBorderStyle GetStyle() const { return m_nStyle; }
@@ -173,7 +204,7 @@ public:
bool isEmpty() const { return m_aWidthImpl.IsEmpty( ); }
bool isDouble() const { return m_aWidthImpl.IsDouble(); }
- sal_uInt16 getWidth() const { return GetOutWidth() + GetInWidth() + GetDistance(); }
+ sal_uInt16 GetScaledWidth() const { return GetOutWidth() + GetInWidth() + GetDistance(); }
static Color darkColor( Color aMain );
static Color lightColor( Color aMain );
diff --git a/editeng/prj/build.lst b/editeng/prj/build.lst
index bba7f26667..838b288d27 100755
--- a/editeng/prj/build.lst
+++ b/editeng/prj/build.lst
@@ -1,3 +1,2 @@
ed editeng : L10N:l10n svtools xmloff linguistic NULL
ed editeng\prj nmake - all ed_prj NULL
-
diff --git a/editeng/qa/items/borderline_test.cxx b/editeng/qa/items/borderline_test.cxx
new file mode 100644
index 0000000000..ad8ba40d58
--- /dev/null
+++ b/editeng/qa/items/borderline_test.cxx
@@ -0,0 +1,110 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * Version: MPL 1.1 / GPLv3+ / LGPLv3+
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (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.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Initial Developer of the Original Code is
+ * [ insert your name / company etc. here eg. Jim Bob <jim@bob.org> ]
+ * Portions created by the Initial Developer are Copyright (C) 2010 the
+ * Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s): Jim Bob <jim@bob.org>
+ * Ted <ted@bear.com>
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
+ * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
+ * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
+ * instead of those above.
+ */
+
+#include <cppunit/TestFixture.h>
+#include <cppunit/extensions/HelperMacros.h>
+#include <cppunit/plugin/TestPlugIn.h>
+
+#include <editeng/borderline.hxx>
+
+#define TEST_WIDTH long( 200 )
+
+#define THINTHICKSG_IN_WIDTH long( 200 )
+#define THINTHICKSG_OUT_WIDTH long( 75 )
+#define THINTHICKSG_DIST_WIDTH long( 75 )
+
+#define THINTHICKLG_IN_WIDTH long( 75 )
+#define THINTHICKLG_OUT_WIDTH long( 150 )
+#define THINTHICKLG_DIST_WIDTH long( 200 )
+
+namespace {
+
+class BorderLineTest : public CppUnit::TestFixture
+{
+ public:
+ void testGuessWidthDouble();
+ void testGuessWidthNoMatch();
+ void testGuessWidthThinthickSmallgap();
+ void testGuessWidthThinthickLargegap();
+
+ CPPUNIT_TEST_SUITE(BorderLineTest);
+ CPPUNIT_TEST(testGuessWidthDouble);
+ CPPUNIT_TEST(testGuessWidthNoMatch);
+ CPPUNIT_TEST(testGuessWidthThinthickSmallgap);
+ CPPUNIT_TEST(testGuessWidthThinthickLargegap);
+ CPPUNIT_TEST_SUITE_END();
+};
+
+CPPUNIT_TEST_SUITE_REGISTRATION(BorderLineTest);
+
+void BorderLineTest::testGuessWidthDouble()
+{
+ // Normal double case
+ SvxBorderLine line;
+ line.SetLinesWidths( DOUBLE, TEST_WIDTH, TEST_WIDTH, TEST_WIDTH );
+ CPPUNIT_ASSERT_EQUAL( DOUBLE, line.GetStyle() );
+ CPPUNIT_ASSERT_EQUAL( TEST_WIDTH, line.GetWidth() );
+}
+
+void BorderLineTest::testGuessWidthNoMatch()
+{
+ SvxBorderLine line;
+ line.SetLinesWidths( DOUBLE,
+ 1, 2, 3 );
+ CPPUNIT_ASSERT_EQUAL( DOUBLE, line.GetStyle() );
+ CPPUNIT_ASSERT_EQUAL( long( 0 ), line.GetWidth() );
+}
+
+void BorderLineTest::testGuessWidthThinthickSmallgap()
+{
+ SvxBorderLine line;
+ line.SetLinesWidths( DOUBLE,
+ THINTHICKSG_IN_WIDTH,
+ THINTHICKSG_OUT_WIDTH,
+ THINTHICKSG_DIST_WIDTH );
+ CPPUNIT_ASSERT_EQUAL( THINTHICK_SMALLGAP, line.GetStyle() );
+ CPPUNIT_ASSERT_EQUAL( TEST_WIDTH, line.GetWidth() );
+}
+
+void BorderLineTest::testGuessWidthThinthickLargegap()
+{
+ SvxBorderLine line;
+ line.SetLinesWidths( DOUBLE,
+ THINTHICKLG_IN_WIDTH,
+ THINTHICKLG_OUT_WIDTH,
+ THINTHICKLG_DIST_WIDTH );
+ CPPUNIT_ASSERT_EQUAL( THINTHICK_LARGEGAP, line.GetStyle() );
+ CPPUNIT_ASSERT_EQUAL( TEST_WIDTH, line.GetWidth() );
+}
+
+}
+
+CPPUNIT_PLUGIN_IMPLEMENT();
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/editeng/qa/items/makefile.mk b/editeng/qa/items/makefile.mk
new file mode 100644
index 0000000000..3d6b16eda5
--- /dev/null
+++ b/editeng/qa/items/makefile.mk
@@ -0,0 +1,94 @@
+#
+# Version: MPL 1.1 / GPLv3+ / LGPLv3+
+#
+# The contents of this file are subject to the Mozilla Public License Version
+# 1.1 (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.mozilla.org/MPL/
+#
+# Software distributed under the License is distributed on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+# for the specific language governing rights and limitations under the
+# License.
+#
+# The Initial Developer of the Original Code is
+# [ Novell Inc. Cédric Bosdonnat <cbosdonnat@novell.com> ]
+# Portions created by the Initial Developer are Copyright (C) 2010 the
+# Initial Developer. All Rights Reserved.
+#
+# Contributor(s):
+#
+# Alternatively, the contents of this file may be used under the terms of
+# either the GNU General Public License Version 3 or later (the "GPLv3+"), or
+# the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
+# in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
+# instead of those above.
+#
+PRJ=..$/..
+
+PRJNAME=editeng
+TARGET=test-items
+ENABLE_EXCEPTIONS=TRUE
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+
+#building with stlport, but cppunit was not built with stlport
+.IF "$(USE_SYSTEM_STL)"!="YES"
+.IF "$(SYSTEM_CPPUNIT)"=="YES"
+CFLAGSCXX+=-DADAPT_EXT_STL
+.ENDIF
+.ENDIF
+
+CFLAGSCXX += $(CPPUNIT_CFLAGS)
+DLLPRE = # no leading "lib" on .so files
+
+
+# --- Targets ------------------------------------------------------
+
+SHL1TARGET = borderline_test
+SHL1OBJS = \
+ $(SLO)$/borderline_test.obj
+
+SHL1LIBS= \
+ $(SLB)$/items.lib \
+ $(SLB)$/misc.lib \
+ $(SLB)$/rtf.lib \
+ $(SLB)$/uno.lib \
+ $(SLB)$/accessibility.lib \
+ $(SLB)$/editeng.lib \
+ $(SLB)$/outliner.lib \
+ $(SLB)$/xml.lib
+
+SHL1STDLIBS= \
+ $(CPPUNITLIB) \
+ $(XMLOFFLIB) \
+ $(BASEGFXLIB) \
+ $(LNGLIB) \
+ $(SVTOOLLIB) \
+ $(TKLIB) \
+ $(VCLLIB) \
+ $(SVLLIB) \
+ $(SOTLIB) \
+ $(UNOTOOLSLIB) \
+ $(TOOLSLIB) \
+ $(I18NISOLANGLIB) \
+ $(I18NPAPERLIB) \
+ $(COMPHELPERLIB) \
+ $(UCBHELPERLIB) \
+ $(CPPUHELPERLIB) \
+ $(CPPULIB) \
+ $(SALLIB) \
+ $(SALHELPERLIB) \
+ $(ICUUCLIB)
+
+SHL1VERSIONMAP = version.map
+SHL1IMPLIB = i$(SHL1TARGET)
+DEF1NAME = $(SHL1TARGET)
+
+
+SLOFILES = $(SHL1OBJS)
+
+.INCLUDE : target.mk
+.INCLUDE : _cppunit.mk
diff --git a/editeng/qa/items/version.map b/editeng/qa/items/version.map
new file mode 100644
index 0000000000..01cc9afa06
--- /dev/null
+++ b/editeng/qa/items/version.map
@@ -0,0 +1,34 @@
+#
+# Version: MPL 1.1 / GPLv3+ / LGPLv3+
+#
+# The contents of this file are subject to the Mozilla Public License Version
+# 1.1 (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.mozilla.org/MPL/
+#
+# Software distributed under the License is distributed on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+# for the specific language governing rights and limitations under the
+# License.
+#
+# The Initial Developer of the Original Code is
+# [ insert your name / company etc. here eg. Jim Bob <jim@bob.org> ]
+# Portions created by the Initial Developer are Copyright (C) 2010 the
+# Initial Developer. All Rights Reserved.
+#
+# Contributor(s): Jim Bob <jim@bob.org>
+# Ted <ted@bear.com>
+#
+# Alternatively, the contents of this file may be used under the terms of
+# either the GNU General Public License Version 3 or later (the "GPLv3+"), or
+# the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
+# in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
+# instead of those above.
+#
+UDK_3_0_0 {
+ global:
+ cppunitTestPlugIn;
+
+ local:
+ *;
+};
diff --git a/editeng/source/items/borderline.cxx b/editeng/source/items/borderline.cxx
new file mode 100644
index 0000000000..038158574b
--- /dev/null
+++ b/editeng/source/items/borderline.cxx
@@ -0,0 +1,473 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_editeng.hxx"
+
+
+// include ---------------------------------------------------------------
+#include <basegfx/color/bcolor.hxx>
+#include <basegfx/color/bcolortools.hxx>
+
+#include <editeng/borderline.hxx>
+#include <editeng/itemtype.hxx>
+
+// class SvxBorderLine --------------------------------------------------
+
+Color SvxBorderLine::darkColor( Color aMain )
+{
+ return aMain;
+}
+
+Color SvxBorderLine::lightColor( Color aMain )
+{
+
+ // Divide Luminance by 2
+ basegfx::BColor color = aMain.getBColor( );
+ basegfx::BColor hsl = basegfx::tools::rgb2hsl( color );
+ hsl.setZ( hsl.getZ() * 0.5 );
+ color = basegfx::tools::hsl2rgb( hsl );
+
+ return Color( color );
+}
+
+Color lcl_compute3DColor( Color aMain, int nLight, int nMedium, int nDark )
+{
+ basegfx::BColor color = aMain.getBColor( );
+ basegfx::BColor hsl = basegfx::tools::rgb2hsl( color );
+
+ int nCoef = 0;
+ if ( hsl.getZ( ) >= 0.5 )
+ nCoef = nLight;
+ else if ( 0.5 > hsl.getZ() && hsl.getZ() >= 0.25 )
+ nCoef = nMedium;
+ else
+ nCoef = nDark;
+
+ double L = hsl.getZ() * 255.0 + nCoef;
+ hsl.setZ( L / 255.0 );
+ color = basegfx::tools::hsl2rgb( hsl );
+
+ return Color( color );
+}
+
+Color SvxBorderLine::threeDLightColor( Color aMain )
+{
+ // These values have been defined in an empirical way
+ return lcl_compute3DColor( aMain, 3, 40, 83 );
+}
+
+Color SvxBorderLine::threeDDarkColor( Color aMain )
+{
+ // These values have been defined in an empirical way
+ return lcl_compute3DColor( aMain, -85, -43, -1 );
+}
+
+Color SvxBorderLine::threeDMediumColor( Color aMain )
+{
+ // These values have been defined in an empirical way
+ return lcl_compute3DColor( aMain, -42, -0, 42 );
+}
+
+SvxBorderLine::SvxBorderLine( const Color *pCol, long nWidth,
+ SvxBorderStyle nStyle, bool bUseLeftTop,
+ Color (*pColorOutFn)( Color ), Color (*pColorInFn)( Color ),
+ Color (*pColorGapFn)( Color ) )
+: m_nWidth( nWidth )
+, m_aWidthImpl( SvxBorderLine::getWidthImpl( nStyle ) )
+, m_nMult( 1 )
+, m_nDiv( 1 )
+, m_nStyle( nStyle )
+, m_bUseLeftTop( bUseLeftTop )
+, m_pColorOutFn( pColorOutFn )
+, m_pColorInFn( pColorInFn )
+, m_pColorGapFn( pColorGapFn )
+{
+ if ( pCol )
+ aColor = *pCol;
+}
+
+BorderWidthImpl SvxBorderLine::getWidthImpl( SvxBorderStyle nStyle )
+{
+ BorderWidthImpl aImpl;
+
+ switch ( nStyle )
+ {
+ // No line: no width
+ case NONE:
+ aImpl = BorderWidthImpl( CHANGE_LINE1, 0.0 );
+ break;
+
+ // Single lines
+ case SOLID:
+ case DOTTED:
+ case DASHED:
+ aImpl = BorderWidthImpl( CHANGE_LINE1, 1.0 );
+ break;
+
+ // Double lines
+
+ case DOUBLE:
+ aImpl = BorderWidthImpl(
+ CHANGE_LINE1 | CHANGE_LINE2 | CHANGE_DIST,
+ 1.0, 1.0, 1.0 );
+ break;
+
+ case THINTHICK_SMALLGAP:
+ aImpl = BorderWidthImpl( CHANGE_LINE1, 1.0, 75.0, 75.0 );
+ break;
+
+ case THINTHICK_MEDIUMGAP:
+ aImpl = BorderWidthImpl(
+ CHANGE_LINE1 | CHANGE_LINE2 | CHANGE_DIST,
+ 1.0, 0.5, 0.5 );
+ break;
+
+ case THINTHICK_LARGEGAP:
+ aImpl = BorderWidthImpl( CHANGE_DIST, 75.0, 150.0, 1.0 );
+ break;
+
+ case THICKTHIN_SMALLGAP:
+ aImpl = BorderWidthImpl( CHANGE_DIST, 75.0, 1.0, 75.0 );
+ break;
+
+ case THICKTHIN_MEDIUMGAP:
+ aImpl = BorderWidthImpl(
+ CHANGE_LINE1 | CHANGE_LINE2 | CHANGE_DIST,
+ 0.5, 1.0, 0.5 );
+ break;
+
+ case THICKTHIN_LARGEGAP:
+ aImpl = BorderWidthImpl( CHANGE_DIST, 150.0, 75.0, 1.0 );
+ break;
+
+ // Engraved / Embossed
+ /*
+ * Word compat: the lines widths are exactly following this rule, shouldbe:
+ * 0.75pt up to 3pt and then 3pt
+ */
+
+ case EMBOSSED:
+ case ENGRAVED:
+ aImpl = BorderWidthImpl(
+ CHANGE_LINE1 | CHANGE_LINE2 | CHANGE_DIST,
+ 0.5, 0.5, 1.0 );
+ break;
+
+ // Inset / Outset
+ /*
+ * Word compat: the gap width should be measured relatively to the biggest width for the
+ * row or column.
+ */
+ case OUTSET:
+ aImpl = BorderWidthImpl(
+ CHANGE_LINE2 | CHANGE_DIST,
+ 75.0, 1.0, 1.0 );
+ break;
+
+ case INSET:
+ aImpl = BorderWidthImpl(
+ CHANGE_LINE1 | CHANGE_DIST,
+ 1.0, 75.0, 1.0 );
+ break;
+ }
+
+ return aImpl;
+}
+
+// -----------------------------------------------------------------------
+
+SvxBorderLine::SvxBorderLine( const SvxBorderLine& r )
+{
+ *this = r;
+}
+
+// -----------------------------------------------------------------------
+
+SvxBorderLine& SvxBorderLine::operator=( const SvxBorderLine& r )
+{
+ aColor = r.aColor;
+ m_aWidthImpl = r.m_aWidthImpl;
+ m_nStyle = r.m_nStyle;
+ m_bUseLeftTop = r.m_bUseLeftTop;
+ m_pColorOutFn = r.m_pColorOutFn;
+ m_pColorInFn = r.m_pColorInFn;
+ m_pColorGapFn = r.m_pColorGapFn;
+ return *this;
+}
+
+// -----------------------------------------------------------------------
+
+void SvxBorderLine::ScaleMetrics( long nMult, long nDiv )
+{
+ m_nMult = nMult;
+ m_nDiv = nDiv;
+}
+
+void SvxBorderLine::SetLinesWidths( SvxBorderStyle nStyle, sal_uInt16 nIn, sal_uInt16 nOut, sal_uInt16 nDist )
+{
+ if ( nStyle == DOUBLE )
+ {
+ static SvxBorderStyle aDoubleStyles[] =
+ {
+ DOUBLE,
+ THINTHICK_SMALLGAP,
+ THINTHICK_MEDIUMGAP,
+ THINTHICK_LARGEGAP,
+ THICKTHIN_SMALLGAP,
+ THICKTHIN_MEDIUMGAP,
+ THICKTHIN_LARGEGAP
+ };
+
+
+ int i = 0, len = sizeof( aDoubleStyles ) / sizeof( SvxBorderStyle );
+ long nWidth = 0;
+ SvxBorderStyle nTestStyle;
+ while ( i < len && nWidth == 0 )
+ {
+ nTestStyle = aDoubleStyles[i];
+ BorderWidthImpl aWidthImpl = getWidthImpl( nTestStyle );
+ nWidth = aWidthImpl.GuessWidth( nIn, nOut, nDist );
+ i++;
+ }
+
+ // If anything matched, then set it
+ if ( nWidth > 0 )
+ nStyle = nTestStyle;
+
+ SetStyle( nStyle );
+ m_nWidth = nWidth;
+ }
+ else
+ {
+ SetStyle( nStyle );
+ m_nWidth = m_aWidthImpl.GuessWidth( nIn, nOut, nDist );
+ }
+}
+
+sal_uInt16 SvxBorderLine::GetOutWidth() const
+{
+ sal_uInt16 nOut = (sal_uInt16)Scale( m_aWidthImpl.GetLine2( m_nWidth ), m_nMult, m_nDiv );
+ if ( m_bMirrorWidths )
+ nOut = (sal_uInt16)Scale( m_aWidthImpl.GetLine2( m_nWidth ), m_nMult, m_nDiv );
+ return nOut;
+}
+
+sal_uInt16 SvxBorderLine::GetInWidth() const
+{
+ sal_uInt16 nIn = (sal_uInt16)Scale( m_aWidthImpl.GetLine1( m_nWidth ), m_nMult, m_nDiv );
+ if ( m_bMirrorWidths )
+ nIn = (sal_uInt16)Scale( m_aWidthImpl.GetLine1( m_nWidth ), m_nMult, m_nDiv );
+ return nIn;
+}
+
+sal_uInt16 SvxBorderLine::GetDistance() const
+{
+ return (sal_uInt16)Scale( m_aWidthImpl.GetGap( m_nWidth ), m_nMult, m_nDiv );
+}
+
+// -----------------------------------------------------------------------
+
+sal_Bool SvxBorderLine::operator==( const SvxBorderLine& rCmp ) const
+{
+ return ( ( aColor == rCmp.aColor ) &&
+ ( m_aWidthImpl == rCmp.m_aWidthImpl ) &&
+ ( m_nStyle == rCmp.GetStyle() ) &&
+ ( m_bUseLeftTop == rCmp.m_bUseLeftTop ) &&
+ ( m_pColorOutFn == rCmp.m_pColorOutFn ) &&
+ ( m_pColorInFn == rCmp.m_pColorInFn ) &&
+ ( m_pColorGapFn == rCmp.m_pColorGapFn ) );
+}
+
+void SvxBorderLine::SetStyle( SvxBorderStyle nNew )
+{
+ m_nStyle = nNew;
+ switch ( nNew )
+ {
+ case EMBOSSED:
+ m_pColorOutFn = threeDLightColor;
+ m_pColorInFn = threeDDarkColor;
+ m_pColorGapFn = threeDMediumColor;
+ m_bUseLeftTop = true;
+ break;
+ case ENGRAVED:
+ m_pColorOutFn = threeDDarkColor;
+ m_pColorInFn = threeDLightColor;
+ m_pColorGapFn = threeDMediumColor;
+ m_bUseLeftTop = true;
+ break;
+ case OUTSET:
+ m_pColorOutFn = lightColor;
+ m_pColorInFn = darkColor;
+ m_bUseLeftTop = true;
+ m_pColorGapFn = NULL;
+ break;
+ case INSET:
+ m_pColorOutFn = darkColor;
+ m_pColorInFn = lightColor;
+ m_bUseLeftTop = true;
+ m_pColorGapFn = NULL;
+ break;
+ default:
+ m_pColorOutFn = darkColor;
+ m_pColorInFn = darkColor;
+ m_bUseLeftTop = false;
+ m_pColorGapFn = NULL;
+ break;
+ }
+}
+
+Color SvxBorderLine::GetColorOut( bool bLeftOrTop ) const
+{
+ Color aResult = aColor;
+
+ if ( m_aWidthImpl.IsDouble() && m_pColorOutFn != NULL )
+ {
+ if ( !bLeftOrTop && m_bUseLeftTop )
+ aResult = (*m_pColorInFn)( aColor );
+ else
+ aResult = (*m_pColorOutFn)( aColor );
+ }
+
+ return aResult;
+}
+
+Color SvxBorderLine::GetColorIn( bool bLeftOrTop ) const
+{
+ Color aResult = aColor;
+
+ if ( m_aWidthImpl.IsDouble() && m_pColorInFn != NULL )
+ {
+ if ( !bLeftOrTop && m_bUseLeftTop )
+ aResult = (*m_pColorOutFn)( aColor );
+ else
+ aResult = (*m_pColorInFn)( aColor );
+ }
+
+ return aResult;
+}
+
+Color SvxBorderLine::GetColorGap( ) const
+{
+ Color aResult = aColor;
+
+ if ( m_aWidthImpl.IsDouble() && m_pColorGapFn != NULL )
+ {
+ aResult = (*m_pColorGapFn)( aColor );
+ }
+
+ return aResult;
+}
+
+// -----------------------------------------------------------------------
+
+XubString SvxBorderLine::GetValueString( SfxMapUnit eSrcUnit,
+ SfxMapUnit eDestUnit,
+ const IntlWrapper* pIntl,
+ sal_Bool bMetricStr) const
+{
+#ifndef SVX_LIGHT
+
+ static const sal_uInt16 aStyleIds[] =
+ {
+ RID_SOLID,
+ RID_DOTTED,
+ RID_DASHED,
+ RID_DOUBLE,
+ RID_THINTHICK_SMALLGAP,
+ RID_THINTHICK_MEDIUMGAP,
+ RID_THINTHICK_LARGEGAP,
+ RID_THICKTHIN_SMALLGAP,
+ RID_THICKTHIN_MEDIUMGAP,
+ RID_THICKTHIN_LARGEGAP,
+ RID_EMBOSSED,
+ RID_ENGRAVED,
+ RID_OUTSET,
+ RID_INSET
+ };
+ sal_uInt16 nResId = aStyleIds[m_nStyle];
+ String aStr;
+ aStr += sal_Unicode('(');
+ aStr += ::GetColorString( aColor );
+ aStr += cpDelim;
+
+ if ( nResId )
+ aStr += EE_RESSTR(nResId);
+ else
+ {
+ String sMetric = EE_RESSTR(GetMetricId( eDestUnit ));
+ aStr += GetMetricText( (long)GetInWidth(), eSrcUnit, eDestUnit, pIntl );
+ if ( bMetricStr )
+ aStr += sMetric;
+ aStr += cpDelim;
+ aStr += GetMetricText( (long)GetOutWidth(), eSrcUnit, eDestUnit, pIntl );
+ if ( bMetricStr )
+ aStr += sMetric;
+ aStr += cpDelim;
+ aStr += GetMetricText( (long)GetDistance(), eSrcUnit, eDestUnit, pIntl );
+ if ( bMetricStr )
+ aStr += sMetric;
+ }
+ aStr += sal_Unicode(')');
+ return aStr;
+#else
+ return UniString();
+#endif
+}
+
+bool SvxBorderLine::HasPriority( const SvxBorderLine& rOtherLine ) const
+{
+ const sal_uInt16 nThisSize = GetOutWidth() + GetDistance() + GetInWidth();
+ const sal_uInt16 nOtherSize = rOtherLine.GetOutWidth() + rOtherLine.GetDistance() + rOtherLine.GetInWidth();
+
+ if (nThisSize > nOtherSize)
+ {
+ return true;
+ }
+ else if (nThisSize < nOtherSize)
+ {
+ return false;
+ }
+ else
+ {
+ if ( rOtherLine.GetInWidth() && !GetInWidth() )
+ {
+ return true;
+ }
+ else if ( GetInWidth() && !rOtherLine.GetInWidth() )
+ {
+ return false;
+ }
+ else
+ {
+ return false;
+ }
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/editeng/source/items/frmitems.cxx b/editeng/source/items/frmitems.cxx
index e5a1df7a66..4e92082b9d 100644
--- a/editeng/source/items/frmitems.cxx
+++ b/editeng/source/items/frmitems.cxx
@@ -94,9 +94,6 @@
#include <editeng/memberids.hrc>
#include <editeng/editerr.hxx>
-#include <basegfx/color/bcolor.hxx>
-#include <basegfx/color/bcolortools.hxx>
-
using namespace ::rtl;
using namespace ::com::sun::star;
@@ -1544,387 +1541,6 @@ void SvxShadowItem::SetEnumValue( sal_uInt16 nVal )
SetLocation( (const SvxShadowLocation)nVal );
}
-// class SvxBorderLine --------------------------------------------------
-
-Color SvxBorderLine::darkColor( Color aMain )
-{
- return aMain;
-}
-
-Color SvxBorderLine::lightColor( Color aMain )
-{
-
- // Divide Luminance by 2
- basegfx::BColor color = aMain.getBColor( );
- basegfx::BColor hsl = basegfx::tools::rgb2hsl( color );
- hsl.setZ( hsl.getZ() * 0.5 );
- color = basegfx::tools::hsl2rgb( hsl );
-
- return Color( color );
-}
-
-Color lcl_compute3DColor( Color aMain, int nLight, int nMedium, int nDark )
-{
- basegfx::BColor color = aMain.getBColor( );
- basegfx::BColor hsl = basegfx::tools::rgb2hsl( color );
-
- int nCoef = 0;
- if ( hsl.getZ( ) >= 0.5 )
- nCoef = nLight;
- else if ( 0.5 > hsl.getZ() && hsl.getZ() >= 0.25 )
- nCoef = nMedium;
- else
- nCoef = nDark;
-
- double L = hsl.getZ() * 255.0 + nCoef;
- hsl.setZ( L / 255.0 );
- color = basegfx::tools::hsl2rgb( hsl );
-
- return Color( color );
-}
-
-Color SvxBorderLine::threeDLightColor( Color aMain )
-{
- // These values have been defined in an empirical way
- return lcl_compute3DColor( aMain, 3, 40, 83 );
-}
-
-Color SvxBorderLine::threeDDarkColor( Color aMain )
-{
- // These values have been defined in an empirical way
- return lcl_compute3DColor( aMain, -85, -43, -1 );
-}
-
-Color SvxBorderLine::threeDMediumColor( Color aMain )
-{
- // These values have been defined in an empirical way
- return lcl_compute3DColor( aMain, -42, -0, 42 );
-}
-
-SvxBorderLine::SvxBorderLine( const Color *pCol, long nWidth,
- SvxBorderStyle nStyle, bool bUseLeftTop,
- Color (*pColorOutFn)( Color ), Color (*pColorInFn)( Color ),
- Color (*pColorGapFn)( Color ) )
-: m_nWidth( nWidth )
-, m_aWidthImpl( SvxBorderLine::getWidthImpl( nStyle ) )
-, m_nMult( 1 )
-, m_nDiv( 1 )
-, m_nStyle( nStyle )
-, m_bUseLeftTop( bUseLeftTop )
-, m_pColorOutFn( pColorOutFn )
-, m_pColorInFn( pColorInFn )
-, m_pColorGapFn( pColorGapFn )
-{
- if ( pCol )
- aColor = *pCol;
-}
-
-BorderWidthImpl SvxBorderLine::getWidthImpl( SvxBorderStyle nStyle )
-{
- BorderWidthImpl aImpl;
-
- switch ( nStyle )
- {
- case SOLID:
- case DOTTED:
- case DASHED:
- aImpl = BorderWidthImpl( CHANGE_LINE1, 1.0 );
- break;
-
- // Double lines
-
- case DOUBLE:
- aImpl = BorderWidthImpl(
- CHANGE_LINE1 | CHANGE_LINE2 | CHANGE_DIST,
- 1.0, 1.0, 1.0 );
- break;
-
- case THINTHICK_SMALLGAP:
- aImpl = BorderWidthImpl( CHANGE_LINE1, 1.0, 75.0, 75.0 );
- break;
-
- case THINTHICK_MEDIUMGAP:
- aImpl = BorderWidthImpl(
- CHANGE_LINE1 | CHANGE_LINE2 | CHANGE_DIST,
- 1.0, 0.5, 0.5 );
- break;
-
- case THINTHICK_LARGEGAP:
- aImpl = BorderWidthImpl( CHANGE_DIST, 75.0, 150.0, 1.0 );
- break;
-
- case THICKTHIN_SMALLGAP:
- aImpl = BorderWidthImpl( CHANGE_DIST, 75.0, 1.0, 75.0 );
- break;
-
- case THICKTHIN_MEDIUMGAP:
- aImpl = BorderWidthImpl(
- CHANGE_LINE1 | CHANGE_LINE2 | CHANGE_DIST,
- 0.5, 1.0, 0.5 );
- break;
-
- case THICKTHIN_LARGEGAP:
- aImpl = BorderWidthImpl( CHANGE_DIST, 150.0, 75.0, 1.0 );
- break;
-
- // Engraved / Embossed
- /*
- * Word compat: the lines widths are exactly following this rule, shouldbe:
- * 0.75pt up to 3pt and then 3pt
- */
-
- case EMBOSSED:
- case ENGRAVED:
- aImpl = BorderWidthImpl(
- CHANGE_LINE1 | CHANGE_LINE2 | CHANGE_DIST,
- 0.5, 0.5, 1.0 );
- break;
-
- // Inset / Outset
- /*
- * Word compat: the gap width should be measured relatively to the biggest width for the
- * row or column.
- */
- case OUTSET:
- aImpl = BorderWidthImpl(
- CHANGE_LINE2 | CHANGE_DIST,
- 75.0, 1.0, 1.0 );
- break;
-
- case INSET:
- aImpl = BorderWidthImpl(
- CHANGE_LINE1 | CHANGE_DIST,
- 1.0, 75.0, 1.0 );
- break;
- }
-
- return aImpl;
-}
-
-// -----------------------------------------------------------------------
-
-SvxBorderLine::SvxBorderLine( const SvxBorderLine& r )
-{
- *this = r;
-}
-
-// -----------------------------------------------------------------------
-
-SvxBorderLine& SvxBorderLine::operator=( const SvxBorderLine& r )
-{
- aColor = r.aColor;
- m_aWidthImpl = r.m_aWidthImpl;
- m_nStyle = r.m_nStyle;
- m_bUseLeftTop = r.m_bUseLeftTop;
- m_pColorOutFn = r.m_pColorOutFn;
- m_pColorInFn = r.m_pColorInFn;
- m_pColorGapFn = r.m_pColorGapFn;
- return *this;
-}
-
-// -----------------------------------------------------------------------
-
-void SvxBorderLine::ScaleMetrics( long nMult, long nDiv )
-{
- m_nMult = nMult;
- m_nDiv = nDiv;
-}
-
-void SvxBorderLine::SetLinesWidths( SvxBorderStyle nStyle, sal_uInt16 nIn, sal_uInt16 nOut, sal_uInt16 nDist )
-{
- SetStyle( nStyle );
- m_nWidth = m_aWidthImpl.GuessWidth( nIn, nOut, nDist );
-}
-
-sal_uInt16 SvxBorderLine::GetOutWidth() const
-{
- return (sal_uInt16)Scale( m_aWidthImpl.GetLine2( m_nWidth ), m_nMult, m_nDiv );
-}
-
-sal_uInt16 SvxBorderLine::GetInWidth() const
-{
- return (sal_uInt16)Scale( m_aWidthImpl.GetLine1( m_nWidth ), m_nMult, m_nDiv );
-}
-
-sal_uInt16 SvxBorderLine::GetDistance() const
-{
- return (sal_uInt16)Scale( m_aWidthImpl.GetGap( m_nWidth ), m_nMult, m_nDiv );
-}
-
-// -----------------------------------------------------------------------
-
-sal_Bool SvxBorderLine::operator==( const SvxBorderLine& rCmp ) const
-{
- return ( ( aColor == rCmp.aColor ) &&
- ( m_aWidthImpl == rCmp.m_aWidthImpl ) &&
- ( m_nStyle == rCmp.GetStyle() ) &&
- ( m_bUseLeftTop == rCmp.m_bUseLeftTop ) &&
- ( m_pColorOutFn == rCmp.m_pColorOutFn ) &&
- ( m_pColorInFn == rCmp.m_pColorInFn ) &&
- ( m_pColorGapFn == rCmp.m_pColorGapFn ) );
-}
-
-void SvxBorderLine::SetStyle( SvxBorderStyle nNew )
-{
- m_nStyle = nNew;
- switch ( nNew )
- {
- case EMBOSSED:
- m_pColorOutFn = threeDLightColor;
- m_pColorInFn = threeDDarkColor;
- m_pColorGapFn = threeDMediumColor;
- m_bUseLeftTop = true;
- break;
- case ENGRAVED:
- m_pColorOutFn = threeDDarkColor;
- m_pColorInFn = threeDLightColor;
- m_pColorGapFn = threeDMediumColor;
- m_bUseLeftTop = true;
- break;
- case OUTSET:
- m_pColorOutFn = lightColor;
- m_pColorInFn = darkColor;
- m_bUseLeftTop = true;
- m_pColorGapFn = NULL;
- break;
- case INSET:
- m_pColorOutFn = darkColor;
- m_pColorInFn = lightColor;
- m_bUseLeftTop = true;
- m_pColorGapFn = NULL;
- break;
- default:
- m_pColorOutFn = darkColor;
- m_pColorInFn = darkColor;
- m_bUseLeftTop = false;
- m_pColorGapFn = NULL;
- break;
- }
-}
-
-Color SvxBorderLine::GetColorOut( bool bLeftOrTop ) const
-{
- Color aResult = aColor;
-
- if ( m_aWidthImpl.IsDouble() && m_pColorOutFn != NULL )
- {
- if ( !bLeftOrTop && m_bUseLeftTop )
- aResult = (*m_pColorInFn)( aColor );
- else
- aResult = (*m_pColorOutFn)( aColor );
- }
-
- return aResult;
-}
-
-Color SvxBorderLine::GetColorIn( bool bLeftOrTop ) const
-{
- Color aResult = aColor;
-
- if ( m_aWidthImpl.IsDouble() && m_pColorInFn != NULL )
- {
- if ( !bLeftOrTop && m_bUseLeftTop )
- aResult = (*m_pColorOutFn)( aColor );
- else
- aResult = (*m_pColorInFn)( aColor );
- }
-
- return aResult;
-}
-
-Color SvxBorderLine::GetColorGap( ) const
-{
- Color aResult = aColor;
-
- if ( m_aWidthImpl.IsDouble() && m_pColorGapFn != NULL )
- {
- aResult = (*m_pColorGapFn)( aColor );
- }
-
- return aResult;
-}
-
-// -----------------------------------------------------------------------
-
-XubString SvxBorderLine::GetValueString( SfxMapUnit eSrcUnit,
- SfxMapUnit eDestUnit,
- const IntlWrapper* pIntl,
- sal_Bool bMetricStr) const
-{
- static const sal_uInt16 aStyleIds[] =
- {
- RID_SOLID,
- RID_DOTTED,
- RID_DASHED,
- RID_DOUBLE,
- RID_THINTHICK_SMALLGAP,
- RID_THINTHICK_MEDIUMGAP,
- RID_THINTHICK_LARGEGAP,
- RID_THICKTHIN_SMALLGAP,
- RID_THICKTHIN_MEDIUMGAP,
- RID_THICKTHIN_LARGEGAP,
- RID_EMBOSSED,
- RID_ENGRAVED,
- RID_OUTSET,
- RID_INSET
- };
- sal_uInt16 nResId = aStyleIds[m_nStyle];
- String aStr;
- aStr += sal_Unicode('(');
- aStr += ::GetColorString( aColor );
- aStr += cpDelim;
-
- if ( nResId )
- aStr += EE_RESSTR(nResId);
- else
- {
- String sMetric = EE_RESSTR(GetMetricId( eDestUnit ));
- aStr += GetMetricText( (long)GetInWidth(), eSrcUnit, eDestUnit, pIntl );
- if ( bMetricStr )
- aStr += sMetric;
- aStr += cpDelim;
- aStr += GetMetricText( (long)GetOutWidth(), eSrcUnit, eDestUnit, pIntl );
- if ( bMetricStr )
- aStr += sMetric;
- aStr += cpDelim;
- aStr += GetMetricText( (long)GetDistance(), eSrcUnit, eDestUnit, pIntl );
- if ( bMetricStr )
- aStr += sMetric;
- }
- aStr += sal_Unicode(')');
- return aStr;
-}
-
-bool SvxBorderLine::HasPriority( const SvxBorderLine& rOtherLine ) const
-{
- const sal_uInt16 nThisSize = GetOutWidth() + GetDistance() + GetInWidth();
- const sal_uInt16 nOtherSize = rOtherLine.GetOutWidth() + rOtherLine.GetDistance() + rOtherLine.GetInWidth();
-
- if (nThisSize > nOtherSize)
- {
- return true;
- }
- else if (nThisSize < nOtherSize)
- {
- return false;
- }
- else
- {
- if ( rOtherLine.GetInWidth() && !GetInWidth() )
- {
- return true;
- }
- else if ( GetInWidth() && !rOtherLine.GetInWidth() )
- {
- return false;
- }
- else
- {
- return false;
- }
- }
-}
-
// class SvxBoxItem ------------------------------------------------------
SvxBoxItem::SvxBoxItem( const SvxBoxItem& rCpy ) :
diff --git a/editeng/source/items/makefile.mk b/editeng/source/items/makefile.mk
index 350d9cbede..9ebb12c66f 100644
--- a/editeng/source/items/makefile.mk
+++ b/editeng/source/items/makefile.mk
@@ -53,6 +53,7 @@ EXCEPTIONSFILES= \
$(SLO)$/bulitem.obj \
$(SLO)$/flditem.obj \
$(SLO)$/frmitems.obj \
+ $(SLO)$/borderline.obj \
$(SLO)$/itemtype.obj \
$(SLO)$/numitem.obj \
$(SLO)$/paperinf.obj \