You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openoffice.apache.org by af...@apache.org on 2013/01/21 11:29:05 UTC

svn commit: r1436260 [3/5] - in /openoffice/branches/sidebar/main: framework/inc/services/ framework/source/services/ offapi/com/sun/star/ui/ officecfg/registry/data/org/openoffice/Office/UI/ postprocess/rebase/ sd/source/ui/func/ sd/source/ui/presente...

Added: openoffice/branches/sidebar/main/svx/source/sidebar/PanelFactory.cxx
URL: http://svn.apache.org/viewvc/openoffice/branches/sidebar/main/svx/source/sidebar/PanelFactory.cxx?rev=1436260&view=auto
==============================================================================
--- openoffice/branches/sidebar/main/svx/source/sidebar/PanelFactory.cxx (added)
+++ openoffice/branches/sidebar/main/svx/source/sidebar/PanelFactory.cxx Mon Jan 21 10:29:03 2013
@@ -0,0 +1,146 @@
+/**************************************************************
+ * 
+ * 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 "sidebar/PanelFactory.hxx"
+
+#include "text/TextPropertyPanel.hxx"
+
+#include <toolkit/helper/vclunohelper.hxx>
+#include <vcl/window.hxx>
+#include <sfx2/sfxbasecontroller.hxx>
+#include <rtl/ref.hxx>
+
+
+using namespace css;
+using namespace cssu;
+using ::rtl::OUString;
+
+
+namespace svx { namespace sidebar {
+
+#define A2S(s) ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(s))
+#define IMPLEMENTATION_NAME "org.apache.openoffice.comp.svx.sidebar.PanelFactory"
+#define SERVICE_NAME "com.sun.star.ui.UIElementFactory"
+
+
+::rtl::OUString SAL_CALL PanelFactory::getImplementationName (void)
+{
+    return A2S(IMPLEMENTATION_NAME);
+}
+
+
+
+
+cssu::Reference<cssu::XInterface> SAL_CALL PanelFactory::createInstance (
+    const uno::Reference<lang::XMultiServiceFactory>& rxFactory)
+    throw(uno::Exception)
+{
+    (void)rxFactory;
+    
+    ::rtl::Reference<PanelFactory> pPanelFactory (new PanelFactory());
+    cssu::Reference<cssu::XInterface> xService (static_cast<XWeak*>(pPanelFactory.get()), cssu::UNO_QUERY);
+    return xService;
+}
+
+
+
+
+cssu::Sequence<OUString> SAL_CALL PanelFactory::getSupportedServiceNames (void)
+{
+    cssu::Sequence<OUString> aServiceNames (1);
+    aServiceNames[0] = A2S(SERVICE_NAME);
+    return aServiceNames;
+
+}
+
+
+
+
+PanelFactory::PanelFactory (void)
+    : PanelFactoryInterfaceBase(m_aMutex)
+{
+}
+
+
+
+
+PanelFactory::~PanelFactory (void)
+{
+}
+
+
+
+
+Reference<ui::XUIElement> SAL_CALL PanelFactory::createUIElement (
+    const ::rtl::OUString& rsResourceURL,
+    const ::cssu::Sequence<css::beans::PropertyValue>& rArguments)
+    throw(
+        container::NoSuchElementException,
+        lang::IllegalArgumentException,
+        RuntimeException)
+{
+    Reference<ui::XUIElement> xElement;
+    Reference<awt::XWindow> xParentWindow;
+    Reference<frame::XFrame> xFrame;
+    SfxBindings* pBindings = NULL;
+
+    for (sal_Int32 nIndex(0),nCount(rArguments.getLength()); nIndex<nCount; ++nIndex)
+    {
+        const beans::PropertyValue& rValue (rArguments[nIndex]);
+        if (rValue.Name.equalsAscii("ParentWindow"))
+        {
+            xParentWindow = Reference<awt::XWindow>(rValue.Value, UNO_QUERY);
+        }
+        else if (rValue.Name.equalsAscii("Frame"))
+        {
+            xFrame = Reference<frame::XFrame>(rValue.Value, UNO_QUERY);
+        }
+        else if (rValue.Name.equalsAscii("SfxBindings"))
+        {
+            sal_uInt64 nValue;
+            if (rValue.Value >>= nValue)
+                pBindings = reinterpret_cast<SfxBindings*>(nValue);
+        }
+    }
+
+    ::Window* pParentWindow = VCLUnoHelper::GetWindow(xParentWindow);
+    if ( ! xParentWindow.is() || pParentWindow==NULL)
+        throw RuntimeException(
+            A2S("PanelFactory::createUIElement called without ParentWindow"),
+            NULL);
+    if ( ! xFrame.is())
+        throw RuntimeException(
+            A2S("PanelFactory::createUIElement called without Frame"),
+            NULL);
+    if (pBindings == NULL)
+        throw RuntimeException(
+            A2S("PanelFactory::createUIElement called without SfxBindings"),
+            NULL);
+
+    if (rsResourceURL.endsWithAsciiL("/TextPropertyPanel", strlen("/TextPropertyPanel")))
+        xElement = TextPropertyPanel::Create(rsResourceURL, pParentWindow, xFrame, pBindings);
+
+    return xElement;
+}
+
+
+
+} } // end of namespace svx::sidebar

Added: openoffice/branches/sidebar/main/svx/source/sidebar/text/SvxSBFontNameBox.cxx
URL: http://svn.apache.org/viewvc/openoffice/branches/sidebar/main/svx/source/sidebar/text/SvxSBFontNameBox.cxx?rev=1436260&view=auto
==============================================================================
--- openoffice/branches/sidebar/main/svx/source/sidebar/text/SvxSBFontNameBox.cxx (added)
+++ openoffice/branches/sidebar/main/svx/source/sidebar/text/SvxSBFontNameBox.cxx Mon Jan 21 10:29:03 2013
@@ -0,0 +1,178 @@
+/**************************************************************
+ * 
+ * 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_svx.hxx"
+
+#include "SvxSBFontNameBox.hxx"
+
+#include <unotools/fontoptions.hxx>
+#include <sfx2/objsh.hxx>
+#include <sfx2/dispatch.hxx>
+#include <editeng/flstitem.hxx>
+#include <editeng/editids.hrc>
+#include <editeng/fontitem.hxx>
+
+
+const static sal_uInt16 MAX_MRU_FONTNAME_ENTRIES = 5;
+
+
+namespace svx { namespace sidebar {
+
+namespace {
+    bool GetDocFontList_Impl( const FontList** ppFontList, SvxSBFontNameBox* pBox )
+    {
+        bool bChanged = false;
+        const SfxObjectShell* pDocSh = SfxObjectShell::Current();
+        SvxFontListItem* pFontListItem = NULL;
+
+        if ( pDocSh )
+            pFontListItem =
+                (SvxFontListItem*)pDocSh->GetItem( SID_ATTR_CHAR_FONTLIST );
+
+        if ( pFontListItem )
+        {
+            const FontList*	pNewFontList = pFontListItem->GetFontList();
+            DBG_ASSERT( pNewFontList, "Doc-FontList not available!" );
+
+            if ( !*ppFontList )
+            {
+                *ppFontList = pNewFontList;
+                bChanged = true;
+            }
+            else
+            {
+                bChanged = ( *ppFontList != pNewFontList );
+                if( !bChanged && pBox!=NULL )
+                    bChanged = ( pBox->GetListCount() != pNewFontList->GetFontNameCount() );
+                HACK(vergleich ist unvollstaendig)
+
+                    if ( bChanged )
+                        *ppFontList = pNewFontList;
+            }
+
+            if ( pBox )
+                pBox->Enable();
+        }
+        else if ( pBox )
+            pBox->Disable();
+
+        // in die FontBox ggf. auch die neue Liste f"ullen
+        if ( pBox && bChanged )
+        {
+            if ( *ppFontList )
+                pBox->Fill( *ppFontList );
+            else
+                pBox->Clear();
+        }
+        return bChanged;
+    }
+}
+
+
+
+
+SvxSBFontNameBox::SvxSBFontNameBox( Window* pParent,  const ResId& rResId  ) :
+	FontNameBox	( pParent, rResId )
+,	pFontList	( NULL )
+,	nFtCount	( 0 )
+,	bInput(false)
+,	pBindings(NULL)
+{
+    EnableControls_Impl();
+//	StartListening( *SFX_APP() );
+}
+
+void SvxSBFontNameBox::EnableControls_Impl()
+{
+	SvtFontOptions aFontOpt;
+	bool bEnable = aFontOpt.IsFontHistoryEnabled();
+	sal_uInt16 nEntries = bEnable ? MAX_MRU_FONTNAME_ENTRIES : 0;
+	if ( GetMaxMRUCount() != nEntries )
+	{
+		// refill in the next GetFocus-Handler
+		pFontList = NULL;
+		Clear();
+		SetMaxMRUCount( nEntries );
+	}
+
+	bEnable = aFontOpt.IsFontWYSIWYGEnabled();
+	EnableWYSIWYG( bEnable );
+	EnableSymbols( bEnable );
+}
+
+void SvxSBFontNameBox::FillList()
+{
+	Selection aOldSel = GetSelection();
+	GetDocFontList_Impl( &pFontList, this );
+	aCurText = GetText();
+	SetSelection( aOldSel );
+}
+
+long SvxSBFontNameBox::PreNotify( NotifyEvent& rNEvt )
+{
+	const sal_uInt16 nType (rNEvt.GetType());
+
+	if ( EVENT_MOUSEBUTTONDOWN == nType || EVENT_GETFOCUS == nType )
+		FillList();
+    return FontNameBox::PreNotify( rNEvt );
+}
+//<<modify
+long SvxSBFontNameBox::Notify( NotifyEvent& rNEvt) //SfxBroadcaster& rBC, const SfxHint& rHint 
+{
+	//SfxItemSetHint* pHint = PTR_CAST(SfxItemSetHint, &rHint);
+	//if ( pHint )
+	//	EnableControls_Impl();
+	bool bHandle = 0;
+	if ( rNEvt.GetType() == EVENT_KEYINPUT )
+	{
+		const sal_uInt16 nCode (rNEvt.GetKeyEvent()->GetKeyCode().GetCode());
+
+		if( nCode == KEY_RETURN)
+		{
+			bHandle = 1;
+			Select();
+		}
+	}
+
+	return bHandle ? bHandle : FontNameBox::Notify( rNEvt );
+} 
+void SvxSBFontNameBox::Select()
+{
+	FontNameBox::Select();
+
+	if ( !IsTravelSelect() )
+	{
+		FillList();
+		FontInfo aInfo( pFontList->Get( GetText(),WEIGHT_NORMAL, ITALIC_NORMAL ) );//meWeight, meItalic 
+    
+		SvxFontItem aFontItem( aInfo.GetFamily(), aInfo.GetName(), aInfo.GetStyleName(),
+			aInfo.GetPitch(), aInfo.GetCharSet(), SID_ATTR_CHAR_FONT );
+
+		pBindings->GetDispatcher()->Execute( SID_ATTR_CHAR_FONT, SFX_CALLMODE_RECORD, &aFontItem, 0L );
+		pBindings->Invalidate(SID_ATTR_CHAR_FONT,true,false);
+	}
+}
+void SvxSBFontNameBox::SetBindings(SfxBindings* pB)
+{
+	pBindings = pB;
+}
+
+} } // end of namespace svx::sidebar

Added: openoffice/branches/sidebar/main/svx/source/sidebar/text/SvxSBFontNameBox.hxx
URL: http://svn.apache.org/viewvc/openoffice/branches/sidebar/main/svx/source/sidebar/text/SvxSBFontNameBox.hxx?rev=1436260&view=auto
==============================================================================
--- openoffice/branches/sidebar/main/svx/source/sidebar/text/SvxSBFontNameBox.hxx (added)
+++ openoffice/branches/sidebar/main/svx/source/sidebar/text/SvxSBFontNameBox.hxx Mon Jan 21 10:29:03 2013
@@ -0,0 +1,80 @@
+/**************************************************************
+ * 
+ * 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 SVX_SIDEBAR_SB_FONT_NAME_BOX_HXX
+#define SVX_SIDEBAR_SB_FONT_NAME_BOX_HXX
+
+#include <sfx2/bindings.hxx>
+#include <svtools/ctrlbox.hxx>
+#include <svtools/ctrltool.hxx>
+
+/*
+#include <sfx2/sectionpage.hxx>
+#include <svx/svxdllapi.h>
+#include <vcl/fixed.hxx>
+
+#include <vcl/button.hxx>
+#include <svl/lstner.hxx>
+#include <vcl/toolbox.hxx>
+
+#include <svx/tbxcolorupdate.hxx>
+#include <svx/svxenum.hxx>
+#include <svx/fhgtitem.hxx>
+
+#define FONT_COLOR			1
+#define BACK_COLOR			2
+*/
+namespace svx
+{
+    class ToolboxButtonColorUpdater;
+}
+
+namespace svx { namespace sidebar {
+
+class SvxSBFontNameBox : public FontNameBox//, public SfxListener
+{
+private:
+	const FontList*	pFontList;
+	Font			aCurFont;
+	String			aCurText;
+	sal_uInt16 nFtCount;
+   	bool bInput;
+	void			EnableControls_Impl();
+	SfxBindings*	pBindings;//
+protected:
+	virtual void 	Select();
+	
+public:
+    SvxSBFontNameBox( Window* pParent, const ResId& rResId  );
+	void			FillList();
+	sal_uInt16 GetListCount() { return nFtCount; }
+	void			Clear() { FontNameBox::Clear(); nFtCount = 0; }
+	void			Fill( const FontList* pList )
+						{ FontNameBox::Fill( pList );
+						  nFtCount = pList->GetFontNameCount(); }
+	void			SetBindings(SfxBindings* pBinding);//
+	virtual long	PreNotify( NotifyEvent& rNEvt );
+	virtual long	Notify(  NotifyEvent& rNEvt );//
+};
+
+} } // end of namespace svx::sidebar
+
+#endif

