You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openoffice.apache.org by or...@apache.org on 2013/03/14 21:00:20 UTC

svn commit: r1456629 [2/3] - in /openoffice/branches/sidebar/main: default_images/sw/res/sidebar/ default_images/sw/res/sidebar/pageproppanel/ officecfg/registry/data/org/openoffice/Office/UI/ sw/ sw/inc/ sw/sdi/ sw/source/core/doc/ sw/source/ui/app/ s...

Added: openoffice/branches/sidebar/main/sw/source/ui/sidebar/PageMarginControl.cxx
URL: http://svn.apache.org/viewvc/openoffice/branches/sidebar/main/sw/source/ui/sidebar/PageMarginControl.cxx?rev=1456629&view=auto
==============================================================================
--- openoffice/branches/sidebar/main/sw/source/ui/sidebar/PageMarginControl.cxx (added)
+++ openoffice/branches/sidebar/main/sw/source/ui/sidebar/PageMarginControl.cxx Thu Mar 14 20:00:19 2013
@@ -0,0 +1,505 @@
+/**************************************************************
+ * 
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ * 
+ *************************************************************/
+
+#include "precompiled_sw.hxx"
+
+#include "PageMarginControl.hxx"
+#include "PagePropertyPanel.hxx"
+#include "PagePropertyPanel.hrc"
+
+#include <swtypes.hxx>
+
+#include <svx/sidebar/ValueSetWithTextControl.hxx>
+
+#define SWPAGE_LEFT_GVALUE      String("Sw_Page_Left", 12, RTL_TEXTENCODING_ASCII_US)
+#define SWPAGE_RIGHT_GVALUE     String("Sw_Page_Right", 13, RTL_TEXTENCODING_ASCII_US)
+#define SWPAGE_TOP_GVALUE       String("Sw_Page_Top", 11, RTL_TEXTENCODING_ASCII_US)
+#define SWPAGE_DOWN_GVALUE      String("Sw_Page_Down", 12, RTL_TEXTENCODING_ASCII_US)
+#define SWPAGE_MIRROR_GVALUE    String("Sw_Page_Mirrored", 16, RTL_TEXTENCODING_ASCII_US)
+
+
+namespace sw { namespace sidebar {
+
+PageMarginControl::PageMarginControl(
+    Window* pParent,
+    PagePropertyPanel& rPanel,
+    const SvxLongLRSpaceItem& aPageLRMargin,
+    const SvxLongULSpaceItem& aPageULMargin,
+    const bool bMirrored,
+    const Size aPageSize,
+    const sal_Bool bLandscape,
+    const FieldUnit eFUnit,
+    const SfxMapUnit eUnit )
+    : ::svx::sidebar::PopupControl( pParent, SW_RES(RID_POPUP_SWPAGE_MARGIN) )
+    , mpMarginValueSet( new ::svx::sidebar::ValueSetWithTextControl( ::svx::sidebar::ValueSetWithTextControl::IMAGE_TEXT, this, SW_RES(VS_MARGIN) ) )
+    , maCustom(this, SW_RES(FT_CUSTOM))
+    , maLeft(this, SW_RES(FT_LEFT))
+    , maInner(this, SW_RES(FT_INNER))
+    , maLeftMarginEdit(this, SW_RES(MF_SWLEFT_MARGIN))
+    , maRight(this, SW_RES(FT_RIGHT))
+    , maOuter(this, SW_RES(FT_OUTER))
+    , maRightMarginEdit(this, SW_RES(MF_SWRIGHT_MARGIN))
+    , maTop(this, SW_RES(FT_TOP))
+    , maTopMarginEdit(this, SW_RES(MF_SWTOP_MARGIN))
+    , maBottom(this, SW_RES(FT_BOTTOM))
+    , maBottomMarginEdit(this, SW_RES(MF_SWBOTTOM_MARGIN))
+    , maWidthHeightField( this, SW_RES(FLD_WIDTH_HEIGHT) )
+    , mnPageLeftMargin( aPageLRMargin.GetLeft() )
+    , mnPageRightMargin( aPageLRMargin.GetRight() )
+    , mnPageTopMargin( aPageULMargin.GetUpper() )
+    , mnPageBottomMargin( aPageULMargin.GetLower() )
+    , mbMirrored( bMirrored )
+    , meUnit( eUnit )
+    , mnUserCustomPageLeftMargin(0)
+    , mnUserCustomPageRightMargin(0)
+    , mnUserCustomPageTopMargin(0)
+    , mnUserCustomPageBottomMargin(0)
+    , mbUserCustomMirrored(false)
+    , mbCustomValuesUsed( false )
+    , mrPagePropPanel(rPanel)
+{
+    maWidthHeightField.Hide();
+    SetFieldUnit( maWidthHeightField, eFUnit );
+
+    const bool bCustomValuesAvailable = GetUserCustomValues();
+
+    mpMarginValueSet->SetStyle( mpMarginValueSet->GetStyle() | WB_3DLOOK | WB_NO_DIRECTSELECT );
+    mpMarginValueSet->SetColor( GetSettings().GetStyleSettings().GetMenuColor() );
+
+    FillValueSet( bLandscape, bCustomValuesAvailable );
+
+    mpMarginValueSet->SetNoSelection();
+    mpMarginValueSet->SetSelectHdl( LINK(this, PageMarginControl,ImplMarginHdl ) );
+    mpMarginValueSet->Show();
+
+    SelectValueSetItem();
+    mpMarginValueSet->Format();
+    mpMarginValueSet->StartSelection();
+
+    SetFieldUnit( maLeftMarginEdit, eFUnit );
+    Link aLinkLR = LINK( this, PageMarginControl, ModifyLRMarginHdl );
+    maLeftMarginEdit.SetModifyHdl( aLinkLR );
+    SetMetricValue( maLeftMarginEdit, mnPageLeftMargin, meUnit );
+
+    SetFieldUnit( maRightMarginEdit, eFUnit );
+    maRightMarginEdit.SetModifyHdl( aLinkLR );
+    SetMetricValue( maRightMarginEdit, mnPageRightMargin, meUnit );
+
+    Link aLinkUL = LINK( this, PageMarginControl, ModifyULMarginHdl );
+    SetFieldUnit( maTopMarginEdit, eFUnit );
+    maTopMarginEdit.SetModifyHdl( aLinkUL );
+    SetMetricValue( maTopMarginEdit, mnPageTopMargin, meUnit );
+
+    SetFieldUnit( maBottomMarginEdit, eFUnit );
+    maBottomMarginEdit.SetModifyHdl( aLinkUL );
+    SetMetricValue( maBottomMarginEdit, mnPageBottomMargin, meUnit );
+
+    SetMetricFieldMaxValues( aPageSize );
+
+    if ( mbMirrored )
+    {
+        maLeft.Hide();
+        maRight.Hide();
+        maInner.Show();
+        maOuter.Show();
+    }
+    else
+    {
+        maLeft.Show();
+        maRight.Show();
+        maInner.Hide();
+        maOuter.Hide();
+    }
+
+    FreeResource();
+}
+
+
+PageMarginControl::~PageMarginControl(void)
+{
+    delete mpMarginValueSet;
+
+    StoreUserCustomValues();
+}
+
+
+void PageMarginControl::SetMetricFieldMaxValues( const Size aPageSize )
+{
+    const long nML = maLeftMarginEdit.Denormalize( maLeftMarginEdit.GetValue(FUNIT_TWIP) );
+    const long nMR = maRightMarginEdit.Denormalize( maRightMarginEdit.GetValue(FUNIT_TWIP) );
+    const long nMT = maTopMarginEdit.Denormalize(maTopMarginEdit.GetValue(FUNIT_TWIP) );
+    const long nMB = maBottomMarginEdit.Denormalize( maBottomMarginEdit.GetValue(FUNIT_TWIP) );
+
+    const long nPH  = LogicToLogic( aPageSize.Height(), (MapUnit)meUnit, MAP_TWIP );
+    const long nPW  = LogicToLogic( aPageSize.Width(),  (MapUnit)meUnit, MAP_TWIP );
+
+    // Left
+    long nMax = nPW - nMR - MINBODY;
+    maLeftMarginEdit.SetMax(maLeftMarginEdit.Normalize(nMax), FUNIT_TWIP);
+
+    // Right
+    nMax = nPW - nML - MINBODY;
+    maRightMarginEdit.SetMax(maRightMarginEdit.Normalize(nMax), FUNIT_TWIP);
+
+    //Top
+    nMax = nPH - nMB - MINBODY;
+    maTopMarginEdit.SetMax(maTopMarginEdit.Normalize(nMax), FUNIT_TWIP);
+
+    //Bottom
+    nMax = nPH - nMT -  MINBODY;
+    maBottomMarginEdit.SetMax(maTopMarginEdit.Normalize(nMax), FUNIT_TWIP);
+}
+
+
+void PageMarginControl::FillValueSet( 
+    const bool bLandscape,
+    const bool bUserCustomValuesAvailable )
+{
+    const XubString aLeft = SW_RES(STR_MARGIN_TOOLTIP_LEFT);
+    const XubString aRight = SW_RES(STR_MARGIN_TOOLTIP_RIGHT);
+    const XubString aTop = SW_RES(STR_MARGIN_TOOLTIP_TOP);
+    const XubString aBottom = SW_RES(STR_MARGIN_TOOLTIP_BOT);
+
+    SetMetricValue( maWidthHeightField, SWPAGE_NARROW_VALUE, meUnit );
+    const XubString aNarrowValText = maWidthHeightField.GetText();
+    XubString aHelpText = aLeft;
+    aHelpText += aNarrowValText;
+    aHelpText += aRight;
+    aHelpText += aNarrowValText;
+    aHelpText += aTop;
+    aHelpText += aNarrowValText;
+    aHelpText += aBottom;
+    aHelpText += aNarrowValText;
+    mpMarginValueSet->AddItem(
+        (bLandscape ? SW_RES(IMG_NARROW_L) : SW_RES(IMG_NARROW) ), 0,
+        SW_RES(STR_NARROW), &aHelpText );
+
+    SetMetricValue( maWidthHeightField, SWPAGE_NORMAL_VALUE, meUnit );
+    const XubString aNormalValText = maWidthHeightField.GetText();
+    aHelpText = aLeft;
+    aHelpText += aNormalValText;
+    aHelpText += aRight;
+    aHelpText += aNormalValText;
+    aHelpText += aTop;
+    aHelpText += aNormalValText;
+    aHelpText += aBottom;
+    aHelpText += aNormalValText;
+    mpMarginValueSet->AddItem(
+        (bLandscape ? SW_RES(IMG_NORMAL_L) : SW_RES(IMG_NORMAL) ), 0,
+        SW_RES(STR_NORMAL), &aHelpText );
+
+    SetMetricValue( maWidthHeightField, SWPAGE_WIDE_VALUE1, meUnit );
+    const XubString aWide1ValText = maWidthHeightField.GetText();
+    SetMetricValue( maWidthHeightField, SWPAGE_WIDE_VALUE2, meUnit );
+    const XubString aWide2ValText = maWidthHeightField.GetText();
+    aHelpText = aLeft;
+    aHelpText += aWide2ValText;
+    aHelpText += aRight;
+    aHelpText += aWide2ValText;
+    aHelpText += aTop;
+    aHelpText += aWide1ValText;
+    aHelpText += aBottom;
+    aHelpText += aWide1ValText;
+    mpMarginValueSet->AddItem(
+        (bLandscape ? SW_RES(IMG_WIDE_L) : SW_RES(IMG_WIDE) ), 0,
+        SW_RES(STR_WIDE), &aHelpText );
+
+    const XubString aInner = SW_RES(STR_MARGIN_TOOLTIP_INNER);
+    const XubString aOuter = SW_RES(STR_MARGIN_TOOLTIP_OUTER);
+
+    SetMetricValue( maWidthHeightField, SWPAGE_WIDE_VALUE3, meUnit );
+    const XubString aWide3ValText = maWidthHeightField.GetText();
+    aHelpText = aInner;
+    aHelpText += aWide3ValText;
+    aHelpText += aOuter;
+    aHelpText += aWide3ValText;
+    aHelpText += aTop;
+    aHelpText += aWide1ValText;
+    aHelpText += aBottom;
+    aHelpText += aWide1ValText;
+    mpMarginValueSet->AddItem( 
+        (bLandscape ? SW_RES(IMG_MIRRORED_L) : SW_RES(IMG_MIRRORED) ), 0,
+        SW_RES(STR_MIRRORED), &aHelpText );
+
+    if ( bUserCustomValuesAvailable )
+    {
+        aHelpText = mbUserCustomMirrored ? aInner : aLeft;
+        SetMetricValue( maWidthHeightField, mnUserCustomPageLeftMargin, meUnit );
+        aHelpText += maWidthHeightField.GetText();
+        aHelpText += mbUserCustomMirrored ? aOuter : aRight;
+        SetMetricValue( maWidthHeightField, mnUserCustomPageRightMargin, meUnit );
+        aHelpText += maWidthHeightField.GetText();
+        aHelpText += aTop;
+        SetMetricValue( maWidthHeightField, mnUserCustomPageTopMargin, meUnit );
+        aHelpText += maWidthHeightField.GetText();
+        aHelpText += aBottom;
+        SetMetricValue( maWidthHeightField, mnUserCustomPageBottomMargin, meUnit );
+        aHelpText += maWidthHeightField.GetText();
+    }
+    else
+    {
+        aHelpText = XubString();
+    }
+    mpMarginValueSet->AddItem(
+        (bUserCustomValuesAvailable ? SW_RES(IMG_CUSTOM) : SW_RES(IMG_CUSTOM_DIS) ), 0,
+        SW_RES(STR_LCVALUE), &aHelpText );
+}
+
+
+void PageMarginControl::SelectValueSetItem()
+{
+    const long cTolerance = 5;
+
+    if( abs(mnPageLeftMargin - SWPAGE_NARROW_VALUE) <= cTolerance &&
+        abs(mnPageRightMargin - SWPAGE_NARROW_VALUE) <= cTolerance &&
+        abs(mnPageTopMargin - SWPAGE_NARROW_VALUE) <= cTolerance &&
+        abs(mnPageBottomMargin - SWPAGE_NARROW_VALUE) <= cTolerance &&
+        !mbMirrored )
+    {
+        mpMarginValueSet->SelectItem(1);
+    }
+    else if( abs(mnPageLeftMargin - SWPAGE_NORMAL_VALUE) <= cTolerance &&
+        abs(mnPageRightMargin - SWPAGE_NORMAL_VALUE) <= cTolerance &&
+        abs(mnPageTopMargin - SWPAGE_NORMAL_VALUE) <= cTolerance &&		
+        abs(mnPageBottomMargin - SWPAGE_NORMAL_VALUE) <= cTolerance &&
+        !mbMirrored )
+    {
+        mpMarginValueSet->SelectItem(2);
+    }
+    else if( abs(mnPageLeftMargin - SWPAGE_WIDE_VALUE2) <= cTolerance &&
+        abs(mnPageRightMargin - SWPAGE_WIDE_VALUE2) <= cTolerance &&
+        abs(mnPageTopMargin - SWPAGE_WIDE_VALUE1) <= cTolerance &&		
+        abs(mnPageBottomMargin - SWPAGE_WIDE_VALUE1) <= cTolerance &&
+        !mbMirrored )
+    {
+        mpMarginValueSet->SelectItem(3);
+    }
+    else if( abs(mnPageLeftMargin - SWPAGE_WIDE_VALUE3) <= cTolerance &&
+        abs(mnPageRightMargin - SWPAGE_WIDE_VALUE1) <= cTolerance &&
+        abs(mnPageTopMargin - SWPAGE_WIDE_VALUE1) <= cTolerance &&
+        abs(mnPageBottomMargin - SWPAGE_WIDE_VALUE1) <= cTolerance &&
+        mbMirrored )
+    {
+        mpMarginValueSet->SelectItem(4);
+    }
+    else 
+    {
+        mpMarginValueSet->SelectItem(0);
+    }
+};
+
+
+IMPL_LINK(PageMarginControl, ImplMarginHdl, void *, pControl)
+{
+    mpMarginValueSet->SetNoSelection();
+    if ( pControl == mpMarginValueSet )
+    {
+        const sal_uInt16 iPos = mpMarginValueSet->GetSelectItemId();
+        bool bMirrored = false;
+        switch ( iPos )
+        {
+        case 1:
+            mnPageLeftMargin = SWPAGE_NARROW_VALUE;
+            mnPageRightMargin = SWPAGE_NARROW_VALUE;
+            mnPageTopMargin = SWPAGE_NARROW_VALUE;
+            mnPageBottomMargin = SWPAGE_NARROW_VALUE;
+            bMirrored = false;
+            break;
+        case 2:
+            mnPageLeftMargin = SWPAGE_NORMAL_VALUE;
+            mnPageRightMargin = SWPAGE_NORMAL_VALUE;
+            mnPageTopMargin = SWPAGE_NORMAL_VALUE;
+            mnPageBottomMargin = SWPAGE_NORMAL_VALUE;
+            bMirrored = false;
+            break;
+        case 3:
+            mnPageLeftMargin = SWPAGE_WIDE_VALUE2;
+            mnPageRightMargin = SWPAGE_WIDE_VALUE2;
+            mnPageTopMargin = SWPAGE_WIDE_VALUE1;
+            mnPageBottomMargin = SWPAGE_WIDE_VALUE1;
+            bMirrored = false;
+            break;
+        case 4:
+            mnPageLeftMargin = SWPAGE_WIDE_VALUE3;
+            mnPageRightMargin = SWPAGE_WIDE_VALUE1;
+            mnPageTopMargin = SWPAGE_WIDE_VALUE1;
+            mnPageBottomMargin = SWPAGE_WIDE_VALUE1;
+            bMirrored = true;
+            break;
+        case 5:
+            mnPageLeftMargin = mnUserCustomPageLeftMargin;
+            mnPageRightMargin = mnUserCustomPageRightMargin;
+            mnPageTopMargin = mnUserCustomPageTopMargin;
+            mnPageBottomMargin = mnUserCustomPageBottomMargin;
+            bMirrored = mbUserCustomMirrored;
+            break;
+        }
+
+        mrPagePropPanel.ExecuteMarginLRChange( mnPageLeftMargin, mnPageRightMargin );
+        mrPagePropPanel.ExecuteMarginULChange( mnPageTopMargin, mnPageBottomMargin );
+        if ( mbMirrored != bMirrored )
+        {
+            mbMirrored = bMirrored;
+            mrPagePropPanel.ExecutePageLayoutChange( mbMirrored );
+        }
+
+        mbCustomValuesUsed = false;
+    }
+
+    mrPagePropPanel.ClosePageMarginPopup();
+    return 0;
+}
+
+
+IMPL_LINK( PageMarginControl, ModifyLRMarginHdl, MetricField *, EMPTYARG )
+{
+    mpMarginValueSet->SetNoSelection();
+    mpMarginValueSet->SelectItem(0);
+    mpMarginValueSet->Format();
+    mpMarginValueSet->StartSelection();
+
+    mnPageLeftMargin = GetCoreValue( maLeftMarginEdit, meUnit );
+    mnPageRightMargin = GetCoreValue( maRightMarginEdit, meUnit );
+    mrPagePropPanel.ExecuteMarginLRChange( mnPageLeftMargin, mnPageRightMargin );
+    mbCustomValuesUsed = true;
+    return 0;
+}
+
+IMPL_LINK( PageMarginControl, ModifyULMarginHdl, MetricField *, EMPTYARG )
+{
+    mpMarginValueSet->SetNoSelection();
+    mpMarginValueSet->SelectItem(0);
+    mpMarginValueSet->Format();
+    mpMarginValueSet->StartSelection();
+
+    mnPageTopMargin = GetCoreValue( maTopMarginEdit, meUnit );
+    mnPageBottomMargin = GetCoreValue( maBottomMarginEdit, meUnit );
+    mrPagePropPanel.ExecuteMarginULChange( mnPageTopMargin, mnPageBottomMargin );
+    mbCustomValuesUsed = true;
+    return 0;
+}
+
+
+bool PageMarginControl::GetUserCustomValues()
+{
+    bool bUserCustomValuesAvailable = false;
+
+    SvtViewOptions aWinOpt( E_WINDOW, SWPAGE_LEFT_GVALUE );
+    if ( aWinOpt.Exists() )
+    {
+        ::com::sun::star::uno::Sequence < ::com::sun::star::beans::NamedValue > aSeq = aWinOpt.GetUserData();
+        ::rtl::OUString aTmp;
+        if ( aSeq.getLength())
+            aSeq[0].Value >>= aTmp;
+        String aWinData( aTmp );
+        mnUserCustomPageLeftMargin = aWinData.ToInt32();
+        bUserCustomValuesAvailable = true;
+    }
+
+    SvtViewOptions aWinOpt2( E_WINDOW, SWPAGE_RIGHT_GVALUE );
+    if ( aWinOpt2.Exists() )
+    {
+        ::com::sun::star::uno::Sequence < ::com::sun::star::beans::NamedValue > aSeq = aWinOpt2.GetUserData();
+        ::rtl::OUString aTmp;
+        if ( aSeq.getLength())
+            aSeq[0].Value >>= aTmp;
+        String aWinData( aTmp );
+        mnUserCustomPageRightMargin = aWinData.ToInt32();
+        bUserCustomValuesAvailable = true;
+    }
+
+    SvtViewOptions aWinOpt3( E_WINDOW, SWPAGE_TOP_GVALUE );
+    if ( aWinOpt3.Exists() )
+    {
+        ::com::sun::star::uno::Sequence < ::com::sun::star::beans::NamedValue > aSeq = aWinOpt3.GetUserData();
+        ::rtl::OUString aTmp;
+        if ( aSeq.getLength())
+            aSeq[0].Value >>= aTmp;
+        String aWinData( aTmp );
+        mnUserCustomPageTopMargin = aWinData.ToInt32();
+        bUserCustomValuesAvailable = true;
+    }
+
+    SvtViewOptions aWinOpt4( E_WINDOW, SWPAGE_DOWN_GVALUE );
+    if ( aWinOpt4.Exists() )
+    {
+        ::com::sun::star::uno::Sequence < ::com::sun::star::beans::NamedValue > aSeq = aWinOpt4.GetUserData();
+        ::rtl::OUString aTmp;
+        if ( aSeq.getLength())
+            aSeq[0].Value >>= aTmp;
+        String aWinData( aTmp );
+        mnUserCustomPageBottomMargin = aWinData.ToInt32();
+        bUserCustomValuesAvailable = true;
+    }
+
+    SvtViewOptions aWinOpt5( E_WINDOW, SWPAGE_MIRROR_GVALUE );
+    if ( aWinOpt5.Exists() )
+    {
+        ::com::sun::star::uno::Sequence < ::com::sun::star::beans::NamedValue > aSeq = aWinOpt5.GetUserData();
+        ::rtl::OUString aTmp;
+        if ( aSeq.getLength())
+            aSeq[0].Value >>= aTmp;
+        String aWinData( aTmp );
+        mbUserCustomMirrored = aWinData.ToInt32() == 0 ? false : true;
+        bUserCustomValuesAvailable = true;
+    }
+
+    return bUserCustomValuesAvailable;
+}
+
+void PageMarginControl::StoreUserCustomValues()
+{
+    if ( !mbCustomValuesUsed )
+    {
+        return;
+    }
+
+    ::com::sun::star::uno::Sequence < ::com::sun::star::beans::NamedValue > aSeq(1);
+    SvtViewOptions aWinOpt( E_WINDOW, SWPAGE_LEFT_GVALUE );
+
+    aSeq[0].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("mnPageLeftMargin") );
+    aSeq[0].Value <<= ::rtl::OUString( String::CreateFromInt64( mnPageLeftMargin ));
+    aWinOpt.SetUserData( aSeq );
+
+    SvtViewOptions aWinOpt2( E_WINDOW, SWPAGE_RIGHT_GVALUE );
+    aSeq[0].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("mnPageRightMargin") );
+    aSeq[0].Value <<= ::rtl::OUString( String::CreateFromInt64( mnPageRightMargin ));
+    aWinOpt2.SetUserData( aSeq );
+
+    SvtViewOptions aWinOpt3( E_WINDOW, SWPAGE_TOP_GVALUE );
+    aSeq[0].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("mnPageTopMargin") );
+    aSeq[0].Value <<= ::rtl::OUString( String::CreateFromInt64( mnPageTopMargin ));
+    aWinOpt3.SetUserData( aSeq );
+
+    SvtViewOptions aWinOpt4( E_WINDOW, SWPAGE_DOWN_GVALUE );
+    aSeq[0].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("mnPageBottomMargin") );
+    aSeq[0].Value <<= ::rtl::OUString( String::CreateFromInt64( mnPageBottomMargin ));
+    aWinOpt4.SetUserData( aSeq );
+
+    SvtViewOptions aWinOpt5( E_WINDOW, SWPAGE_MIRROR_GVALUE );
+    aSeq[0].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("mbMirrored") );
+    aSeq[0].Value <<= ::rtl::OUString( String::CreateFromInt64( (mbMirrored ? 1 : 0) ));
+    aWinOpt5.SetUserData( aSeq );
+}
+
+
+} } // end of namespace sw::sidebar
+

