[Libreoffice-commits] .: 3 commits - basegfx/inc basegfx/Library_basegfx.mk basegfx/Package_inc.mk basegfx/source basegfx/StaticLibrary_basegfx_s.mk Makefile sc/source sd/source solenv/bin svx/inc svx/source sw/source

Jan Holesovsky kendy at kemper.freedesktop.org
Wed Jan 25 03:36:23 PST 2012


 Makefile                                |    5 +
 basegfx/Library_basegfx.mk              |    1 
 basegfx/Package_inc.mk                  |    1 
 basegfx/StaticLibrary_basegfx_s.mk      |    1 
 basegfx/inc/basegfx/tools/zoomtools.hxx |   52 +++++++++++
 basegfx/source/tools/zoomtools.cxx      |  150 ++++++++++++++++++++++++++++++++
 sc/source/ui/view/prevwsh.cxx           |    6 -
 sc/source/ui/view/tabview.cxx           |    7 -
 sd/source/ui/view/viewshel.cxx          |    7 -
 solenv/bin/mkdocs.sh                    |    2 
 svx/inc/svx/zoom_def.hxx                |    4 
 svx/source/stbctrls/zoomsliderctrl.cxx  |    7 -
 sw/source/ui/uiview/viewport.cxx        |    7 -
 13 files changed, 226 insertions(+), 24 deletions(-)

New commits:
commit 3092e57f0c46ab1eafebcff0ad875acdd49d4e45
Author: Jan Holesovsky <kendy at suse.cz>
Date:   Wed Jan 25 12:35:29 2012 +0100

    Add a note to the toplevel Makefile where to actually edit stuff.

diff --git a/Makefile b/Makefile
index 9f6c897..ed8e30e 100644
--- a/Makefile
+++ b/Makefile
@@ -26,6 +26,11 @@
 #
 #*************************************************************************
 
+# The real targets are in solenv/gbuild/Module.mk, resp.
+# solenv/gbuild/extensions/post_BuildplTargets.mk, this file only forwards
+# the calls - please look there if you want to edit what this toplevel
+# Makefile does.
+
 SRCDIR:=$(patsubst %/,%,$(dir $(realpath $(firstword $(MAKEFILE_LIST)))))
 
 ifeq ($(strip $(gb_SourceEnvAndRecurse_STAGE)),)
commit 1195d989d454a96e3b9fb0c0b6053db61b68f0b1
Author: Jan Holesovsky <kendy at suse.cz>
Date:   Wed Jan 25 12:34:56 2012 +0100

    Allow killing 'make docs' by Ctrl-c.

diff --git a/solenv/bin/mkdocs.sh b/solenv/bin/mkdocs.sh
index 1112b0f..dbf4c46 100755
--- a/solenv/bin/mkdocs.sh
+++ b/solenv/bin/mkdocs.sh
@@ -89,7 +89,7 @@ do
   echo "Ref-Tags:   $DOXYGEN_REF_TAGFILES"
   echo "Title:      $DOXYGEN_PROJECTNAME"
 
-  nice -15 doxygen "$DOXYGEN_CFG"
+  nice -15 doxygen "$DOXYGEN_CFG" || exit 1
 
   # setup referenced tagfiles for next round
   DOXYGEN_REF_TAGFILES="$DOXYGEN_REF_TAGFILES $DOXYGEN_OUR_TAGFILE=$BASE_URL/$PROJECT/html"
commit 315d2ddc161e4b296febe9e54c3cfc9270310bfe
Author: Tim Hardeck <thardeck at suse.com>
Date:   Wed Jan 18 16:42:55 2012 +0100

    optimized zoom to use more common intervals
    
    Round zoom values beginning with 50 to a multiple of 5, with 100 to one
    of 10, with 500 to one of 50 and with 1000 to one of 100.
    The step 100 is enforced to have one fixed point.