Added: openoffice/branches/sidebar/main/svx/source/sidebar/text/SvxTextFontColorPage.cxx
URL: http://svn.apache.org/viewvc/openoffice/branches/sidebar/main/svx/source/sidebar/text/SvxTextFontColorPage.cxx?rev=1436260&view=auto
==============================================================================
--- openoffice/branches/sidebar/main/svx/source/sidebar/text/SvxTextFontColorPage.cxx (added)
+++ openoffice/branches/sidebar/main/svx/source/sidebar/text/SvxTextFontColorPage.cxx Mon Jan 21 10:29:03 2013
@@ -0,0 +1,179 @@
+/**************************************************************
+ * 
+ * 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_svx.hxx"
+
+namespace sidebar {
+
+class SvxTextPropertyPage::SvxTextFontColorPage:public SfxPopupPage
+{
+public:
+	SvxTextFontColorPage(Window* pParent, SvxTextPropertyPage* pPage);
+	void GetFocus();
+	void SetCurColorSelect(Color aCol, BOOL bAvl);
+private:	
+	SvxTextPropertyPage* mpPage;
+	SfxBindings*		mpBindings;
+	ValueSet			maVSColor;
+
+	void initial();
+	void FillColors();
+	DECL_LINK(VSSelectHdl, void *);
+};
+SvxTextPropertyPage::SvxTextFontColorPage::SvxTextFontColorPage(Window* pParent, SvxTextPropertyPage* pPage)
+:	SfxPopupPage( pParent,SVX_RES(RID_POPUPPANEL_TEXTPAGE_FONT_COLOR))
+,	mpPage(pPage)
+,	mpBindings(NULL)
+,	maVSColor( this, SVX_RES(VS_FONT_COLOR))
+{
+	initial();
+	FreeResource();
+	if (mpPage)
+		mpBindings = mpPage->GetBindings();
+}
+
+void SvxTextPropertyPage::SvxTextFontColorPage::initial()
+{
+	WinBits nBits = ( maVSColor.GetStyle() | WB_NONEFIELD | WB_ITEMBORDER | WB_NAMEFIELD | WB_3DLOOK | WB_NO_DIRECTSELECT | WB_SELECTIFOLLOWMOUSE); //Modified  for color picker migration 01/20/10
+	maVSColor.SetText( String( SVX_RES( STR_AUTOMATICE ) ) );
+	maVSColor.SetStyle( nBits );
+	//Modified  for color picker migration 01/20/10
+	//maVSColor.SetColCount( 10 );
+	//maVSColor.SetLineCount( 10 );
+	maVSColor.SetColCount( 12 );
+	maVSColor.SetLineCount( 12 );
+	//End
+	const Size aSize15x15 = Size( 15, 15 );
+	maVSColor.CalcWindowSizePixel( aSize15x15 );
+	maVSColor.Show();
+
+	Link aLink =  LINK( this, SvxTextFontColorPage, VSSelectHdl ) ;
+    maVSColor.SetSelectHdl(aLink);
+}
+void SvxTextPropertyPage::SvxTextFontColorPage::FillColors()
+{
+	SfxObjectShell* pDocSh = SfxObjectShell::Current();
+	const SfxPoolItem* pItem = NULL;
+	XColorTable* pColorTable = NULL;
+	FASTBOOL bOwn = FALSE;
+
+	DBG_ASSERT( pDocSh, "DocShell not found!" );
+
+	if ( pDocSh && ( 0 != ( pItem = pDocSh->GetItem( SID_COLOR_TABLE ) ) ) )
+		pColorTable = ( (SvxColorTableItem*)pItem )->GetColorTable();
+
+	if ( !pColorTable )
+	{
+		bOwn = TRUE;
+		pColorTable = new XColorTable( SvtPathOptions().GetPalettePath() );
+	}
+
+	if ( pColorTable )
+	{
+		short i	= 0;
+		long nCount	= pColorTable->Count();
+		XColorEntry* pEntry	= NULL;
+		Color aColWhite( COL_WHITE );
+		String aStrWhite( SVX_RES( RID_SVXITEMS_COLOR_WHITE ) );
+
+		maVSColor.Clear();
+		maVSColor.SetStyle( maVSColor.GetStyle() & ~WB_VSCROLL );
+		for ( i = 0; i < nCount; i++ )
+		{
+            pEntry = pColorTable->GetColor(i);
+			maVSColor.InsertItem(	i + 1, pEntry->GetColor(), pEntry->GetName() );
+		}
+		//Modified   for color picker migration.01/20/10
+		while ( i < 144 )
+		{
+			maVSColor.InsertItem( i + 1, aColWhite, aStrWhite );
+			i++;
+		}
+		if ( nCount > 144 )
+		{
+			maVSColor.SetStyle( maVSColor.GetStyle() | WB_VSCROLL );
+		}
+		//End
+	}
+
+	if ( bOwn )
+		delete pColorTable;
+
+	maVSColor.Show();
+}
+void SvxTextPropertyPage::SvxTextFontColorPage::GetFocus()
+{
+	maVSColor.GrabFocus();
+}
+void SvxTextPropertyPage::SvxTextFontColorPage::SetCurColorSelect(Color aCol, BOOL bAvailable)
+{
+//	USHORT nType = mpPage->GetCurrColorType();
+		
+	FillColors();	
+	short nCol = GetItemId_Impl( maVSColor, aCol );
+	if(! bAvailable)
+	{
+		maVSColor.SetNoSelection();
+		return;
+	}
+
+	//if not found
+	if( nCol == -1)
+	{
+		maVSColor.SetNoSelection();
+	}
+	else
+	{
+		maVSColor.SelectItem( nCol );
+	}
+}
+IMPL_LINK(SvxTextPropertyPage::SvxTextFontColorPage, VSSelectHdl, void *, pControl)
+{
+	if(pControl = &maVSColor)
+	{
+		USHORT nType = mpPage->GetCurrColorType();
+
+		USHORT iPos = maVSColor.GetSelectItemId();
+		Color aColor = maVSColor.GetItemColor( iPos );	  
+		if(nType == FONT_COLOR)
+		{
+			if(iPos == 0)
+				aColor = COL_AUTO;
+			SvxColorItem aColorItem(aColor, SID_ATTR_CHAR_COLOR);
+			mpBindings->GetDispatcher()->Execute(SID_ATTR_CHAR_COLOR, SFX_CALLMODE_RECORD, &aColorItem, 0L);
+			mpPage->SetColor(aColor);
+		}
+		else if(nType == BACK_COLOR)
+		{
+			if(iPos == 0)
+				aColor = COL_TRANSPARENT;
+			SvxBrushItem aBrushItem(aColor, SID_ATTR_BRUSH_CHAR);
+			mpBindings->GetDispatcher()->Execute(SID_ATTR_BRUSH_CHAR, SFX_CALLMODE_RECORD, &aBrushItem, 0L);
+			mpPage->SetBackColor(aColor);
+		}
+
+		if (mpPage->GetFontColorFloatWin()->IsInPopupMode() )
+			mpPage->GetFontColorFloatWin()->EndPopupMode();
+	}
+	return( 0L );
+}
+
+} // end of namespace sidebar

Added: openoffice/branches/sidebar/main/svx/source/sidebar/text/SvxTextSpacingPage.cxx
URL: http://svn.apache.org/viewvc/openoffice/branches/sidebar/main/svx/source/sidebar/text/SvxTextSpacingPage.cxx?rev=1436260&view=auto
==============================================================================
--- openoffice/branches/sidebar/main/svx/source/sidebar/text/SvxTextSpacingPage.cxx (added)
+++ openoffice/branches/sidebar/main/svx/source/sidebar/text/SvxTextSpacingPage.cxx Mon Jan 21 10:29:03 2013
@@ -0,0 +1,536 @@
+/**************************************************************
+ * 
+ * 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_svx.hxx"
+
+namespace sidebar {
+
+class SvxTextPropertyPage::SvxTextSpacingPage:public SfxPopupPage
+{
+public:
+	SvxTextSpacingPage(Window* pParent, SvxTextPropertyPage* pPage);
+	~SvxTextSpacingPage();
+	void GetFocus();
+	void SetControlState(bool bLBAvailable,bool bAvailable, long nKerning);
+	virtual void Paint(const Rectangle& rect);
+	//add 
+	short GetLastCustomState();
+	long  GetLastCustomValue();
+	//add end
+
+private:	
+	SvxTextPropertyPage* mpPage;
+	SfxBindings*		mpBindings;
+
+	SvxValueSetCustom	maVSSpacing;
+
+	FixedText			maLastCus;
+//	Control				maBorder;
+
+	FixedText			maFTSpacing;
+	ListBox				maLBKerning;
+	FixedText			maFTBy;
+	MetricField			maEditKerning;
+
+	Image*				mpImg;
+	Image*				mpImgSel;
+	XubString*			mpStr;
+	XubString*			mpStrTip;
+
+	Image				maImgCus;
+	Image				maImgCusGrey;
+	XubString			maStrCus;
+	XubString			maStrCusE;		//add 
+	XubString			maStrCusC;		//add 
+	XubString			maStrCusN;		//add 
+	XubString			maStrUnit;		//add 
+
+	long				mnCustomKern;
+	short				mnLastCus;		
+	bool				mbCusEnable;
+	bool				mbVS;
+
+	void initial();
+	DECL_LINK(VSSelHdl, void*);
+	DECL_LINK(KerningSelectHdl, ListBox*);
+	DECL_LINK(KerningModifyHdl,  MetricField*);
+};
+SvxTextPropertyPage::SvxTextSpacingPage::SvxTextSpacingPage(Window* pParent, SvxTextPropertyPage* pPage)
+:	SfxPopupPage( pParent,SVX_RES(RID_POPUPPANEL_TEXTPAGE_SPACING))
+,	mpPage(pPage)
+,	mpBindings(NULL)
+,	maVSSpacing		(this, SVX_RES(VS_SPACING))
+,	maLastCus		(this, SVX_RES(FT_LASTCUSTOM))
+//,	maBorder		(this, SVX_RES(CT_BORDER))
+,	maFTSpacing		(this, SVX_RES(FT_SPACING))
+,	maLBKerning		(this, SVX_RES(LB_KERNING))
+,	maFTBy			(this, SVX_RES(FT_BY))
+,	maEditKerning	(this, SVX_RES(ED_KERNING))
+
+,	mpImg			(NULL)
+,	mpImgSel		(NULL)
+,	mpStr			(NULL)
+,	mpStrTip		(NULL)
+		
+,	maImgCus		(SVX_RES(IMG_CUSTOM))
+,	maImgCusGrey	(SVX_RES(IMG_CUSTOM_GRAY))
+,	maStrCus		(SVX_RES(STR_CUSTOM))
+,	maStrCusE		(SVX_RES(STR_CUSTOM_E_TIP))	//add 
+,	maStrCusC		(SVX_RES(STR_CUSTOM_C_TIP))	//add 
+,	maStrCusN		(SVX_RES(STR_NORMAL_TIP))	//add 
+,	maStrUnit		(SVX_RES(STR_PT))			//add 
+
+,	mnCustomKern(0)
+,	mnLastCus ( SPACING_NOCUSTOM )
+,	mbCusEnable(false)
+,	mbVS(true)
+{
+	initial();
+	FreeResource();
+	if (mpPage)
+		mpBindings = mpPage->GetBindings();
+	Link aLink = LINK(this, SvxTextSpacingPage, KerningSelectHdl);
+	maLBKerning.SetSelectHdl(aLink);
+	aLink =LINK(this, SvxTextSpacingPage, KerningModifyHdl);
+	maEditKerning.SetModifyHdl(aLink);
+
+}
+SvxTextPropertyPage::SvxTextSpacingPage::~SvxTextSpacingPage()
+{
+	delete[] mpImg;
+	delete[] mpImgSel;
+	delete[] mpStr;
+	delete[] mpStrTip;
+}
+void SvxTextPropertyPage::SvxTextSpacingPage::Paint(const Rectangle& rect)
+{
+	SfxPopupPage::Paint(rect);
+	Color aOldLineColor = GetLineColor();
+	Color aOldFillColor = GetFillColor();
+
+	//Point aPos = maBorder.GetPosPixel();	
+	//Size aSize = maBorder.GetSizePixel();
+	Point aPos( LogicToPixel( Point( CUSTOM_X, CUSTOM_Y), MAP_APPFONT ));
+	Size aSize( LogicToPixel( Size(  CUSTOM_WIDTH, CUSTOM_HEIGHT ), MAP_APPFONT ));
+	Rectangle aRect( aPos, aSize );
+	aRect.Left() -= 1;
+	aRect.Top() -= 1;
+	aRect.Right() += 1;
+	aRect.Bottom() += 1;
+
+
+	Color aLineColor(189,201,219);
+	if(!GetSettings().GetStyleSettings().GetHighContrastMode())
+		SetLineColor(aLineColor);
+	else
+		SetLineColor(GetSettings().GetStyleSettings().GetShadowColor());
+	SetFillColor(COL_TRANSPARENT);
+	//add  for high contract
+	//if(GetSettings().GetStyleSettings().GetHighContrastMode())
+	//{
+	//	maBorder.SetBackground(GetSettings().GetStyleSettings().GetMenuColor());
+	//	maFTSpacing.SetBackground(GetSettings().GetStyleSettings().GetMenuColor());
+	//	maFTBy.SetBackground(GetSettings().GetStyleSettings().GetMenuColor());
+	//}
+	DrawRect(aRect);
+
+
+	SetLineColor(aOldLineColor);
+	SetFillColor(aOldFillColor);
+}
+void SvxTextPropertyPage::SvxTextSpacingPage::initial()
+{
+	maVSSpacing.SetStyle( maVSSpacing.GetStyle()| WB_3DLOOK |  WB_NO_DIRECTSELECT  );
+	//for high contract
+	if(GetSettings().GetStyleSettings().GetHighContrastMode())
+	{
+		maVSSpacing.SetControlBackground(GetSettings().GetStyleSettings().GetMenuColor());
+		maVSSpacing.SetColor(GetSettings().GetStyleSettings().GetMenuColor());
+		maVSSpacing.SetBackground(GetSettings().GetStyleSettings().GetMenuColor());
+		maFTSpacing.SetBackground(GetSettings().GetStyleSettings().GetMenuColor());
+		maFTBy.SetBackground(GetSettings().GetStyleSettings().GetMenuColor());
+	}
+	mpImg = new Image[5];
+	mpImg[0] = Image(SVX_RES(IMG_VERY_TIGHT));
+	mpImg[1] = Image(SVX_RES(IMG_TIGHT));
+	mpImg[2] = Image(SVX_RES(IMG_NORMAL));
+	mpImg[3] = Image(SVX_RES(IMG_LOOSE));
+	mpImg[4] = Image(SVX_RES(IMG_VERY_LOOSE));
+
+	mpImgSel = new Image[5];
+	mpImgSel[0] = Image(SVX_RES(IMG_VERY_TIGHT_S));
+	mpImgSel[1] = Image(SVX_RES(IMG_TIGHT_S));
+	mpImgSel[2] = Image(SVX_RES(IMG_NORMAL_S));
+	mpImgSel[3] = Image(SVX_RES(IMG_LOOSE_S));
+	mpImgSel[4] = Image(SVX_RES(IMG_VERY_LOOSE_S));
+
+	mpStr = new XubString[5];
+	mpStr[0] = XubString(SVX_RES(STR_VERY_TIGHT));
+	mpStr[1] = XubString(SVX_RES(STR_TIGHT));
+	mpStr[2] = XubString(SVX_RES(STR_NORMAL));
+	mpStr[3] = XubString(SVX_RES(STR_LOOSE));
+	mpStr[4] = XubString(SVX_RES(STR_VERY_LOOSE));
+	maVSSpacing.InsertItemSet(5, mpImg, mpImgSel,mpStr);
+
+	mpStrTip = new XubString[5];
+	mpStrTip[0] = XubString(SVX_RES(STR_VERY_TIGHT_TIP));
+	mpStrTip[1] = XubString(SVX_RES(STR_TIGHT_TIP));
+	mpStrTip[2] = XubString(SVX_RES(STR_NORMAL_TIP));
+	mpStrTip[3] = XubString(SVX_RES(STR_LOOSE_TIP));
+	mpStrTip[4] = XubString(SVX_RES(STR_VERY_LOOSE_TIP));
+	maVSSpacing.SetDefaultTip(mpStr);	//modify
+	maVSSpacing.SetDefaultTip(mpStrTip, TRUE); //Add
+
+	maVSSpacing.InsertCustom(maImgCus, maImgCusGrey, maStrCus);
+	maVSSpacing.SetCustomTip(maStrCus); //Add
+
+	maVSSpacing.SetSelItem(0);			
+	Link aLink = LINK(this, SvxTextSpacingPage,VSSelHdl );
+	maVSSpacing.SetSelectHdl(aLink);
+	maVSSpacing.StartSelection();
+	maVSSpacing.Show();
+}
+void SvxTextPropertyPage::SvxTextSpacingPage::GetFocus()
+{
+	if(!mbVS)
+		maLBKerning.GrabFocus();
+	else
+		maVSSpacing.GrabFocus();
+}
+void SvxTextPropertyPage::SvxTextSpacingPage::SetControlState(bool bLBAvailable,bool bAvailable, long nKerning)
+{
+	mbVS = true;
+	maVSSpacing.SetSelItem(0);
+	SvtViewOptions aWinOpt( E_WINDOW, SIDEBAR_SPACING_GLOBAL_VALUE );
+    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 );
+		mnCustomKern = aWinData.ToInt32();
+		mnLastCus = SPACING_CLOSE_BY_CUS_EDIT;
+		mbCusEnable = true;
+	}
+	else
+	{
+		mnLastCus = SPACING_NOCUSTOM;
+		mbCusEnable = false;
+	}
+
+	if( !mnLastCus ) 
+	{
+		maVSSpacing.SetCusEnable(false);
+		maVSSpacing.SetCustomTip(maStrCus,TRUE);  //LAST CUSTOM no tip defect //add 
+	}
+	else
+	{
+		//set custom tips
+		maVSSpacing.SetCusEnable(true);
+		if(mnCustomKern > 0)
+		{	
+			String aStrTip( maStrCusE);   //LAST CUSTOM no tip defect //add 
+			aStrTip.Append( String::CreateFromDouble( (double)mnCustomKern / 10));
+			//aStrTip.Append(String("pt", 2, RTL_TEXTENCODING_ASCII_US));
+			aStrTip.Append(maStrUnit);		// modify 
+			maVSSpacing.SetCustomTip(aStrTip,TRUE);
+		}
+		else if(mnCustomKern < 0)
+		{	
+			String aStrTip(maStrCusC) ;		//LAST CUSTOM no tip defect //add 
+			aStrTip.Append( String::CreateFromDouble( (double)-mnCustomKern / 10));
+			//aStrTip.Append(String("pt", 2, RTL_TEXTENCODING_ASCII_US));
+			aStrTip.Append(maStrUnit);		// modify 
+			maVSSpacing.SetCustomTip(aStrTip,TRUE);
+		}	
+		else
+		{	
+			String aStrTip(maStrCusN) ;		//LAST CUSTOM no tip defect //add 
+			maVSSpacing.SetCustomTip(aStrTip,TRUE);
+		}
+		
+	}
+
+	if(bLBAvailable && bAvailable)
+	{
+		maLBKerning.Enable();
+		maFTSpacing.Enable();
+
+		if(mpPage == NULL)
+			return;
+		SfxMapUnit eUnit = mpPage->GetSpaceController().GetCoreMetric();
+        MapUnit eOrgUnit = (MapUnit)eUnit;
+        MapUnit ePntUnit( MAP_POINT );			
+        long nBig = maEditKerning.Normalize(nKerning);
+        nKerning = LogicToLogic( nBig, eOrgUnit, ePntUnit );
+
+		if ( nKerning > 0 )
+        {
+			maFTBy.Enable();
+            maEditKerning.Enable();
+            maEditKerning.SetMax( 9999 );
+            maEditKerning.SetLast( 9999 );
+            maEditKerning.SetValue( nKerning );
+            maLBKerning.SelectEntryPos( SIDEBAR_SPACE_EXPAND );
+			if(nKerning == 30)
+			{
+				maVSSpacing.SetSelItem(4);
+			}
+			else if(nKerning == 60)
+			{
+				maVSSpacing.SetSelItem(5);
+			}
+			else
+			{
+				maVSSpacing.SetSelItem(0);
+				mbVS = false;
+			}
+        }
+        else if ( nKerning < 0 )
+        {
+			maFTBy.Enable();
+            maEditKerning.Enable();
+            maEditKerning.SetValue( -nKerning );
+            maLBKerning.SelectEntryPos( SIDEBAR_SPACE_CONDENSED );
+            long nMax = mpPage->GetSelFontSize()/6;
+            maEditKerning.SetMax( maEditKerning.Normalize( nMax ), FUNIT_POINT );
+            maEditKerning.SetLast( maEditKerning.GetMax( maEditKerning.GetUnit() ) );
+			if( nKerning == -30 )
+			{
+				maVSSpacing.SetSelItem(1);
+			}
+			else if( nKerning == -15 )
+			{
+				maVSSpacing.SetSelItem(2);
+			}
+			else
+			{
+				maVSSpacing.SetSelItem(0);
+				mbVS = false;
+			}
+        }
+        else
+        {
+			maVSSpacing.SetSelItem(3);
+			maLBKerning.SelectEntryPos( SIDEBAR_SPACE_NORMAL );
+			maFTBy.Disable();
+            maEditKerning.Disable();
+            maEditKerning.SetValue( 0 );
+            maEditKerning.SetMax( 9999 );
+            maEditKerning.SetLast( 9999 );
+        }
+	}
+	else if(bLBAvailable && !bAvailable)
+	{	
+		//modified 
+		maVSSpacing.SetSelItem(0);
+		mbVS = false;
+		maLBKerning.Enable();
+		maFTSpacing.Enable();
+		maLBKerning.SetNoSelection();
+		maEditKerning.SetText(String());
+		maEditKerning.Disable();
+		maFTBy.Disable();
+	}
+	else
+	{
+		maVSSpacing.SetSelItem(0);
+		mbVS = false;
+		maEditKerning.SetText(String());
+        maLBKerning.SetNoSelection();
+		maLBKerning.Disable();
+		maFTSpacing.Disable();
+        maEditKerning.Disable();
+		maFTBy.Disable();
+	}
+	GetFocus();
+	maVSSpacing.Format();
+	maVSSpacing.StartSelection();
+}
+IMPL_LINK(SvxTextPropertyPage::SvxTextSpacingPage, VSSelHdl, void *, pControl)
+{
+//	mnLastCus = SPACING_CLOSE_BY_CLICK_ICON;
+
+	if(pControl == &maVSSpacing)  
+	{		
+		USHORT iPos = maVSSpacing.GetSelectItemId();
+		short nKern = 0;
+		SfxMapUnit eUnit = mpPage->GetSpaceController().GetCoreMetric();
+		long nVal = 0;
+		if(iPos == 1)
+		{
+			nVal = LogicToLogic(30, MAP_POINT, (MapUnit)eUnit);
+			nKern = (short)maEditKerning.Denormalize(nVal);
+			SvxKerningItem aKernItem(-nKern, SID_ATTR_CHAR_KERNING);
+			mpBindings->GetDispatcher()->Execute(SID_ATTR_CHAR_KERNING, SFX_CALLMODE_RECORD, &aKernItem, 0L);
+			mpPage->SetSpacing(-nKern);
+			mnLastCus = SPACING_CLOSE_BY_CLICK_ICON;
+		}
+		else if(iPos == 2)
+		{
+			nVal = LogicToLogic(15, MAP_POINT, (MapUnit)eUnit);
+			nKern = (short)maEditKerning.Denormalize(nVal);
+			SvxKerningItem aKernItem(-nKern, SID_ATTR_CHAR_KERNING);
+			mpBindings->GetDispatcher()->Execute(SID_ATTR_CHAR_KERNING, SFX_CALLMODE_RECORD, &aKernItem, 0L);
+			mpPage->SetSpacing(-nKern);
+			mnLastCus = SPACING_CLOSE_BY_CLICK_ICON;
+		}
+		else if(iPos == 3)
+		{
+			SvxKerningItem aKernItem(0, SID_ATTR_CHAR_KERNING);
+			mpBindings->GetDispatcher()->Execute(SID_ATTR_CHAR_KERNING, SFX_CALLMODE_RECORD, &aKernItem, 0L);
+			mpPage->SetSpacing(0);
+			mnLastCus = SPACING_CLOSE_BY_CLICK_ICON;
+		}
+		else if(iPos == 4)
+		{
+			nVal = LogicToLogic(30, MAP_POINT, (MapUnit)eUnit);
+			nKern = (short)maEditKerning.Denormalize(nVal);
+			SvxKerningItem aKernItem(nKern, SID_ATTR_CHAR_KERNING);
+			mpBindings->GetDispatcher()->Execute(SID_ATTR_CHAR_KERNING, SFX_CALLMODE_RECORD, &aKernItem, 0L);
+			mpPage->SetSpacing(nKern);
+			mnLastCus = SPACING_CLOSE_BY_CLICK_ICON;
+		}
+		else if(iPos == 5)
+		{
+			nVal = LogicToLogic(60, MAP_POINT, (MapUnit)eUnit);
+			nKern = (short)maEditKerning.Denormalize(nVal);
+			SvxKerningItem aKernItem(nKern, SID_ATTR_CHAR_KERNING);
+			mpBindings->GetDispatcher()->Execute(SID_ATTR_CHAR_KERNING, SFX_CALLMODE_RECORD, &aKernItem, 0L);
+			mpPage->SetSpacing(nKern);
+			mnLastCus = SPACING_CLOSE_BY_CLICK_ICON;
+		}
+		else if(iPos == 6)
+		{
+			//modified 
+			if(mbCusEnable)
+			{
+				nVal = LogicToLogic(mnCustomKern, MAP_POINT, (MapUnit)eUnit);
+				nKern = (short)maEditKerning.Denormalize(nVal);
+				SvxKerningItem aKernItem(nKern , SID_ATTR_CHAR_KERNING);
+				mpBindings->GetDispatcher()->Execute(SID_ATTR_CHAR_KERNING, SFX_CALLMODE_RECORD, &aKernItem, 0L);
+				mpPage->SetSpacing(nKern);
+				mnLastCus = SPACING_CLOSE_BY_CLICK_ICON;
+			}
+			else
+			{
+				maVSSpacing.SetNoSelection();		//add , set no selection and keep the last select item 
+				maVSSpacing.Format();
+				Invalidate();
+				maVSSpacing.StartSelection();
+			}
+			//modify end
+		}
+		
+		if(iPos < 6 || (iPos == 6 && mbCusEnable)) //add 
+			if (mpPage->GetSpacingFloatWin()->IsInPopupMode() )
+				mpPage->GetSpacingFloatWin()->EndPopupMode();
+	}
+
+
+		
+	return 0;
+}
+
+IMPL_LINK(SvxTextPropertyPage::SvxTextSpacingPage, KerningSelectHdl, ListBox*, EMPTYARG)
+{
+	if ( maLBKerning.GetSelectEntryPos() > 0 )
+	{
+		maFTBy.Enable();
+		maEditKerning.Enable();
+	}
+	else
+	{
+		maEditKerning.SetValue( 0 );
+		maFTBy.Disable();
+		maEditKerning.Disable();
+	}
+
+	if(maVSSpacing.GetSelItem())
+	{
+		maVSSpacing.SetSelItem(0);	//modify 
+		maVSSpacing.Format();
+		Invalidate();
+		maVSSpacing.StartSelection();
+	}
+	KerningModifyHdl( NULL );
+	return 0;
+}
+IMPL_LINK(SvxTextPropertyPage::SvxTextSpacingPage, KerningModifyHdl, MetricField*, EMPTYARG)
+{
+	if(maVSSpacing.GetSelItem())
+	{
+		maVSSpacing.SetSelItem(0);	//modify 
+		maVSSpacing.Format();
+		Invalidate();
+		maVSSpacing.StartSelection();
+	}
+	USHORT nPos = maLBKerning.GetSelectEntryPos();
+    short nKern = 0;
+    SfxMapUnit eUnit = mpPage->GetSpaceController().GetCoreMetric();
+	mnLastCus = SPACING_CLOSE_BY_CUS_EDIT; 
+	if ( nPos == SIDEBAR_SPACE_EXPAND || nPos == SIDEBAR_SPACE_CONDENSED )
+    {
+        long nTmp = static_cast<long>(maEditKerning.GetValue());
+        if ( nPos == SIDEBAR_SPACE_CONDENSED )
+		{
+			long nMax =  mpPage->GetSelFontSize()/6;
+			maEditKerning.SetMax( maEditKerning.Normalize( nMax ), FUNIT_TWIP );
+			maEditKerning.SetLast( maEditKerning.GetMax( maEditKerning.GetUnit() ) );
+			if(nTmp > maEditKerning.GetMax())
+				nTmp = maEditKerning.GetMax();
+			mnCustomKern = -nTmp;
+			long nVal = LogicToLogic( nTmp, MAP_POINT, (MapUnit)eUnit );
+			nKern = (short)maEditKerning.Denormalize( nVal );
+            nKern *= - 1;		
+		}
+		else
+		{
+			maEditKerning.SetMax( 9999 );
+			maEditKerning.SetLast( 9999 );
+			if(nTmp > maEditKerning.GetMax(FUNIT_TWIP))
+				nTmp = maEditKerning.GetMax(FUNIT_TWIP);
+			mnCustomKern = nTmp;
+			long nVal = LogicToLogic( nTmp, MAP_POINT, (MapUnit)eUnit );
+			nKern = (short)maEditKerning.Denormalize( nVal );	
+		}
+    }
+	else
+	{
+		mnCustomKern = 0;
+	}
+	SvxKerningItem aKernItem(nKern, SID_ATTR_CHAR_KERNING);
+	mpBindings->GetDispatcher()->Execute(SID_ATTR_CHAR_KERNING, SFX_CALLMODE_RECORD, &aKernItem, 0L);
+	mpPage->SetSpacing(nKern);
+	return 0;
+}
+short  SvxTextPropertyPage::SvxTextSpacingPage::GetLastCustomState()
+{
+	return mnLastCus;
+}
+long  SvxTextPropertyPage::SvxTextSpacingPage::GetLastCustomValue()
+{
+	return mnCustomKern;
+}
+
+} // end of namespace sidebar

Added: openoffice/branches/sidebar/main/svx/source/sidebar/text/SvxTextUnderlinePage.cxx
URL: http://svn.apache.org/viewvc/openoffice/branches/sidebar/main/svx/source/sidebar/text/SvxTextUnderlinePage.cxx?rev=1436260&view=auto
==============================================================================
--- openoffice/branches/sidebar/main/svx/source/sidebar/text/SvxTextUnderlinePage.cxx (added)
+++ openoffice/branches/sidebar/main/svx/source/sidebar/text/SvxTextUnderlinePage.cxx Mon Jan 21 10:29:03 2013
@@ -0,0 +1,348 @@
+/**************************************************************
+ * 
+ * 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_svx.hxx"
+
+namespace sidebar {
+
+class SvxTextPropertyPage::SvxTextUnderlinePage:public SfxPopupPage
+{
+public:
+	SvxTextUnderlinePage(Window* pParent, SvxTextPropertyPage* pPage);
+	void GetFocus();
+	void SetUnderlineSelect(FontUnderline eLine);
+	virtual void Paint(const Rectangle& rect);
+	ValueSet& GetValueSet();
+	Control& GetPB();
+private:	
+	SvxTextPropertyPage* mpPage;
+	SfxBindings*		mpBindings;
+	ValueSet			maVSUnderline;
+	SymCustomButton::HoverButton			maPBOptions;
+
+	Image				maIMGSingle;
+	Image				maIMGDouble;
+	Image				maIMGBold;
+	Image				maIMGDot;
+	Image				maIMGDotBold;
+	Image				maIMGDash;
+	Image				maIMGDashLong;
+	Image				maIMGDashDot;
+	Image				maIMGDashDotDot;
+	Image				maIMGWave;
+
+	//add  for high contract
+	Image				maIMGSingleH;
+	Image				maIMGDoubleH;
+	Image				maIMGBoldH;
+	Image				maIMGDotH;
+	Image				maIMGDotBoldH;
+	Image				maIMGDashH;
+	Image				maIMGDashLongH;
+	Image				maIMGDashDotH;
+	Image				maIMGDashDotDotH;
+	Image				maIMGWaveH;
+
+	Image				maIMGSingleSel;
+	Image				maIMGDoubleSel;
+	Image				maIMGBoldSel;
+	Image				maIMGDotSel;
+	Image				maIMGDotBoldSel;
+	Image				maIMGDashSel;
+	Image				maIMGDashLongSel;
+	Image				maIMGDashDotSel;
+	Image				maIMGDashDotDotSel;
+	Image				maIMGWaveSel;
+
+	void initial();
+
+	DECL_LINK( PBClickHdl, PushButton *);
+	DECL_LINK(VSSelectHdl, void *);
+};
+
+SvxTextPropertyPage::SvxTextUnderlinePage::SvxTextUnderlinePage(Window* pParent, SvxTextPropertyPage* pPage)
+:	SfxPopupPage( pParent,SVX_RES(RID_POPUPPANEL_TEXTPAGE_UNDERLINE))
+,	mpPage(pPage)
+,	mpBindings(NULL)
+,	maVSUnderline( this, SVX_RES(VS_UNDERLINE))
+,	maPBOptions	(this, SVX_RES(PB_OPTIONS),Bitmap( SVX_RES( BMP_UNDERLINE_MORE )), Bitmap( SVX_RES( BMP_UNDERLINE_MORE_H )) )
+
+,	maIMGSingle		(SVX_RES(IMG_SINGLE))
+,	maIMGDouble		(SVX_RES(IMG_DOUBLE))
+,	maIMGBold		(SVX_RES(IMG_BOLD2))
+,	maIMGDot		(SVX_RES(IMG_DOT))
+,	maIMGDotBold	(SVX_RES(IMG_DOT_BOLD))
+,	maIMGDash		(SVX_RES(IMG_DASH))
+,	maIMGDashLong	(SVX_RES(IMG_DASH_LONG))
+,	maIMGDashDot	(SVX_RES(IMG_DASH_DOT))
+,	maIMGDashDotDot	(SVX_RES(IMG_DASH_DOT_DOT))
+,	maIMGWave		(SVX_RES(IMG_WAVE))
+
+// high contrast
+,	maIMGSingleH	(SVX_RES(IMG_SINGLE_H))
+,	maIMGDoubleH	(SVX_RES(IMG_DOUBLE_H))
+,	maIMGBoldH		(SVX_RES(IMG_BOLD2_H))
+,	maIMGDotH		(SVX_RES(IMG_DOT_H))
+,	maIMGDotBoldH	(SVX_RES(IMG_DOT_BOLD_H))
+,	maIMGDashH		(SVX_RES(IMG_DASH_H))
+,	maIMGDashLongH	(SVX_RES(IMG_DASH_LONG_H))
+,	maIMGDashDotH	(SVX_RES(IMG_DASH_DOT_H))
+,	maIMGDashDotDotH(SVX_RES(IMG_DASH_DOT_DOT_H))
+,	maIMGWaveH		(SVX_RES(IMG_WAVE_H))
+
+,	maIMGSingleSel		(SVX_RES(IMG_SINGLE_SEL))
+,	maIMGDoubleSel		(SVX_RES(IMG_DOUBLE_SEL))
+,	maIMGBoldSel		(SVX_RES(IMG_BOLD2_SEL))
+,	maIMGDotSel			(SVX_RES(IMG_DOT_SEL))
+,	maIMGDotBoldSel		(SVX_RES(IMG_DOT_BOLD_SEL))
+,	maIMGDashSel		(SVX_RES(IMG_DASH_SEL))
+,	maIMGDashLongSel	(SVX_RES(IMG_DASH_LONG_SEL))
+,	maIMGDashDotSel		(SVX_RES(IMG_DASH_DOT_SEL))
+,	maIMGDashDotDotSel	(SVX_RES(IMG_DASH_DOT_DOT_SEL))
+,	maIMGWaveSel		(SVX_RES(IMG_WAVE_SEL))
+
+{
+	initial();
+	FreeResource();
+	if (mpPage)
+		mpBindings = mpPage->GetBindings();
+}
+void SvxTextPropertyPage::SvxTextUnderlinePage::Paint(const Rectangle& rect)
+{
+	SfxPopupPage::Paint(rect);
+	Color aOldLineColor = GetLineColor();
+	Color aOldFillColor = GetFillColor();
+
+	Point aPos = maPBOptions.GetPosPixel();	
+	Size aSize = maPBOptions.GetSizePixel();
+	Rectangle aRect( aPos, aSize );
+	aRect.Left() -= 1;
+	aRect.Top() -= 1;
+	aRect.Right() += 1;
+	aRect.Bottom() += 1;
+
+	Color aLineColor(159,173,199);
+	if(!GetSettings().GetStyleSettings().GetHighContrastMode())
+		SetLineColor(aLineColor);
+	else
+		SetLineColor(GetSettings().GetStyleSettings().GetShadowColor());
+	SetFillColor(COL_TRANSPARENT);
+	DrawRect(aRect);
+
+	SetLineColor(aOldLineColor);
+	SetFillColor(aOldFillColor);
+}
+
+void SvxTextPropertyPage::SvxTextUnderlinePage::initial()
+{
+	maPBOptions.SetDefBkColor(GetSettings().GetStyleSettings().GetHighContrastMode()?
+		GetSettings().GetStyleSettings().GetMenuColor():
+		GetSettings().GetStyleSettings().GetPopupPanelBackgroundColor());//Color(244,245,249)//for high contract
+	maPBOptions.SetHoverBkColor(GetSettings().GetStyleSettings().GetHighContrastMode()?
+		GetSettings().GetStyleSettings().GetMenuColor():
+		GetSettings().GetStyleSettings().GetCustButtonHoverColor() );//Color( 93, 120, 163 )
+	maPBOptions.SetHoverTxtColor( GetSettings().GetStyleSettings().GetCustButtonTextHoverColor() );//Color( 255, 255, 255 )
+	maPBOptions.SetIcoPosX( 2);
+	maVSUnderline.SetColor(GetSettings().GetStyleSettings().GetMenuColor());
+
+	Link aLink = LINK( this, SvxTextUnderlinePage, PBClickHdl ) ;
+	maPBOptions.SetClickHdl(aLink);
+
+	maVSUnderline.SetStyle( maVSUnderline.GetStyle()| WB_3DLOOK |  WB_NO_DIRECTSELECT  );// WB_NAMEFIELD | WB_ITEMBORDER |WB_DOUBLEBORDER | WB_NONEFIELD |
+
+	maVSUnderline.InsertItem(1, maIMGSingle ,String(SVX_RES(STR_SINGLE)));
+	maVSUnderline.SetItemData(1, (void*)(ULONG)UNDERLINE_SINGLE);
+
+	maVSUnderline.InsertItem(2, maIMGDouble ,String(SVX_RES(STR_DOUBLE)));
+	maVSUnderline.SetItemData(2, (void*)(ULONG)UNDERLINE_DOUBLE);
+
+	maVSUnderline.InsertItem(3, maIMGBold, String(SVX_RES(STR_BOLD)));
+	maVSUnderline.SetItemData(3,(void*)(ULONG)UNDERLINE_BOLD);
+
+	maVSUnderline.InsertItem(4, maIMGDot, String(SVX_RES(STR_DOT)));
+	maVSUnderline.SetItemData(4,(void*)(ULONG)UNDERLINE_DOTTED);
+
+	maVSUnderline.InsertItem(5, maIMGDotBold, String(SVX_RES(STR_DOT_BOLD)));
+	maVSUnderline.SetItemData(5,(void*)(ULONG)UNDERLINE_BOLDDOTTED);
+
+	maVSUnderline.InsertItem(6, maIMGDash, String(SVX_RES(STR_DASH)));
+	maVSUnderline.SetItemData(6,(void*)(ULONG)UNDERLINE_DASH);
+
+	maVSUnderline.InsertItem(7, maIMGDashLong,String(SVX_RES(STR_DASH_LONG)));
+	maVSUnderline.SetItemData(7,(void*)(ULONG)UNDERLINE_LONGDASH);
+
+	maVSUnderline.InsertItem(8, maIMGDashDot, String(SVX_RES(STR_DASH_DOT)));
+	maVSUnderline.SetItemData(8,(void*)(ULONG)UNDERLINE_DASHDOT);
+
+	maVSUnderline.InsertItem(9, maIMGDashDotDot, String(SVX_RES(STR_DASH_DOT_DOT)));
+	maVSUnderline.SetItemData(9,(void*)(ULONG)UNDERLINE_DASHDOTDOT);
+
+	maVSUnderline.InsertItem(10, maIMGWave, String(SVX_RES(STR_WAVE)));
+	maVSUnderline.SetItemData(10,(void*)(ULONG)UNDERLINE_WAVE);
+
+	maVSUnderline.SetColCount( 1 );
+	aLink =  LINK( this, SvxTextUnderlinePage, VSSelectHdl ) ;
+    maVSUnderline.SetSelectHdl(aLink);
+
+	maVSUnderline.StartSelection();
+	maVSUnderline.Show();
+}
+
+void SvxTextPropertyPage::SvxTextUnderlinePage::GetFocus()
+{
+	maPBOptions.GrabFocus();
+}
+void SvxTextPropertyPage::SvxTextUnderlinePage::SetUnderlineSelect(FontUnderline eLine)
+{
+	// high contrast
+	maVSUnderline.SetItemImage(1,  GetDisplayBackground().GetColor().IsDark()? maIMGSingleH :maIMGSingle);
+	maVSUnderline.SetItemImage(2,  GetDisplayBackground().GetColor().IsDark()? maIMGDoubleH : maIMGDouble );
+	maVSUnderline.SetItemImage(3, GetDisplayBackground().GetColor().IsDark()? maIMGBoldH : maIMGBold);
+	maVSUnderline.SetItemImage(4, GetDisplayBackground().GetColor().IsDark()? maIMGDotH : maIMGDot);
+	maVSUnderline.SetItemImage(5, GetDisplayBackground().GetColor().IsDark()? maIMGDotBoldH :maIMGDotBold);
+	maVSUnderline.SetItemImage(6,  GetDisplayBackground().GetColor().IsDark()? maIMGDashH :maIMGDash);
+	maVSUnderline.SetItemImage(7, GetDisplayBackground().GetColor().IsDark()? maIMGDashLongH : maIMGDashLong);
+	maVSUnderline.SetItemImage(8, GetDisplayBackground().GetColor().IsDark()? maIMGDashDotH : maIMGDashDot); 
+	maVSUnderline.SetItemImage(9, GetDisplayBackground().GetColor().IsDark()? maIMGDashDotDotH : maIMGDashDotDot);
+	maVSUnderline.SetItemImage(10, GetDisplayBackground().GetColor().IsDark()? maIMGWaveH : maIMGWave);
+//	maVSUnderline.SelectItem(0);		//delete 
+//	maVSUnderline.SetNoSelection();
+
+	switch(eLine)
+	{
+	case UNDERLINE_SINGLE:
+		maVSUnderline.SetItemImage(1, maIMGSingleSel);
+		maVSUnderline.SelectItem(1);	//add 
+		maVSUnderline.GrabFocus();
+		break;
+	case UNDERLINE_DOUBLE:
+		maVSUnderline.SetItemImage(2, maIMGDoubleSel);
+		maVSUnderline.SelectItem(2);	//add 
+		maVSUnderline.GrabFocus();
+		break;
+	case UNDERLINE_BOLD:
+		maVSUnderline.SetItemImage(3, maIMGBoldSel);
+		maVSUnderline.SelectItem(3);	//add 
+		maVSUnderline.GrabFocus();
+		break;	
+	case UNDERLINE_DOTTED:
+		maVSUnderline.SetItemImage(4, maIMGDotSel);
+		maVSUnderline.SelectItem(4);	//add 
+		maVSUnderline.GrabFocus();
+		break;
+	case UNDERLINE_BOLDDOTTED:
+		maVSUnderline.SetItemImage(5, maIMGDotBoldSel);
+		maVSUnderline.SelectItem(5);	//add 
+		maVSUnderline.GrabFocus();
+		break;
+	case UNDERLINE_DASH:
+		maVSUnderline.SetItemImage(6, maIMGDashSel);
+		maVSUnderline.SelectItem(6);	//add 
+		maVSUnderline.GrabFocus();
+		break;
+	case UNDERLINE_LONGDASH:
+		maVSUnderline.SetItemImage(7, maIMGDashLongSel);
+		maVSUnderline.SelectItem(7);	//add 
+		maVSUnderline.GrabFocus();
+		break;
+	case UNDERLINE_DASHDOT:
+		maVSUnderline.SetItemImage(8, maIMGDashDotSel);
+		maVSUnderline.SelectItem(8);	//add 
+		maVSUnderline.GrabFocus();
+		break;
+	case UNDERLINE_DASHDOTDOT:
+		maVSUnderline.SetItemImage(9, maIMGDashDotDotSel);
+		maVSUnderline.SelectItem(9);	//add 
+		maVSUnderline.GrabFocus();
+		break;
+	case UNDERLINE_WAVE:
+		maVSUnderline.SetItemImage(10, maIMGWaveSel);
+		maVSUnderline.SelectItem(10);	//add 
+		maVSUnderline.GrabFocus();
+		break;
+	case UNDERLINE_NONE:
+	default:
+		maVSUnderline.SelectItem(1,false);
+		maVSUnderline.SetNoSelection();//add 
+		maPBOptions.GrabFocus();
+	}
+	maVSUnderline.StartSelection();
+	//removed 
+	//if(mpPage->meContextType == PROPERTY_CONTEXT_SC_CELL)
+	//	maPBOptions.Disable();
+	//else
+	//	maPBOptions.Enable();
+	//removed end
+}
+ValueSet& SvxTextPropertyPage::SvxTextUnderlinePage::GetValueSet()
+{
+	return maVSUnderline;
+}
+Control& SvxTextPropertyPage::SvxTextUnderlinePage::GetPB()
+{
+	return maPBOptions;
+}
+IMPL_LINK(SvxTextPropertyPage::SvxTextUnderlinePage, VSSelectHdl, void *, pControl)
+{
+	if(pControl == &maVSUnderline)  
+	{
+		USHORT iPos = maVSUnderline.GetSelectItemId();
+		FontUnderline eUnderline = (FontUnderline)(ULONG)maVSUnderline.GetItemData( iPos );
+
+		//<<modified 
+		//SvxTextLineItem aLineItem(eUnderline, SID_ATTR_CHAR_UNDERLINE);
+		SvxUnderlineItem aLineItem(eUnderline, SID_ATTR_CHAR_UNDERLINE);
+		//modify end>>
+
+		//<<add , this line of code will keep the new underline use pre-color
+		aLineItem.SetColor(mpPage->GetUnderlineColor());   
+		//add end>>
+		mpBindings->GetDispatcher()->Execute(SID_ATTR_CHAR_UNDERLINE, SFX_CALLMODE_RECORD, &aLineItem, 0L);
+
+		//add , for the popup page not update immediately
+		mpPage->SetUnderline(eUnderline);
+		//add end
+		mpPage->SetDefaultUnderline(eUnderline);
+
+		if (mpPage->GetUnderlineFloatWin()->IsInPopupMode() )
+			mpPage->GetUnderlineFloatWin()->EndPopupMode();
+	}
+	return( 0L );
+}
+
+IMPL_LINK(SvxTextPropertyPage::SvxTextUnderlinePage, PBClickHdl, PushButton *, pPBtn)
+{
+	if(pPBtn == &maPBOptions)  
+	{
+		if (mpBindings)
+		{
+			SfxDispatcher* pDisp = mpBindings->GetDispatcher();
+			pDisp->Execute( SID_CHAR_DLG_EFFECT, SFX_CALLMODE_ASYNCHRON );
+		}
+		//add 
+		if (mpPage->GetUnderlineFloatWin()->IsInPopupMode() )
+			mpPage->GetUnderlineFloatWin()->EndPopupMode();
+		//add end
+	}
+	return 0;
+}
+
+} // end of namespace sidebar