Added: openoffice/branches/sidebar/main/sw/source/ui/sidebar/PageMarginControl.hxx
URL: http://svn.apache.org/viewvc/openoffice/branches/sidebar/main/sw/source/ui/sidebar/PageMarginControl.hxx?rev=1456629&view=auto
==============================================================================
--- openoffice/branches/sidebar/main/sw/source/ui/sidebar/PageMarginControl.hxx (added)
+++ openoffice/branches/sidebar/main/sw/source/ui/sidebar/PageMarginControl.hxx Thu Mar 14 20:00:19 2013
@@ -0,0 +1,120 @@
+/**************************************************************
+ * 
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ * 
+ *************************************************************/
+
+#ifndef _SW_SIDEBAR_PAGE_MARGIN_CONTROL_HXX_
+#define _SW_SIDEBAR_PAGE_MARGIN_CONTROL_HXX_
+
+#include <svx/sidebar/PopupControl.hxx>
+
+#include <tools/fldunit.hxx>
+#include <svl/poolitem.hxx>
+#include <unotools/viewoptions.hxx>
+
+#include <vector>
+
+#define SWPAGE_NARROW_VALUE    720
+#define SWPAGE_NORMAL_VALUE    1136
+#define SWPAGE_WIDE_VALUE1     1440
+#define SWPAGE_WIDE_VALUE2	   2880
+#define SWPAGE_WIDE_VALUE3	   1800
+
+
+namespace svx { namespace sidebar {
+    class ValueSetWithTextControl;
+} }
+
+static const long MINBODY = 284; //0.5 cm in twips
+
+namespace sw { namespace sidebar {
+
+class PagePropertyPanel;
+
+
+class PageMarginControl
+    : public ::svx::sidebar::PopupControl
+{
+public:
+    PageMarginControl(
+        Window* pParent,
+        PagePropertyPanel& rPanel,
+        const SvxLongLRSpaceItem& aPageLRMargin,
+        const SvxLongULSpaceItem& aPageULMargin,
+        const bool bMirrored,
+        const Size aPageSize,
+        const sal_Bool bLandscape,
+        const FieldUnit eFUnit,
+        const SfxMapUnit eUnit );
+    ~PageMarginControl(void);
+
+private:
+    ::svx::sidebar::ValueSetWithTextControl* mpMarginValueSet;
+
+    FixedText maCustom;
+    FixedText maLeft;
+    FixedText maInner;
+    MetricField maLeftMarginEdit;
+    FixedText maRight;
+    FixedText maOuter;
+    MetricField maRightMarginEdit;
+    FixedText maTop;
+    MetricField maTopMarginEdit;
+    FixedText maBottom;
+    MetricField maBottomMarginEdit;
+
+    // hidden metric field
+    MetricField maWidthHeightField;
+
+    long mnPageLeftMargin;
+    long mnPageRightMargin;
+    long mnPageTopMargin;
+    long mnPageBottomMargin;
+    bool mbMirrored;
+
+    const SfxMapUnit meUnit;
+
+    long mnUserCustomPageLeftMargin;
+    long mnUserCustomPageRightMargin;
+    long mnUserCustomPageTopMargin;
+    long mnUserCustomPageBottomMargin;
+    bool mbUserCustomMirrored;
+
+    bool mbCustomValuesUsed;
+
+    PagePropertyPanel& mrPagePropPanel;
+
+    DECL_LINK( ImplMarginHdl, void* );
+    DECL_LINK( ModifyLRMarginHdl, MetricField* );
+    DECL_LINK( ModifyULMarginHdl, MetricField* );
+
+    void SetMetricFieldMaxValues( const Size aPageSize );
+
+    bool GetUserCustomValues();
+    void StoreUserCustomValues();
+
+    void FillValueSet(
+        const bool bLandscape,
+        const bool bUserCustomValuesAvailable );
+    void SelectValueSetItem();
+};
+
+} } // end of namespace sw::sidebar
+
+#endif