diff --git a/basegfx/Library_basegfx.mk b/basegfx/Library_basegfx.mk
index fa0607b..fc6a479 100644
--- a/basegfx/Library_basegfx.mk
+++ b/basegfx/Library_basegfx.mk
@@ -66,6 +66,7 @@ $(eval $(call gb_Library_add_linked_libs,basegfx,\
 $(eval $(call gb_Library_add_exception_objects,basegfx,\
 	basegfx/source/tools/b2dclipstate \
 	basegfx/source/tools/canvastools \
+	basegfx/source/tools/zoomtools \
 	basegfx/source/tools/gradienttools \
 	basegfx/source/tools/keystoplerp \
 	basegfx/source/tools/liangbarsky \
diff --git a/basegfx/Package_inc.mk b/basegfx/Package_inc.mk
index 5767a8f..13b5ff8 100644
--- a/basegfx/Package_inc.mk
+++ b/basegfx/Package_inc.mk
@@ -37,6 +37,7 @@ $(eval $(call gb_Package_add_file,basegfx_inc,inc/basegfx/tools/unopolypolygon.h
 $(eval $(call gb_Package_add_file,basegfx_inc,inc/basegfx/tools/tools.hxx,basegfx/tools/tools.hxx))
 $(eval $(call gb_Package_add_file,basegfx_inc,inc/basegfx/tools/unotools.hxx,basegfx/tools/unotools.hxx))
 $(eval $(call gb_Package_add_file,basegfx_inc,inc/basegfx/tools/gradienttools.hxx,basegfx/tools/gradienttools.hxx))
+$(eval $(call gb_Package_add_file,basegfx_inc,inc/basegfx/tools/zoomtools.hxx,basegfx/tools/zoomtools.hxx))
 $(eval $(call gb_Package_add_file,basegfx_inc,inc/basegfx/numeric/ftools.hxx,basegfx/numeric/ftools.hxx))
 $(eval $(call gb_Package_add_file,basegfx_inc,inc/basegfx/tuple/b3i64tuple.hxx,basegfx/tuple/b3i64tuple.hxx))
 $(eval $(call gb_Package_add_file,basegfx_inc,inc/basegfx/tuple/b3dtuple.hxx,basegfx/tuple/b3dtuple.hxx))
diff --git a/basegfx/StaticLibrary_basegfx_s.mk b/basegfx/StaticLibrary_basegfx_s.mk
index 79d6ed9..69616f7 100644
--- a/basegfx/StaticLibrary_basegfx_s.mk
+++ b/basegfx/StaticLibrary_basegfx_s.mk
@@ -72,6 +72,7 @@ $(WORKDIR)/CustomTarget/basegfx/source/%.cxx : $(SRCDIR)/basegfx/source/%.cxx
 $(eval $(call gb_StaticLibrary_add_generated_exception_objects,basegfx_s,\
 	CustomTarget/basegfx/source/tools/liangbarsky \
 	CustomTarget/basegfx/source/tools/canvastools \
+	CustomTarget/basegfx/source/tools/zoomtools \
 	CustomTarget/basegfx/source/tools/gradienttools \
 	CustomTarget/basegfx/source/tools/keystoplerp \
 	CustomTarget/basegfx/source/tools/unopolypolygon \
diff --git a/basegfx/inc/basegfx/tools/zoomtools.hxx b/basegfx/inc/basegfx/tools/zoomtools.hxx
new file mode 100644
index 0000000..566418d
--- /dev/null
+++ b/basegfx/inc/basegfx/tools/zoomtools.hxx
@@ -0,0 +1,52 @@
+/* -*- 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 or as specified alternatively below. 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.
+ *
+ * Major Contributor(s):
+ * Copyright (C) 2012 Tim Hardeck <thardeck at suse.com>
+ *
+ * All Rights Reserved.
+ *
+ * For minor contributions see the git repository.
+ *
+ * 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.
+ */
+
+#ifndef _BGFX_TOOLS_ZOOMTOOLS_HXX
+#define _BGFX_TOOLS_ZOOMTOOLS_HXX
+
+#include <sal/types.h>
+#include <basegfx/basegfxdllapi.h>
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace basegfx
+{
+    /** This namespace provides functions for optimized geometric zooming
+    */
+    namespace zoomtools
+    {
+        BASEGFX_DLLPUBLIC long zoomOut(long nCurrent);
+        BASEGFX_DLLPUBLIC long zoomIn(long nCurrent);
+        BASEGFX_DLLPUBLIC int zoomOut(int nCurrent);
+        BASEGFX_DLLPUBLIC int zoomIn(int nCurrent);
+    }
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/basegfx/source/tools/zoomtools.cxx b/basegfx/source/tools/zoomtools.cxx
new file mode 100644
index 0000000..c6c8044
--- /dev/null
+++ b/basegfx/source/tools/zoomtools.cxx
@@ -0,0 +1,150 @@
+/* -*- 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 or as specified alternatively below. 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.
+ *
+ * Major Contributor(s):
+ * Copyright (C) 2012 Tim Hardeck <thardeck at suse.com>
+ *
+ * All Rights Reserved.
+ *
+ * For minor contributions see the git repository.
+ *
+ * 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 <basegfx/tools/zoomtools.hxx>
+
+namespace basegfx
+{
+namespace zoomtools
+{
+
+/** 2^(1/4) as the default step
+
+    This ensures (unless the rounding is used) that 4 steps lead
+    to double / half zoom level.
+*/
+const double ZOOM_FACTOR = 1.1892071150027210667175;
+
+/**
+* Round a value against a specified multiple. Values below half
+* of the multiple are rounded down and all others are rounded up.
+*
+* @param nCurrent current value
+* @param nMultiple multiple against which the current value is rounded
+*/
+static long roundMultiple(long nCurrent, int nMultiple)
+{
+    // round zoom to a multiple of nMultiple
+    return (( nCurrent + nMultiple / 2 ) - ( nCurrent + nMultiple / 2 ) % nMultiple);
+}
+
+/**
+* Convert geometric progression results into more common values by
+* rounding them against certain multiples depending on the size.
+* Beginning with 50 the multiple is 5, with 100, 10, and so on.
+*
+* @param nCurrent current zoom factor
+*/
+static long roundZoom(double nCurrent)
+{
+    // convert nCurrent properly to int
+    long nNew = nCurrent + 0.5;
+
+    // round to more common numbers above 50
+    if (nNew > 1000) {
+        nNew = roundMultiple(nNew, 100);
+    } else if ( nNew > 500 ) {
+        nNew = roundMultiple(nNew, 50);
+    } else if ( nNew > 100 ) {
+        nNew = roundMultiple(nNew, 10);
+    } else if ( nNew > 50 ) {
+        nNew = roundMultiple(nNew, 5);
+    }
+
+    return nNew;
+}
+
+/**
+* Make sure that a certain step isn't skipped during the zooming
+* progress.
+*
+* @param nCurrent current zoom factor
+* @param nPrevious previous zoom factor
+* @param nStep step which shouldn't be skipped
+*/
+static long enforceStep(long nCurrent, long nPrevious, int nStep)
+{
+    if ((( nCurrent > nStep ) && ( nPrevious < nStep ))
+    || (( nCurrent < nStep ) && ( nPrevious > nStep )))
+        return nStep;
+    else
+        return nCurrent;
+}
+
+/**
+* Increasing the zoom level.
+*
+* @param nCurrent current zoom factor
+*/
+long zoomIn(long nCurrent)
+{
+    long nNew = roundZoom( nCurrent * ZOOM_FACTOR );
+    // make sure 100% isn't skipped
+    nNew = enforceStep(nNew, nCurrent, 100);
+    nNew = enforceStep(nNew, nCurrent, 25);
+    return nNew;
+}
+
+/**
+* Decreasing the zoom level.
+*
+* @param nCurrent current zoom factor
+*/
+long zoomOut(long nCurrent)
+{
+    long nNew = roundZoom( nCurrent / ZOOM_FACTOR );
+    // make sure 100% isn't skipped
+    nNew = enforceStep(nNew, nCurrent, 100);
+    nNew = enforceStep(nNew, nCurrent, 25);
+    return nNew;
+}
+
+/**
+* Increasing the zoom level.
+*
+* @param nCurrent current zoom factor
+*/
+int zoomIn(int nCurrent)
+{
+    return static_cast<int>( zoomIn( long( nCurrent ) ) );
+}
+
+/**
+* Decreasing the zoom level.
+*
+* @param nCurrent current zoom factor
+*/
+int zoomOut(int nCurrent)
+{
+    return static_cast<int>( zoomOut( long( nCurrent ) ) );
+}
+
+} // namespace zoomtools
+} // namespace basegfx
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/view/prevwsh.cxx b/sc/source/ui/view/prevwsh.cxx
index e85f9ca..9dbe51f 100644
--- a/sc/source/ui/view/prevwsh.cxx
+++ b/sc/source/ui/view/prevwsh.cxx
@@ -75,8 +75,8 @@
 #include <svx/svxdlg.hxx>
 #include <svx/dialogs.hrc>
 
+#include <basegfx/tools/zoomtools.hxx>
 #include <svx/zoom_def.hxx>
-#include <rtl/math.hxx>
 
 #include "sc.hrc"
 #include "scabstdlg.hxx"
@@ -449,9 +449,9 @@ sal_Bool ScPreviewShell::ScrollCommand( const CommandEvent& rCEvt )
         long nOld = pPreview->GetZoom();
         long nNew = nOld;
         if ( pData->GetDelta() < 0 )
-            nNew = Max( (long) MINZOOM, (long)::rtl::math::round( nOld / ZOOM_FACTOR ));
+            nNew = Max( (long) MINZOOM, basegfx::zoomtools::zoomOut( nOld ));
         else
-            nNew = Min( (long) MAXZOOM, (long)::rtl::math::round( nOld * ZOOM_FACTOR ));
+            nNew = Min( (long) MAXZOOM, basegfx::zoomtools::zoomIn( nOld ));
 
         if ( nNew != nOld )
         {
diff --git a/sc/source/ui/view/tabview.cxx b/sc/source/ui/view/tabview.cxx
index 326af1a..8e8124a 100644
--- a/sc/source/ui/view/tabview.cxx
+++ b/sc/source/ui/view/tabview.cxx
@@ -149,8 +149,7 @@
 #include <string>
 #include <algorithm>
 
-#include <svx/zoom_def.hxx>
-#include <rtl/math.hxx>
+#include <basegfx/tools/zoomtools.hxx>
 
 #define SPLIT_MARGIN    30
 #define SC_ICONSIZE     36
@@ -1060,9 +1059,9 @@ bool ScTabView::ScrollCommand( const CommandEvent& rCEvt, ScSplitPos ePos )
             long nOld = (long)(( rOldY.GetNumerator() * 100 ) / rOldY.GetDenominator());
             long nNew = nOld;
             if ( pData->GetDelta() < 0 )
-                nNew = Max( (long) MINZOOM, (long)::rtl::math::round( nOld / ZOOM_FACTOR ));
+                nNew = Max( (long) MINZOOM, basegfx::zoomtools::zoomOut( nOld ));
             else
-                nNew = Min( (long) MAXZOOM, (long)::rtl::math::round( nOld * ZOOM_FACTOR ));
+                nNew = Min( (long) MAXZOOM, basegfx::zoomtools::zoomIn( nOld ));
 
             if ( nNew != nOld )
             {
diff --git a/sd/source/ui/view/viewshel.cxx b/sd/source/ui/view/viewshel.cxx
index b1cc2d3..e4ae7f0 100644
--- a/sd/source/ui/view/viewshel.cxx
+++ b/sd/source/ui/view/viewshel.cxx
@@ -82,8 +82,7 @@
 #include <sfx2/request.hxx>
 #include "SpellDialogChildWindow.hxx"
 
-#include <svx/zoom_def.hxx>
-#include <rtl/math.hxx>
+#include <basegfx/tools/zoomtools.hxx>
 
 #include "Window.hxx"
 #include "fupoor.hxx"
@@ -719,9 +718,9 @@ bool ViewShell::HandleScrollCommand(const CommandEvent& rCEvt, ::sd::Window* pWi
                         long        nNewZoom;
 
                         if( pData->GetDelta() < 0L )
-                            nNewZoom = Max( (long) pWin->GetMinZoom(), (long)::rtl::math::round( nOldZoom / ZOOM_FACTOR ));
+                            nNewZoom = Max( (long) pWin->GetMinZoom(), basegfx::zoomtools::zoomOut( nOldZoom ));
                         else
-                            nNewZoom = Min( (long) pWin->GetMaxZoom(), (long)::rtl::math::round( nOldZoom * ZOOM_FACTOR ));
+                            nNewZoom = Min( (long) pWin->GetMaxZoom(), basegfx::zoomtools::zoomIn( nOldZoom ));
 
                         SetZoom( nNewZoom );
                         Invalidate( SID_ATTR_ZOOM );
diff --git a/svx/inc/svx/zoom_def.hxx b/svx/inc/svx/zoom_def.hxx
index 9f1a8ef..0a24476 100644
--- a/svx/inc/svx/zoom_def.hxx
+++ b/svx/inc/svx/zoom_def.hxx
@@ -8,8 +8,4 @@
 
 #endif
 
-// Zoom factor for Calc, Writer, Draw and Impress
-// We use 2^(1/4) so that 4 steps lead to double / half size
-#define ZOOM_FACTOR    1.1892071150027210667175
-
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/stbctrls/zoomsliderctrl.cxx b/svx/source/stbctrls/zoomsliderctrl.cxx
index a845eb9..afab9c4 100644
--- a/svx/source/stbctrls/zoomsliderctrl.cxx
+++ b/svx/source/stbctrls/zoomsliderctrl.cxx
@@ -36,8 +36,7 @@
 #include <svx/dialmgr.hxx>
 #include <svx/dialogs.hrc>
 
-#include <svx/zoom_def.hxx>
-#include <rtl/math.hxx>
+#include <basegfx/tools/zoomtools.hxx>
 
 #include <set>
 
@@ -360,11 +359,11 @@ sal_Bool SvxZoomSliderControl::MouseButtonDown( const MouseEvent & rEvt )
 
     // click to - button
     if ( nXDiff >= nButtonLeftOffset && nXDiff <= nButtonRightOffset )
-        mpImpl->mnCurrentZoom = ::rtl::math::round( mpImpl->mnCurrentZoom / ZOOM_FACTOR );
+        mpImpl->mnCurrentZoom = basegfx::zoomtools::zoomOut( mpImpl->mnCurrentZoom );
     // click to + button
     else if ( nXDiff >= aControlRect.GetWidth() - nSliderXOffset + nButtonLeftOffset &&
               nXDiff <= aControlRect.GetWidth() - nSliderXOffset + nButtonRightOffset )
-        mpImpl->mnCurrentZoom = ::rtl::math::round( mpImpl->mnCurrentZoom * ZOOM_FACTOR );
+        mpImpl->mnCurrentZoom = basegfx::zoomtools::zoomIn( mpImpl->mnCurrentZoom );
     // click to slider
     else if( nXDiff >= nSliderXOffset && nXDiff <= aControlRect.GetWidth() - nSliderXOffset )
         mpImpl->mnCurrentZoom = Offset2Zoom( nXDiff );
diff --git a/sw/source/ui/uiview/viewport.cxx b/sw/source/ui/uiview/viewport.cxx
index e630087..ae6ef20 100644
--- a/sw/source/ui/uiview/viewport.cxx
+++ b/sw/source/ui/uiview/viewport.cxx
@@ -52,8 +52,7 @@
 
 #include <IDocumentSettingAccess.hxx>
 
-#include <svx/zoom_def.hxx>
-#include <rtl/math.hxx>
+#include <basegfx/tools/zoomtools.hxx>
 
 //Das SetVisArea der DocShell darf nicht vom InnerResizePixel gerufen werden.
 //Unsere Einstellungen muessen aber stattfinden.
@@ -1312,9 +1311,9 @@ sal_Bool SwView::HandleWheelCommands( const CommandEvent& rCEvt )
     {
         sal_uInt16 nFact = pWrtShell->GetViewOptions()->GetZoom();
         if( 0L > pWData->GetDelta() )
-            nFact = static_cast< sal_uInt16 >(Max( 20, (int)::rtl::math::round( nFact / ZOOM_FACTOR )));
+            nFact = static_cast< sal_uInt16 >(Max( 20, basegfx::zoomtools::zoomOut( nFact )));
         else
-            nFact = static_cast< sal_uInt16 >(Min( 600, (int)::rtl::math::round( nFact * ZOOM_FACTOR )));
+            nFact = static_cast< sal_uInt16 >(Min( 600, basegfx::zoomtools::zoomIn( nFact )));
 
         SetZoom( SVX_ZOOM_PERCENT, nFact );
         bOk = sal_True;


More information about the Libreoffice-commits mailing list