Added: openoffice/branches/sidebar/main/sw/source/ui/sidebar/PageOrientationControl.cxx
URL: http://svn.apache.org/viewvc/openoffice/branches/sidebar/main/sw/source/ui/sidebar/PageOrientationControl.cxx?rev=1456629&view=auto
==============================================================================
--- openoffice/branches/sidebar/main/sw/source/ui/sidebar/PageOrientationControl.cxx (added)
+++ openoffice/branches/sidebar/main/sw/source/ui/sidebar/PageOrientationControl.cxx Thu Mar 14 20:00:19 2013
@@ -0,0 +1,93 @@
+/**************************************************************
+ * 
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ * 
+ *************************************************************/
+
+#include "precompiled_sw.hxx"
+
+#include "PageOrientationControl.hxx"
+#include "PagePropertyPanel.hxx"
+#include "PagePropertyPanel.hrc"
+
+#include <swtypes.hxx>
+
+#include <svx/sidebar/ValueSetWithTextControl.hxx>
+
+namespace sw { namespace sidebar {
+
+PageOrientationControl::PageOrientationControl(
+    Window* pParent,
+    PagePropertyPanel& rPanel,
+    const sal_Bool bLandscape )
+    : ::svx::sidebar::PopupControl( pParent, SW_RES(RID_POPUP_SWPAGE_ORIENTATION) )
+    , mpOrientationValueSet( new ::svx::sidebar::ValueSetWithTextControl( ::svx::sidebar::ValueSetWithTextControl::IMAGE_TEXT, this, SW_RES(VS_ORIENTATION) ) )
+    , mbLandscape( bLandscape )
+    , mrPagePropPanel(rPanel)
+{
+    mpOrientationValueSet->SetStyle( mpOrientationValueSet->GetStyle() | WB_3DLOOK | WB_NO_DIRECTSELECT );
+    mpOrientationValueSet->SetColor(GetSettings().GetStyleSettings().GetMenuColor());
+
+    // initialize <ValueSetWithText> control
+    {
+        mpOrientationValueSet->AddItem( SW_RES(IMG_PORTRAIT), 0, SW_RES(STR_PORTRAIT), 0 );
+        mpOrientationValueSet->AddItem( SW_RES(IMG_LANDSCAPE), 0, SW_RES(STR_LANDSCAPE), 0 );
+    }
+
+    Link aLink = LINK(this, PageOrientationControl,ImplOrientationHdl );
+    mpOrientationValueSet->SetSelectHdl(aLink);
+    mpOrientationValueSet->SetNoSelection();
+    mpOrientationValueSet->StartSelection();
+    mpOrientationValueSet->Show();
+    mpOrientationValueSet->SelectItem( (mbLandscape == sal_True) ? 2 : 1 );
+    mpOrientationValueSet->GrabFocus();
+    mpOrientationValueSet->Format();
+    mpOrientationValueSet->StartSelection();
+
+    FreeResource();
+}
+
+
+PageOrientationControl::~PageOrientationControl(void)
+{
+    delete mpOrientationValueSet;
+}
+
+
+IMPL_LINK(PageOrientationControl, ImplOrientationHdl, void *, pControl)
+{
+    mpOrientationValueSet->SetNoSelection();
+    if ( pControl == mpOrientationValueSet )
+    {
+        const sal_uInt32 iPos = mpOrientationValueSet->GetSelectItemId();
+        const bool bChanged = ( ( iPos == 1 ) && mbLandscape ) ||
+                              ( ( iPos == 2 ) && !mbLandscape );
+        if ( bChanged )
+        {
+            mbLandscape = !mbLandscape;
+            mrPagePropPanel.ExecuteOrientationChange( mbLandscape );
+        }
+    }
+
+    mrPagePropPanel.ClosePageOrientationPopup();
+    return 0;
+}
+
+
+} } // end of namespace sw::sidebar
+

Added: openoffice/branches/sidebar/main/sw/source/ui/sidebar/PageOrientationControl.hxx
URL: http://svn.apache.org/viewvc/openoffice/branches/sidebar/main/sw/source/ui/sidebar/PageOrientationControl.hxx?rev=1456629&view=auto
==============================================================================
--- openoffice/branches/sidebar/main/sw/source/ui/sidebar/PageOrientationControl.hxx (added)
+++ openoffice/branches/sidebar/main/sw/source/ui/sidebar/PageOrientationControl.hxx Thu Mar 14 20:00:19 2013
@@ -0,0 +1,58 @@
+/**************************************************************
+ * 
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ * 
+ *************************************************************/
+
+#ifndef _SW_SIDEBAR_PAGE_ORIENTATION_CONTROL_HXX_
+#define _SW_SIDEBAR_PAGE_ORIENTATION_CONTROL_HXX_
+
+#include <svx/sidebar/PopupControl.hxx>
+
+namespace svx { namespace sidebar {
+    class ValueSetWithTextControl;
+} }
+
+namespace sw { namespace sidebar {
+
+class PagePropertyPanel;
+
+
+class PageOrientationControl
+    : public ::svx::sidebar::PopupControl
+{
+public:
+    PageOrientationControl(
+        Window* pParent,
+        PagePropertyPanel& rPanel,
+        const sal_Bool bLandscape );
+    ~PageOrientationControl(void);
+
+private:
+    ::svx::sidebar::ValueSetWithTextControl* mpOrientationValueSet;
+
+    sal_Bool mbLandscape;
+
+    PagePropertyPanel& mrPagePropPanel;
+
+    DECL_LINK(ImplOrientationHdl, void*);
+};
+
+} } // end of namespace sw::sidebar
+
+#endif

Added: openoffice/branches/sidebar/main/sw/source/ui/sidebar/PagePropertyPanel.cxx
URL: http://svn.apache.org/viewvc/openoffice/branches/sidebar/main/sw/source/ui/sidebar/PagePropertyPanel.cxx?rev=1456629&view=auto
==============================================================================
--- openoffice/branches/sidebar/main/sw/source/ui/sidebar/PagePropertyPanel.cxx (added)
+++ openoffice/branches/sidebar/main/sw/source/ui/sidebar/PagePropertyPanel.cxx Thu Mar 14 20:00:19 2013
@@ -0,0 +1,779 @@
+/************************************************************************
+*
+* Licensed Materials - Property of IBM.
+* (C) Copyright IBM Corporation 2003, 2012.  All Rights Reserved.
+* U.S. Government Users Restricted Rights:
+* Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
+*
+************************************************************************/
+
+#include "precompiled_sw.hxx"
+
+#include "PagePropertyPanel.hxx"
+#include "PagePropertyPanel.hrc"
+
+#include "PropertyPanel.hrc"
+
+#include <svx/sidebar/PopupContainer.hxx>
+#include "PageOrientationControl.hxx"
+#include "PageMarginControl.hxx"
+#include "PageSizeControl.hxx"
+#include "PageColumnControl.hxx"
+
+#include <swtypes.hxx>
+#include <cmdid.h>
+#include <errhdl.hxx>
+
+#include <svl/intitem.hxx>
+#include <editeng/sizeitem.hxx>
+#include <editeng/paperinf.hxx>
+#include <svx/svxids.hrc>
+#include <svx/dlgutil.hxx>
+#include <svx/rulritem.hxx>
+
+#include <sfx2/sidebar/ControlFactory.hxx>
+#include <sfx2/dispatch.hxx>
+#include <sfx2/bindings.hxx>
+#include <sfx2/viewsh.hxx>
+#include <sfx2/objsh.hxx>
+
+#include <boost/bind.hpp>
+
+#define A2S(pString) (::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(pString)))
+
+#define SetFldVal(rField, lValue) (rField).SetValue((rField).Normalize(lValue), FUNIT_TWIP)
+
+
+namespace sw { namespace sidebar {
+
+PagePropertyPanel* PagePropertyPanel::Create (
+    Window* pParent,
+    const cssu::Reference<css::frame::XFrame>& rxFrame,
+    SfxBindings* pBindings)
+{
+    if (pParent == NULL)
+        throw ::com::sun::star::lang::IllegalArgumentException(A2S("no parent Window given to PagePropertyPanel::Create"), NULL, 0);
+    if ( ! rxFrame.is())
+        throw ::com::sun::star::lang::IllegalArgumentException(A2S("no XFrame given to PagePropertyPanel::Create"), NULL, 1);
+    if (pBindings == NULL)
+        throw ::com::sun::star::lang::IllegalArgumentException(A2S("no SfxBindings given to PagePropertyPanel::Create"), NULL, 2);
+    
+    return new PagePropertyPanel(
+        pParent,
+        rxFrame,
+        pBindings);
+}
+
+PagePropertyPanel::PagePropertyPanel(
+            Window* pParent,
+            const cssu::Reference<css::frame::XFrame>& rxFrame,
+            SfxBindings* pBindings)
+    : Control(pParent, SW_RES(RID_PROPERTYPANEL_SWPAGE))
+    , mxFrame(rxFrame)
+    , maContext()
+    , mpBindings(pBindings)
+    // visible controls
+    , maFtOrientation( this, SW_RES(FT_ORIENTATION) )
+    , mpToolBoxOrientationBackground( ::sfx2::sidebar::ControlFactory::CreateToolBoxBackground(this) )
+    , mpToolBoxOrientation( ::sfx2::sidebar::ControlFactory::CreateToolBox( mpToolBoxOrientationBackground.get(), SW_RES(TB_ORIENTATION)) )
+    , maFtMargin( this, SW_RES(FT_MARGIN) )
+    , mpToolBoxMarginBackground( ::sfx2::sidebar::ControlFactory::CreateToolBoxBackground(this) )
+    , mpToolBoxMargin( ::sfx2::sidebar::ControlFactory::CreateToolBox( mpToolBoxMarginBackground.get(), SW_RES(TB_MARGIN)) )
+    , maFtSize( this, SW_RES(FT_SIZE) )
+    , mpToolBoxSizeBackground( ::sfx2::sidebar::ControlFactory::CreateToolBoxBackground(this) )
+    , mpToolBoxSize( ::sfx2::sidebar::ControlFactory::CreateToolBox( mpToolBoxSizeBackground.get(), SW_RES(TB_SIZE)) )
+    , maFtColumn( this, SW_RES(FT_COLUMN) )
+    , mpToolBoxColumnBackground( ::sfx2::sidebar::ControlFactory::CreateToolBoxBackground(this) )
+    , mpToolBoxColumn( ::sfx2::sidebar::ControlFactory::CreateToolBox( mpToolBoxColumnBackground.get(), SW_RES(TB_COLUMN)) )
+    // image resources
+    , maImgSize					(NULL)
+    , maImgSize_L					(NULL)
+    , mImgPortrait				(SW_RES(IMG_PAGE_PORTRAIT))
+    , mImgLandscape				(SW_RES(IMG_PAGE_LANDSCAPE))
+    , mImgNarrow					(SW_RES(IMG_PAGE_NARROW))
+    , mImgNormal					(SW_RES(IMG_PAGE_NORMAL))
+    , mImgWide					(SW_RES(IMG_PAGE_WIDE))
+    , mImgMirrored				(SW_RES(IMG_PAGE_MIRRORED))
+    , mImgMarginCustom			(SW_RES(IMG_PAGE_MARGIN_CUSTOM))
+    , mImgNarrow_L				(SW_RES(IMG_PAGE_NARROW_L))
+    , mImgNormal_L				(SW_RES(IMG_PAGE_NORMAL_L))
+    , mImgWide_L					(SW_RES(IMG_PAGE_WIDE_L))
+    , mImgMirrored_L				(SW_RES(IMG_PAGE_MIRRORED_L))
+    , mImgMarginCustom_L			(SW_RES(IMG_PAGE_MARGIN_CUSTOM_L))
+    , mImgA3						(SW_RES(IMG_PAGE_A3))
+    , mImgA4						(SW_RES(IMG_PAGE_A4))
+    , mImgA5						(SW_RES(IMG_PAGE_A5))
+    , mImgB4						(SW_RES(IMG_PAGE_B4))
+    , mImgB5						(SW_RES(IMG_PAGE_B5))
+    , mImgC5						(SW_RES(IMG_PAGE_C5))
+    , mImgLetter					(SW_RES(IMG_PAGE_LETTER))
+    , mImgLegal					(SW_RES(IMG_PAGE_LEGAL))
+    , mImgSizeNone				(SW_RES(IMG_PAGE_SIZE_NONE))
+    , mImgA3_L					(SW_RES(IMG_PAGE_A3_L))
+    , mImgA4_L					(SW_RES(IMG_PAGE_A4_L))
+    , mImgA5_L					(SW_RES(IMG_PAGE_A5_L))
+    , mImgB4_L					(SW_RES(IMG_PAGE_B4_L))
+    , mImgB5_L					(SW_RES(IMG_PAGE_B5_L))
+    , mImgC5_L					(SW_RES(IMG_PAGE_C5_L))
+    , mImgLetter_L				(SW_RES(IMG_PAGE_LETTER_L))
+    , mImgLegal_L					(SW_RES(IMG_PAGE_LEGAL_L))
+    , mImgSizeNone_L				(SW_RES(IMG_PAGE_SIZE_NONE_L))
+    , mImgColumn1					(SW_RES(IMG_PAGE_COLUMN_1))
+    , mImgColumn2					(SW_RES(IMG_PAGE_COLUMN_2))
+    , mImgColumn3					(SW_RES(IMG_PAGE_COLUMN_3))
+    , mImgLeft					(SW_RES(IMG_PAGE_COLUMN_LEFT))
+    , mImgRight					(SW_RES(IMG_PAGE_COLUMN_RIGHT))
+    , mImgColumnNone				(SW_RES(IMG_PAGE_COLUMN_NONE))
+    , mImgColumn1_L				(SW_RES(IMG_PAGE_COLUMN_1_L))
+    , mImgColumn2_L				(SW_RES(IMG_PAGE_COLUMN_2_L))
+    , mImgColumn3_L				(SW_RES(IMG_PAGE_COLUMN_3_L))
+    , mImgLeft_L					(SW_RES(IMG_PAGE_COLUMN_LEFT_L))
+    , mImgRight_L					(SW_RES(IMG_PAGE_COLUMN_RIGHT_L))
+    , mImgColumnNone_L			(SW_RES(IMG_PAGE_COLUMN_NONE_L))
+
+    , mpPageItem( new SvxPageItem(SID_ATTR_PAGE) )
+    , mpPageLRMarginItem( new SvxLongLRSpaceItem( 0, 0, SID_ATTR_LONG_LRSPACE ) )
+    , mpPageULMarginItem( new SvxLongULSpaceItem( 0, 0, SID_ATTR_LONG_ULSPACE ) )
+    , mpPageSizeItem( new SvxSizeItem(SID_ATTR_PAGE_SIZE) )
+    , mePaper( PAPER_USER )
+    , mpPageColumnTypeItem( new SfxInt16Item(SID_ATTR_SWPAGE_COLUMN) )
+
+    , meFUnit()
+    , meUnit()
+
+    , m_aSwPagePgULControl		(SID_ATTR_LONG_ULSPACE, *pBindings, *this)
+    , m_aSwPagePgLRControl		(SID_ATTR_LONG_LRSPACE, *pBindings, *this)
+    , m_aSwPagePgSizeControl		(SID_ATTR_PAGE_SIZE, *pBindings, *this)
+    , m_aSwPagePgControl			(SID_ATTR_PAGE, *pBindings, *this)
+    , m_aSwPageColControl			(SID_ATTR_SWPAGE_COLUMN, *pBindings, *this)
+    , m_aSwPagePgMetricControl	(SID_ATTR_METRIC, *pBindings, *this)
+
+    , mpOrientationPopup()
+    , mpMarginPopup()
+    , mpSizePopup()
+    , mpColumnPopup()
+{
+    Initialize();
+    FreeResource();
+}
+
+PagePropertyPanel::~PagePropertyPanel()
+{
+    delete[] maImgSize;
+    delete[] maImgSize_L;
+
+    // destroy the toolbox windows.
+    mpToolBoxOrientation.reset();
+    mpToolBoxMargin.reset();
+    mpToolBoxSize.reset();
+    mpToolBoxColumn.reset();
+
+    // destroy the background windows of the toolboxes.
+    mpToolBoxOrientationBackground.reset();
+    mpToolBoxMarginBackground.reset();
+    mpToolBoxSizeBackground.reset();
+    mpToolBoxColumnBackground.reset();
+}
+
+void PagePropertyPanel::Initialize()
+{
+    // popup for page orientation
+    Link aLink = LINK( this, PagePropertyPanel, ClickOrientationHdl );
+    mpToolBoxOrientation->SetDropdownClickHdl( aLink );
+    mpToolBoxOrientation->SetSelectHdl( aLink );
+    mpToolBoxOrientation->SetItemImage( TBI_ORIENTATION, mImgPortrait);
+    mpToolBoxOrientation->SetItemBits( TBI_ORIENTATION, mpToolBoxOrientation->GetItemBits( TBI_ORIENTATION ) | TIB_DROPDOWNONLY );
+    mpToolBoxOrientation->SetQuickHelpText(TBI_ORIENTATION,String(SW_RES(STR_QHELP_TB_ORIENTATION)));
+    mpToolBoxOrientation->SetOutputSizePixel( mpToolBoxOrientation->CalcWindowSizePixel() );
+    mpToolBoxOrientation->SetBackground( Wallpaper() );
+    mpToolBoxOrientation->SetPaintTransparent( sal_True );
+
+    // popup for page margins
+    aLink = LINK( this, PagePropertyPanel, ClickMarginHdl );
+    mpToolBoxMargin->SetDropdownClickHdl( aLink );
+    mpToolBoxMargin->SetSelectHdl( aLink );
+    mpToolBoxMargin->SetItemImage(TBI_MARGIN, mImgNormal);
+    mpToolBoxMargin->SetItemBits( TBI_MARGIN, mpToolBoxMargin->GetItemBits( TBI_MARGIN ) | TIB_DROPDOWNONLY );
+    mpToolBoxMargin->SetQuickHelpText(TBI_MARGIN,String(SW_RES(STR_QHELP_TB_MARGIN)));
+    mpToolBoxMargin->SetOutputSizePixel( mpToolBoxMargin->CalcWindowSizePixel() );
+    mpToolBoxMargin->SetBackground(Wallpaper());
+    mpToolBoxMargin->SetPaintTransparent( sal_True );
+
+    // popup for page size
+    aLink = LINK( this, PagePropertyPanel, ClickSizeHdl );
+    mpToolBoxSize->SetDropdownClickHdl( aLink );
+    mpToolBoxSize->SetSelectHdl( aLink );
+    mpToolBoxSize->SetItemImage(TBI_SIZE, mImgLetter);
+    mpToolBoxSize->SetItemBits( TBI_SIZE, mpToolBoxSize->GetItemBits( TBI_SIZE ) | TIB_DROPDOWNONLY );
+    mpToolBoxSize->SetQuickHelpText(TBI_SIZE,String(SW_RES(STR_QHELP_TB_SIZE)));
+    mpToolBoxSize->SetOutputSizePixel( mpToolBoxSize->CalcWindowSizePixel() );
+    mpToolBoxSize->SetBackground(Wallpaper());
+    mpToolBoxSize->SetPaintTransparent( sal_True );
+    maImgSize = new Image[8];
+    maImgSize[0] = mImgA3;
+    maImgSize[1] = mImgA4;
+    maImgSize[2] = mImgA5;
+    maImgSize[3] = mImgB4;
+    maImgSize[4] = mImgB5;
+    maImgSize[5] = mImgC5;
+    maImgSize[6] = mImgLetter;
+    maImgSize[7] = mImgLegal;
+    maImgSize_L = new Image[8];
+    maImgSize_L[0] = mImgA3_L;
+    maImgSize_L[1] = mImgA4_L;
+    maImgSize_L[2] = mImgA5_L;
+    maImgSize_L[3] = mImgB4_L;
+    maImgSize_L[4] = mImgB5_L;
+    maImgSize_L[5] = mImgC5_L;
+    maImgSize_L[6] = mImgLetter_L;
+    maImgSize_L[7] = mImgLegal_L;
+
+    // popup for page column property
+    aLink = LINK( this, PagePropertyPanel, ClickColumnHdl );
+    mpToolBoxColumn->SetDropdownClickHdl( aLink );
+    mpToolBoxColumn->SetSelectHdl( aLink );
+    mpToolBoxColumn->SetItemImage(TBI_COLUMN, mImgColumn1);
+    mpToolBoxColumn->SetItemBits( TBI_COLUMN, mpToolBoxColumn->GetItemBits( TBI_COLUMN ) | TIB_DROPDOWNONLY );
+    mpToolBoxColumn->SetQuickHelpText(TBI_COLUMN,String(SW_RES(STR_QHELP_TB_COLUMN)));
+    mpToolBoxColumn->SetOutputSizePixel( mpToolBoxColumn->CalcWindowSizePixel() );
+    mpToolBoxColumn->SetBackground(Wallpaper());
+    mpToolBoxColumn->SetPaintTransparent( sal_True );
+
+    meFUnit = GetModuleFieldUnit(); 
+    meUnit  = m_aSwPagePgSizeControl.GetCoreMetric();
+
+    // 'pull' for page style's attribute values
+    mpBindings->Update( SID_ATTR_LONG_LRSPACE );
+    mpBindings->Update( SID_ATTR_LONG_ULSPACE );
+    mpBindings->Update( SID_ATTR_PAGE );
+    mpBindings->Update( SID_ATTR_PAGE_SIZE );
+}
+
+
+void PagePropertyPanel::DataChanged( const DataChangedEvent& rEvent )
+{
+    // currently nothing special to do
+
+    // forward to base class
+    Control::DataChanged( rEvent );
+}
+
+
+void PagePropertyPanel::HandleContextChange( const ::sfx2::sidebar::EnumContext aContext)
+{
+    if (maContext == aContext)
+    {
+        // nothing to do.
+        return;
+    }
+
+    maContext = aContext;
+
+    // TODO: reactions on certain context switches
+}
+
+
+void PagePropertyPanel::ShowPageStyleFormatDialog( void )
+{
+    mpBindings->GetDispatcher()->Execute( FN_FORMAT_PAGE_DLG, SFX_CALLMODE_ASYNCHRON );
+}
+
+
+
+
+::svx::sidebar::PopupControl* PagePropertyPanel::CreatePageOrientationControl( ::svx::sidebar::PopupContainer* pParent )
+{
+    return new PageOrientationControl( pParent, *this , mpPageItem->IsLandscape() );
+}
+
+
+IMPL_LINK( PagePropertyPanel, ClickOrientationHdl, ToolBox*, pToolBox )
+{
+    mpOrientationPopup.reset(
+        new ::svx::sidebar::Popup(
+            this,
+            ::boost::bind(&PagePropertyPanel::CreatePageOrientationControl, this, _1),
+            ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Page orientation")) ) );
+    mpOrientationPopup->Show( *pToolBox );
+
+    return 0L;
+}
+
+
+void PagePropertyPanel::ExecuteOrientationChange( const sal_Bool bLandscape )
+{
+    {
+        // set new page orientation
+        mpPageItem->SetLandscape( bLandscape );
+
+        // swap the width and height of the page size
+        mpPageSizeItem->SetSize( Size( mpPageSizeItem->GetSize().Height(), mpPageSizeItem->GetSize().Width() ) );
+
+        // apply changed attributes
+        GetBindings()->GetDispatcher()->Execute( SID_ATTR_PAGE_SIZE, SFX_CALLMODE_RECORD, mpPageSizeItem.get(), mpPageItem.get(), 0L );
+    }
+
+    // check, if margin values still fit to the changed page size.
+    // if not, adjust margin values
+    {
+        const long nML = mpPageLRMarginItem->GetLeft();
+        const long nMR = mpPageLRMarginItem->GetRight();
+        const long nTmpPW = nML + nMR + MINBODY;
+
+        const long nPW  = mpPageSizeItem->GetSize().Width();
+
+        if ( nTmpPW > nPW )
+        {
+            if ( nML <= nMR )
+            {
+                ExecuteMarginLRChange( mpPageLRMarginItem->GetLeft(), nMR - (nTmpPW - nPW ) );
+            }
+            else
+            {
+                ExecuteMarginLRChange( nML - (nTmpPW - nPW ), mpPageLRMarginItem->GetRight() );
+            }
+        }
+
+        const long nMT = mpPageULMarginItem->GetUpper();
+        const long nMB = mpPageULMarginItem->GetLower();
+        const long nTmpPH = nMT + nMB + MINBODY;
+
+        const long nPH  = mpPageSizeItem->GetSize().Height();
+
+        if ( nTmpPH > nPH )
+        {
+            if ( nMT <= nMB )
+            {
+                ExecuteMarginULChange( mpPageULMarginItem->GetUpper(), nMB - ( nTmpPH - nPH ) );
+            }
+            else
+            {
+                ExecuteMarginULChange( nMT - ( nTmpPH - nPH ), mpPageULMarginItem->GetLower() );
+            }
+        }
+    }
+}
+
+
+void PagePropertyPanel::ClosePageOrientationPopup()
+{
+    mpOrientationPopup->Hide();
+    mpOrientationPopup.reset( 0 );
+}
+
+
+
+
+::svx::sidebar::PopupControl* PagePropertyPanel::CreatePageMarginControl( ::svx::sidebar::PopupContainer* pParent )
+{
+    return new PageMarginControl( 
+        pParent, 
+        *this,
+        *mpPageLRMarginItem.get(),
+        *mpPageULMarginItem.get(),
+        mpPageItem->GetPageUsage() == SVX_PAGE_MIRROR,
+        mpPageSizeItem->GetSize(),
+        mpPageItem->IsLandscape(),
+        meFUnit,
+        meUnit );
+}
+
+
+void PagePropertyPanel::ExecuteMarginLRChange(
+    const long nPageLeftMargin,
+    const long nPageRightMargin )
+{
+    mpPageLRMarginItem->SetLeft( nPageLeftMargin );
+    mpPageLRMarginItem->SetRight( nPageRightMargin );
+    GetBindings()->GetDispatcher()->Execute( SID_ATTR_LONG_LRSPACE, SFX_CALLMODE_RECORD, mpPageLRMarginItem.get(),  0L );	
+}
+
+void PagePropertyPanel::ExecuteMarginULChange(
+    const long nPageTopMargin,
+    const long nPageBottomMargin )
+{
+    mpPageULMarginItem->SetUpper( nPageTopMargin );
+    mpPageULMarginItem->SetLower( nPageBottomMargin );
+    GetBindings()->GetDispatcher()->Execute( SID_ATTR_LONG_ULSPACE, SFX_CALLMODE_RECORD, mpPageULMarginItem.get(),  0L );
+}
+
+
+void PagePropertyPanel::ExecutePageLayoutChange( const bool bMirrored )
+{
+    mpPageItem->SetPageUsage( bMirrored ? SVX_PAGE_MIRROR : SVX_PAGE_ALL );
+    GetBindings()->GetDispatcher()->Execute( SID_ATTR_PAGE, SFX_CALLMODE_RECORD, mpPageItem.get(),  0L );
+}
+
+
+IMPL_LINK( PagePropertyPanel, ClickMarginHdl, ToolBox*, pToolBox )
+{
+    mpMarginPopup.reset(
+        new ::svx::sidebar::Popup(
+            this,
+            ::boost::bind(&PagePropertyPanel::CreatePageMarginControl, this, _1),
+            ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Page margins")) ) );
+    mpMarginPopup->Show( *pToolBox );
+
+    return 0L;
+}
+
+
+void PagePropertyPanel::ClosePageMarginPopup()
+{
+    mpMarginPopup->Hide();
+    mpMarginPopup.reset( 0 );
+}
+
+
+
+
+::svx::sidebar::PopupControl* PagePropertyPanel::CreatePageSizeControl( ::svx::sidebar::PopupContainer* pParent )
+{
+    return new PageSizeControl( 
+        pParent, 
+        *this,
+        mePaper,
+        mpPageItem->IsLandscape(),
+        meFUnit );
+}
+
+
+void PagePropertyPanel::ExecuteSizeChange( const Paper ePaper )
+{
+    Size aPageSize = SvxPaperInfo::GetPaperSize( ePaper, (MapUnit)(meUnit) );
+    if ( mpPageItem->IsLandscape() )
+    {
+        Swap( aPageSize );
+    }
+    mpPageSizeItem->SetSize( aPageSize );
+
+    mpBindings->GetDispatcher()->Execute(SID_ATTR_PAGE_SIZE, SFX_CALLMODE_RECORD, mpPageSizeItem.get(),  0L );	
+}
+
+
+IMPL_LINK( PagePropertyPanel, ClickSizeHdl, ToolBox*, pToolBox )
+{
+    mpSizePopup.reset(
+        new ::svx::sidebar::Popup(
+            this,
+            ::boost::bind(&PagePropertyPanel::CreatePageSizeControl, this, _1),
+            ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Page size")) ) );
+    mpSizePopup->Show( *pToolBox );
+
+    return 0L;
+}
+
+
+void PagePropertyPanel::ClosePageSizePopup()
+{
+    mpSizePopup->Hide();
+    mpSizePopup.reset( 0 );
+}
+
+
+
+
+::svx::sidebar::PopupControl* PagePropertyPanel::CreatePageColumnControl( ::svx::sidebar::PopupContainer* pParent )
+{
+    return new PageColumnControl(
+        pParent,
+        *this,
+        mpPageColumnTypeItem->GetValue(),
+        mpPageItem->IsLandscape() );
+}
+
+
+void PagePropertyPanel::ExecuteColumnChange( const sal_uInt16 nColumnType )
+{
+    mpPageColumnTypeItem->SetValue( nColumnType );
+    mpBindings->GetDispatcher()->Execute(SID_ATTR_SWPAGE_COLUMN, SFX_CALLMODE_RECORD, mpPageColumnTypeItem.get(),  0L );
+}
+
+
+IMPL_LINK( PagePropertyPanel, ClickColumnHdl, ToolBox*, pToolBox )
+{
+    mpColumnPopup.reset(
+        new ::svx::sidebar::Popup(
+            this,
+            ::boost::bind(&PagePropertyPanel::CreatePageColumnControl, this, _1),
+            ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Page columns")) ) );
+    mpColumnPopup->Show( *pToolBox );
+
+    return 0L;
+}
+
+
+void PagePropertyPanel::ClosePageColumnPopup()
+{
+    mpColumnPopup->Hide();
+    mpColumnPopup.reset( 0 );
+}
+
+
+
+
+void PagePropertyPanel::NotifyItemUpdate(
+    const sal_uInt16 nSId,
+    const SfxItemState eState,
+    const SfxPoolItem* pState)
+{
+    switch( nSId )
+    {
+    case SID_ATTR_SWPAGE_COLUMN:
+        {
+            if ( eState >= SFX_ITEM_AVAILABLE && 
+                 pState && pState->ISA(SfxInt16Item) )
+            {
+                mpPageColumnTypeItem.reset( static_cast<SfxInt16Item*>(pState->Clone()) );
+                ChangeColumnImage( mpPageColumnTypeItem->GetValue() );
+            }
+        }
+        break;
+    case SID_ATTR_LONG_LRSPACE:
+        if ( eState >= SFX_ITEM_AVAILABLE &&
+             pState && pState->ISA(SvxLongLRSpaceItem) )
+        {
+            mpPageLRMarginItem.reset( static_cast<SvxLongLRSpaceItem*>(pState->Clone()) );
+            ChangeMarginImage();
+        }
+        break;
+
+    case SID_ATTR_LONG_ULSPACE:
+        if ( eState >= SFX_ITEM_AVAILABLE &&
+             pState && pState->ISA(SvxLongULSpaceItem) )
+        {
+            mpPageULMarginItem.reset( static_cast<SvxLongULSpaceItem*>(pState->Clone()) );
+            ChangeMarginImage();
+        }
+        break;
+
+    case SID_ATTR_PAGE:
+        if ( eState >= SFX_ITEM_AVAILABLE && 
+             pState && pState->ISA(SvxPageItem) )
+        {
+            mpPageItem.reset( static_cast<SvxPageItem*>(pState->Clone()) );
+            if ( mpPageItem->IsLandscape() )
+            {
+                mpToolBoxOrientation->SetItemImage(TBI_ORIENTATION, mImgLandscape);
+            }
+            else
+            {
+                mpToolBoxOrientation->SetItemImage(TBI_ORIENTATION, mImgPortrait);
+            }
+            ChangeMarginImage();
+            ChangeSizeImage();
+            ChangeColumnImage( mpPageColumnTypeItem->GetValue() );
+        }
+        break;
+
+    case SID_ATTR_PAGE_SIZE:
+        mpBindings->Invalidate( SID_ATTR_PAGE, sal_True, sal_False );
+        if ( eState >= SFX_ITEM_AVAILABLE &&
+             pState && pState->ISA(SvxSizeItem) )
+        {
+            mpPageSizeItem.reset( static_cast<SvxSizeItem*>(pState->Clone()) );
+            ChangeSizeImage();
+        }
+        break;
+    case SID_ATTR_METRIC:
+        MetricState( eState, pState );
+        break;
+    }
+}
+
+
+void PagePropertyPanel::MetricState( SfxItemState eState, const SfxPoolItem* pState )
+{
+    meFUnit = FUNIT_NONE;
+    if ( pState && eState >= SFX_ITEM_DEFAULT )
+    {
+        meFUnit = (FieldUnit)( (const SfxUInt16Item*)pState )->GetValue();
+    }
+    else
+    {
+        SfxViewFrame* pFrame = SfxViewFrame::Current();
+        SfxObjectShell* pSh = NULL;
+        if ( pFrame )
+            pSh = pFrame->GetObjectShell();
+        if ( pSh )
+        {
+            SfxModule* pModule = pSh->GetModule();
+            if ( pModule )
+            {
+                const SfxPoolItem* pItem = pModule->GetItem( SID_ATTR_METRIC );
+                if ( pItem )
+                    meFUnit = (FieldUnit)( (SfxUInt16Item*)pItem )->GetValue();
+            }
+            else
+            {
+                DBG_ERRORFILE( "<PagePropertyPanel::MetricState(..)>: no module found" );
+            }
+        }
+    }
+}
+
+
+
+
+void PagePropertyPanel::ChangeMarginImage()
+{
+    if ( mpPageLRMarginItem.get() == 0 ||
+         mpPageULMarginItem.get() == 0 ||
+         mpPageItem.get() == 0 )
+    {
+        return;
+    }
+
+    const long cTolerance = 5;
+
+    if( abs(mpPageLRMarginItem->GetLeft() - SWPAGE_NARROW_VALUE) <= cTolerance &&
+        abs(mpPageLRMarginItem->GetRight() - SWPAGE_NARROW_VALUE) <= cTolerance &&
+        abs(mpPageULMarginItem->GetUpper() - SWPAGE_NARROW_VALUE) <= cTolerance &&
+        abs(mpPageULMarginItem->GetLower() - SWPAGE_NARROW_VALUE) <= cTolerance &&
+        mpPageItem->GetPageUsage() != SVX_PAGE_MIRROR )
+        mpToolBoxMargin->SetItemImage( TBI_MARGIN, mpPageItem->IsLandscape() ? mImgNarrow_L : mImgNarrow );
+
+    else if( abs(mpPageLRMarginItem->GetLeft() - SWPAGE_NORMAL_VALUE) <= cTolerance &&
+        abs(mpPageLRMarginItem->GetRight() - SWPAGE_NORMAL_VALUE) <= cTolerance &&
+        abs(mpPageULMarginItem->GetUpper() - SWPAGE_NORMAL_VALUE) <= cTolerance &&
+        abs(mpPageULMarginItem->GetLower() - SWPAGE_NORMAL_VALUE) <= cTolerance &&
+        mpPageItem->GetPageUsage() != SVX_PAGE_MIRROR )
+        mpToolBoxMargin->SetItemImage(TBI_MARGIN, mpPageItem->IsLandscape() ? mImgNormal_L : mImgNormal );
+
+    else if( abs(mpPageLRMarginItem->GetLeft() - SWPAGE_WIDE_VALUE2) <= cTolerance &&
+        abs(mpPageLRMarginItem->GetRight() - SWPAGE_WIDE_VALUE2) <= cTolerance &&
+        abs(mpPageULMarginItem->GetUpper() - SWPAGE_WIDE_VALUE1) <= cTolerance &&
+        abs(mpPageULMarginItem->GetLower() - SWPAGE_WIDE_VALUE1) <= cTolerance &&
+        mpPageItem->GetPageUsage() != SVX_PAGE_MIRROR )
+        mpToolBoxMargin->SetItemImage(TBI_MARGIN, mpPageItem->IsLandscape() ? mImgWide_L : mImgWide );
+
+    else if( abs(mpPageLRMarginItem->GetLeft() - SWPAGE_WIDE_VALUE3) <= cTolerance &&
+        abs(mpPageLRMarginItem->GetRight() - SWPAGE_WIDE_VALUE1) <= cTolerance &&
+        abs(mpPageULMarginItem->GetUpper() - SWPAGE_WIDE_VALUE1) <= cTolerance &&
+        abs(mpPageULMarginItem->GetLower() - SWPAGE_WIDE_VALUE1) <= cTolerance &&
+        mpPageItem->GetPageUsage() == SVX_PAGE_MIRROR )
+        mpToolBoxMargin->SetItemImage(TBI_MARGIN, mpPageItem->IsLandscape() ? mImgMirrored_L : mImgMirrored );
+
+    else 
+        mpToolBoxMargin->SetItemImage(TBI_MARGIN, mpPageItem->IsLandscape() ? mImgMarginCustom_L : mImgMarginCustom );
+}
+
+
+void PagePropertyPanel::ChangeSizeImage()
+{
+    if ( mpPageSizeItem.get() == 0 ||
+         mpPageItem.get() == 0 )
+    {
+        return;
+    }
+
+    Size aTmpPaperSize = mpPageSizeItem->GetSize();
+    if ( mpPageItem->IsLandscape() )
+    {
+        Swap( aTmpPaperSize ); // Swap(..) defined in editeng/paperinf.hxx
+    }
+
+    mePaper = SvxPaperInfo::GetSvxPaper( aTmpPaperSize, static_cast<MapUnit>(meUnit), sal_True );
+
+    sal_uInt16 nImageIdx = 0;
+    switch ( mePaper )
+    {
+    case PAPER_A3:
+        nImageIdx = 1;
+        break;
+    case PAPER_A4:
+        nImageIdx = 2;
+        break;
+    case PAPER_A5:
+        nImageIdx = 3;
+        break;
+    case PAPER_B4_ISO:
+        nImageIdx = 4;
+        break;
+    case PAPER_B5_ISO:
+        nImageIdx = 5;
+        break;
+    case PAPER_ENV_C5:
+        nImageIdx = 6;
+        break;
+    case PAPER_LETTER:
+        nImageIdx = 7;
+        break;
+    case PAPER_LEGAL:
+        nImageIdx = 8;
+        break;
+    default:
+        nImageIdx = 0;
+        mePaper = PAPER_USER;
+        break;
+    }
+
+    if ( nImageIdx == 0 )
+    {
+        mpToolBoxSize->SetItemImage( TBI_SIZE, 
+                                     ( mpPageItem->IsLandscape() ? mImgSizeNone_L : mImgSizeNone  ) );
+    }
+    else
+    {
+        mpToolBoxSize->SetItemImage( TBI_SIZE, 
+                                     ( mpPageItem->IsLandscape() ? maImgSize_L[nImageIdx-1] : maImgSize[nImageIdx-1] ) );
+    }
+}
+
+
+void PagePropertyPanel::ChangeColumnImage( const sal_uInt16 nColumnType )
+{
+    if ( mpPageItem.get() == 0 )
+    {
+        return;
+    }
+
+    if ( !mpPageItem->IsLandscape() )
+    {
+        switch( nColumnType )
+        {
+        case 1:
+            mpToolBoxColumn->SetItemImage(TBI_COLUMN, mImgColumn1);
+            break;
+        case 2:
+            mpToolBoxColumn->SetItemImage(TBI_COLUMN, mImgColumn2);
+            break;
+        case 3:
+            mpToolBoxColumn->SetItemImage(TBI_COLUMN, mImgColumn3);
+            break;
+        case 4:
+            mpToolBoxColumn->SetItemImage(TBI_COLUMN, mImgLeft);
+            break;
+        case 5:
+            mpToolBoxColumn->SetItemImage(TBI_COLUMN, mImgRight);
+            break;
+        default:
+            mpToolBoxColumn->SetItemImage(TBI_COLUMN, mImgColumnNone);
+        }
+    }
+    else
+    {
+        switch( nColumnType )
+        {
+        case 1:
+            mpToolBoxColumn->SetItemImage(TBI_COLUMN, mImgColumn1_L);
+            break;
+        case 2:
+            mpToolBoxColumn->SetItemImage(TBI_COLUMN, mImgColumn2_L);
+            break;
+        case 3:
+            mpToolBoxColumn->SetItemImage(TBI_COLUMN, mImgColumn3_L);
+            break;
+        case 4:
+            mpToolBoxColumn->SetItemImage(TBI_COLUMN, mImgLeft_L);
+            break;
+        case 5:
+            mpToolBoxColumn->SetItemImage(TBI_COLUMN, mImgRight_L);
+            break;
+        default:
+            mpToolBoxColumn->SetItemImage(TBI_COLUMN, mImgColumnNone_L);
+        }
+    }
+}
+
+} } // end of namespace ::sw::sidebar

Added: openoffice/branches/sidebar/main/sw/source/ui/sidebar/PagePropertyPanel.hrc
URL: http://svn.apache.org/viewvc/openoffice/branches/sidebar/main/sw/source/ui/sidebar/PagePropertyPanel.hrc?rev=1456629&view=auto
==============================================================================
--- openoffice/branches/sidebar/main/sw/source/ui/sidebar/PagePropertyPanel.hrc (added)
+++ openoffice/branches/sidebar/main/sw/source/ui/sidebar/PagePropertyPanel.hrc Thu Mar 14 20:00:19 2013
@@ -0,0 +1,201 @@
+/**************************************************************
+* 
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements.  See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership.  The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License.  You may obtain a copy of the License at
+* 
+*   http://www.apache.org/licenses/LICENSE-2.0
+* 
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied.  See the License for the
+* specific language governing permissions and limitations
+* under the License.
+* 
+*************************************************************/
+
+//#include <sfx2/propertypanel.hrc>
+#include "PropertyPanel.hrc"
+	
+#define FT_ORIENTATION			1
+#define TB_ORIENTATION			2
+#define FT_MARGIN				3
+#define TB_MARGIN				4
+#define FT_SIZE					5
+#define TB_SIZE					6
+#define FT_COLUMN				7
+#define TB_COLUMN				8
+#define TBI_MARGIN				9
+#define IMG_PORTRAIT			10
+#define IMG_LANDSCAPE			11
+#define STR_PORTRAIT			12
+#define STR_LANDSCAPE			13
+#define ED_SWPAPER_WIDTH		14
+#define ED_SWPAPER_HEIGHT		15
+#define LB_SWPAPER_TRAY			16
+#define LB_SWPAPER_SIZE			17
+#define MF_SWLEFT_MARGIN		18
+#define MF_SWRIGHT_MARGIN		19
+#define MF_SWTOP_MARGIN			20
+#define MF_SWBOTTOM_MARGIN		21
+#define TBI_SIZE				22
+#define VS_SIZE					23
+#define STR_LCVALUE				24
+#define FT_CUSTOM				25
+#define FLD_WIDTH_HEIGHT		26
+
+#define TBI_ORIENTATION			28
+#define VS_ORIENTATION          29
+#define IMG_PAGE_PORTRAIT		30
+#define IMG_PAGE_LANDSCAPE		31
+#define IMG_NARROW			    32
+#define IMG_NORMAL			    33
+#define IMG_WIDE			    34
+#define IMG_MIRRORED			35
+#define STR_NARROW			    36
+#define STR_NORMAL			    37
+#define STR_WIDE			    38
+#define STR_MIRRORED			39
+#define VS_MARGIN				40
+#define	IMG_CUSTOM				41
+#define FT_LEFT					42
+#define FT_RIGHT				43
+#define FT_TOP					44
+#define FT_BOTTOM				45
+#define FT_INNER				46
+#define FT_OUTER				47
+#define	TBI_COLUMN				48
+#define VS_COLUMN				49
+#define MBOX_WIDTH				50
+#define IMG_ONE					51
+#define IMG_TWO					52
+#define IMG_THREE				53
+#define IMG_LEFT				54
+#define IMG_RIGHT				55
+#define STR_ONE					56
+#define STR_TWO					57
+#define STR_THREE				58
+#define STR_LEFT				59
+#define STR_RIGHT				60
+#define CB_COLUMN_MORE			61
+
+#define CB_SIZE_MORE			61
+
+#define IMG_PAGE_NARROW			64
+#define IMG_PAGE_NORMAL			65
+#define IMG_PAGE_WIDE			63
+#define IMG_PAGE_MIRRORED		67
+#define IMG_PAGE_MARGIN_CUSTOM	68
+#define IMG_PAGE_A3				69
+#define IMG_PAGE_A4				70
+#define IMG_PAGE_A5				71
+#define IMG_PAGE_B4				72
+#define IMG_PAGE_B5				73
+#define IMG_PAGE_C5				74
+#define IMG_PAGE_LETTER			75
+#define IMG_PAGE_LEGAL			76
+#define IMG_PAGE_COLUMN_1		77
+#define IMG_PAGE_COLUMN_2		78
+#define IMG_PAGE_COLUMN_3		79
+#define IMG_PAGE_COLUMN_LEFT	80
+#define IMG_PAGE_COLUMN_RIGHT   81
+#define IMG_PAGE_SIZE_NONE		82
+#define IMG_PAGE_COLUMN_NONE	83
+#define IMG_PAGE_COLUMN_1_L		84
+#define IMG_PAGE_COLUMN_2_L		85
+#define IMG_PAGE_COLUMN_3_L		86
+#define IMG_PAGE_COLUMN_LEFT_L	87
+#define IMG_PAGE_COLUMN_RIGHT_L 88
+#define IMG_PAGE_COLUMN_NONE_L	89
+#define IMG_ONE_L				90
+#define IMG_TWO_L				91
+#define IMG_THREE_L				92
+#define IMG_LEFT_L				93
+#define IMG_RIGHT_L				94
+#define IMG_PAGE_A3_L			95
+#define IMG_PAGE_A4_L			96
+#define IMG_PAGE_A5_L			97
+#define IMG_PAGE_B4_L			98
+#define IMG_PAGE_B5_L			99
+#define IMG_PAGE_C5_L			100
+#define IMG_PAGE_LETTER_L		101
+#define IMG_PAGE_LEGAL_L		102
+#define IMG_PAGE_SIZE_NONE_L	103
+#define IMG_PAGE_NARROW_L		104
+#define IMG_PAGE_NORMAL_L		105
+#define IMG_PAGE_WIDE_L			106
+#define IMG_PAGE_MIRRORED_L		107
+#define IMG_PAGE_MARGIN_CUSTOM_L	108
+#define IMG_NARROW_L			109
+#define IMG_NORMAL_L			110
+#define IMG_WIDE_L			    111
+#define IMG_MIRRORED_L			112
+#define FLD_LEFT_MARGIN			113
+#define FLD_RIGHT_MARGIN		114
+#define FLD_TOP_MARGIN			115
+#define FLD_BOTTOM_MARGIN		116
+
+#define STR_QHELP_TB_ORIENTATION	117
+#define STR_QHELP_TB_MARGIN			118
+#define STR_QHELP_TB_SIZE			119
+#define STR_QHELP_TB_COLUMN			120
+#define IMG_CUSTOM_DIS			121
+//
+#define STR_MARGIN_TOOLTIP_LEFT				122
+#define STR_MARGIN_TOOLTIP_RIGHT				123
+#define STR_MARGIN_TOOLTIP_INNER				124
+#define STR_MARGIN_TOOLTIP_OUTER				125
+#define STR_MARGIN_TOOLTIP_TOP					126
+#define STR_MARGIN_TOOLTIP_BOT					127
+
+#define POPUP_MARGIN            4
+#define VS_WIDTH				78
+#define ITEM_HEIGHT				17 
+#define ITEM_HEIGHT2			15 
+
+//========================================Position==============================================
+
+#define FT_ORIENTATION_X			SECTIONPAGE_MARGIN_HORIZONTAL
+#define FT_ORIENTATION_Y			SECTIONPAGE_MARGIN_VERTICAL_TOP
+#define TBX_ORIENTATION_X			FT_ORIENTATION_X
+#define TBX_ORIENTATION_Y			FT_ORIENTATION_Y + TEXT_HEIGHT + TEXT_CONTROL_SPACING_VERTICAL
+#define FT_MARGIN_X					FT_ORIENTATION_X + MBOX_WIDTH + CONTROL_SPACING_HORIZONTAL
+#define FT_MARGIN_Y					FT_ORIENTATION_Y
+#define TBX_MARGIN_X				FT_MARGIN_X
+#define TBX_MARGIN_Y				TBX_ORIENTATION_Y
+#define FT_SIZE_X					FT_ORIENTATION_X
+#define FT_SIZE_Y					TBX_ORIENTATION_Y + 20 + CONTROL_SPACING_VERTICAL
+#define TBX_SIZE_X					FT_SIZE_X
+#define TBX_SIZE_Y					FT_SIZE_Y + TEXT_HEIGHT + TEXT_CONTROL_SPACING_VERTICAL
+#define FT_COLUMN_X					FT_MARGIN_X
+#define FT_COLUMN_Y					FT_SIZE_Y
+#define TBX_COLUMN_X				FT_COLUMN_X
+#define TBX_COLUMN_Y				TBX_SIZE_Y
+
+#define FT_CUSTOM_X					POPUP_MARGIN + OFFSET_X
+#define FT_CUSTOM_Y					POPUPPANEL_MARGIN_SMALL * 2 + ITEM_HEIGHT * 5
+
+#define POP_BORDER_X						POPUP_MARGIN + OFFSET_X + 1
+#define POP_BORDER_Y						POPUPPANEL_MARGIN_SMALL * 3 + ITEM_HEIGHT * 5 + TEXT_HEIGHT
+#define BD_WIDTH							VS_WIDTH - 6
+#define BD_HEIGHT							MBOX_HEIGHT*4 + CONTROL_SPACING_VERTICAL*5
+
+#define FT_X								POP_BORDER_X + 	CONTROL_SPACING_HORIZONTAL
+#define MF_X								FT_X + 25 +	CONTROL_SPACING_HORIZONTAL
+#define LEFT_MF_Y							POP_BORDER_Y + 	CONTROL_SPACING_VERTICAL
+#define RIGHT_MF_Y							LEFT_MF_Y + MBOX_HEIGHT + CONTROL_SPACING_VERTICAL
+#define TOP_MF_Y							RIGHT_MF_Y + MBOX_HEIGHT + CONTROL_SPACING_VERTICAL
+#define BOTTOM_MF_Y							TOP_MF_Y + MBOX_HEIGHT + CONTROL_SPACING_VERTICAL
+#define FT_LEFT_Y							LEFT_MF_Y + 1
+#define FT_RIGHT_Y							RIGHT_MF_Y + 1
+#define FT_TOP_Y							TOP_MF_Y + 1
+#define FT_BOTTOM_Y							BOTTOM_MF_Y + 1
+
+#define MARGIN_PANEL_HEIGHT					POP_BORDER_Y + 	BD_HEIGHT + POPUP_MARGIN + OFFSET_Y
+#define CUST_MORE_BUTTON_IMG_OFF_X			POPUPPANEL_MARGIN_HORIZONTAL + OFFSET_X
+#define PAGE_HEIGHT							TBX_COLUMN_Y + 20 + SECTIONPAGE_MARGIN_VERTICAL_BOT
\ No newline at end of file

Added: openoffice/branches/sidebar/main/sw/source/ui/sidebar/PagePropertyPanel.hxx
URL: http://svn.apache.org/viewvc/openoffice/branches/sidebar/main/sw/source/ui/sidebar/PagePropertyPanel.hxx?rev=1456629&view=auto
==============================================================================
--- openoffice/branches/sidebar/main/sw/source/ui/sidebar/PagePropertyPanel.hxx (added)
+++ openoffice/branches/sidebar/main/sw/source/ui/sidebar/PagePropertyPanel.hxx Thu Mar 14 20:00:19 2013
@@ -0,0 +1,232 @@
+/**************************************************************
+* 
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements.  See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership.  The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License.  You may obtain a copy of the License at
+* 
+*   http://www.apache.org/licenses/LICENSE-2.0
+* 
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied.  See the License for the
+* specific language governing permissions and limitations
+* under the License.
+* 
+*************************************************************/
+
+#ifndef SW_SIDEBAR_PAGE_PROPERTY_PANEL_HXX
+#define SW_SIDEBAR_PAGE_PROPERTY_PANEL_HXX
+
+#include <svx/sidebar/Popup.hxx>
+
+#include <sfx2/sidebar/SidebarPanelBase.hxx>
+#include <sfx2/sidebar/ControllerItem.hxx>
+
+namespace svx { namespace sidebar {
+    class PopupControl;
+} }
+
+#include <i18npool/paper.hxx>
+
+#include <svx/pageitem.hxx>
+#include <editeng/sizeitem.hxx>
+
+#include <vcl/ctrl.hxx>
+#include <vcl/fixed.hxx>
+#include <vcl/button.hxx>
+#include <vcl/toolbox.hxx>
+#include <vcl/lstbox.hxx>
+#include <vcl/field.hxx>
+
+#include <boost/scoped_ptr.hpp>
+
+
+namespace sw { namespace sidebar {
+
+    class PagePropertyPanel 
+        : public Control,
+          public ::sfx2::sidebar::SidebarPanelBase::ContextChangeReceiverInterface,
+          public ::sfx2::sidebar::ControllerItem::ItemUpdateReceiverInterface
+    {
+    public:
+        static PagePropertyPanel* Create(
+            Window* pParent,
+            const cssu::Reference<css::frame::XFrame>& rxFrame,
+            SfxBindings* pBindings);
+
+        // override Window::DataChanged(..) inherited via Control to react on certain changes
+        virtual void DataChanged( const DataChangedEvent& rEvent );
+
+        // interface of ::sfx2::sidebar::SidebarPanelBase::ContextChangeReceiverInterface
+        virtual void HandleContextChange(
+            const ::sfx2::sidebar::EnumContext aContext);
+
+        // interface of ::sfx2::sidebar::ControllerItem::ItemUpdateReceiverInterface
+        virtual void NotifyItemUpdate(
+            const sal_uInt16 nSId,
+            const SfxItemState eState,
+            const SfxPoolItem* pState);
+
+        // action on 'More Options' button in panel title
+        void ShowPageStyleFormatDialog( void );
+
+        SfxBindings* GetBindings() const
+        {
+            return mpBindings;
+        }
+
+
+        ::svx::sidebar::PopupControl* CreatePageOrientationControl( ::svx::sidebar::PopupContainer* pParent );
+        void ExecuteOrientationChange( const sal_Bool bLandscape );
+        void ClosePageOrientationPopup();
+
+        ::svx::sidebar::PopupControl* CreatePageMarginControl( ::svx::sidebar::PopupContainer* pParent );
+        void ExecuteMarginLRChange( 
+            const long nPageLeftMargin,
+            const long nPageRightMargin );
+        void ExecuteMarginULChange(
+            const long nPageTopMargin,
+            const long nPageBottomMargin );
+        void ExecutePageLayoutChange( const bool bMirrored );
+        void ClosePageMarginPopup();
+
+        ::svx::sidebar::PopupControl* CreatePageSizeControl( ::svx::sidebar::PopupContainer* pParent );
+        void ExecuteSizeChange( const Paper ePaper );
+        void ClosePageSizePopup();
+
+        ::svx::sidebar::PopupControl* CreatePageColumnControl( ::svx::sidebar::PopupContainer* pParent );
+        void ExecuteColumnChange( const sal_uInt16 nColumnType );
+        void ClosePageColumnPopup();
+
+    private:
+        PagePropertyPanel(
+            Window* pParent,
+            const cssu::Reference<css::frame::XFrame>& rxFrame,
+            SfxBindings* pBindings);
+        virtual ~PagePropertyPanel(void);
+
+        cssu::Reference<css::frame::XFrame> mxFrame;
+        ::sfx2::sidebar::EnumContext maContext;
+        SfxBindings* mpBindings;
+
+        // toolboxes - on click open corresponding popup
+        FixedText   maFtOrientation;
+        ::boost::scoped_ptr<Window> mpToolBoxOrientationBackground;
+        ::boost::scoped_ptr<ToolBox> mpToolBoxOrientation;
+        FixedText				maFtMargin;
+        ::boost::scoped_ptr<Window> mpToolBoxMarginBackground;
+        ::boost::scoped_ptr<ToolBox> mpToolBoxMargin;
+        FixedText				maFtSize;
+        ::boost::scoped_ptr<Window> mpToolBoxSizeBackground;
+        ::boost::scoped_ptr<ToolBox> mpToolBoxSize;
+        FixedText				maFtColumn;
+        ::boost::scoped_ptr<Window> mpToolBoxColumnBackground;
+        ::boost::scoped_ptr<ToolBox> mpToolBoxColumn;
+
+        Image*					maImgSize;
+        Image*					maImgSize_L;
+        Image					mImgPortrait;
+        Image					mImgLandscape;
+        Image					mImgNarrow;
+        Image					mImgNormal;
+        Image					mImgWide;
+        Image					mImgMirrored;
+        Image					mImgMarginCustom;
+        Image					mImgNarrow_L;
+        Image					mImgNormal_L;
+        Image					mImgWide_L;
+        Image					mImgMirrored_L;
+        Image					mImgMarginCustom_L;
+        Image					mImgA3;
+        Image					mImgA4;
+        Image					mImgA5;
+        Image					mImgB4;
+        Image					mImgB5;
+        Image					mImgC5;
+        Image					mImgLetter;
+        Image					mImgLegal;
+        Image					mImgSizeNone;
+        Image					mImgA3_L;
+        Image					mImgA4_L;
+        Image					mImgA5_L;
+        Image					mImgB4_L;
+        Image					mImgB5_L;
+        Image					mImgC5_L;
+        Image					mImgLetter_L;
+        Image					mImgLegal_L;
+        Image					mImgSizeNone_L;
+        Image					mImgColumn1;
+        Image					mImgColumn2;
+        Image					mImgColumn3;
+        Image					mImgLeft;
+        Image					mImgRight;
+        Image					mImgColumnNone;
+        Image					mImgColumn1_L;
+        Image					mImgColumn2_L;
+        Image					mImgColumn3_L;
+        Image					mImgLeft_L;
+        Image					mImgRight_L;
+        Image					mImgColumnNone_L;
+
+        // item keeping the following page style attributes:
+        // - page orientation
+        // - page usage - only left, only right, both, mirrored
+        // item also hold the numbering type for the page style which should
+        // be kept stable.
+        ::boost::scoped_ptr<SvxPageItem> mpPageItem;
+
+        // item keeping the page style's left and right margins
+        ::boost::scoped_ptr<SvxLongLRSpaceItem> mpPageLRMarginItem;
+        // item keeping the page style's top and bottom margins
+        ::boost::scoped_ptr<SvxLongULSpaceItem> mpPageULMarginItem;
+
+        // item keeping the page style's page size
+        ::boost::scoped_ptr<SvxSizeItem> mpPageSizeItem;
+        // Paper corresponding to the page style's page size
+        Paper mePaper;
+
+        // item keeping the page column type
+        ::boost::scoped_ptr<SfxInt16Item> mpPageColumnTypeItem;
+
+        FieldUnit 			meFUnit;
+        SfxMapUnit			meUnit;
+
+        // controller items
+        ::sfx2::sidebar::ControllerItem m_aSwPagePgULControl;
+        ::sfx2::sidebar::ControllerItem m_aSwPagePgLRControl;
+        ::sfx2::sidebar::ControllerItem m_aSwPagePgSizeControl;
+        ::sfx2::sidebar::ControllerItem m_aSwPagePgControl;
+        ::sfx2::sidebar::ControllerItem m_aSwPageColControl;
+        ::sfx2::sidebar::ControllerItem m_aSwPagePgMetricControl;
+        
+        // popups
+        ::boost::scoped_ptr< ::svx::sidebar::Popup > mpOrientationPopup;
+        ::boost::scoped_ptr< ::svx::sidebar::Popup > mpMarginPopup;
+        ::boost::scoped_ptr< ::svx::sidebar::Popup > mpSizePopup;
+        ::boost::scoped_ptr< ::svx::sidebar::Popup > mpColumnPopup;
+
+        // handler for popup toolboxes to show the popups
+        DECL_LINK(ClickOrientationHdl, ToolBox* );
+        DECL_LINK(ClickMarginHdl, ToolBox* );
+        DECL_LINK(ClickSizeHdl, ToolBox* );
+        DECL_LINK(ClickColumnHdl, ToolBox* );
+
+        void Initialize();
+
+        void MetricState( SfxItemState eState, const SfxPoolItem* pState );
+
+        // helper to adjust popup toolbox' images
+        void ChangeMarginImage();
+        void ChangeSizeImage();
+        void ChangeColumnImage( const sal_uInt16 nColumnType );
+
+    };
+
+} } // end of namespace ::sw::sidebar
+
+#endif